/* ---------- Theme tokens (shared with mferet.com) ---------- */
:root {
  --bg: #f6f2ea;
  --surface: #ffffff;
  --surface-2: #efe9df;
  --text: #1c1a24;
  --muted: #5c5869;
  --border: #e3dcd0;
  --accent: #5b2fd6;
  --accent-2: #0277bd;
  --accent-soft: rgba(91, 47, 214, 0.1);
  --glow: 0 1px 2px rgba(28, 26, 36, 0.06), 0 8px 24px rgba(28, 26, 36, 0.06);
  --sun: #f2a516;
  --rain: #2f8fd6;
  --night: rgba(28, 26, 36, 0.06);
  --moon: #8c86a8;
  --cloud-fill: #ffffff;
  --cloud-dark: #8a8698;
  --cloud-edge: #b9b3c6;
  --snow: #ffffff;
  --bolt: #f2b416;
  --sky-top: rgba(2, 119, 189, 0.07);
  --storm-sky: #2a2f4a;
  --ph-calm: #b8c7b0;
  --ph-build: #e9a23b;
  --ph-peak: #c2413a;
  --ph-release: #2aa198;
  --radius: 14px;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0a12;
    --surface: #16131e;
    --surface-2: #1e1a29;
    --text: #ece9f5;
    --muted: #a6a1b8;
    --border: #2b2639;
    --accent: #a78bfa;
    --accent-2: #4fc3f7;
    --accent-soft: rgba(167, 139, 250, 0.12);
    --glow: 0 0 0 1px rgba(167, 139, 250, 0.08), 0 0 36px rgba(124, 77, 255, 0.18);
    --sun: #ffc24a;
    --rain: #4fc3f7;
    --night: rgba(0, 0, 0, 0.25);
    --moon: #d8d2f0;
    --cloud-fill: #4a4560;
    --cloud-dark: #2a2638;
    --cloud-edge: #6d6788;
    --snow: #eef6ff;
    --bolt: #ffd23f;
    --sky-top: rgba(79, 195, 247, 0.08);
    --storm-sky: #000000;
    --ph-calm: #4f5e4c;
    --ph-build: #f0b04a;
    --ph-peak: #ff6b5e;
    --ph-release: #3fd0c1;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0c0a12;
  --surface: #16131e;
  --surface-2: #1e1a29;
  --text: #ece9f5;
  --muted: #a6a1b8;
  --border: #2b2639;
  --accent: #a78bfa;
  --accent-2: #4fc3f7;
  --accent-soft: rgba(167, 139, 250, 0.12);
  --glow: 0 0 0 1px rgba(167, 139, 250, 0.08), 0 0 36px rgba(124, 77, 255, 0.18);
  --sun: #ffc24a;
  --rain: #4fc3f7;
  --night: rgba(0, 0, 0, 0.25);
  --moon: #d8d2f0;
  --cloud-fill: #4a4560;
  --cloud-dark: #2a2638;
  --cloud-edge: #6d6788;
  --snow: #eef6ff;
  --bolt: #ffd23f;
  --sky-top: rgba(79, 195, 247, 0.08);
  --storm-sky: #000000;
  --ph-calm: #4f5e4c;
  --ph-build: #f0b04a;
  --ph-peak: #ff6b5e;
  --ph-release: #3fd0c1;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font-body);
}
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-2); }
h1, h2 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 0.5em; }
h1 { font-size: clamp(2.2rem, 5.5vw, 3.4rem); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.3rem; font-weight: 700; }
p { margin: 0 0 1em; }
.mono { font-family: var(--font-mono); font-size: 0.88em; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }

/* ---------- Layout ---------- */
.top { padding: 40px 0 8px; position: relative; }

