/* D&D sheet only: the existing mobile layout keeps its dimensions. */
.character-profile, .character-notes { display: grid; gap: 20px; margin-bottom: 26px; }
.character-profile[hidden], .character-profile [hidden], .character-notes[hidden], .character-notes [hidden] { display: none !important; }
.profile-info { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin: 0; }
.profile-detail { min-width: 0; }
.profile-detail dt { margin-bottom: 6px; color: var(--muted); font: 700 11px/1.4 system-ui,sans-serif; }
.profile-detail dd { min-height: 44px; box-sizing: border-box; margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; background: #11262c; color: var(--text); font: 600 15px/1.5 system-ui,sans-serif; overflow-wrap: anywhere; }
.profile-heading, .character-note h3 { margin: 0 0 9px; color: var(--accent); font: 700 13px/1.4 system-ui,sans-serif; }
.profile-narrative p, .character-note p { margin: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 7px; background: #153139; color: var(--text); font: 400 14px/1.7 system-ui,sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; }
.character-note .sheet-textarea { box-sizing: border-box; field-sizing: content; min-height: 130px; font: 400 14px/1.7 system-ui,sans-serif; }
.profile-appearance-row { display: grid; grid-template-columns: minmax(0,180px) minmax(0,1fr); gap: 18px; align-items: start; }
.profile-portrait { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1; overflow: hidden; border: 1px solid #987d4d; border-radius: 12px; background: #24464b; color: #f0d49d; }
.profile-portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.profile-initial { font: 600 64px/1 Georgia,serif; }
@media (max-width: 699px) {
  .character-profile { gap: 17px; }
  .profile-appearance-row { grid-template-columns: 96px minmax(0,1fr); gap: 12px; }
  .profile-physical { gap: 10px; }
  .profile-detail dd { padding: 9px 8px; font-size: 14px; }
  .profile-detail dt { font-size: 10px; }
  .profile-narrative p { padding: 11px 12px; }
}
.equipment-summary { margin: 0 0 20px; padding: 14px 16px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; background: #19343a; }
.equipment-summary h2 { margin: 0 0 12px; color: var(--accent); font: 700 13px/1.4 system-ui, sans-serif; }
.equipment-summary p { margin: 0; color: var(--text); font: 400 14px/1.7 system-ui, sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; }
:is(.cabinet.sheet-open, body:has(> main.sheet)) {
  --bg: #0c1c21;
  --panel: #142b31;
  --border: #36535a;
  --text: #f3f3e9;
  --muted: #b0c4c8;
  --accent: #f0c879;
  --accent-text: #172525;
  --teal: #7ee3b8;
  --danger: #ff9b89;
  --sheet-cyan: #87d8f0;
  --sheet-violet: #d0b3ff;
  color-scheme: dark;
  background: var(--bg);
}

.cabinet.sheet-open :is(.sheet-name, .section-label, .sheet-choices legend) { color: var(--accent); }
.cabinet.sheet-open .sheet-name { font-family: Georgia, "Times New Roman", serif; }
.cabinet.sheet-open .sheet-subtitle { color: #c5d4d5; }
.cabinet.sheet-open .sheet-portrait {
  background: #244c51;
  border-color: #bd995c;
  color: #ffe3ab;
  border-radius: 9px;
  box-shadow: 0 0 0 3px #d9b87013;
}
.cabinet.sheet-open :is(.metric-value, .sheet-input[type="number"], .hp-readout) { font-variant-numeric: tabular-nums; }
.cabinet.sheet-open .sheet-header-stats > .sheet-stat { background: #142e35; border-color: #36535a; border-radius: 9px; }
.cabinet.sheet-open .sheet-header-stats > .sheet-stat:nth-child(2) { color: #f0c879; background: #363222; border-color: #857044; }
.cabinet.sheet-open .sheet-header-stats > .sheet-stat:nth-child(3) { color: var(--sheet-violet); background: #2b2943; border-color: #71628d; }
.cabinet.sheet-open .sheet-header-stats .shield-stat { color: #b8efff; border-color: #61bddb; background: #123b4a; border-radius: 9px 9px 23px 23px; }
.cabinet.sheet-open [data-hp-state="normal"] { --hp-state-color: #7ee3b8; }
.cabinet.sheet-open [data-hp-state="warning"] { --hp-state-color: #ffcf78; }
.cabinet.sheet-open [data-hp-state="critical"] { --hp-state-color: #ff9b89; }
.cabinet.sheet-open [data-hp-state="unknown"] { --hp-state-color: #b0c4c8; }
.cabinet.sheet-open .sheet-header-stats .hp-stat {
  color: var(--hp-state-color, #7ee3b8);
  border-color: var(--hp-state-color, #7ee3b8);
  background: #153d32;
  box-shadow: inset 0 0 20px #7ee3b80a;
}
.cabinet.sheet-open .sheet-header-stats .hp-stat[data-hp-state="warning"] { background: #3d3320; }
.cabinet.sheet-open .sheet-header-stats .hp-stat[data-hp-state="critical"] { background: #482b2b; }
.cabinet.sheet-open .stat-label { color: #c0d1d4; }
.cabinet.sheet-open .sheet-save-state { color: var(--teal); }
.cabinet.sheet-open .sheet-save-state[data-state="error"] { color: var(--danger); }
.cabinet.sheet-open .sheet-save-state:is([data-state="dirty"], [data-state="saving"]) { color: var(--accent); }

/* Color follows the six real ability groups; labels remain the primary cue. */
.cabinet.sheet-open .ability-block { --ability-color: #ffac95; }
.cabinet.sheet-open .ability-block:nth-child(2) { --ability-color: #8ddda5; }
.cabinet.sheet-open .ability-block:nth-child(3) { --ability-color: #f1d18c; }
.cabinet.sheet-open .ability-block:nth-child(4) { --ability-color: #9ed5ff; }
.cabinet.sheet-open .ability-block:nth-child(5) { --ability-color: #c7b0f5; }
.cabinet.sheet-open .ability-block:nth-child(6) { --ability-color: #f1afd0; }
.cabinet.sheet-open .ability-score { border-color: var(--ability-color); }
.cabinet.sheet-open .ability-score :is(.field-label, .sheet-input) { color: var(--ability-color); }
.cabinet.sheet-open .roll-value { background: #203c44; border-color: #54777f; color: #f0f8f8; border-radius: 6px; }
.cabinet.sheet-open .ability-block .roll-value {
  color: var(--ability-color);
  border-color: color-mix(in srgb, var(--ability-color) 50%, #29444a);
  background: color-mix(in srgb, var(--ability-color) 12%, #10272d);
}
.cabinet.sheet-open .ability-roll { color: #c3d1d3; }
.cabinet.sheet-open .skill-row.is-proficient { background: #1c443f; }
.cabinet.sheet-open .skill-row.is-proficient .skill-name { color: #b2f2d2; }
.cabinet.sheet-open .skill-row::before { color: #9fc4ca; }
.cabinet.sheet-open .skill-row.is-proficient::before { color: var(--teal); }
.cabinet.sheet-open .skill-rank { background: transparent; }
.cabinet.sheet-open :is(.sheet-input, .sheet-textarea) { background-color: #11262c; border-color: #45616a; border-radius: 6px; }
.cabinet.sheet-open .ability-score .sheet-input { background: transparent; border-color: transparent; }
.cabinet.sheet-open :is(.sheet-input, .sheet-textarea)::placeholder { color: #9aafb5; }
.cabinet.sheet-open :is(.sheet-input, .sheet-textarea):hover { border-color: #73949c; }
.cabinet.sheet-open .sheet-input:invalid { border-color: var(--danger); }
.cabinet.sheet-open :is(select, .skill-rank) option { background: #142b31; color: var(--text); }
.cabinet.sheet-open .sheet-check input { accent-color: var(--teal); }
.cabinet.sheet-open .passive-row .metric-value { color: var(--sheet-cyan); }
.cabinet.sheet-open :is(.sheet-button, .combat-stat) { background-color: #1a343a; border-color: #49666d; border-radius: 7px; }
.cabinet.sheet-open .sheet-combat > .sheet-field { background-color: #243039; border-color: #5d6674; border-radius: 7px; }
.cabinet.sheet-open .sheet-combat > .combat-stat:first-child { color: #b7eaff; background-color: #173b49; border-color: #5b9cac; }
.cabinet.sheet-open .inspiration .inspiration-icon { color: #bcaf8e; }
.cabinet.sheet-open .inspiration[aria-pressed="true"] { background-color: #41371f; border-color: var(--accent); }
.cabinet.sheet-open .inspiration[aria-pressed="true"] .inspiration-icon { color: #ffda81; text-shadow: 0 0 12px #ffcc7350; }
.cabinet.sheet-open .condition-stat { background-color: #3b2e30; border-color: #a5766c; }
.cabinet.sheet-open .sheet-tabs { border-bottom-color: #3b555a; }
.cabinet.sheet-open .sheet-tab { color: #b9cdd0; }
.cabinet.sheet-open .sheet-tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.cabinet.sheet-open .collection-row { background: #162e34; border-color: #36535a; border-radius: 8px; }
.cabinet.sheet-open .attacks-row { border-left-color: #c28e72; box-shadow: inset 3px 0 #c28e72; }
.cabinet.sheet-open .equipment-row { border-left-color: #80b3a4; box-shadow: inset 3px 0 #80b3a4; }
.cabinet.sheet-open .sheet-remove { color: #c4c1b9; }
.cabinet.sheet-open .sheet-remove:hover { color: var(--danger); background: #582e2b; border-radius: 5px; }
.cabinet.sheet-open .sheet-warning { color: #f4cd8f; }
.cabinet.sheet-open .sheet-error { color: #ffc0b0; background: #44292b; border-color: var(--danger); }
.cabinet.sheet-open .sheet-coins .field-label { color: #f0ce92; }
.cabinet.sheet-open .sheet-coins .sheet-input { color: #ffe3a9; background: #302e22; border-color: #776441; }
.cabinet.sheet-open .sheet-wild-shape { border-color: #4b7770; }
.cabinet.sheet-open .sheet-wild-shape[data-active="true"] { background-color: #163c302e; }

/* Spell and assistant surfaces have a distinct violet family. */
.cabinet.sheet-open :is(.spell-stat .metric-value, .grimoire-title, .dnd-advice-title) { color: var(--sheet-violet); }
.cabinet.sheet-open .slot-row { border-color: #48405a; }
.cabinet.sheet-open .slot-circle { border-color: #b093df; background: #221f32; }
.cabinet.sheet-open .slot-circle[aria-pressed="true"] { background: #bf9aed; border-color: #dfc8ff; box-shadow: inset 0 0 0 3px #5b427e; }
.cabinet.sheet-open .slot-count { color: #c5b5db; }
.cabinet.sheet-open .grimoire-card { background: #25283b; border-color: #605474; border-radius: 10px; box-shadow: inset 3px 0 #a486cf; }
.cabinet.sheet-open .grimoire-spell-name { color: #ead9ff; }
.cabinet.sheet-open .grimoire-spell-meta { color: #cabedc; }
.cabinet.sheet-open .grimoire-spell-summary { color: #b5bdcd; }
.cabinet.sheet-open .grimoire-badge { background: #423453; color: #ead7ff; }
.cabinet.sheet-open .grimoire-card .sheet-button[aria-pressed="true"] { background: #3c3051; color: #eedbff; border-color: #b895e6; }
.cabinet.sheet-open .dnd-advice-topic[aria-pressed="true"] { background: #413354; border-color: #be9ce9; color: #f0dfff; }
.cabinet.sheet-open .dnd-advice-submit { background: #694b87; border-color: #b48ddc; color: #fff3ff; }
.cabinet.sheet-open .dnd-advice-source { color: #bcdfff; }
.cabinet.sheet-open :is(.sheet-dialog, .grimoire-dialog) { background: #142b31; border-color: #8d7952; color: var(--text); border-radius: 12px; }
.cabinet.sheet-open :is(.sheet-dialog, .grimoire-dialog)::backdrop { background: #030c10cf; backdrop-filter: blur(4px); }
.cabinet.sheet-open .grimoire-dialog { background: #202638; border-color: #b499d3; }
.cabinet.sheet-open .hp-counter { --hp-bg: #0e242a; --hp-text: #f3f3e9; --hp-border: #53767c; --hp-teal: #7ee3b8; border-color: #53766c; }
.cabinet.sheet-open .hp-counter .hp-key { background-color: #18353c; border-radius: 7px; }
.cabinet.sheet-open .hp-counter .hp-heal { color: #a2f1c9; background-color: #1a4436; border-color: #6fb995; }
.cabinet.sheet-open .hp-counter .hp-damage { color: #ffc1ac; background-color: #4a2d2a; border-color: #b77567; }
.cabinet.sheet-open .hp-counter .hp-temp { color: #b4e9ff; }
.cabinet.sheet-open .hp-counter .hp-settings { color: #c2cbd2 !important; }
.cabinet.sheet-open .hp-counter .hp-expression { background-color: #0c1d22; border-color: #7caaa9; border-radius: 7px; }
.cabinet.sheet-open .initiative-result { background: #25243e; box-shadow: 0 8px 32px #0008, inset 0 0 0 1px #a88ac2; }
.cabinet.sheet-open :is(.initiative-subtitle, .initiative-damage) { color: #f4d18e; }
.cabinet.sheet-open .initiative-total { color: #f3d397; }

.cabinet.sheet-open :is(.sheet-button, button.sheet-stat, .combat-stat, .roll-value, .slot-circle):hover:not(:disabled) {
  background-color: #31515a;
  border-color: #c9cfb5;
}
.cabinet.sheet-open :is(.sheet-tab, .sheet-back, .grimoire-spell-name):hover { color: #ffe0a4; }
.cabinet.sheet-open :is(button, input, select, textarea, a, summary, [role="tabpanel"]):focus-visible {
  outline: 2px solid #ffda88;
  outline-offset: 3px;
}
.cabinet.sheet-open :is(button, a, summary):active { filter: brightness(.92); }
.cabinet.sheet-open .sheet-input:focus-visible, .cabinet.sheet-open .sheet-textarea:focus-visible { background-color: #1b353b; }

@media (min-width: 700px) {
  .cabinet.sheet-open .sheet-hero {
    padding-inline: 18px;
    background: #132e34;
    border: 1px solid #466366;
    border-radius: 12px;
    box-shadow: inset 3px 0 #d6b674, 0 8px 24px #0002;
  }
  .cabinet.sheet-open .sheet-header-stats .sheet-stat { min-height: 64px; }
  .cabinet.sheet-open .ability-score { padding-bottom: 7px; border-bottom-width: 2px; }
  .cabinet.sheet-open .sheet-right { background: #11272d; border-radius: 10px; box-shadow: 0 0 0 12px #11272d; }
}

@media (max-width: 699px) {
  .cabinet.sheet-open .sheet-mobile-header { background: #15353c; box-shadow: inset 0 3px #c8a767, 0 5px 20px #0003; }
  .cabinet.sheet-open .sheet-mobile-header .sheet-name { font-family: inherit; color: #f7ddb0; }
  .cabinet.sheet-open .sheet-mobile-subtitle { color: #c6dcdd; }
  .cabinet.sheet-open .sheet-mobile-tools-toggle { color: #f1d093; }
  .cabinet.sheet-open .sheet-mobile-tools-toggle::after { background: var(--teal); }
  .cabinet.sheet-open .sheet-mobile-tools-toggle:is([data-save-state="dirty"], [data-save-state="saving"])::after { background: var(--accent); }
  .cabinet.sheet-open .sheet-mobile-tools-toggle[data-save-state="error"]::after { background: var(--danger); }
  .cabinet.sheet-open .sheet-topbar[popover] { background: #142e35; border-color: #8f7c53; color: var(--text); box-shadow: 0 12px 40px #0009; }
  .cabinet.sheet-open .sheet-mobile-menu-status { color: #b9ced1; }
  .cabinet.sheet-open .sheet-mobile-header .sheet-header-stats > .sheet-stat:not(.hp-stat) { background: transparent; border-color: transparent; }
  .cabinet.sheet-open .sheet-mobile-header .sheet-header-stats > .sheet-stat:nth-child(2) { color: #f0d18f; }
  .cabinet.sheet-open .sheet-mobile-header .shield-stat { border: 0; border-radius: 0; color: #d6f6ff; }
  .cabinet.sheet-open .shield-stat .sheet-mobile-stat-icon { color: #72cce8; }
  .cabinet.sheet-open .sheet-mobile-header .hp-stat { background: #174536; border-color: var(--hp-state-color, #7ee3b8); border-radius: 7px; }
  .cabinet.sheet-open .sheet-mobile-shape-toggle { color: #d5b6ff; }
  .cabinet.sheet-open .sheet-mobile-header .stat-label { color: #c5dce0; }
  .cabinet.sheet-open .sheet-mobile-header .combat-stat { background: transparent; border: 0; border-radius: 0; }
  .cabinet.sheet-open .sheet-mobile-header .combat-stat .metric-value { color: #b7eaff; background: #123e4c; border-color: #6c9fac; border-radius: 7px; }
  .cabinet.sheet-open .sheet-mobile-header .inspiration-icon { background: #333528; border-color: #9c8d63; border-radius: 7px; }
  .cabinet.sheet-open .sheet-mobile-header .inspiration[aria-pressed="true"] .inspiration-icon { background: #50401f; border-color: #e9c878; }
  .cabinet.sheet-open .sheet-mobile-header .sheet-mobile-condition-count { color: #ffd0b8; background: #48332d; border-color: #ac8774; border-radius: 7px; }
  .cabinet.sheet-open .sheet-mobile-header .sheet-combat > .sheet-field { background: transparent; border: 0; border-radius: 0; }
  .cabinet.sheet-open .sheet-mobile-header .sheet-combat .sheet-input { background: #28333d; color: #dad4e9; border-color: #818596; border-radius: 7px; }
  .cabinet.sheet-open .sheet-mobile-header .sheet-combat .field-label { color: #c5dce0; }
  .cabinet.sheet-open .sheet-mobile-collapse { color: #c9dcdd; }
  .cabinet.sheet-open .sheet-mobile-collapse::before, .cabinet.sheet-open .sheet-mobile-collapse::after { background: #58777b; }
  .cabinet.sheet-open .sheet-mobile-section-select { background: #1c3036; border-color: #b79a63; box-shadow: inset 3px 0 #e5c47d; color: #f3dfb9; border-radius: 7px; }
  .cabinet.sheet-open .sheet-mobile-section-picker > svg { color: #e3c07d; }
  .cabinet.sheet-open .ability-score::after { background: var(--ability-color); opacity: .4; }
  .cabinet.sheet-open .ability-score :is(.field-label, .sheet-input) { color: var(--ability-color); }
  .cabinet.sheet-open .ability-block[aria-label="Телосложение"] .ability-score .field-label { font-size: 22px; white-space: nowrap; overflow-wrap: normal; }
  .cabinet.sheet-open .ability-roll { border-color: #607c83; color: #cbdcde; }
  .cabinet.sheet-open .ability-roll > .roll-value { border-color: #72969b; }
  .cabinet.sheet-open .ability-roll .sheet-check input:checked { background: #8ae6b9; box-shadow: inset 0 0 0 3px #0c1c21; }
  .cabinet.sheet-open .skill-row > .roll-value { border-color: #72969b; }
  .cabinet.sheet-open #sheet-root :is(button, input, select, textarea, a):focus-visible { outline-color: #ffda88; }
}

@media (max-width: 359px) {
  .cabinet.sheet-open .ability-block[aria-label="Телосложение"] .ability-score .field-label { font-size: 18px; }
}

/* The account's read-only route has its own DOM and no body class. */
body:has(> main.sheet) > header { background: #122b31; border-color: #45605f; }
body:has(> main.sheet) .logo { color: #f0ce8e; font-family: Georgia, "Times New Roman", serif; }
main.sheet .sheet-head { border-bottom: 1px solid #806c48; padding-bottom: 20px; }
main.sheet .sheet-title { color: #f5d49a; font-family: Georgia, "Times New Roman", serif; font-weight: 600; }
main.sheet .sheet-head .portrait { background: #254b51; border: 1px solid #c7a46a; color: #f5d49a; }
main.sheet .sheet-section { background: #132c33; border-color: #3c5960; border-radius: 12px; }
main.sheet .sheet-section h2 { color: #ebca8b; }
main.sheet .stat { background: #19343b; border-color: #47636b; border-radius: 8px; }
main.sheet :is(.stat dd, .ability-mod, .check-value) { font-variant-numeric: tabular-nums; }
/* Read-only HP has no status attribute, so its colors stay neutral. */
main.sheet #sheet > .sheet-section:first-of-type .stat:nth-child(3) { background: #173f4f; border-color: #629eb3; }
main.sheet #sheet > .sheet-section:first-of-type .stat:nth-child(3) dd { color: #b7ebff; }
main.sheet #sheet > .sheet-section:first-of-type .stat:nth-child(6) { background: #342d49; border-color: #8b76ac; }
main.sheet #sheet > .sheet-section:first-of-type .stat:nth-child(6) dd { color: #dfc3ff; }
main.sheet .ability { --ability-color: #ffac95; background: #172e35; border-color: #557077; box-shadow: inset 0 3px var(--ability-color); }
main.sheet .ability:nth-child(2) { --ability-color: #8ddda5; }
main.sheet .ability:nth-child(3) { --ability-color: #f1d18c; }
main.sheet .ability:nth-child(4) { --ability-color: #9ed5ff; }
main.sheet .ability:nth-child(5) { --ability-color: #c7b0f5; }
main.sheet .ability:nth-child(6) { --ability-color: #f1afd0; }
main.sheet :is(.ability-name, .ability-mod) { color: var(--ability-color); }
main.sheet .check-list li { border-color: #36515b; }
main.sheet .mark { color: #9be5c1; }
body:has(> main.sheet) a:focus-visible { outline: 2px solid #ffda88; outline-offset: 3px; }
