/* переменные тянутся из catalog.css/elements.css - этот файл подключаем после nav.css.
   .sheet-page выглядит как лист бумаги; в @media print режется через break-after: page */

.page{ max-width:900px; }

.sheet-toolbar{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:14px 22px;
  background:var(--color-paper);
  border:1px solid var(--color-line);
  border-radius:12px;
  box-shadow:var(--shadow);
  padding:14px 18px;
  margin-bottom:22px;
  position:sticky;
  top:62px; /* высота .site-header плюс запас, см. nav.css */
  z-index:40;
}
.sheet-toolbar__group{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px 14px;
}
.sheet-toolbar__label{
  color:#8a7757;
  font-size:11px;
  font-weight:700;
  letter-spacing:.8px;
  text-transform:uppercase;
  margin-right:2px;
}
.block-toggle{
  display:inline-flex;
  align-items:center;
  gap:6px;
  cursor:pointer;
  user-select:none;
  font-size:13px;
  color:var(--color-dark);
}
.block-toggle input{
  accent-color:var(--color-amber);
  width:15px;
  height:15px;
}
.sheet-toolbar__actions{ display:flex; gap:8px; margin-left:auto; }
.sheet-toolbar__btn{
  display:inline-flex;
  align-items:center;
  gap:6px;
  background:var(--color-sand);
  border:1px solid var(--color-line);
  color:var(--color-amber-dark);
  font-family:inherit;
  font-size:13px;
  font-weight:600;
  padding:8px 14px;
  border-radius:9px;
  cursor:pointer;
  transition:background .15s, border-color .15s;
}
.sheet-toolbar__btn:hover{ background:var(--color-sand-dark); }
.sheet-toolbar__btn--primary{
  background:linear-gradient(135deg,var(--color-amber) 0%,var(--color-amber-dark) 100%);
  border-color:transparent;
  color:#fff;
}
.sheet-toolbar__btn--primary:hover{ filter:brightness(1.06); }
.sheet-toolbar__btn--danger{
  background:var(--color-paper);
  border-color:#c99;
  color:#a33;
}
.sheet-toolbar__btn--danger:hover{ background:#fdeaea; border-color:#a33; }
.sheet-toolbar__status{
  color:#8a7757;
  font-size:12px;
  font-style:italic;
  margin-left:6px;
}

.sheet-page{
  position:relative;
  background:var(--color-paper);
  border:1px solid var(--color-line);
  border-top:4px solid var(--color-amber);
  border-radius:14px;
  box-shadow:var(--shadow);
  padding:26px 30px 32px;
  margin-bottom:24px;
}
.sheet-page__pagenum{
  margin-top:-6px;
  margin-bottom:14px;
  text-align:center;
  font-size:11px;
  color:#a89a7d;
  font-style:italic;
}

.sheet-block{ margin-bottom:24px; break-inside:avoid; }
.sheet-block:last-child{ margin-bottom:0; }
.sheet-block__title{
  display:flex;
  align-items:center;
  gap:8px;
  margin-bottom:12px;
  padding-bottom:6px;
  border-bottom:2px solid var(--color-sand);
  font-family:'Neucha',cursive;
  font-size:21px;
  color:var(--color-amber-dark);
}
.sheet-block__title::before{
  content:'';
  display:inline-block;
  width:5px;
  height:20px;
  border-radius:3px;
  background:linear-gradient(180deg,var(--color-amber-soft),var(--color-amber));
  flex:0 0 auto;
}

.sheet-header{
  display:grid;
  grid-template-columns:2fr 1fr 1fr 1fr;
  gap:14px;
  margin-bottom:20px;
  padding-bottom:18px;
  border-bottom:2px solid var(--color-sand);
}
.field{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.field__label{
  font-size:10.5px;
  font-weight:700;
  letter-spacing:.8px;
  text-transform:uppercase;
  color:#8a7757;
}
.field input[type=text],
.field input[type=number],
.field select,
.field textarea{
  font-family:inherit;
  font-size:14px;
  color:var(--color-dark);
  background:var(--color-paper-2);
  border:1px solid var(--color-line);
  border-radius:8px;
  padding:7px 10px;
}
.field input[type=text]:focus,
.field input[type=number]:focus,
.field select:focus,
.field textarea:focus{
  outline:2px solid var(--color-amber-soft);
  outline-offset:1px;
}
.field--name input{
  font-family:'Neucha',cursive;
  font-size:22px;
  padding:6px 10px;
}
.field textarea{
  resize:vertical;
  min-height:70px;
  line-height:1.5;
  font-size:13.5px;
}
.field textarea.autosize{ overflow:hidden; resize:none; }

.stats-grid{ display:grid; grid-template-columns:repeat(6,1fr); gap:12px; }
.stat-card{
  position:relative;
  background:var(--color-paper-2);
  border:1px solid var(--color-line);
  border-radius:12px;
  padding:14px 10px 12px;
  text-align:center;
  overflow:hidden;
  transition:box-shadow .15s, border-color .15s;
}
.stat-card::before{
  content:'';
  position:absolute;
  top:0; left:0; right:0;
  height:3px;
  background:linear-gradient(90deg,var(--color-amber-soft),var(--color-amber));
}
.stat-card:hover{
  box-shadow:var(--shadow);
  border-color:var(--color-amber-soft);
}
.stat-card__name{
  font-size:11px;
  font-weight:700;
  letter-spacing:.5px;
  text-transform:uppercase;
  color:var(--color-amber-dark);
  margin-bottom:6px;
}
.stat-card__score{
  width:52px;
  margin:0 auto 6px;
  text-align:center;
  font-family:'Neucha',cursive;
  font-size:22px;
  border:1px solid var(--color-line);
  border-radius:8px;
  background:var(--color-paper);
  padding:3px 0;
}
.stat-card__mod{
  font-family:'Neucha',cursive;
  font-size:19px;
  font-weight:700;
  color:var(--color-amber-dark);
  margin-bottom:6px;
  text-shadow:0 1px 0 rgba(255,255,255,.5);
}
.stat-card__save{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  font-size:10.5px;
  color:#6b5a45;
}
.stat-card__save input{
  accent-color:var(--color-amber);
  width:13px;
  height:13px;
}

@media (max-width:720px){
  .stats-grid{ grid-template-columns:repeat(3,1fr); }
  .sheet-header{ grid-template-columns:1fr 1fr; }
}

.skills-grid{ display:grid; grid-template-columns:repeat(2,1fr); gap:4px 24px; }
.skill-row{
  display:flex;
  align-items:center;
  gap:8px;
  padding:4px 2px;
  font-size:13px;
  border-bottom:1px dashed rgba(0,0,0,.06);
}
.skill-row input[type=checkbox]{
  accent-color:var(--color-amber);
  width:14px;
  height:14px;
  flex:0 0 auto;
}
.skill-row__mod{
  font-weight:700;
  color:var(--color-amber-dark);
  width:30px;
  text-align:right;
  flex:0 0 auto;
}
.skill-row__name{ flex:1 1 auto; }
.skill-row__stat{
  font-size:10.5px;
  color:#8a7757;
  flex:0 0 auto;
}
@media (max-width:640px){
  .skills-grid{ grid-template-columns:1fr; }
}

.combat-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(110px,1fr));
  gap:10px;
}
.combat-item{
  background:var(--color-paper-2);
  border:1px solid var(--color-line);
  border-radius:10px;
  padding:10px 8px;
  text-align:center;
  transition:box-shadow .15s, border-color .15s;
}
.combat-item:hover{
  border-color:var(--color-amber-soft);
  box-shadow:var(--shadow);
}
.combat-item__label{
  font-size:10px;
  letter-spacing:.6px;
  text-transform:uppercase;
  color:#8a7757;
  margin-bottom:5px;
}
.combat-item input{
  width:100%;
  text-align:center;
  font-family:'Neucha',cursive;
  font-size:20px;
  border:1px solid var(--color-line);
  border-radius:7px;
  padding:4px 0;
  background:var(--color-paper);
}
.combat-item input[readonly]{
  background:var(--color-sand);
  color:var(--color-amber-dark);
  font-weight:700;
}

