/* StoryFoundry v1.2.0rc3 · three complete, local-only themes.
   Neutral writing surfaces are the default. No fonts/images/API calls are loaded. */
:root,
:root[data-sf-theme="modern"] {
  color-scheme: light;
  --shadow:var(--sf-shadow); --bg:#F7F8FA; --paper:#FFFFFF; --ink:#22252B; --muted:#687280; --border:#E4E6EA;
  --green:#4C647B; --green2:#EAF0F5; --gold:#8B7190; --blue:#4C647B;
  --red:#B64D47; --redbg:#FAEDEB;
  --sf-side:#F5F6F8; --sf-panel:#FFFFFF; --sf-heading:#22252B; --sf-subtle:#77818F;
  --sf-soft:#F2F4F7; --sf-hover:#E9EDF2; --sf-hero:#F0F3F7; --sf-input:#FFFFFF;
  --sf-reader:#FFFFFF; --sf-reader-ink:#22252B; --sf-accent:#4C647B; --sf-accent-hover:#394F65;
  --sf-accent-soft:#E9EFF5; --sf-on-accent:#FFFFFF; --sf-line:#E4E6EA;
  --sf-shadow:0 8px 30px rgba(34,42,52,.045); --sf-focus:#4C647B;
}
:root[data-sf-theme="paper"] {
  color-scheme: light;
  --bg:#F7F4EF; --paper:#FFFDF9; --ink:#292724; --muted:#756F72; --border:#E7DFD7;
  --green:#776476; --green2:#F0EAEE; --gold:#A47B60; --blue:#776476;
  --red:#AF554B; --redbg:#F9EEEB;
  --sf-side:#F3EFE9; --sf-panel:#FFFDF9; --sf-heading:#292724; --sf-subtle:#817A7D;
  --sf-soft:#F4EEE8; --sf-hover:#EEE5E7; --sf-hero:#F4ECE5; --sf-input:#FFFEFC;
  --sf-reader:#FFFDF9; --sf-reader-ink:#292724; --sf-accent:#776476; --sf-accent-hover:#625063;
  --sf-accent-soft:#F0E8EE; --sf-on-accent:#FFFFFF; --sf-line:#E7DFD7;
  --sf-shadow:0 8px 30px rgba(80,61,52,.045); --sf-focus:#776476;
}
:root[data-sf-theme="graphite"] {
  color-scheme: dark;
  --bg:#1B1C20; --paper:#25272B; --ink:#ECEEF1; --muted:#B3BAC4; --border:#414650;
  --green:#9AB1C7; --green2:#313E4B; --gold:#D6B08B; --blue:#9AB1C7;
  --red:#F0A59D; --redbg:#3E2D31;
  --sf-side:#202227; --sf-panel:#292C32; --sf-heading:#F2F3F6; --sf-subtle:#A9B2BE;
  --sf-soft:#2D3037; --sf-hover:#363C45; --sf-hero:#292E36; --sf-input:#30343B;
  --sf-reader:#25272B; --sf-reader-ink:#ECEEF1; --sf-accent:#9AB1C7; --sf-accent-hover:#BDD0E1;
  --sf-accent-soft:#344454; --sf-on-accent:#1B252F; --sf-line:#414650;
  --sf-shadow:0 10px 34px rgba(0,0,0,.21); --sf-focus:#B3CBDF;
}

