/* Screen themes share semantic colors. Print keeps the publication styles. */
@media screen {
  :root:root { color-scheme: light dark; }
  :root[data-theme="light"] { color-scheme: light; }
  :root[data-theme="dark"] { color-scheme: dark; }
  :root {
    --theme-bg: light-dark(#f4f1e8, #0b1012);
    --theme-panel: light-dark(#fcfaf4, #111719);
    --theme-raised: light-dark(#e9e5da, #161d20);
    --theme-text: light-dark(#202724, #f1efe7);
    --theme-heading: light-dark(#141c19, #fbfaf5);
    --theme-muted: light-dark(#525e57, #aab2ae);
    --theme-meta: light-dark(#525e57, #a0aaa4);
    --theme-line: light-dark(#20272426, #f2f2ea24);
    --theme-line-strong: light-dark(#20272445, #f2f2ea45);
    --theme-gold: light-dark(#795609, #e5b94f);
    --theme-gold-soft: light-dark(#946914, #cb902d);
    --theme-gold-bright: light-dark(#6f4e08, #f5db98);
    --theme-pink: light-dark(#a32461, #f34b9d);
    --theme-cyan: light-dark(#14697a, #63d7e3);
    --theme-highlight: light-dark(#eee2c2, #342b15);
    --theme-header: light-dark(#f4f1e8f2, #0b1012e6);
  }
  html:not([data-study-theme]) {
    --ink: var(--theme-bg); --ink-soft: var(--theme-panel); --ink-raised: var(--theme-raised);
    --paper: var(--theme-text); --paper-deep: var(--theme-text); --white: var(--theme-heading);
    --muted: var(--theme-muted); --muted-dark: var(--theme-muted); --muted-meta: var(--theme-meta);
    --line: var(--theme-line); --line-strong: var(--theme-line-strong);
    --signal: var(--theme-gold); --terminal: var(--theme-pink); --cyber: var(--theme-cyan);
    --reading-paper: var(--theme-panel); --reading-paper-deep: var(--theme-raised);
    --reading-ink: var(--theme-text); --reading-muted: var(--theme-muted);
  }
  .research-page { --signal: var(--theme-gold); }
  .site-header, .reference-page .site-header { background: var(--theme-header); }
  .site-nav a, .site-footer > div { color: var(--theme-text); }
  .discovery-search { background: var(--theme-panel); color: var(--theme-text); border-color: var(--theme-line-strong); }
  .discovery-search input { color: var(--theme-text); }
  .discovery-search input::placeholder { color: var(--theme-muted); opacity: 1; }
  .discovery-search button { background: var(--theme-gold); color: var(--theme-bg); }
  .library-filters input { color-scheme: inherit; }
  .reference-page { background: var(--theme-bg); color: var(--theme-text); }
  .reference-page .site-footer { background: var(--theme-bg); color: var(--theme-text); }
  .article-paper { color-scheme: inherit; --article-accent: var(--theme-gold) !important; }
  body[style*="--cyber"] .article-paper { --article-accent: var(--theme-cyan) !important; }
  body[style*="--terminal"] .article-paper { --article-accent: var(--theme-pink) !important; }
  .article-masthead__deck, .article-byline, .research-bridge__facts dd { color: var(--theme-text); }
  .article-masthead__meta, .article-llm-credit, .research-bridge__content > p,
  .article-toc p, .article-toc a, .article-copy code, .ai-contribution p { color: var(--theme-muted); }
  .article-toc li, .article-toc li:last-child, .article-copy h2, .ai-contribution,
  .article-toc--mobile { border-color: var(--theme-line-strong); }
  .article-copy hr { background: var(--theme-line-strong); }
  .theme-control { display: inline-flex; flex-shrink: 0; }
  html body .theme-control .theme-trigger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 9px;
    border: 1px solid transparent; border-radius: 3px; background: transparent;
    color: var(--theme-muted) !important; box-shadow: none; cursor: pointer; transform: none;
  }
  html body .theme-control .theme-trigger:is(:hover, [aria-expanded="true"]) {
    border-color: var(--theme-line-strong); background: var(--theme-panel); color: var(--theme-text) !important;
  }
  .theme-control .theme-menu {
    position: fixed; inset: auto; margin: 0; box-sizing: border-box;
    width: 184px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow-y: auto;
    padding: 6px; border: 1px solid var(--theme-line); border-radius: 4px;
    background: var(--theme-panel); color: var(--theme-text);
    box-shadow: 0 8px 24px light-dark(#20272426, #00000066);
    font: 400 16px/1.5 'DM Sans', system-ui, sans-serif;
  }
  html body .theme-control .theme-option {
    display: flex; align-items: center; justify-content: flex-start; gap: 10px;
    width: 100%; min-height: 44px; height: auto; padding: 10px 12px; margin: 0;
    background: transparent; color: var(--theme-text) !important; border: 0; border-radius: 2px;
    font: inherit; letter-spacing: 0; text-transform: none; text-align: left;
    box-shadow: none; transform: none; cursor: pointer;
  }
  html body .theme-control .theme-option:is(:hover, :focus-visible) { background: var(--theme-raised); color: var(--theme-text) !important; }
  html body .theme-control :is(.theme-trigger, .theme-option):focus-visible { outline: 2px solid var(--theme-gold); outline-offset: -2px; }
  .theme-control[hidden], .theme-control [hidden] { display: none !important; }
  .theme-control svg { display: block; flex: 0 0 22px; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .theme-check { margin-left: auto; font-size: 14px; }
  .theme-utility { display: inline-flex; align-items: center; }
  body > .theme-utility { position: fixed; bottom: 1rem; right: 1rem; z-index: 100; }
  @media (max-width: 600px) { .site-header .site-nav { gap: .65rem; flex-wrap: wrap; } }

}
@media print { .theme-control, .theme-utility { display: none !important; } }