.combat-item select#f-hitDieCustom{
  width:100%;
  margin-top:6px;
  font-family:'Neucha',cursive;
  font-size:15px;
  text-align:center;
  text-align-last:center;
  color:var(--color-amber-dark);
  background:var(--color-paper);
  border:1px solid var(--color-line);
  border-radius:7px;
  padding:4px 6px;
  cursor:pointer;
  transition:border-color .15s, box-shadow .15s;
  appearance:none;
  -webkit-appearance:none;
  background-image:linear-gradient(45deg, transparent 50%, var(--color-amber) 50%), linear-gradient(135deg, var(--color-amber) 50%, transparent 50%);
  background-position:calc(100% - 14px) center, calc(100% - 9px) center;
  background-size:5px 5px, 5px 5px;
  background-repeat:no-repeat;
}
.combat-item select#f-hitDieCustom:hover{
  border-color:var(--color-amber-soft);
}
.combat-item select#f-hitDieCustom:focus{
  outline:none;
  border-color:var(--color-amber);
  box-shadow:0 0 0 2px rgba(184,114,12,.18);
}

input[type=number]{
  position:relative;
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button{
  opacity:1;
  height:22px;
  cursor:pointer;
  filter:sepia(60%) saturate(400%) hue-rotate(-10deg) brightness(.9);
}
.combat-item input[type=number]{
  transition:border-color .15s, box-shadow .15s;
}
.combat-item input[type=number]:hover,
.combat-item input[type=number]:focus{
  border-color:var(--color-amber-soft);
  outline:none;
}
.combat-item input[type=number]:focus{
  box-shadow:0 0 0 2px rgba(184,114,12,.18);
}
.field input[type=number]:hover,
.field input[type=number]:focus,
.stat-card__score:hover,
.stat-card__score:focus,
.resource-row input[type=number]:hover,
.resource-row input[type=number]:focus{
  border-color:var(--color-amber-soft);
  outline:none;
  box-shadow:0 0 0 2px rgba(184,114,12,.15);
}

/* firefox то показывает стрелки, то нет - textfield их прячет постоянно, а на hover/focus возвращаем обратно */
input[type=number]{ -moz-appearance:textfield; }
input[type=number]:hover,
input[type=number]:focus{
  -moz-appearance:auto;
}

.resources-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.resource-row{
  display:flex;
  align-items:center;
  gap:8px;
  background:var(--color-paper-2);
  border:1px solid var(--color-line);
  border-radius:9px;
  padding:8px 10px;
}
.resource-row input[type=text]{
  flex:1 1 150px;
  font-weight:600;
  border:none;
  background:transparent;
  font-size:13.5px;
  padding:2px 4px;
}
.resource-row input[type=number]{
  width:56px;
  text-align:center;
  border:1px solid var(--color-line);
  border-radius:6px;
  padding:4px;
  background:var(--color-paper);
}
.resource-row__sep{ color:#8a7757; }
.resource-row__remove{
  flex:0 0 auto;
  background:none;
  border:none;
  border-radius:6px;
  padding:2px 6px;
  color:#a33;
  font-size:16px;
  cursor:pointer;
}
.resource-row__remove:hover{ background:rgba(163,51,51,.1); }
.add-row-btn{
  align-self:flex-start;
  background:var(--color-sand);
  border:1px dashed var(--color-line);
  color:var(--color-amber-dark);
  font-size:12.5px;
  font-weight:600;
  padding:7px 14px;
  border-radius:8px;
  cursor:pointer;
  margin-top:4px;
}
.add-row-btn:hover{ background:var(--color-sand-dark); }

.paths-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(160px,1fr));
  gap:8px;
}
.path-check{
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid var(--color-line);
  border-left:4px solid var(--path-color, var(--color-amber));
  border-radius:8px;
  padding:8px 10px;
  font-size:12.5px;
  background:var(--color-paper-2);
  transition:background .12s;
}
.path-check:has(input:checked){
  background:var(--color-sand);
  font-weight:600;
}
.path-check input{
  accent-color:var(--color-amber);
  width:14px;
  height:14px;
  flex:0 0 auto;
}

