/**
 * /characterforge/css/spell_contexts.css
 * Responsive dark-fantasy spell manager sections shared by editor and sheets.
 */
.spell-source { border:1px solid var(--gold,#c5a059); border-radius:5px; margin:14px 0; padding:12px; background:#12100e; }
.spell-source > summary { font-family:'Cinzel',serif; color:var(--gold,#c5a059); cursor:pointer; font-size:1.05rem; }
.spell-source p,.spell-source small { font-family:'Crimson Pro',serif; }
.spell-counts { color:#e4ca8e; }
.spell-note { color:#bcb7ae; }
.spell-warning { border-left:3px solid #c5a059; padding:7px 10px; background:#302719; }
.spell-filters { display:flex; flex-wrap:wrap; gap:12px; padding:12px 0; }
.spell-filters label { display:flex; flex-direction:column; gap:5px; color:#e4ca8e; flex:1 1 135px; }
.spell-filters input,.spell-filters select,.spell-source-actions select { background:#080706; color:#eee; border:1px solid #75623d; border-radius:3px; padding:8px; max-width:100%; }
.spell-source-row { display:flex; align-items:start; justify-content:space-between; gap:12px; padding:12px 0; border-bottom:1px solid #3d3324; }
.spell-source-row > div:first-child { flex:1; min-width:0; }
.spell-description > summary { cursor:pointer; color:#eadbb9; }
.spell-description > div { padding:12px 0; }
.spell-source-actions { display:flex; flex-direction:column; align-items:stretch; gap:6px; max-width:180px; }
.spell-source-actions small { color:#c6b99b; }
.spell-source-actions button:disabled { opacity:.55; cursor:default; }
.spell-source :focus-visible { outline:2px solid #e4c57b; outline-offset:3px; }
.spell-choice-links { display:flex; flex-wrap:wrap; gap:8px; }
.spell-context-modal { width:95%; max-width:850px!important; max-height:90vh; overflow-y:auto; }
#forge-tabs [hidden] { display:none!important; }
@media(max-width:540px) { .spell-source {padding:9px;} .spell-source-row {flex-direction:column;} .spell-source-actions {max-width:100%;flex-direction:row;flex-wrap:wrap;} }

/* Reference-style accordion sections retain the Forge palette and typography. */
.spell-manager-group{margin:12px 0;border:1px solid #51432d;border-radius:4px;background:#171410}
.spell-manager-group>summary{display:flex;align-items:center;justify-content:space-between;gap:12px;list-style:none;cursor:pointer;padding:16px;font:700 1.05rem 'Cinzel',serif;background:linear-gradient(#372b23,#251d18);color:#f2dfb1}
.spell-manager-group>summary::-webkit-details-marker{display:none}
.spell-manager-group>summary:after{content:'⌄';font:700 1.4rem sans-serif;flex:none}
.spell-manager-group[open]>summary{border-left:4px solid #a52c32;padding-left:12px}
.spell-manager-group[open]>summary:after{content:'⌃'}
.spell-manager-group>div,.spell-manager-group>p{margin:0;padding:12px 16px}
.spell-slot-summary{display:flex;flex-wrap:wrap;gap:12px;margin-left:auto}
.spell-slot-summary>span{display:flex;flex-direction:column;text-align:center;font-family:'Crimson Pro',serif}
.spell-slot-summary small{font-weight:400}
.spell-level-filter{flex:1 1 100%}
.spell-level-chips{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.spell-level-chips button{min-width:48px;background:transparent;border:1px solid #a64a42;color:#efdcba;padding:8px;border-radius:4px}
.spell-level-chips button[aria-pressed=true]{background:#6e2025;border-color:#e0b86c;color:white}
.spell-source-row .spell-description>summary{font-size:1.05rem;font-style:italic}
.spell-manager-group .spell-source-row{align-items:start;padding:9px 0}
.spell-manager-group .spell-source-actions button{padding:7px 12px;min-width:95px;border:1px solid #a64a42;background:transparent;color:#f0d5b4}
.spell-status:empty{display:none}
@media(max-width:540px){
 .spell-manager-group>summary{font-size:.9rem;padding:12px}
 .spell-manager-group .spell-source-row{flex-direction:row;gap:8px}
 .spell-manager-group .spell-source-actions{flex-direction:column;max-width:115px}
 .spell-manager-group>div{padding:10px}
 .spell-slot-summary{gap:6px}
}

/* Sheet-style spell drawer uses the same placement as the inspection drawer. */
#spell-manager-modal.cf-spell-drawer{background:transparent;justify-content:flex-end;align-items:stretch;padding:0;pointer-events:none}
#spell-manager-modal.cf-spell-drawer>.forge-modal{pointer-events:auto;margin:0;width:min(540px,60vw)!important;max-width:none!important;height:100dvh;max-height:100dvh;box-sizing:border-box;border-radius:0;overflow:auto;box-shadow:-12px 0 32px #0008;background:#e8d5b5 url('/characterforge/img/char-assets/sunshine-summer-3840-v1.webp') center/cover;color:#2b180d;font-family:'Crimson Pro',serif}
.cf-spell-drawer h2,.cf-spell-drawer summary,.cf-spell-drawer button{font-family:'Cinzel',serif}
.cf-spell-drawer .spell-source{background:transparent;border-color:#ad8c4e}
.cf-spell-drawer .spell-source>summary,.cf-spell-drawer .spell-counts,.cf-spell-drawer .spell-note,.cf-spell-drawer .spell-filters label,.cf-spell-drawer .spell-description>summary,.cf-spell-drawer .spell-source-actions small{color:#52341d}
.cf-spell-drawer .spell-manager-group{background:#fff8;border-color:#b69a64}
.cf-spell-drawer .spell-manager-group>summary{background:#540b0e url('/characterforge/img/char-assets/header-center.webp') center/auto 100%;color:#fff7df}
.cf-spell-drawer .spell-warning{background:#d4b87545;color:#52341d}
.cf-spell-drawer .spell-filters input,.cf-spell-drawer .spell-filters select,.cf-spell-drawer .spell-source-actions select{background:#fff9;color:#2b180d;border-color:#ad8c4e}
.cf-spell-drawer .spell-source-actions button,.cf-spell-drawer .spell-level-chips button{background:#fff8;color:#6e2025}
.cf-spell-drawer .spell-level-chips button[aria-pressed=true]{background:#8b232a;color:white}
.cf-spell-drawer .spell-source-row{border-color:#b69a6466}
.cf-spell-filter{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0 12px}
.cf-spell-filter button{font:700 .8rem 'Cinzel',serif;border:0;border-radius:7px;background:#e9e9e7;color:#64717a;padding:9px 12px;min-height:38px;cursor:pointer}
.cf-spell-filter button[aria-pressed=true]{background:#c82b30;color:white}
.cf-spell-filter button:focus-visible{outline:2px solid #6e4e1b;outline-offset:2px}
@media(max-width:600px){#spell-manager-modal.cf-spell-drawer>.forge-modal{width:100vw!important;padding:15px}.cf-spell-filter button{padding:8px;flex:0 0 auto}}

.cf-spell-drawer .spell-level-chips button{flex:0 0 auto;min-width:52px;width:auto;padding:8px 10px;box-sizing:border-box}

/* Compact sheet-colored filters shared by the spellcasting panel and drawer. */
.cf-spell-filter,.cf-spell-drawer .spell-level-chips{gap:4px;margin:6px 0}
.cf-spell-filter button,.cf-spell-drawer .spell-level-chips button{
    flex:0 0 auto;width:auto;min-width:30px;min-height:28px;
    padding:4px 7px;font:700 .68rem/1.2 'Cinzel',serif;
    color:#6e4e1b;background:#f5ead3;border:1px solid #b69a64;border-radius:4px;
}
.cf-spell-filter button[aria-pressed=true],.cf-spell-drawer .spell-level-chips button[aria-pressed=true]{
    color:#fff7df;background:#540b0e;border-color:#8a692c;
}
.cf-spell-filter button:hover,.cf-spell-drawer .spell-level-chips button:hover{border-color:#6e4e1b;box-shadow:0 0 0 1px #b69a6440}
.cf-spell-drawer{--spell-metadata-color:#52341d}
.cf-spell-drawer .spell-metadata,.cf-spell-drawer .spell-metadata strong{color:#52341d}
.cf-spell-drawer .spell-level-filter>strong{font-size:.82rem}
.cf-spell-drawer .spell-filters{gap:8px;padding:8px 12px}

/* Side drawers keep the underlying sheet sharp. */
#forge-modal-overlay.cf-inspecting,#spell-manager-modal.cf-spell-drawer{backdrop-filter:none!important;-webkit-backdrop-filter:none!important}
.cf-spell-drawer .spell-manager-group .spell-source-row{display:flow-root}
.cf-spell-drawer .spell-source-row>.spell-source-actions{float:right;margin:0 0 6px 12px;max-width:125px}
.cf-spell-drawer .spell-source-row>div:not(.spell-source-actions){display:block;min-width:0}
.cf-spell-drawer .spell-source-row .spell-description>summary{font-size:.9rem;line-height:1.5;min-height:30px;padding:3px 0}
.cf-spell-drawer .spell-list-level{font-family:'Crimson Pro',serif;font-style:normal;color:#6e4e1b}
.cf-spell-drawer .spell-source-actions button{font-size:.72rem;min-width:78px;min-height:28px;padding:5px 8px}
.cf-spell-drawer .spell-description-body{clear:both;display:flow-root;padding:10px 0}
.cf-spell-drawer .spell-description-body>img{height:auto!important;max-width:35%!important;width:140px!important;object-fit:initial!important}
.cf-spell-drawer .spell-entry-note{display:block;font-size:.75rem}

.spell-source-row>.spell-source-actions{order:2;flex:0 0 auto}
.spell-source-row>div:not(.spell-source-actions){order:1;flex:1;min-width:0}

/* Shared sheet drawer shell, side handle and feature-style disclosure icons. */
#forge-modal-overlay.cf-inspecting,#spell-manager-modal.cf-spell-drawer{pointer-events:auto}
.cf-drawer-handle{position:absolute;top:24px;right:min(540px,60vw);width:30px;height:48px;padding:0;border:1px solid #a88642;border-right:0;border-radius:7px 0 0 7px;background:#540b0e;color:#f3d478;cursor:pointer;pointer-events:auto;font-size:15px}
.cf-drawer-close{display:none!important}
.cf-drawer-handle:focus-visible{outline:2px solid #e4bd60;outline-offset:2px}
.sheet-body #forge-modal-overlay.cf-inspecting>.forge-modal{background:#e8d5b5 url('/characterforge/img/char-assets/sunshine-summer-3840-v1.webp') center/cover;color:#2b180d;font-family:'Crimson Pro',serif;--spell-metadata-color:#52341d}
.sheet-body .cf-inspecting :is(h2,h3,h4,summary,button){font-family:'Cinzel',serif}
.sheet-body .cf-inspecting :is(#forge-modal-title,.cf-play-note,.cf-play-field,.cf-play-condition-options p){color:#52341d}
.sheet-body .cf-inspecting .cf-play :is(input,select){background:#fff9;color:#2b180d;border-color:#ad8c4e}
.sheet-body .cf-inspecting .cf-play a{color:#6e4e1b}
.sheet-body .cf-inspecting .cf-play-error{color:#902d25}
.sheet-body .cf-inspecting .cf-play-condition-options details{background:#fff6;border-color:#b69a64}
.sheet-body .cf-inspecting .cf-play-condition-options summary{font-size:.85rem}
:is(.cf-inspecting,.cf-spell-drawer) details>summary{list-style:none}
:is(.cf-inspecting,.cf-spell-drawer) details>summary::-webkit-details-marker{display:none}
:is(.cf-inspecting,.cf-spell-drawer) details>summary::after{
 content:'';display:inline-block;float:right;flex:none;width:18px;height:18px;margin-left:8px;
 background:url('/characterforge/img/char-assets/dropdown-arrow.webp') center/contain no-repeat;transform:none;
}
:is(.cf-inspecting,.cf-spell-drawer) details[open]>summary::after{content:'';transform:rotate(180deg)}
@media(max-width:600px){
 #forge-modal-overlay.cf-inspecting>.forge-modal,#forge-modal-overlay.cf-inspecting>.cf-play-dialog,#spell-manager-modal.cf-spell-drawer>.forge-modal{width:calc(100vw - 30px)!important}
 .cf-drawer-handle{right:calc(100vw - 30px);top:16px}
}

/* Readable parchment controls and legacy breakdown text in inspection drawers. */
.sheet-body .cf-inspecting .forge-modal{--gold:#805b20;--gold-bright:#805b20}
.sheet-body .cf-inspecting #forge-modal-msg{color:#2b180d}
.sheet-body .cf-inspecting #forge-modal-msg [style*="color:#ccc"],
.sheet-body .cf-inspecting #forge-modal-msg [style*="color:#888"],
.sheet-body .cf-inspecting #forge-modal-msg [style*="color:#eee"]{color:#52341d!important}
.sheet-body .cf-inspecting .forge-modal button{font-size:.72rem;padding:5px 8px;background:#fff8;color:#6e2025;border:1px solid #ad8c4e}
.sheet-body .cf-inspecting .forge-modal :is(input,select,textarea){background:#fff9;color:#2b180d;border-color:#ad8c4e}

/* Parchment descriptions must override legacy dark-modal inline colors. */
.sheet-body .cf-inspecting #forge-modal-msg :is(div,p,span,strong,em,li,td,th,caption,h2,h3,h4),
.cf-spell-drawer .spell-description-body :is(div,p,span,strong,em,li,td,th,caption,h2,h3,h4){color:#382312!important}
.sheet-body .cf-inspecting #forge-modal-msg :is(table,thead,tbody,tr,td,th),
.cf-spell-drawer .spell-description-body :is(table,thead,tbody,tr,td,th){background:#fff5!important;border-color:#aa8c58!important}
.sheet-body .cf-inspecting #forge-modal-msg a{color:#764719!important}
.cf-spell-drawer .spell-manager-group .spell-source-row{padding:4px 0}
.cf-spell-drawer .spell-source-row .spell-description>summary{font-size:.85rem;min-height:24px;padding:1px 0}
.cf-spell-drawer .spell-source-row>.spell-source-actions{margin:0 0 3px 7px}
.cf-spell-drawer .spell-manager-group .spell-source-actions button{font-size:.6rem;line-height:1.2;width:76px;min-width:76px;min-height:24px;padding:3px 4px}
.cf-spell-drawer .spell-source-actions .spell-automatic:disabled{opacity:1;color:#6e4e1b;background:#e7dac0;border-color:#aa8c58;cursor:default}

.sheet-body .cf-inspecting #forge-modal-msg .cf-play-error{color:#902d25!important}

/* Parchment item editing is scoped to inspection drawers, never VTT modals. */
#forge-modal-overlay.cf-inspecting #forge-modal-msg :is(input:not([type=checkbox]),select,option,textarea,button,[contenteditable=true]){
 background:#f7edd8!important;color:#382312!important;border-color:#ad8c4e!important;font-family:'Crimson Pro',serif;
}
#forge-modal-overlay.cf-inspecting #forge-modal-msg label{color:#52341d!important}
#forge-modal-overlay.cf-inspecting #forge-modal-msg .custom-form-scroll,
#forge-modal-overlay.cf-inspecting #add-item-custom-view [style*="overflow-y"],
#forge-modal-overlay.cf-inspecting .item-details-content{max-height:none!important;overflow-y:visible!important}
#forge-modal-overlay.cf-inspecting #add-item-custom-view :is(div[style*="background"],table,thead,tbody,tr,td,th),
#forge-modal-overlay.cf-inspecting #forge-modal-msg div:has(>#modal-item-qty){background:#fff5!important;border-color:#ad8c4e!important}
#forge-modal-overlay.cf-inspecting #forge-modal-msg button{font-family:'Cinzel',serif}

#forge-modal-overlay.cf-inspecting #forge-modal-msg .cf-custom-condition-remove{background:none!important;border:0!important;padding:0!important;color:#8e171e!important;text-decoration:none;font-size:.8rem}

.cf-drawer-mobile-x{display:none}
@media(max-width:600px){
 #forge-modal-overlay.cf-inspecting .cf-drawer-handle{display:none!important}
 #forge-modal-overlay.cf-inspecting .forge-modal{width:100vw!important;max-width:100vw!important;margin:0!important;box-sizing:border-box;padding-top:52px!important}
 #forge-modal-overlay.cf-inspecting .cf-drawer-mobile-x{display:block;position:absolute;right:12px;top:8px;width:40px;height:40px;font-size:26px;z-index:2}
 #forge-modal-overlay.cf-inspecting .cf-drawer-close{display:inline-block!important;min-height:44px}
}

/* Drawer navigation is UI; links within the definition retain document styling. */
.cc-drawer-nav a,.cc-drawer-nav a:hover{text-decoration:none!important}
@media(max-width:600px){#forge-modal-overlay.cf-inspecting .cf-drawer-mobile-x{background:#211c14;color:#f3d478;border:1px solid #a88642;border-radius:4px;cursor:pointer}}

.cf-spell-action-wrap{position:relative;display:inline-flex;flex-direction:column;align-items:stretch}
.cf-spell-action-wrap[data-tooltip]:hover::after,.cf-spell-action-wrap[data-tooltip]:focus-visible::after{content:attr(data-tooltip);position:absolute;right:0;top:calc(100% + 6px);z-index:20;max-width:220px;width:max-content;white-space:normal;pointer-events:none;padding:5px 8px;border-radius:4px;background:#171512;color:#eddfc4;border:1px solid #8c6f3e;box-shadow:0 4px 12px #0008;font:12px/1.35 'Crimson Pro',sans-serif;text-align:left}


/* Actionable choice notices stay above controls, never inside spell action rows. */
.spell-choice-summary:empty{display:none}
.spell-choice-summary{display:flex;flex-direction:column;gap:3px;margin:8px 0;padding:7px 9px;border-left:2px solid var(--gold,#c5a059);background:#302719}
.spell-choice-summary .spell-correction-link{display:block;width:100%;min-width:0;border:0;background:none;color:#eadbb9;text-align:left;font:400 .88rem/1.3 'Crimson Pro',serif;padding:2px 0;white-space:normal;overflow-wrap:anywhere;cursor:pointer;text-decoration:underline}
.cf-spell-drawer .spell-choice-summary{background:#d4b87545}
.cf-spell-drawer .spell-choice-summary .spell-correction-link{color:#52341d}

/* Unified spell lists in the advanced builder and both character sheets. */
.cf-flat-spells .cf-flat-counts p { margin:.25rem 0; }
.cf-flat-spells .spell-filters { align-items:center; gap:6px; }
.cf-flat-spells .spell-filters > input,
.cf-flat-spells .spell-filters > select { min-width:0; max-width:100%; }
.cf-flat-spells .spell-level-chips { flex:1 0 100%; }
.cf-flat-list > h3 { margin:14px 0 4px; color:var(--gold-bright,var(--gold,#c5a059)); font-family:'Cinzel',serif; }
.cf-flat-list .spell-source-row { display:flex; flex-direction:row; gap:8px; padding:7px 0; }
.cf-flat-list .spell-source-actions { flex:0 0 min(135px,34%); max-width:135px; min-width:0; flex-direction:column; align-items:stretch; }
.cf-flat-list .spell-source-actions button { min-width:0; width:100%; margin:0; padding:4px 6px; white-space:normal; font-size:.75rem; }
.cf-flat-list .spell-description > summary { overflow-wrap:anywhere; }
.cf-flat-spell-sources { margin:.4rem 0; padding-left:1.1rem; font-size:.86rem; }
.cf-flat-spell-badge { font-size:.74rem; color:var(--gold-bright,var(--gold,#c5a059)); text-align:center; }
.cf-spell-drawer .cf-flat-list > h3,.cf-spell-drawer .cf-flat-spell-badge { color:#52341d; }
.cf-spell-drawer .cf-flat-list .spell-source-actions { float:none; margin:0; }

/* Flat source rows: separate removal gutter and stable preparer alignment. */
.cf-flat-list .spell-source-row { display:grid; grid-template-columns:minmax(0,1fr) min(112px,30%) 30px; align-items:start; }
.cf-flat-list .spell-source-row > div:first-child { grid-column:1; grid-row:1; }
.cf-flat-list .spell-source-row > .spell-source-actions { grid-column:2; grid-row:1; min-width:0; max-width:none; }
.cf-flat-source-subtitle { display:block; font:italic .78rem/1.3 'Crimson Pro',serif; opacity:.9; overflow-wrap:anywhere; }
.cf-flat-list .cf-flat-remove-column { grid-column:3; grid-row:1; min-width:0; }
.cf-flat-list .cf-flat-remove-column button { box-sizing:border-box; width:28px; height:28px; min-width:0; min-height:0; padding:0; margin:0; border:1px solid #e7a495; background:#901f27; color:#fff; line-height:1; font:700 1.1rem/1 sans-serif; }
.cf-flat-list .cf-flat-remove-column button:disabled { opacity:.55; }
.cf-flat-spell-badge { display:block; border:1px solid currentColor; border-radius:3px; padding:4px 3px; line-height:1.1; }

/* Sheet spell drawers: keep disclosure on the name's first line, not below its source. */
:is(.sheet-body,.sheet2-body) .cf-spell-drawer .spell-source-row .spell-description > summary {
 position:relative; padding-left:24px; text-align:left;
}
:is(.sheet-body,.sheet2-body) .cf-spell-drawer .spell-source-row .spell-description > summary::after { display:none; }
:is(.sheet-body,.sheet2-body) .cf-spell-drawer .spell-source-row .spell-description > summary::before {
 content:''; position:absolute; left:0; top:3px; width:18px; height:18px;
 background:url('/characterforge/img/char-assets/dropdown-arrow.webp') center/contain no-repeat;
 transform:none; pointer-events:none;
}
:is(.sheet-body,.sheet2-body) .cf-spell-drawer .spell-source-row .spell-description[open] > summary::before { transform:rotate(180deg); }

/* Keep the summary in its name column, but let native disclosure content use the whole sheet drawer row. */
:is(.sheet-body,.sheet2-body) .cf-spell-drawer .cf-flat-list .spell-source-row > div:first-child {
 grid-column:1 / -1; min-width:0;
}
:is(.sheet-body,.sheet2-body) .cf-spell-drawer .cf-flat-list .spell-description {
 display:block; min-width:0;
}
:is(.sheet-body,.sheet2-body) .cf-spell-drawer .cf-flat-list .spell-description > summary { width:calc(100% - min(112px,30%) - 46px); min-width:0; box-sizing:border-box; }
:is(.sheet-body,.sheet2-body) .cf-spell-drawer .cf-flat-list .spell-description > :not(summary) {
 grid-column:1 / -1; min-width:0; max-width:100%; box-sizing:border-box;
}
:is(.sheet-body,.sheet2-body) .cf-spell-drawer .cf-flat-list .spell-description-body {
 overflow-wrap:anywhere; overflow-x:auto;
}