/* Shared semantic surfaces. These rules deliberately override legacy hard-coded green/cream styles. */
:root[data-sf-theme] body {background:var(--bg);color:var(--ink);}
:root[data-sf-theme] .sidebar {background:var(--sf-side);border-color:var(--sf-line);}
:root[data-sf-theme] .brand {color:var(--sf-heading);}
:root[data-sf-theme] .brandmark {color:var(--sf-on-accent);background:var(--sf-accent);box-shadow:none;}
:root[data-sf-theme] .brand small,
:root[data-sf-theme] .sidebar .side-label,
:root[data-sf-theme] .sidebar .local-note,
:root[data-sf-theme] .studio-aside-label {color:var(--sf-subtle);}
:root[data-sf-theme] .studio-side-nav button,
:root[data-sf-theme] .studio-recent-link strong {color:var(--ink);}
:root[data-sf-theme] .studio-side-nav button.active,
:root[data-sf-theme] .studio-side-nav button.studio-selected,
:root[data-sf-theme] .studio-side-nav button:hover,
:root[data-sf-theme] .studio-recent-link:hover,
:root[data-sf-theme] .studio-utility-links .nav-item:hover {background:var(--sf-hover);color:var(--sf-accent);}
:root[data-sf-theme] .studio-recent,
:root[data-sf-theme] .sidebar .side-bottom {border-color:var(--sf-line);}
:root[data-sf-theme] .studio-recent-link small,
:root[data-sf-theme] .studio-utilities summary,
:root[data-sf-theme] .studio-work-card p {color:var(--muted);}
:root[data-sf-theme] #topbar,
:root[data-sf-theme] #tabs,
:root[data-sf-theme] #status-strip {background:var(--sf-panel);border-color:var(--sf-line);}
:root[data-sf-theme] #status-strip:empty {display:none;}
:root[data-sf-theme] .top-title h1,
:root[data-sf-theme] .studio-work-card h3,
:root[data-sf-theme] #content .section-title h2 {color:var(--sf-heading);}
:root[data-sf-theme] .top-title .studio-mini,
:root[data-sf-theme] .studio-work-details .studio-mini,
:root[data-sf-theme] .studio-reader-heading .studio-mini {color:var(--sf-subtle);}
:root[data-sf-theme] button.primary,
:root[data-sf-theme] .primary[data-action] {background:var(--sf-accent);border-color:var(--sf-accent);color:var(--sf-on-accent);box-shadow:none;}
:root[data-sf-theme] button.primary:hover:not(:disabled),
:root[data-sf-theme] .primary[data-action]:hover:not(:disabled) {background:var(--sf-accent-hover);border-color:var(--sf-accent-hover);color:var(--sf-on-accent);box-shadow:var(--sf-shadow);}
:root[data-sf-theme] .sidebar .side-actions .icon-button,
:root[data-sf-theme] .topbar-actions button:not(.primary),
:root[data-sf-theme] .studio-reader-tools .studio-tool,
:root[data-sf-theme] .studio-versions button {background:var(--sf-panel);color:var(--ink);border-color:var(--sf-line);}
:root[data-sf-theme] .topbar-actions button:not(.primary):hover,
:root[data-sf-theme] .studio-reader-tools .studio-tool:hover,
:root[data-sf-theme] .studio-versions button:hover {background:var(--sf-hover);border-color:var(--sf-accent);color:var(--sf-accent);}
:root[data-sf-theme] .studio-catalog-controls,
:root[data-sf-theme] .studio-provenance,
:root[data-sf-theme] .studio-recent {border-color:var(--sf-line);}
:root[data-sf-theme] .studio-filters button {color:var(--muted);}
:root[data-sf-theme] .studio-filters button.studio-selected,
:root[data-sf-theme] .studio-filters button:hover {color:var(--sf-accent);background:transparent;border-color:transparent;}
:root[data-sf-theme] .studio-filters button.studio-selected::after {background:var(--sf-accent);}
:root[data-sf-theme] .studio-count {background:var(--sf-soft);color:var(--muted);}
:root[data-sf-theme] .studio-filters .studio-selected .studio-count {background:var(--sf-accent-soft);color:var(--sf-accent);}
:root[data-sf-theme] .studio-work-search input,
:root[data-sf-theme] input,
:root[data-sf-theme] textarea,
:root[data-sf-theme] select {background:var(--sf-input);color:var(--ink);border-color:var(--sf-line);}
:root[data-sf-theme] .studio-work-card,
:root[data-sf-theme] .studio-empty,
:root[data-sf-theme] #content .card,
:root[data-sf-theme] #content .paper {background:var(--sf-panel);color:var(--ink);border-color:var(--sf-line);box-shadow:var(--sf-shadow);}
:root[data-sf-theme] .studio-work-card:hover {border-color:var(--sf-accent);box-shadow:var(--sf-shadow);}
:root[data-sf-theme] .studio-work-card .studio-actions button {color:var(--sf-accent);}
:root[data-sf-theme] .studio-work-card .studio-actions button.studio-card-secondary {color:var(--muted);}
:root[data-sf-theme] .studio-work-card .studio-actions button:hover {color:var(--sf-accent-hover);}
:root[data-sf-theme] .studio-phase,
:root[data-sf-theme] .studio-advanced summary {color:var(--muted);background:transparent;border-color:transparent;}
:root[data-sf-theme] .studio-phase.active,
:root[data-sf-theme] .studio-phase:hover,
:root[data-sf-theme] .studio-advanced.active summary,
:root[data-sf-theme] .studio-advanced summary:hover {color:var(--sf-accent);border-bottom-color:var(--sf-accent);background:transparent;}
:root[data-sf-theme] .studio-advanced-links {background:var(--sf-panel);border-color:var(--sf-line);box-shadow:var(--sf-shadow);}
:root[data-sf-theme] .studio-advanced-links button {color:var(--ink);}
:root[data-sf-theme] .studio-advanced-links button:hover,
:root[data-sf-theme] .studio-advanced-links button.active {background:var(--sf-hover);color:var(--sf-accent);}
:root[data-sf-theme] .studio-next {background:var(--sf-soft);border-color:var(--sf-line);}
:root[data-sf-theme] .studio-next::before {background:var(--sf-accent);}
:root[data-sf-theme] .studio-next-row p {color:var(--ink);}
:root[data-sf-theme] .studio-next-row .studio-mini {color:var(--muted);}
:root[data-sf-theme] .studio-reader-paper {background:var(--sf-reader);border-color:var(--sf-line);box-shadow:var(--sf-shadow);}
:root[data-sf-theme] .studio-reader-paper .studio-prose,
:root[data-sf-theme] .studio-reader-paper .studio-prose p,
:root[data-sf-theme] .studio-reader-paper h3,
:root[data-sf-theme] .studio-reader-paper .studio-archive-heading {color:var(--sf-reader-ink);}
:root[data-sf-theme] .studio-manuscript-break {border-color:var(--sf-line);}
:root[data-sf-theme] .studio-versions button.active {background:var(--sf-accent-soft);border-color:var(--sf-accent);color:var(--sf-accent);}
:root[data-sf-theme] .studio-provenance summary {color:var(--muted);}
:root[data-sf-theme] .status-bar,
:root[data-sf-theme] .note {background:var(--sf-soft);color:var(--ink);border-color:var(--sf-line);}
:root[data-sf-theme] .pill,
:root[data-sf-theme] .tag {background:var(--sf-accent-soft);color:var(--sf-accent);}
:root[data-sf-theme] .pill.red,
:root[data-sf-theme] .note.error {background:var(--redbg);color:var(--red);}
:root[data-sf-theme] .pill.amber,
:root[data-sf-theme] .note.warning {background:var(--sf-soft);color:var(--ink);}
:root[data-sf-theme] .studio-work-card a,
:root[data-sf-theme] #content a {color:var(--sf-accent);}
:root[data-sf-theme] .field input:not([type=checkbox]),
:root[data-sf-theme] .field select,
:root[data-sf-theme] .field textarea,
:root[data-sf-theme] #content textarea {background:var(--sf-input);color:var(--ink);border-color:var(--sf-line);}
:root[data-sf-theme] .field input:focus,
:root[data-sf-theme] .field select:focus,
:root[data-sf-theme] .field textarea:focus,
:root[data-sf-theme] .studio-work-search input:focus {border-color:var(--sf-focus);outline-color:var(--sf-focus);box-shadow:0 0 0 3px var(--sf-accent-soft);}
:root[data-sf-theme] :where(button, a, input, select, textarea, summary):focus-visible {outline:2px solid var(--sf-focus);outline-offset:3px;}
:root[data-sf-theme] dialog,
:root[data-sf-theme] #modal,
:root[data-sf-theme] #modal-content .modal-inner,
:root[data-sf-theme] .dialog-content {background:var(--sf-panel);color:var(--ink);border-color:var(--sf-line);}
:root[data-sf-theme] dialog::backdrop {background:rgba(15,17,21,.6);}
:root[data-sf-theme] summary {color:var(--sf-accent);}
:root[data-sf-theme] #modal .modal-head h2,
:root[data-sf-theme] #content .card h2,
:root[data-sf-theme] #content .card h3 {color:var(--sf-heading);}