.spell-search-row{
  display:flex;
  gap:10px;
  margin-bottom:10px;
}
.spell-search-row select,
.spell-search-row input{
  font-family:inherit;
  font-size:13.5px;
  border:1px solid var(--color-line);
  border-radius:8px;
  padding:7px 10px;
  background:var(--color-paper-2);
}
.spell-search-row input{ flex:1 1 auto; }
.spell-search-results{
  display:flex;
  flex-direction:column;
  gap:4px;
  max-height:180px;
  overflow-y:auto;
  margin-bottom:12px;
  border:1px solid var(--color-line);
  border-radius:8px;
  padding:6px;
}
.spell-search-results:empty{ display:none; }
.spell-result-item{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
  padding:6px 8px;
  border-radius:6px;
  font-size:13px;
  cursor:pointer;
}
.spell-result-item:hover{ background:var(--color-sand); }
.spell-result-item__tier{
  font-size:11px;
  color:#8a7757;
  flex:0 0 auto;
}
.known-spells-list{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}
.known-spell-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  background:var(--color-sand);
  border-radius:12px;
  padding:5px 6px 5px 12px;
  font-size:12.5px;
  color:var(--color-amber-dark);
}
.known-spell-chip a{ color:var(--color-amber-dark); font-weight:600; }
.known-spell-chip button{
  background:rgba(122,74,8,.15);
  border:none;
  color:var(--color-amber-dark);
  width:16px;
  height:16px;
  border-radius:50%;
  cursor:pointer;
  font-size:11px;
  line-height:1;
}
.known-spell-chip button:hover{ background:rgba(122,74,8,.28); }

