/* Shared optional theme. Light is the default; only an explicit choice is saved. */
:root[data-theme="dark"] {
  color-scheme:dark;
  --paper:#191b1e; --ink:#eeeee8; --muted:#b7b9b7;
  --accent:#a8bdf2; --rule:#41454c;
  --blue-light:#536580; --blue-mid:#7795c4; --blue-rich:#a1b8ee;
}
.theme-toggle {
  display:inline-flex; align-items:center; gap:.6rem;
  padding:.5rem .1rem; border:0; background:transparent; color:var(--muted);
  font:inherit; font-size:.8125rem; line-height:1.3; cursor:pointer; white-space:nowrap;
  min-height:44px;
}
.theme-toggle[hidden] { display:none; }
.theme-toggle:focus-visible { outline:2px solid var(--accent); outline-offset:4px; }
.theme-track { display:block; position:relative; width:2rem; height:1.125rem; border:1px solid var(--muted); border-radius:2rem; }
.theme-track::after { content:""; position:absolute; width:.75rem; height:.75rem; left:.125rem; top:.125rem; border-radius:50%; background:var(--muted); }
[data-theme="dark"] .theme-track::after { left:1rem; background:var(--accent); }
.theme-bar { width:min(calc(100% - 3rem),68rem); margin-inline:auto; display:flex; justify-content:flex-end; padding-top:1rem; }
[data-theme="dark"] ::selection { background:#3c507f; color:#fff; }
[data-theme="dark"] .opening-corner-art,
[data-theme="dark"] .countryside-underlay,
[data-theme="dark"] .storybook-stairs,
[data-theme="dark"] .page-art,
[data-theme="dark"] .page-overhang { filter:invert(1) hue-rotate(180deg) saturate(.65); }
[data-theme="dark"] .manhole-link img { filter:invert(1); }
[data-theme="dark"] .highlighter::before { background:rgb(189 216 69 / .24); }
[data-theme="dark"] .truths li::before { color:#bfd0f8; border-color:rgb(156 186 249 / .65); background:rgb(151 186 250 / .06); }
[data-theme="dark"] .truths li::after { border-color:rgb(156 186 249 / .3); }
[data-theme="dark"] .profit-cue { text-decoration-color:rgb(168 189 242 / .65); }
[data-theme="dark"] .back { border-color:var(--rule); }

/* Explicit switch colors stay legible independently of page text variables. */
:root { --toggle-ink:#565653; --toggle-fill:#e9e9e2; }
:root[data-theme="dark"] { --toggle-ink:#b7b9b7; --toggle-fill:#2d333c; }
.theme-toggle { color:var(--toggle-ink); }
.theme-toggle .theme-track { color:var(--toggle-ink); border-color:currentColor; background:var(--toggle-fill); flex-shrink:0; }
.theme-toggle .theme-track::after { background:currentColor; }
.theme-bar { position:relative; z-index:2; }