/* Muted book covers follow the active theme instead of preserving the former green branding. */
:root[data-sf-theme="modern"] .studio-cover-pine {background:linear-gradient(155deg,#71849A,#41566D 85%);}
:root[data-sf-theme="modern"] .studio-cover-indigo {background:linear-gradient(155deg,#8A94A7,#556078 85%);}
:root[data-sf-theme="modern"] .studio-cover-copper {background:linear-gradient(155deg,#A69A92,#726A69 85%);}
:root[data-sf-theme="modern"] .studio-cover-plum {background:linear-gradient(155deg,#9D929F,#6A606D 85%);}
:root[data-sf-theme="modern"] .studio-cover-slate {background:linear-gradient(155deg,#81939E,#536773 85%);}
:root[data-sf-theme="modern"] .studio-cover-moss {background:linear-gradient(155deg,#909BA5,#5C6874 85%);}
:root[data-sf-theme="paper"] .studio-cover-pine {background:linear-gradient(155deg,#9C8991,#705F70 85%);}
:root[data-sf-theme="paper"] .studio-cover-indigo {background:linear-gradient(155deg,#90869A,#5C526D 85%);}
:root[data-sf-theme="paper"] .studio-cover-copper {background:linear-gradient(155deg,#BFA494,#886F65 85%);}
:root[data-sf-theme="paper"] .studio-cover-plum {background:linear-gradient(155deg,#A391A4,#6D5B72 85%);}
:root[data-sf-theme="paper"] .studio-cover-slate {background:linear-gradient(155deg,#9B999F,#6D6B76 85%);}
:root[data-sf-theme="paper"] .studio-cover-moss {background:linear-gradient(155deg,#B1A69C,#756B67 85%);}
:root[data-sf-theme="graphite"] .studio-work-symbol {box-shadow:3px 5px 13px rgba(0,0,0,.35);}
:root[data-sf-theme="graphite"] .studio-cover-pine {background:linear-gradient(155deg,#586A81,#344557 85%);}
:root[data-sf-theme="graphite"] .studio-cover-indigo {background:linear-gradient(155deg,#70788F,#454E67 85%);}
:root[data-sf-theme="graphite"] .studio-cover-copper {background:linear-gradient(155deg,#8D7472,#594A50 85%);}
:root[data-sf-theme="graphite"] .studio-cover-plum {background:linear-gradient(155deg,#796D83,#51465A 85%);}
:root[data-sf-theme="graphite"] .studio-cover-slate {background:linear-gradient(155deg,#657885,#3B505C 85%);}
:root[data-sf-theme="graphite"] .studio-cover-moss {background:linear-gradient(155deg,#72818A,#465561 85%);}

/* Dark mode: cover the older static text widgets, side panels, editors and modal controls. */
:root[data-sf-theme="graphite"] .sidebar .nav-item,
:root[data-sf-theme="graphite"] #content .muted,
:root[data-sf-theme="graphite"] #content .micro,
:root[data-sf-theme="graphite"] #content .small-text,
:root[data-sf-theme="graphite"] #content .mini-label,
:root[data-sf-theme="graphite"] #content .hint,
:root[data-sf-theme="graphite"] #modal .small-text {color:var(--muted);}
:root[data-sf-theme="graphite"] .card,
:root[data-sf-theme="graphite"] .paper,
:root[data-sf-theme="graphite"] .character,
:root[data-sf-theme="graphite"] .scene-plan,
:root[data-sf-theme="graphite"] .relation,
:root[data-sf-theme="graphite"] .finding,
:root[data-sf-theme="graphite"] .quote,
:root[data-sf-theme="graphite"] .review-card,
:root[data-sf-theme="graphite"] .reader-note,
:root[data-sf-theme="graphite"] .history-item,
:root[data-sf-theme="graphite"] .diff-grid pre,
:root[data-sf-theme="graphite"] .source-panel {background:var(--sf-panel);color:var(--ink);border-color:var(--sf-line);}
:root[data-sf-theme="graphite"] .status-bar.error,
:root[data-sf-theme="graphite"] .finding.blocking {background:var(--redbg);color:var(--ink);border-color:var(--red);}
:root[data-sf-theme="graphite"] th,
:root[data-sf-theme="graphite"] .table-wrap th {background:var(--sf-soft);color:var(--ink);}
:root[data-sf-theme="graphite"] td,
:root[data-sf-theme="graphite"] th,
:root[data-sf-theme="graphite"] .divider {border-color:var(--sf-line);}
:root[data-sf-theme="graphite"] .prose,
:root[data-sf-theme="graphite"] .paper p,
:root[data-sf-theme="graphite"] .paper h2,
:root[data-sf-theme="graphite"] .brief-premise,
:root[data-sf-theme="graphite"] .section-title {color:var(--ink);}
:root[data-sf-theme="graphite"] .export-choice {background:var(--sf-input);color:var(--sf-accent);border-color:var(--sf-line);}
:root[data-sf-theme="graphite"] pre,
:root[data-sf-theme="graphite"] code {color:var(--ink);}

/* A compact, discoverable switcher stays visible in the sidebar, including mobile. */
.sf-theme-footer {margin:6px 0 8px;}
.sf-theme-trigger {width:100%;display:flex;align-items:center;gap:9px;min-height:38px;padding:8px 10px;
  text-align:left;border:1px solid var(--sf-line);border-radius:10px;background:var(--sf-panel);color:var(--ink);font-size:12px;}
.sf-theme-trigger:hover {background:var(--sf-hover);border-color:var(--sf-accent);}
.sf-theme-trigger .sf-theme-icon {display:grid;place-items:center;width:18px;height:18px;color:var(--sf-accent);font-size:17px;}
.sf-theme-trigger .sf-theme-current {margin-left:auto;color:var(--muted);font-size:11px;}
.sf-theme-trigger:focus-visible,.sf-theme-choice:focus-visible {outline:2px solid var(--sf-focus);outline-offset:3px;}
.sf-theme-chooser {max-width:660px;}
.sf-theme-help {color:var(--muted);font-size:13px;line-height:1.8;margin:0 0 19px;}
.sf-theme-choices {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;}
.sf-theme-choice {display:flex;position:relative;flex-direction:column;align-items:stretch;gap:11px;padding:13px;min-width:0;
  text-align:left;border:1px solid var(--sf-line);border-radius:12px;background:var(--sf-panel);color:var(--ink);}
.sf-theme-choice:hover,.sf-theme-choice.is-selected {border-color:var(--sf-accent);box-shadow:0 0 0 1px var(--sf-accent-soft);}
.sf-theme-swatches {display:flex;height:62px;border:1px solid var(--sf-line);border-radius:7px;overflow:hidden;}
.sf-theme-swatches i {display:block;flex:1;min-width:0;}
.sf-theme-description {display:grid;gap:5px;}
.sf-theme-description strong {font-size:13px;color:var(--ink);}
.sf-theme-description small {font-size:11px;line-height:1.5;color:var(--muted);}
.sf-theme-selected {position:absolute;top:8px;right:8px;display:grid;place-items:center;width:19px;height:19px;
  border-radius:50%;background:var(--sf-accent);color:var(--sf-on-accent);font-size:12px;opacity:0;}
.sf-theme-choice.is-selected .sf-theme-selected {opacity:1;}
.sf-theme-status {margin:17px 0 0;font-size:12px;color:var(--muted);line-height:1.6;}
@media(max-width:800px) {
 .sf-theme-footer {position:static;margin:0;}
 .sf-theme-trigger {width:auto;min-height:27px;padding:3px 8px;gap:5px;font-size:10px;}
 .sf-theme-trigger .sf-theme-icon {font-size:13px;width:13px;height:13px;}
 .sf-theme-current {font-size:10px;}
 .sf-theme-choices {grid-template-columns:1fr;gap:9px;}
 .sf-theme-choice {flex-direction:row;align-items:center;gap:12px;}
 .sf-theme-swatches {flex:0 0 96px;height:53px;}
 .sf-theme-description {flex:1;}
}
@media(max-width:480px) {.sf-theme-trigger .sf-theme-current{display:none}}
@media(prefers-reduced-motion:reduce){.sf-theme-trigger,.sf-theme-choice{transition:none!important;}}

/* External swatch rules comply with the server's style-src 'self' policy. */
.sf-theme-swatches-modern i:nth-child(1){background:#F7F8FA}
.sf-theme-swatches-modern i:nth-child(2){background:#FFFFFF}
.sf-theme-swatches-modern i:nth-child(3){background:#22252B}
.sf-theme-swatches-modern i:nth-child(4){background:#4C647B}
.sf-theme-swatches-paper i:nth-child(1){background:#F7F4EF}
.sf-theme-swatches-paper i:nth-child(2){background:#FFFDF9}
.sf-theme-swatches-paper i:nth-child(3){background:#292724}
.sf-theme-swatches-paper i:nth-child(4){background:#776476}
.sf-theme-swatches-graphite i:nth-child(1){background:#1B1C20}
.sf-theme-swatches-graphite i:nth-child(2){background:#25272B}
.sf-theme-swatches-graphite i:nth-child(3){background:#ECEEF1}
.sf-theme-swatches-graphite i:nth-child(4){background:#9AB1C7}

/* Public pages share the same palette and browser preference as the workspace. */
.public-theme-control{display:flex;align-items:center;gap:9px;font-family:system-ui,sans-serif;font-size:11px;color:var(--muted)}
.public-theme-control select{font:inherit;background:var(--sf-input);color:var(--ink);border:1px solid var(--sf-line);border-radius:4px;padding:7px 9px;max-width:140px}
.public-theme-control select:focus-visible{outline:2px solid var(--sf-focus);outline-offset:3px}