.equipment-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
}
.equip-slot{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.equip-slot__label{
  font-size:10.5px;
  font-weight:700;
  letter-spacing:.5px;
  text-transform:uppercase;
  color:#8a7757;
}
.equip-slot input{
  font-family:inherit;
  font-size:13.5px;
  border:1px solid var(--color-line);
  border-radius:8px;
  padding:6px 10px;
  background:var(--color-paper-2);
}
.accessories-limit{
  display:flex;
  align-items:center;
  gap:10px;
  margin-top:6px;
  font-size:12.5px;
  color:#6b5a45;
}
.accessories-limit input{
  width:44px;
  text-align:center;
  border:1px solid var(--color-line);
  border-radius:6px;
  padding:4px;
}
@media (max-width:640px){
  .equipment-grid{ grid-template-columns:1fr; }
}

.mastery-picker{
  display:flex;
  gap:10px;
  align-items:center;
  margin-bottom:14px;
  flex-wrap:wrap;
}
.mastery-picker select{
  font-family:inherit;
  font-size:13.5px;
  border:1px solid var(--color-line);
  border-radius:8px;
  padding:7px 10px;
  background:var(--color-paper-2);
}
.mastery-tiers{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.mastery-tier{
  display:flex;
  gap:10px;
  align-items:flex-start;
  border:1px solid var(--color-line);
  border-radius:9px;
  padding:8px 12px;
  background:var(--color-paper-2);
  opacity:.5;
  transition:opacity .15s, background .15s, border-color .15s;
}
.mastery-tier.is-unlocked{
  opacity:1;
  background:var(--color-sand);
  border-color:var(--color-amber-soft);
}
.mastery-tier__num{
  flex:0 0 auto;
  width:26px;
  height:26px;
  border-radius:50%;
  background:var(--color-amber);
  color:#fff;
  font-family:'Neucha',cursive;
  font-size:14px;
  display:flex;
  align-items:center;
  justify-content:center;
}
.mastery-tier__body{ flex:1 1 auto; }
.mastery-tier__type{
  font-size:10px;
  font-weight:700;
  letter-spacing:.4px;
  text-transform:uppercase;
  color:var(--color-amber-dark);
  margin-bottom:2px;
}
.mastery-tier__text{
  font-size:12.5px;
  line-height:1.5;
  color:#4a3d2a;
}
.mastery-tier input[type=checkbox]{
  accent-color:var(--color-amber);
  width:16px;
  height:16px;
  margin-top:2px;
  flex:0 0 auto;
}

.mastery-entry{
  border:1px solid var(--color-line);
  border-radius:10px;
  padding:12px 14px;
  margin-bottom:14px;
  background:var(--color-paper-2);
}
.mastery-entry__head{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom:8px;
}
.mastery-entry__name{
  font-family:'Neucha',cursive;
  font-size:18px;
  color:var(--color-amber-dark);
  flex:1 1 auto;
}
.mastery-entry__tier-select{
  font-family:inherit;
  font-size:12.5px;
  border:1px solid var(--color-line);
  border-radius:6px;
  padding:4px 6px;
  background:var(--color-paper);
}
.mastery-entry__remove{
  background:none;
  border:none;
  color:#a33;
  cursor:pointer;
  font-size:17px;
  padding:2px 6px;
  border-radius:6px;
  flex:0 0 auto;
}
.mastery-entry__remove:hover{ background:rgba(163,51,51,.1); }

.field select,
.spell-search-row select,
.mastery-picker select,
.mastery-entry__tier-select{
  appearance:none;
  -webkit-appearance:none;
  background-image:linear-gradient(45deg, transparent 50%, var(--color-amber) 50%), linear-gradient(135deg, var(--color-amber) 50%, transparent 50%);
  background-position:calc(100% - 14px) center, calc(100% - 9px) center;
  background-size:5px 5px, 5px 5px;
  background-repeat:no-repeat;
  padding-right:28px;
  cursor:pointer;
  transition:border-color .15s, box-shadow .15s;
}
.field select:hover,
.spell-search-row select:hover,
.mastery-picker select:hover,
.mastery-entry__tier-select:hover{
  border-color:var(--color-amber-soft);
}
.spell-search-row select:focus,
.mastery-picker select:focus,
.mastery-entry__tier-select:focus{
  outline:none;
  border-color:var(--color-amber);
  box-shadow:0 0 0 2px rgba(184,114,12,.18);
}

.known-spells-group{
  margin-bottom:10px;
}
.known-spells-group__title{
  font-size:11px;
  font-weight:700;
  letter-spacing:.8px;
  text-transform:uppercase;
  color:#8a7757;
  margin-bottom:6px;
}

.available-spells-list{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-bottom:4px;
}
.available-spell-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-family:inherit;
  font-size:12.5px;
  font-weight:600;
  color:var(--color-amber-dark);
  background:var(--color-paper);
  border:1.5px solid var(--color-amber-soft);
  border-radius:12px;
  padding:5px 12px;
  cursor:pointer;
  transition:background .15s, border-color .15s, transform .1s;
}
.available-spell-chip:hover:not(:disabled){
  background:var(--color-sand);
  border-color:var(--color-amber);
  transform:translateY(-1px);
}
.available-spell-chip:disabled,
.available-spell-chip.is-known{
  opacity:.45;
  cursor:default;
  border-style:dashed;
}
.available-spell-chip__tier{
  font-size:10px;
  font-weight:400;
  color:#8a7757;
  font-style:italic;
}

.personality-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
}
@media (max-width:640px){
  .personality-grid{ grid-template-columns:1fr; }
}

