:root {
  color-scheme: light;
  --reader-toolbar: #f0f2e8;
  --reader-stage: #d6dcd5;
  --warning-bg: #fff2db;
  --warning-ink: #795327;
}
[data-theme='dark'] {
  color-scheme: dark;
  --paper: #191f20;
  --white: #222b2c;
  --ink: #e4ebe5;
  --muted: #aab7b0;
  --line: #3b4847;
  --green: #b2d2b5;
  --lime: #354438;
  --pink: #d9a38b;
  --sand: #303a3b;
  --reader-toolbar: #222b2b;
  --reader-stage: #0e1416;
  --warning-bg: #4a3823;
  --warning-ink: #f5d4a0;
}
[hidden] {
  display: none !important;
}
[data-theme='dark'] .primary {
  background: #b2d2b5;
  color: #17221b;
}
[data-theme='dark'] .secondary,
[data-theme='dark'] input,
[data-theme='dark'] select,
[data-theme='dark'] textarea,
[data-theme='dark'] dialog,
[data-theme='dark'] .topic,
[data-theme='dark'] .note-card,
[data-theme='dark'] .notebook-intro,
[data-theme='dark'] .filters .search,
[data-theme='dark'] .compare-bar,
[data-theme='dark'] .maps-toolbar select,
[data-theme='dark'] .map-diagrams section,
[data-theme='dark'] .map-node,
[data-theme='dark'] .flow-node,
[data-theme='dark'] .map-compare-grid > article,
[data-theme='dark'] .pattern-card,
[data-theme='dark'] .pattern-study,
[data-theme='dark'] .study-panel,
[data-theme='dark'] .study-card,
[data-theme='dark'] .study-evidence,
[data-theme='dark'] .study-figure,
[data-theme='dark'] .section-card,
[data-theme='dark'] .section-entry {
  background: var(--white);
  color: var(--ink);
  border-color: var(--line);
}
[data-theme='dark'] .table-wrap th,
[data-theme='dark'] .map-selected,
[data-theme='dark'] .pattern-summary,
[data-theme='dark'] .pattern-method,
[data-theme='dark'] .study-question,
[data-theme='dark'] .study-comparison,
[data-theme='dark'] .section-method {
  background: var(--lime);
}
[data-theme='dark'] .storage-error,
[data-theme='dark'] .map-warning {
  background: var(--warning-bg) !important;
  color: var(--warning-ink) !important;
}
[data-theme='dark'] button:hover,
[data-theme='dark'] a:hover {
  color: #e7bb96;
}
[data-theme='dark'] dialog::backdrop {
  background: #000b;
}
[data-theme='dark'] .view-toggle .selected,
[data-theme='dark'] #toast {
  background: var(--green);
  color: #17221b;
}
[data-theme='dark'] .filters select {
  color: var(--ink);
}
[data-theme='dark'] #compare-tray,
[data-theme='dark'] .study-context,
[data-theme='dark'] .study-issues,
[data-theme='dark'] .study-test,
[data-theme='dark'] .study-sources,
[data-theme='dark'] .study-version,
[data-theme='dark'] .study-route span,
[data-theme='dark'] .study-tasks article,
[data-theme='dark'] .patterns-nav button,
[data-theme='dark'] .pattern-count-grid > article,
[data-theme='dark'] .pattern-levels > div,
[data-theme='dark'] .section-example {
  background: var(--white);
  color: var(--ink);
  border-color: var(--line);
}
[data-theme='dark'] .study-verdict,
[data-theme='dark'] .study-route,
[data-theme='dark'] .study-options article,
[data-theme='dark'] .patterns-principle,
[data-theme='dark'] .pattern-route span,
[data-theme='dark'] .patterns-counts,
[data-theme='dark'] .pattern-status,
[data-theme='dark'] .patterns-related,
[data-theme='dark'] .section-glossary-equivalents,
[data-theme='dark'] .section-glossary-layout #section-glossary-list > button.selected {
  background: var(--lime);
  color: var(--ink);
}
[data-theme='dark'] .pattern-bar {
  background: var(--sand);
}
[data-theme='dark'] .patterns-nav button.selected {
  background: var(--green);
  color: #17221b;
  border-color: var(--green);
}
[data-theme='dark'] .section-identity {
  color: var(--ink);
  background: var(--lime);
}
[data-theme='dark'] .reader-mode-switch button[aria-pressed='true'],
[data-theme='dark'] .reader-controls .tool-active {
  background: var(--green);
  color: #17221b;
}
.theme-toggle {
  white-space: nowrap;
  font-size: 11px;
}
@media (max-width: 600px) {
  .top-actions {
    gap: 12px;
  }
  .theme-toggle {
    font-size: 10px;
  }
}
@media print {
  [data-theme='dark'] {
    color-scheme: light;
    --paper: #fff;
    --white: #fff;
    --ink: #222;
    --muted: #555;
    --line: #ccc;
    --green: #294b3d;
    --lime: #f4f5ef;
    --sand: #eee;
    --warning-bg: #fff2db;
    --warning-ink: #795327;
  }
}
