/* The original cover and title masks are shared; daylight uses paper light and copper ink. */
:root,
:root[data-theme='dark'] {
  color-scheme: dark;
  --page: #17130e;
  --surface: #201910;
  --surface-raised: #2b2116;
  --ink: #f0dfbd;
  --muted: #b6a183;
  --line: #c4a06d40;
  --accent: #b35236;
  --accent-ink: #fff1d3;
  --focus: #d5b478;
  --manuscript-pigment: #f0dfbd;
  --page-gradient: radial-gradient(ellipse at 12% 40%, #33241980, transparent 58%), linear-gradient(180deg, #1c150e, #15100b 61%, #1b130c);
}
:root[data-theme='light'] {
  color-scheme: light;
  --page: #eee7da;
  --surface: #f6f0e6;
  --surface-raised: #fffaf0;
  --ink: #372b20;
  --muted: #75634e;
  --line: #8b6d4540;
  --accent: #8f3628;
  --accent-ink: #fff2df;
  --focus: #87582b;
  --manuscript-pigment: #3b2c1f;
  --paper: #372b20;
  --page-gradient: radial-gradient(ellipse 70rem 80rem at 10% 35%, #e4d6bb70, transparent 65%), linear-gradient(180deg, #f1ebdf, #eee7da 64%, #e8dfce);
}
#themeToggle {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid #d7bd8f33;
  border-radius: 50%;
  color: #e8d4af;
  background: transparent;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
#themeToggle:hover { border-color: #d7bd8f99; background: #e5d3aa0a; }
#themeToggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
:root[data-theme='light'] body { color: var(--ink); background: var(--page); }
:root[data-theme='light'] main { background: var(--page-gradient); }
:root[data-theme='light'] .hero { --paper: var(--ink); background: var(--page); }
:root[data-theme='light'] .hero__read-link { color: #664525; }
:root[data-theme='light'] .hero__read-link:hover { color: var(--accent); }
:root[data-theme='light'] .paper-grain { opacity: .06; }
:root[data-theme='light'] .topbar:not(.is-scrolled) { color: var(--ink); background: linear-gradient(180deg, #f1ebdff2, #eee7dab8 68%, #eee7da00); }
:root[data-theme='light'] .topbar:not(.is-scrolled) :is(#themeToggle, .topbar__sound, .topbar__motion, .topbar__title, .return-grip) { color: var(--ink); border-color: var(--line); }
:root[data-theme='light'] .topbar:not(.is-scrolled) #themeToggle:hover { background: #8b6d4510; }
:root[data-theme='light'] .topbar:not(.is-scrolled) .chapter-nav { border-color: var(--line); background: #f6f0e6d9; }
:root[data-theme='light'] .topbar:not(.is-scrolled) .chapter-nav a { color: var(--muted); }
:root[data-theme='light'] .topbar:not(.is-scrolled) .chapter-nav a:hover { color: var(--ink); background: #8b6d4510; }
:root[data-theme='light'] .topbar:not(.is-scrolled) .chapter-nav a[aria-current] { color: var(--ink); background: #8b6d451c; box-shadow: inset 0 0 0 1px #8b6d4526; }
:root[data-theme='light'] .topbar :is(.topbar__sound, .return-grip) { background: #f6f0e6bf; }
:root[data-theme='light'] .topbar.is-scrolled { color: var(--ink); background: linear-gradient(180deg, #f1ebdff5, #eee7dadb 64%, #eee7da00); }
:root[data-theme='light'] .topbar.is-scrolled :is(#themeToggle, .topbar__sound, .topbar__motion, .topbar__title, .return-grip) { color: var(--ink); border-color: var(--line); }
:root[data-theme='light'] .topbar.is-scrolled #themeToggle:hover { background: #8b6d4510; }
:root[data-theme='light'] .topbar.is-scrolled .chapter-nav { border-color: var(--line); background: #f6f0e6cf; }
:root[data-theme='light'] .topbar.is-scrolled .chapter-nav a { color: var(--muted); }
:root[data-theme='light'] .topbar.is-scrolled .chapter-nav a:hover { color: var(--ink); background: #8b6d4510; }
:root[data-theme='light'] .topbar.is-scrolled .chapter-nav a[aria-current] { color: var(--ink); background: #8b6d451c; box-shadow: inset 0 0 0 1px #8b6d4526; }

/* Daylight stays inside the supplied painting, with the same parallax geometry. */
:root[data-theme='light'] .hero__depth-back .hero__image,
:root[data-theme='light'] .hero.is-depth-active .hero__depth-back .hero__image,
:root[data-theme='light'] .hero__depth-back > .water-artwork {
  filter: saturate(.62) contrast(.84) brightness(1.32) sepia(.14) blur(.45px);
}
:root[data-theme='light'] .hero__veil {
  background:
    linear-gradient(180deg, #f8f1e6a8 0%, #f3ead858 35%, #e7dbc998 65%, #eee7da 100%),
    linear-gradient(90deg, #f2e8d7aa, #f3ead820 65%, #eee7da60);
}
:root[data-theme='light'] .hero__depth-mist {
  opacity: .28;
  background: radial-gradient(ellipse at 78% 92%, #fff9ec75, transparent 54%), radial-gradient(ellipse at 5% 70%, #e1cfa947, transparent 45%);
  filter: blur(12px);
}
:root[data-theme='light'] .hero__ray { background: #fff7df55; opacity: .35; }
:root[data-theme='light'] .hero .eyebrow,
:root[data-theme='light'] .hero__subtitle,
:root[data-theme='light'] .hero__note { color: #6c5135; }
:root[data-theme='light'] .hero__title-art {
  --title-relief: drop-shadow(0 1px 0 #fff8ed6e) drop-shadow(0 3px 6px #7450261a);
}
:root[data-theme='light'] .hero__title-art::after {
  background: linear-gradient(145deg, #503018 0%, #775029 25%, #58371b 48%, #7c542c 64%, #4a2b15 83%, #66401f 100%);
}
:root[data-theme='light'] .hero.is-arriving .hero__title-art::before {
  background-image: linear-gradient(103deg, transparent 43%, #9f774818 48%, #b2844e42 50%, #b18b5526 53%, transparent 59%);
}
:root[data-theme='light'] .hero__arrival::before,
:root[data-theme='light'] .hero__arrival::after { border-color: #9d743b42; box-shadow: none; }
:root[data-theme='light'] :is(.music-section__heading h2, .music-track h3, .authors-section__heading h2) { color: var(--ink); }
:root[data-theme='light'] :is(.music-section__heading p, .music-track p, .music-reading-link, .music-progress__time, .music-volume, .manuscript-player__hint, .reading-footer, .authors-section__heading p, .authors-section__heading > span) { color: var(--muted); }
:root[data-theme='light'] .music-cover { background: var(--surface); box-shadow: 0 24px 64px #59402420; }
:root[data-theme='light'] .music-actions button:not(#playToggle) { color: var(--ink); }
:root[data-theme='light'] .music-actions #playToggle { color: var(--accent-ink); background: var(--accent); }
:root[data-theme='light'] .music-actions #loopToggle[aria-pressed='true'] { color: var(--accent); }
:root[data-theme='light'] :is(.music-progress input, .music-volume input) { accent-color: var(--accent); }
:root[data-theme='light'] :is(.manuscript-player__heading, .manuscript-player__heading button, .manuscript-player__controls button) { color: var(--ink); }
:root[data-theme='light'] .manuscript-player__heading output { color: var(--muted); }
:root[data-theme='light'] :is(.manuscript-player__heading button:hover, .manuscript-player__controls button:not(:disabled):hover) { color: var(--accent); }
:root[data-theme='light'] #followSong[aria-pressed='true'] { color: var(--accent); }
:root[data-theme='light'] #followSong[aria-pressed='false'] { color: var(--muted); }
:root[data-theme='light'] .reading-footer a { color: var(--ink); }
:root[data-theme='light'] .mini-player { color: var(--ink); border-color: var(--line); background: #f6f0e6f2; box-shadow: 0 8px 32px #59402416; }
:root[data-theme='light'] .mini-player button { color: var(--ink); }
:root[data-theme='light'] .mini-player__track small { color: var(--muted); }
:root[data-theme='light'] .player-notice { color: var(--ink); border-color: var(--line); background: var(--surface-raised); box-shadow: 0 12px 32px #5940241a; }

/* The real manuscript index uses parchment surfaces, never an inverted raster. */
:root[data-theme='light'] :is(.manuscript-index, .author-works) { color: var(--ink); }
:root[data-theme='light'] :is(.manuscript-index, .author-works)::backdrop { background: #43301e55; }
:root[data-theme='light'] :is(.manuscript-index__panel, .author-works__panel) { border-color: var(--line); background: var(--surface); box-shadow: -22px 0 70px #59402424; }
:root[data-theme='light'] :is(.manuscript-index__header h2, .author-works__header h2, .manuscript-index__close, .author-works__close, .author-works__empty button) { color: var(--ink); }
:root[data-theme='light'] :is(.manuscript-index__header p, .author-works__count, .author-works__empty p) { color: var(--muted); }
:root[data-theme='light'] :is(.manuscript-index__grid, .author-works__body) { scrollbar-color: #a38b68 var(--surface); }
:root[data-theme='light'] :is(.manuscript-index__item, .author-works__work) { color: var(--muted); border-color: var(--line); background: var(--surface-raised); }
:root[data-theme='light'] :is(.manuscript-index__item:hover, .author-works__work:hover) { border-color: #8b6d4590; background: #ede1cb; }
:root[data-theme='light'] .manuscript-index__item.is-current { color: var(--ink); border-color: var(--focus); background: #e8d9bd; }

/* Fullscreen inspection keeps the same geometry and original alpha in either palette. */
:root[data-theme='light'] .manuscript-viewer { color-scheme: light; color: var(--ink); background: var(--page); }
:root[data-theme='light'] .manuscript-viewer::backdrop { background: var(--page); }
:root[data-theme='light'] .manuscript-viewer__stage { background: radial-gradient(ellipse at 50% 50%, #8b6d4507, transparent 72%); }
:root[data-theme='light'] .manuscript-viewer :is(button, a) { color: var(--ink); }
:root[data-theme='light'] .manuscript-viewer :is(button:not(:disabled):hover, a:hover) { color: var(--accent); border-color: var(--line); background: #8b6d450c; }
:root[data-theme='light'] .manuscript-viewer :is(button:not(:disabled):active, a:active) { background: #8b6d4517; }
:root[data-theme='light'] .manuscript-viewer button:disabled { color: var(--muted); }
:root[data-theme='light'] :is(.manuscript-viewer__title h2, .manuscript-viewer__hint, .manuscript-viewer__status) { color: var(--muted); }
:root[data-theme='light'] :is(.manuscript-viewer__title p, #viewerZoomLabel) { color: var(--ink); }
:root[data-theme='light'] .manuscript-viewer__zoom { border-color: var(--line); background: #8b6d4507; }
:root[data-theme='light'] #viewerCanvas[aria-pressed='true'] { color: var(--ink); border-color: var(--focus); background: #8b6d4512; }
:root[data-theme='light'] :is(button, a, input, [tabindex]):focus-visible { outline-color: var(--focus); }
:root[data-theme='light'] .hero :is(button, a, input, [tabindex]):focus-visible,
:root[data-theme='light'] .topbar:not(.is-scrolled) :is(button, a):focus-visible { outline-color: var(--focus); }
:root[data-theme='light'] .manuscript-viewer__stage:focus-visible { outline-color: #87582b55; }
