:root{--action:#365cdb;--action-on:#fff;--action-soft:#eaf0ff;--click-border:#bccbe3;--theme-card:#fff;--theme-soft:#f0f3f9;--theme-text:#293c59;--theme-prose:#485b79;--theme-muted:#697d9c;--theme-side:#17191e;--theme-side-soft:#252a36;--theme-side-text:#d2d9e8}
.theme-switch{display:flex;align-items:center;gap:12px;margin:0 0 17px;color:var(--theme-side-text);font-size:11px}.theme-switch select{flex:1;min-width:0;background:var(--theme-side-soft);color:var(--theme-side-text);border:1px solid #54617a;border-radius:6px;padding:8px 10px;font:12px var(--font);cursor:pointer}.developer-nav{margin-top:18px;border:1px solid #495772;color:#dbe5fa;background:#232b3d}.developer-nav:hover{background:#314569}.developer-nav:disabled{opacity:.5;cursor:default}.quest-region-controls{display:flex;gap:12px;margin:0 0 22px;padding:14px 16px;border:1px solid var(--click-border);border-radius:9px;background:var(--theme-card)}.quest-region-controls label{display:flex;align-items:center;gap:13px;font-size:12px;color:var(--theme-prose);font-weight:550}.quest-region-controls select{font:13px var(--font);background:var(--theme-card);color:var(--theme-text);padding:9px 13px;min-width:180px;border:1px solid var(--click-border);border-radius:6px;cursor:pointer}
/* White chapter emblems need a dark surface in every theme. */
#quest-list .library-row:has(>.game-image-emblem){grid-template-columns:80px minmax(0,1fr);column-gap:16px;min-height:126px;padding:20px}
#quest-list .game-thumb.game-image-emblem,#quest-reader .game-hero.game-image-emblem{background:radial-gradient(circle at 40% 30%,#52647b,#253449);border:1px solid #78899e;border-radius:12px;opacity:1;object-fit:contain;box-shadow:0 3px 10px #15263824}
#quest-list .game-thumb.game-image-emblem{width:80px;height:80px;padding:12px}
#quest-reader .game-hero.game-image-emblem{width:112px;height:112px;padding:17px;margin:22px 0}
#quest-list .library-row:has(>.game-image-scene){display:grid;grid-template-columns:minmax(0,1fr);gap:8px;padding:14px;text-align:left}
#quest-list .library-row>.game-thumb.game-image-scene{grid-column:1;grid-row:1;width:100%;height:auto;aspect-ratio:16/9;object-fit:cover;padding:0;border-radius:8px;background:#253449}
#quest-list .library-row:has(>.game-image-scene)>small,#quest-list .library-row:has(>.game-image-scene)>strong,#quest-list .library-row:has(>.game-image-scene)>span,#quest-list .library-row:has(>.game-image-scene)>p{grid-column:1;grid-row:auto;margin:0}
@media(max-width:540px){#quest-list .library-row:has(>.game-image-emblem){grid-template-columns:64px minmax(0,1fr);gap:12px;padding:15px;min-height:108px}#quest-list .game-thumb.game-image-emblem{width:64px;height:64px;padding:9px}#quest-reader .game-hero.game-image-emblem{width:96px;height:96px;padding:14px}}
/* Clickable surfaces share a clear outline, visible hover and solid selection. */
.library-row,.result-card,.character-card,.notebook-card{border-color:var(--click-border);box-shadow:0 2px 7px #21365805}.library-row strong,.result-card h3,.character-card strong{color:var(--theme-text)}.library-row:hover,.result-card:hover,.character-card:hover,.notebook-card:hover{border-color:var(--action);background:var(--action-soft);box-shadow:0 3px 13px #294d8a12}.library-row.selected,.result-card.selected,.notebook-card.selected{background:var(--action-soft);border-color:var(--action);box-shadow:inset 4px 0 var(--action)}.library-row i{font-size:15px;font-weight:700;color:var(--action)}
.library-tabs{background:var(--theme-soft);border:1px solid var(--click-border);box-shadow:none;gap:6px}.library-tabs button{border:1px solid var(--click-border);color:var(--theme-prose);background:var(--theme-card);font-weight:600;min-height:36px}.library-tabs button:hover{background:var(--action-soft);color:var(--action);border-color:var(--action)}.library-tabs button.selected,.character-sort-row button.selected,.character-context button.selected,.codex-search-modes button.selected,.story-languages button.selected,.reader-language button.selected,.codex-pieces button.selected,.notebook-folders button.selected{background:var(--action);color:var(--action-on);border-color:var(--action);font-weight:650}.library-tabs button.selected small{color:var(--action-on);opacity:.85}
.codex-search-modes{border-color:var(--click-border)}.codex-search-modes button{border:1px solid transparent;color:var(--theme-prose);font-weight:550}.character-sort-row button,.character-context>div button,.story-languages button,.reader-language button,.codex-pieces button{border:1px solid var(--click-border);color:var(--theme-prose);background:var(--theme-card);min-height:34px}.character-sort-row button:hover,.character-context>div button:hover,.codex-pieces button:hover,.story-languages button:hover,.reader-language button:hover{border-color:var(--action);color:var(--action);background:var(--action-soft)}.character-sort-row button.selected:hover,.codex-pieces button.selected:hover,.story-languages button.selected:hover,.reader-language button.selected:hover{color:var(--action-on);background:var(--action)}
.group-back{border:1px solid var(--click-border);border-radius:7px;background:var(--theme-card);padding:9px 12px;margin:0 0 12px;color:var(--action);font-weight:550}.group-back:hover{background:var(--action-soft);border-color:var(--action)}.secondary{border-color:var(--click-border);color:var(--theme-prose);font-weight:550}.line-note{opacity:.8;color:var(--theme-prose);border:1px solid var(--click-border);border-radius:4px;background:var(--theme-card);padding:2px 5px}.line-note:hover{opacity:1;background:var(--action);color:var(--action-on)}.nav{color:#b9c3d5}.nav.active{background:#304675;color:#fff;box-shadow:inset 3px 0 #94b3ff}.nav.active svg{color:#bed0ff}.search button,.primary,.editor-shell button.primary{background:var(--action);color:var(--action-on)}.search button:hover,.primary:hover{filter:brightness(.94)}
:root[data-theme="dark"]{--paper:#10151e;--white:#1b2330;--green:#91b0ff;--ink:#e1e9f6;--muted:#a2b1c9;--line:#35445a;--gold:#90b0ff;--action:#4569d0;--action-on:#fff;--action-soft:#263655;--click-border:#4a5e7b;--theme-card:#1b2330;--theme-soft:#242f40;--theme-text:#e3ecfb;--theme-prose:#c1cfe4;--theme-muted:#9eafca;--theme-side:#0c111a;--theme-side-soft:#1c273a;--theme-side-text:#cedaf0;color-scheme:dark}
:root[data-theme="mint"]{--paper:#eef7f2;--white:#fcfffd;--green:#14795f;--ink:#23473b;--muted:#6b8b7f;--line:#c9ded4;--gold:#178268;--action:#14795f;--action-on:#fff;--action-soft:#daeee5;--click-border:#a7c9b9;--theme-card:#fcfffd;--theme-soft:#e4f1e9;--theme-text:#234a3c;--theme-prose:#466c5d;--theme-muted:#6b8c7e;--theme-side:#153c32;--theme-side-soft:#214f41;--theme-side-text:#d5eee2;color-scheme:light}
:root:not([data-theme="light"]) .sidebar{background:var(--theme-side);border-color:var(--line)}:root:not([data-theme="light"]) .workspace{background:var(--theme-side-soft);border-color:#52715f66}:root[data-theme="mint"] .brand .emblem{background:#40a988}:root[data-theme="mint"] .brand-period{color:#76d0ac}:root[data-theme="mint"] .nav.active{background:#2b6552;box-shadow:inset 3px 0 #8bdfbd}:root[data-theme="mint"] .nav.active svg{color:#b8f2d8}:root[data-theme="mint"] .developer-nav{background:#204f40;border-color:#568571}
:root:not([data-theme="light"]) .topbar strong,:root:not([data-theme="light"]) h1,:root:not([data-theme="light"]) .library-reader h2,:root:not([data-theme="light"]) .reader-head h2,:root:not([data-theme="light"]) .notebook-card h3,:root:not([data-theme="light"]) .story-scene h3,:root:not([data-theme="light"]) .group-heading,:root:not([data-theme="light"]) .codex-prose h3,:root:not([data-theme="light"]) .character-context strong,:root:not([data-theme="light"]) .character-region h3{color:var(--theme-text)}
:root:not([data-theme="light"]) .library-row,:root:not([data-theme="light"]) .library-reader,:root:not([data-theme="light"]) .result-card,:root:not([data-theme="light"]) #reader,:root:not([data-theme="light"]) .character-card,:root:not([data-theme="light"]) .notebook-card,:root:not([data-theme="light"]) .notebook-panel,:root:not([data-theme="light"]) dialog{background:var(--theme-card);color:var(--theme-text);border-color:var(--click-border)}
:root:not([data-theme="light"]) .library-row.selected,:root:not([data-theme="light"]) .result-card.selected,:root:not([data-theme="light"]) .notebook-card.selected,:root:not([data-theme="light"]) .library-row:hover,:root:not([data-theme="light"]) .result-card:hover,:root:not([data-theme="light"]) .character-card:hover,:root:not([data-theme="light"]) .notebook-card:hover{background:var(--action-soft);border-color:var(--action)}
:root:not([data-theme="light"]) .library-tools input,:root:not([data-theme="light"]) .notes-actions input,:root:not([data-theme="light"]) .search,:root:not([data-theme="light"]) .advanced-fields input,:root:not([data-theme="light"]) .advanced-fields select,:root:not([data-theme="light"]) .codex-classification select,:root:not([data-theme="light"]) .scene-jump select,:root:not([data-theme="light"]) .secondary,:root:not([data-theme="light"]) .icon-button,:root:not([data-theme="light"]) .notebook-list-options select,:root:not([data-theme="light"]) .notebook-folders button,:root:not([data-theme="light"]) dialog input,:root:not([data-theme="light"]) dialog textarea{background:var(--theme-card);border-color:var(--click-border);color:var(--theme-prose)}
:root:not([data-theme="light"]) .search input,:root:not([data-theme="light"]) .prose,:root:not([data-theme="light"]) .script-line p,:root:not([data-theme="light"]) .codex-prose p,:root:not([data-theme="light"]) .story-description,:root:not([data-theme="light"]) .card-excerpt,:root:not([data-theme="light"]) .notebook-card p,:root:not([data-theme="light"]) .codex-set-effect p,:root:not([data-theme="light"]) .nb-body{color:var(--theme-prose)}
:root:not([data-theme="light"]) .reader-language,:root:not([data-theme="light"]) .script-notice,:root:not([data-theme="light"]) .source-block,:root:not([data-theme="light"]) .library-reader-footer,:root:not([data-theme="light"]) .codex-set-summary,:root:not([data-theme="light"]) .choice-block,:root:not([data-theme="light"]) .story-cutscene,:root:not([data-theme="light"]) .game-quest-gallery,:root:not([data-theme="light"]) .nb-header,:root:not([data-theme="light"]) .nb-toolbar,:root:not([data-theme="light"]) .nb-sources,:root:not([data-theme="light"]) .nb-current,:root:not([data-theme="light"]) .nb-footer,:root:not([data-theme="light"]) .nb-history{background:var(--theme-soft);border-color:var(--line);color:var(--theme-prose)}
:root:not([data-theme="light"]) .topic-welcome,:root:not([data-theme="light"]) .empty{background:var(--theme-card);color:var(--theme-muted);border-color:var(--click-border)}:root:not([data-theme="light"]) .topic-welcome h2{color:var(--theme-text)}:root:not([data-theme="light"]) .topic-welcome p{color:var(--theme-muted)}
:root:not([data-theme="light"]) .codex-search-modes,:root:not([data-theme="light"]) .notebook-source-label,:root:not([data-theme="light"]) .nb-source,:root:not([data-theme="light"]) .nb-note-picker select,:root:not([data-theme="light"]) .nb-classify input,:root:not([data-theme="light"]) .nb-header button,:root:not([data-theme="light"]) .nb-current button,:root:not([data-theme="light"]) .nb-body blockquote{background:var(--theme-card);border-color:var(--click-border);color:var(--theme-prose)}
:root:not([data-theme="light"]) .codex-search-modes button.selected,:root:not([data-theme="light"]) .notebook-folders button.selected{background:var(--action);color:#fff}:root:not([data-theme="light"]) .nb-title,:root:not([data-theme="light"]) .nb-header strong,:root:not([data-theme="light"]) .nb-source strong,:root:not([data-theme="light"]) .nb-sources summary,:root:not([data-theme="light"]) .codex-set-summary h3,:root:not([data-theme="light"]) .codex-set-effect b,:root:not([data-theme="light"]) .script-speaker,:root:not([data-theme="light"]) .speaker-line{color:var(--theme-text)}
:root:not([data-theme="light"]) .breadcrumb,:root:not([data-theme="light"]) .workspace-status,:root:not([data-theme="light"]) .section-head p,:root:not([data-theme="light"]) .eyebrow,:root:not([data-theme="light"]) .library-row small,:root:not([data-theme="light"]) .library-row>span,:root:not([data-theme="light"]) .topic-row p,:root:not([data-theme="light"]) .story-breadcrumb,:root:not([data-theme="light"]) .library-tools>span,:root:not([data-theme="light"]) .scene-jump label,:root:not([data-theme="light"]) .library-pages,:root:not([data-theme="light"]) .filters button,:root:not([data-theme="light"]) .filters b,:root:not([data-theme="light"]) .search-language,:root:not([data-theme="light"]) .search-language select,:root:not([data-theme="light"]) .results-meta,:root:not([data-theme="light"]) .results-meta>span:first-child,:root:not([data-theme="light"]) .coverage-summary,:root:not([data-theme="light"]) .search-status,:root:not([data-theme="light"]) .card-bottom,:root:not([data-theme="light"]) .reader-sub,:root:not([data-theme="light"]) .reader-footer,:root:not([data-theme="light"]) .character-tools p,:root:not([data-theme="light"]) .character-card small,:root:not([data-theme="light"]) .character-info,:root:not([data-theme="light"]) .local-warning,:root:not([data-theme="light"]) .notebook-card-meta,:root:not([data-theme="light"]) .notebook-list-options span{color:var(--theme-muted)}
:root:not([data-theme="light"]) .filters button.selected{color:var(--green);border-color:var(--green)}:root:not([data-theme="light"]) .suggestions button,:root:not([data-theme="light"]) .type-badge,:root:not([data-theme="light"]) .note-tags span{background:var(--theme-soft);color:var(--theme-prose);border-color:var(--line)}:root:not([data-theme="light"]) mark{background:var(--action-soft);color:var(--theme-text)}:root:not([data-theme="light"]) .game-thumb,:root:not([data-theme="light"]) .game-portrait,:root:not([data-theme="light"]) .game-avatar,:root:not([data-theme="light"]) .game-hero{background:var(--theme-soft)}
:root:not([data-theme="light"]) .editor-shell input:not([type=file]),:root:not([data-theme="light"]) .editor-shell textarea,:root:not([data-theme="light"]) .editor-shell select,:root:not([data-theme="light"]) .editor-shell button,:root:not([data-theme="light"]) .edit-block,:root:not([data-theme="light"]) .edit-image{background:var(--theme-card);border-color:var(--click-border);color:var(--theme-prose)}:root:not([data-theme="light"]) #content-editor,:root:not([data-theme="light"]) .editor-shell footer{background:var(--theme-soft);border-color:var(--line);color:var(--theme-text)}:root:not([data-theme="light"]) .editor-shell button.primary{background:var(--action);color:#fff}
@media(max-width:820px){.theme-switch{justify-content:center;gap:0}.theme-switch>span{display:none}.theme-switch select{flex:none;width:44px;font-size:9px;padding:7px 1px}.developer-nav{margin-top:12px!important}.sidebar-bottom:has(.theme-switch){display:block;padding:14px 0 0}.sidebar-bottom #about-button{justify-content:center;font-size:0;padding:0;width:100%}.sidebar-bottom #about-button span{font-size:11px}.quest-region-controls{padding:11px}.quest-region-controls label{flex-wrap:wrap;gap:8px;font-size:11px}.quest-region-controls select{min-width:145px;font-size:12px}.library-tabs{gap:5px}.library-tabs button{min-height:34px}}

:root:not([data-theme="light"]) .nb-toolbar button,:root:not([data-theme="light"]) .nb-current button,:root:not([data-theme="light"]) .nb-footer button,:root:not([data-theme="light"]) .nb-source-actions button,:root:not([data-theme="light"]) .nb-history button{color:var(--theme-prose)}