.field--wide textarea{ min-height:110px; }

/* Final cleanup: semantic replacements for static inline presentation. */
.field--span-2{ grid-column:span 2; }
.sheet-block--inset{ margin-top:16px; }
.sheet-help{ margin:-6px 0 10px; color:#8a7757; font-size:12px; font-style:italic; line-height:1.5; }
.spell-search-row--options{ align-items:center; flex-wrap:wrap; gap:10px 16px; margin-top:14px; }
.block-toggle--compact{ font-size:12.5px; }
.spell-search-row__spacer{ flex:1 1 auto; }
.known-spells-count{ color:#8a7757; font-size:12px; }
.known-spells-search{ box-sizing:border-box; width:100%; margin-top:8px; padding:7px 10px; border:1px solid var(--color-line); border-radius:8px; background:var(--color-paper-2); font:inherit; font-size:13.5px; }
.known-spells-search:focus{ outline:none; border-color:var(--yd-brand,var(--color-amber)); box-shadow:0 0 0 3px var(--yd-focus-ring,rgba(210,157,42,.18)); }
.known-spells-list--spaced{ margin-top:10px; }
.field--spaced{ margin-bottom:10px; }
.field--spaced-lg{ margin-bottom:12px; }
.add-row-btn--inline{ margin-top:0; }
@media(max-width:640px){ .field--span-2{ grid-column:auto; } .spell-search-row--options{ align-items:flex-start; } .spell-search-row__spacer{ display:none; } }

/* Stage 3: shared character-sheet geometry. */
.yd-account-page .sheet-toolbar{border-radius:var(--yd-radius-card);box-shadow:var(--yd-shadow-1);padding:var(--yd-space-4) var(--yd-space-5)}
.yd-account-page .sheet-toolbar__btn{min-height:40px;border-radius:var(--yd-radius-control)}
.yd-account-page .sheet-page{border-radius:var(--yd-radius-card);box-shadow:var(--yd-shadow-1)}
.yd-account-page .sheet-block__title{border-bottom-color:var(--yd-surface-muted)}
.yd-account-page .field input[type=text],.yd-account-page .field input[type=number],.yd-account-page .field select,.yd-account-page .field textarea{min-height:40px;border-radius:var(--yd-radius-control);background:var(--yd-surface-raised)}
.yd-account-page .field input[type=text]:focus,.yd-account-page .field input[type=number]:focus,.yd-account-page .field select:focus,.yd-account-page .field textarea:focus{outline:none;border-color:var(--yd-brand);box-shadow:0 0 0 3px var(--yd-focus-ring)}
.yd-account-page .stat-card,.yd-account-page .combat-item,.yd-account-page .resource-row,.yd-account-page .mastery-tier,.yd-account-page .mastery-entry{border-radius:var(--yd-radius-control);box-shadow:var(--yd-shadow-1)}
.yd-account-page .stat-card:hover,.yd-account-page .combat-item:hover{border-color:var(--yd-brand-soft);box-shadow:var(--yd-shadow-2)}
.yd-account-page .known-spell-chip,.yd-account-page .available-spell-chip{border-radius:999px}
.yd-account-page .path-check{border-radius:var(--yd-radius-control)}
.yd-account-page .add-row-btn{min-height:36px;border-radius:var(--yd-radius-control)}
@media (max-width:720px){.yd-account-page .sheet-page{padding:var(--yd-space-4)}.yd-account-page .sheet-toolbar{position:static;padding:var(--yd-space-4)}}

@media print{
  .sheet-toolbar, .site-header, .nav-overlay, .nav-drawer{ display:none !important; }
  body{ background:#fff; padding:0; }
  .cont{ padding:0; max-width:none; }
  .center{ padding:0; }
  .sheet-page{
    box-shadow:none;
    border:1px solid #999;
    border-top:1px solid #999;
    break-after:page;
    margin-bottom:0;
  }
  .sheet-page:last-child{ break-after:auto; }
  .sheet-page__pagenum{ display:none; }
  /* это рабочий инструмент подбора заклинаний, на бумаге он бессмысленен */
  #block-available-spells{ display:none !important; }
  .stat-card::before{ display:none; }
}
