/* Shared palette aliases accommodate the existing portfolio and educational layouts. */
html[data-theme="dark"] { color-scheme: dark; --dim: #9999a3; }
html[data-theme="light"] {
  color-scheme: light;
  --bg: #fbfbfa; --surface: #f1f1ef; --panel: #fff; --raised: #e9eae7;
  --line: #d2d3cf; --line-strong: #92958e; --border: #d2d3cf; --border2: #92958e;
  --text: #17171a; --ink: #17171a; --muted: #46464e; --dim: #606068; --silver: #303632;
  --mint: #006e60; --violet: #5b3a9f; --amber: #815000;
  --accent: #006e60; --note: #1f5fd1; --tip: #006e60; --warn: #815000; --why: #6d3fc0; --ex: #a13a16;
}
[data-theme-toggle], #theme-toggle {
  font: 500 .82rem/1.3 system-ui, sans-serif; border: 1px solid var(--line-strong, #888);
  background: var(--surface, #17171a); color: var(--text, var(--ink, #eee));
  border-radius: 8px; padding: 10px 12px; min-height: 44px; cursor: pointer; white-space: nowrap;
}
.site-theme-fallback { position: fixed; right: 16px; bottom: 16px; z-index: 90; }
[data-theme-toggle]:focus-visible, #theme-toggle:focus-visible { outline: 3px solid var(--accent, currentColor); outline-offset: 3px; }
html[data-theme="light"] .header, html[data-theme="light"] .top { background: #fbfbfaf2; }
html[data-theme="light"] strong, html[data-theme="light"] code,
html[data-theme="light"] .prose > p:first-of-type { color: var(--text); }
html[data-theme="light"] pre, html[data-theme="light"] blockquote,
html[data-theme="light"] .concept, html[data-theme="light"] .lab-stage { background: var(--surface); color: var(--text); }
html[data-theme="light"] pre code { color: inherit; }
html[data-theme="light"] .header nav a:hover { color: var(--text); }
html[data-theme="light"] .prose a:not(.action):hover { text-decoration-color: currentColor; }
html[data-theme="light"] .bit { background: var(--raised); color: var(--text); }
html[data-theme="light"] .bit[data-active=true] { background: #c9eade; color: #174438; }
html[data-theme="light"] .logic-lamp { background: #e5e6e3; color: #303632; }
html[data-theme="light"] .logic-lamp.on { background: #c9eade; color: #174438; }
/* Original diagram artwork keeps its designed contrast; captions follow the page. */
html[data-theme="light"] .schema { background: #14171c; }
html[data-theme="light"] .schema figcaption { color: #d8dde2; }
/* Preserve the neural-network artwork, with a light scrim behind the hero copy. */
html[data-theme="light"] .hero::after {
  background: linear-gradient(to top, var(--bg) 0%, #fbfbfaf5 24%, #fbfbfa99 40%, transparent 65%);
}
html[data-theme="light"] .hero h1 { text-shadow: none; }
html[data-theme="light"] .theme-monochrome { filter: brightness(.15); }
@media (max-width: 800px) {
  .headbar { flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .bar { gap: 10px; }
  .bar > [data-theme-toggle] { margin-left: auto; }
}
@media print { [data-theme-toggle], #theme-toggle { display: none !important; } }