/* Light/dark switch, copied from mferet.com's "Movie mode" button */
.lights {
  position: absolute; top: 16px; right: 0;
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 500 0.85rem var(--font-body);
  padding: 6px 12px 6px 8px; min-height: 36px;
  border-radius: 999px; cursor: pointer;
}
.lights:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.lights-track {
  width: 30px; height: 18px; position: relative;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  transition: background 0.3s;
}
.lights-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #f5b942; box-shadow: 0 0 8px #f5b942;
  transition: transform 0.3s, background 0.3s, box-shadow 0.3s;
}
.lights[aria-pressed="true"] .lights-track { background: #241c3d; }
.lights[aria-pressed="true"] .lights-track::after { transform: translateX(12px); background: #a78bfa; box-shadow: 0 0 10px #7c4dff; }
.lede { color: var(--muted); max-width: 60ch; font-size: 1.05rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--glow);
  padding: 20px;
  margin: 16px 0;
}
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
select, .btn {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}
.btn { cursor: pointer; font-weight: 600; padding: 10px 28px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #0c0a12; }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn:focus-visible, select:focus-visible, .toggle input:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.summary { margin: 8px 0 12px; min-height: 1.5em; }
.now { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.place h2 { margin: 0; font-size: clamp(1.4rem, 4vw, 1.9rem); }
.eyebrow { margin: 0; color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.find { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.search { display: flex; gap: 8px; flex: 1 1 280px; min-width: 0; }
.search .btn { padding: 10px 18px; }
.search input {
  flex: 1;
  min-width: 0;
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}
.search input:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.results { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.results button {
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  cursor: pointer;
}
.results button:hover, .results button:focus-visible { border-color: var(--accent); outline: none; }
.status { margin: 8px 0 0; min-height: 1.5em; color: var(--muted); font-size: 0.92rem; }
.status.error { color: #c0392b; }
:root[data-theme="dark"] .status.error { color: #ff8a80; }
.extras { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-top: 8px; }
.samples { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 0.9rem; }
.samples select { max-width: 100%; }
.btn.small { padding: 6px 14px; min-height: 36px; font-size: 0.9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 10px 0 0; }

/* ---------- Hour strip ---------- */
.fc-head { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; justify-content: space-between; margin: 4px 0 10px; }
.fc-title { font-family: var(--font-display); font-size: 1.05rem; margin: 0; }
.fc-sub { color: var(--muted); font-weight: 500; font-size: 0.85rem; margin-left: 4px; }
.fc-key { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0; list-style: none; font-size: 0.82rem; color: var(--muted); }
.fc-key li { display: inline-flex; align-items: center; gap: 6px; }
.fc-key small { opacity: 0.8; }
.fc-key .sw { display: inline-block; width: 14px; height: 10px; border-radius: 3px; }
/* Same stops as tempColor() in src/icons.js */
.fc-key .sw.temp { width: 40px; background: linear-gradient(to right, rgb(123, 97, 255), rgb(66, 153, 232), rgb(45, 190, 180), rgb(120, 200, 80), rgb(242, 190, 40), rgb(242, 130, 45), rgb(225, 65, 70)); }
.fc-key .sw.rain { height: 6px; background: var(--rain); }
.hours {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 3px;
  height: 210px;
  align-items: end;
  padding: 6px 4px 0;
  border-radius: 10px;
  background: linear-gradient(to bottom, var(--sky-top), transparent 70%);
}
.hour {
  position: relative;
  height: 100%;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) calc(var(--cloud) * 100%), transparent);
  overflow: visible;
}
.hour.night { background-color: var(--night); }
.hour .icon {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 28px);
  aspect-ratio: 1;
}
.hour .icon svg { display: block; }
.hour .temp {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 40px;
  height: calc(10px + var(--t) * (100% - 80px));
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(to top, color-mix(in srgb, var(--bar) 70%, transparent), var(--bar));
}
.hour .rain {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 20px;
  height: calc(2px + var(--pop) * 16px);
  border-radius: 2px;
  background: var(--rain);
  opacity: calc(0.25 + var(--pop) * 0.75);
}
.hour .lbl {
  position: absolute;
  bottom: 0;
  left: 0;
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  z-index: 1;
}
.hour.now { outline: 2px solid var(--accent); outline-offset: 1px; }
.hour.now .temp { background: var(--accent); }

/* ---------- Live sky: follows the hour being played ---------- */
.player {
  --dim: 0; --energy: 0; --wet: 0;
  position: relative;
  background: color-mix(in srgb, var(--storm-sky) calc(var(--energy) * 22% + var(--dim) * 6%), var(--surface));
  transition: background-color 1.2s ease;
}
.player[data-phase="peak"] { box-shadow: var(--glow), 0 0 0 2px color-mix(in srgb, var(--ph-peak) 50%, transparent); }
.player[data-phase="release"] { box-shadow: var(--glow), 0 0 0 2px color-mix(in srgb, var(--ph-release) 45%, transparent); }
.stage { position: relative; }
.sky {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(to bottom, var(--storm-sky), transparent 75%);
  opacity: calc(var(--dim) * 0.18 + var(--energy) * 0.32);
  transition: opacity 1.2s ease;
}
.sky .rainfx {
  position: absolute;
  inset: -40px 0 0;
  background: repeating-linear-gradient(105deg, transparent 0 11px, var(--rain) 11px 12.5px, transparent 12.5px 23px);
  opacity: calc(var(--wet) * 2.2);
  transition: opacity 1s ease;
  animation: rainfall 0.45s linear infinite;
}
@keyframes rainfall { to { transform: translateY(40px); } }
.sky .flash { position: absolute; inset: 0; background: #fff; opacity: 0; }
.sky .flash.on { animation: flash 0.7s ease-out; }
@keyframes flash { 0% { opacity: 0; } 8% { opacity: 0.9; } 20% { opacity: 0.1; } 30% { opacity: 0.7; } 100% { opacity: 0; } }

/* ---------- Description ---------- */
.desc { margin: 12px 0 0; max-width: 75ch; line-height: 1.55; }
.desc strong { font-family: var(--font-display); font-weight: 700; }

/* ---------- Liner notes ---------- */
.liner-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 14px; }
.liner-head h2 { margin: 0; }
.liner-sub { margin: 0; color: var(--muted); font-size: 0.92rem; }
.credits {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1px;
  margin: 0 0 18px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.credits > div { background: var(--surface-2); padding: 10px 14px; }
.credits dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.credits dd { margin: 2px 0 0; font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; line-height: 1.3; }
.story { border-left: 3px solid var(--accent); padding: 2px 0 2px 16px; margin: 0 0 20px; }
.story p { margin: 0 0 0.4em; color: var(--muted); max-width: 70ch; }
.story .story-lead { color: var(--text); font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; line-height: 1.4; }
.note-groups { columns: 280px; column-gap: 14px; }
.note-group { --c: var(--accent); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px 6px; background: var(--surface); break-inside: avoid; margin: 0 0 14px; }
.note-group.harmony { --c: var(--accent); }
.note-group.melody { --c: var(--ph-build); }
.note-group.voices { --c: var(--ph-release); }
.note-group.dynamics { --c: var(--ph-peak); }
.note-group.texture { --c: var(--rain); }
.note-group h3 {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 6px;
  font-family: var(--font-display); font-size: 0.95rem; font-weight: 700;
}
.note-group h3 svg {
  width: 26px; height: 26px; padding: 5px; flex: none;
  border-radius: 8px;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  fill: none; stroke: var(--c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.note-group ul { list-style: none; margin: 0; padding: 0; }
.note-group li { display: flex; flex-direction: column; padding: 8px 0; border-top: 1px solid var(--border); }
.note-group li:first-child { border-top: 0; }
.note-group .effect { font-weight: 600; line-height: 1.4; }
.note-group .cause { color: var(--muted); font-size: 0.85rem; line-height: 1.4; margin-top: 2px; }

/* ---------- Mix ---------- */
.layers { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.toggle { display: inline-flex; gap: 8px; align-items: center; min-height: 44px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

.foot { color: var(--muted); font-size: 0.85rem; padding: 16px 0 40px; }
.foot p { margin: 0 0 0.4em; }

@media (max-width: 560px) {
  .lights-label { display: none; }
  .lights { padding: 6px 8px; }
  .hours { gap: 1px; height: 170px; padding: 4px 0 0; }
  .hour .icon.minor { display: none; }
  .hour .icon { width: 22px; }
  .hour .lbl { font-size: 0.6rem; }
  .now .btn.primary, #geo { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .sky .rainfx { animation: none; }
}
