/* =================================================================
   SOBER7 — night mode. Day is the default "Clear Morning" palette in
   style.css; night swaps the same colour tokens for a calm, low-glare
   spruce palette. Every text colour keeps WCAG AA contrast.
   ================================================================= */
html[data-theme="dark"] {
  --bg: #0F1614;  --bg-rgb: 15, 22, 20;
  --bg-2: #131C19;
  --surface: #17211E;  --surface-rgb: 23, 33, 30;
  --ink: #E9F0EC;  --ink-rgb: 233, 240, 236;
  --text: #E2EAE5;
  --text-2: #B3C2BB;
  --text-3: #93A49C;
  --line: #26342F;
  --line-2: #364741;
  --field-line: #5F726A;
  --line-guide: #1F2B27;
  --gridline: rgba(233, 240, 236, 0.035);
  --accent: #6CC1B6;  --accent-hover: #8BD2C8;
  --accent-soft: #1B3138;
  --sage: #1B3327;
  --ok: #7FD3A6;
  --lavender: #262238;
  --lav-ink: #BDB3EA;
  --peach: #352619;
  --peach-line: #6A4A33;
  --peach-ink: #F3C6A0;
  --error: #F29380;
  --error-bg: #3A201A;
  color-scheme: dark;
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }

/* solid accent surfaces carry dark text in night mode */
html[data-theme="dark"] ::selection { color: #0F1614; }
html[data-theme="dark"] .tag--solid,
html[data-theme="dark"] .scale button.is-on,
html[data-theme="dark"] .player__play,
html[data-theme="dark"] .seg__check.is-done { color: #0F1614; }
html[data-theme="dark"] .toast { background: #E9F0EC; color: #0F1614; }

/* hard-coded light borders and fills from the day palette */
html[data-theme="dark"] .seg__state:not(.is-done),
html[data-theme="dark"] .day-lock.is-open, html[data-theme="dark"] .day-lock.is-progress,
html[data-theme="dark"] .day-status.is-open .day-status__pill, html[data-theme="dark"] .day-status.is-progress .day-status__pill,
html[data-theme="dark"] .gloss__row.is-open .gloss__ico, html[data-theme="dark"] .gloss__row.is-progress .gloss__ico { border-color: #2F5560; }
html[data-theme="dark"] .day-lock.is-done, html[data-theme="dark"] .day-status.is-done .day-status__pill, html[data-theme="dark"] .gloss__row.is-done .gloss__ico { border-color: #2C5A41; }
html[data-theme="dark"] .day-lock.is-locked, html[data-theme="dark"] .day-status.is-locked .day-status__pill,
html[data-theme="dark"] .gloss__row.is-locked .gloss__ico, html[data-theme="dark"] .res-day__ico { border-color: #3D3758; }
html[data-theme="dark"] .res.is-locked, html[data-theme="dark"] .lib-grid .res.is-locked { background: repeating-linear-gradient(135deg, var(--lavender) 0 10px, #2C2842 10px 11px); }
html[data-theme="dark"] .gauge__tick { fill: #3F514A; }
html[data-theme="dark"] img.hero__img, html[data-theme="dark"] .hero__media video { filter: brightness(.82) saturate(.95); }

/* forms */
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { color: var(--ink); }
html[data-theme="dark"] .field, html[data-theme="dark"] input.field, html[data-theme="dark"] select.field, html[data-theme="dark"] textarea { background: #121B18; border-color: var(--field-line); }
html[data-theme="dark"] .lock-field .field[readonly] { background: #16211D; }

/* pages built with fixed light colours */
html[data-theme="dark"] .pm__opt.is-on { background: #1C2B27; }
html[data-theme="dark"] .pw-row__cta { background: #221E35; border-color: #3D3758; color: #C9BFFF !important; }
html[data-theme="dark"] .pw-row__cta:hover { background: #2A2542; }
html[data-theme="dark"] .admin-test, html[data-theme="dark"] .sx-tip--idea, html[data-theme="dark"] .sx-tonight { background: #201C33; border-color: #3D3758; color: #D3CCF5; }
html[data-theme="dark"] .sx-tonight h2 { color: #E6E1FF; }
html[data-theme="dark"] .sx-tip--learn { background: #16252F; border-color: #2B4352; color: #BFD9EC; }
html[data-theme="dark"] .sx-tip--warn { background: #2E1F17; border-color: #5A3B28; color: #F3C6A0; }
html[data-theme="dark"] .sx-quiz.is-ok, html[data-theme="dark"] .sx-quote { background: #172420; }
html[data-theme="dark"] .sx-quote--pledge { background: #1D1A2E; border-left-color: #9C8CF5; }
html[data-theme="dark"] .is-miss .sx-mark { background: #23394A; color: #BFD9EC; }
html[data-theme="dark"] .sx__num { box-shadow: 0 0 0 5px var(--bg); color: #0F1614; }
html[data-theme="dark"] .sx-glance a.is-active span, html[data-theme="dark"] .sx-layout .sx-glance a.is-active span { color: #0F1614; }
html[data-theme="dark"] .tv--light .tv-done { color: #0F1614; }
html[data-theme="dark"] .tv-sheet--light .tv-sheet__panel { background: var(--surface); }
html[data-theme="dark"] .tv-sheet--light { --tv-bg2: #17211E; }
html[data-theme="dark"] .tv-sheet--light .tv-why { background: #201C33; border-color: #3D3758; }
html[data-theme="dark"] .tv-sheet--light .tv-why b { color: #C9BFFF; }
html[data-theme="dark"] .tv-sheet--light .tv-why ul { color: #DDD6FF; }
html[data-theme="dark"] .tv-sheet--light .tv-quote { background: #1B2723; }
html[data-theme="dark"] .tv-sheet--light .tv-match { color: #7FD3A6; }
html[data-theme="dark"] .fp-done h2, html[data-theme="dark"] .done h2 { color: var(--ink); }

/* ---- the day / night switch in the header ---- */
.theme-toggle { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; margin-inline-start: 4px; border-radius: 50%;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer; pointer-events: auto; flex: none;
  transition: background .2s, border-color .2s, transform .2s; }
.theme-toggle:hover { border-color: var(--accent); transform: rotate(-12deg); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .i-sun { display: none; }
html[data-theme="dark"] .theme-toggle .i-sun { display: block; }
html[data-theme="dark"] .theme-toggle .i-moon { display: none; }
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after { transition: background-color .35s ease, color .35s ease, border-color .35s ease, fill .35s ease !important; }

/* photo headers: the light wash becomes a dark wash so light text reads over any photo */
html[data-theme="dark"] .page-hero .hero__scrim {
  background: linear-gradient(90deg, rgba(15,22,20,0.94) 0%, rgba(15,22,20,0.82) 32%, rgba(15,22,20,0.4) 58%, rgba(15,22,20,0) 80%) !important;
}
@media (max-width: 700px) {
  html[data-theme="dark"] .page-hero .hero__scrim { background: linear-gradient(0deg, rgba(15,22,20,0.95) 0%, rgba(15,22,20,0.82) 55%, rgba(15,22,20,0.45) 100%) !important; }
}
html[data-theme="dark"] .sum__next { background: rgba(23,33,30,.88); }
html[data-theme="dark"] .gate .hero__scrim, html[data-theme="dark"] .hero .hero__scrim { background: linear-gradient(90deg, rgba(15,22,20,0.7), rgba(15,22,20,0.15) 70%); }
html[data-theme="dark"] { --cta: #7A55C2; --cta-hover: #8E6AD6; --cta-soft: #3A2F5C; }
