/* Soundscape (Newel Labs Play). Self-contained: no shared stylesheet, system fonts only. */
:root {
  color-scheme: light dark;
  --bg: #f3f1eb;
  --bg-glow: #e6eeec;
  --card: #fcfbf8;
  --card-edge: #e3ded3;
  --ink: #172031;
  --ink-2: #3a4457;
  --muted: #586174;
  --line: #e0dbd0;
  --track: #d9d3c7;
  --sw-edge: #7d8595;
  --accent: #2b6a66;
  --accent-hi: #357c76;
  --on-accent: #ffffff;
  --focus: #9a6c1c;
  --deck-a: #e3ecea;
  --deck-b: #f6f2ea;
  --wave-1: rgba(43, 106, 102, 0.13);
  --wave-2: rgba(166, 120, 40, 0.14);
  --wave-3: rgba(43, 106, 102, 0.26);
  --shadow: 0 1px 2px rgba(23, 32, 49, 0.05), 0 10px 30px -18px rgba(23, 32, 49, 0.30);
  --on-bg-l: 95%; --on-bg-s: 42%;
  --on-edge-l: 76%;
  --on-ink-l: 34%; --on-ink-s: 48%;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131b;
    --bg-glow: #13202a;
    --card: #141b25;
    --card-edge: #222d3c;
    --ink: #e8ecf1;
    --ink-2: #c2c9d4;
    --muted: #97a1b1;
    --line: #243041;
    --track: #2c3849;
    --sw-edge: #7f8a9c;
    --accent: #86cbc1;
    --accent-hi: #9fd9cf;
    --on-accent: #0c1a1f;
    --focus: #e3b863;
    --deck-a: #142430;
    --deck-b: #121822;
    --wave-1: rgba(134, 203, 193, 0.09);
    --wave-2: rgba(227, 184, 99, 0.09);
    --wave-3: rgba(134, 203, 193, 0.2);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -18px rgba(0, 0, 0, 0.7);
    --on-bg-l: 17%; --on-bg-s: 28%;
    --on-edge-l: 34%;
    --on-ink-l: 76%; --on-ink-s: 60%;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 16px/1.6 var(--font);
  color: var(--ink);
  background: radial-gradient(1100px 520px at 50% -140px, var(--bg-glow), transparent 70%) no-repeat, var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hi); }
button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Header + hero */
.top { padding-top: 18px; }
.crumb { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 0.9rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.crumb:hover { color: var(--ink); }
.crumb span[aria-hidden] { opacity: 0.6; font-weight: 400; }
.crumb-mark { width: 18px; height: 18px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), #c9973a); }
.hero { padding: 14px 0 22px; }
h1 { margin: 0 0 12px; line-height: 1.05; }
.h1-name { display: block; font: 600 clamp(2.4rem, 7vw, 3.6rem)/1.02 var(--serif); letter-spacing: -0.02em; }
.h1-sub { display: block; margin-top: 8px; font: 500 clamp(1.05rem, 2.6vw, 1.3rem)/1.3 var(--font); color: var(--accent); letter-spacing: -0.005em; }
.lede { margin: 0; max-width: 640px; color: var(--ink-2); font-size: 1rem; }
@media (min-width: 720px) { .lede { font-size: 1.05rem; } }

/* Player deck */
.deck {
  --pad: 16px;
  position: relative; overflow: hidden;
  border: 1px solid var(--card-edge); border-radius: 22px;
  background: linear-gradient(160deg, var(--deck-a), var(--deck-b) 70%);
  box-shadow: var(--shadow);
  padding: var(--pad) var(--pad) 0;
}
@media (min-width: 720px) { .deck { --pad: 24px; padding-top: 22px; } }
/* the moving shoreline: height is fixed in CSS so drawing never shifts layout */
.scape { display: block; width: calc(100% + 2 * var(--pad)); height: 44px; margin: 12px calc(-1 * var(--pad)) 0; pointer-events: none; }
@media (min-width: 720px) { .scape { height: 52px; margin-top: 8px; } }
.deck-row { display: flex; align-items: center; gap: 14px; min-height: 72px; }
.play {
  width: 68px; height: 68px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; font-size: 30px;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 6px 18px -8px var(--accent);
  transition: transform .15s ease, background-color .2s ease;
  position: relative;
}
.play:hover { background: var(--accent-hi); }
.play:active { transform: scale(0.96); }
.play svg { fill: currentColor; stroke: none; grid-area: 1 / 1; }
.play .ic-pause { display: none; }
.play[data-state="playing"] .ic-play { display: none; }
.play[data-state="playing"] .ic-pause { display: block; }
.play.cue::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--accent); opacity: 0; animation: cue 2.4s ease-out infinite;
}
@keyframes cue { 0% { transform: scale(0.9); opacity: 0.7; } 70%, 100% { transform: scale(1.25); opacity: 0; } }
.now { flex: 1; min-width: 0; }
.now p { margin: 0; }
.now-title { font-weight: 650; font-size: 1.12rem; line-height: 1.3; }
.now-mix { color: var(--muted); font-size: 0.92rem; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 2.7em; }
.ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--card-edge); background: color-mix(in srgb, var(--card) 80%, transparent); font-weight: 600; font-size: 0.95rem;
}
@supports not (background: color-mix(in srgb, red, blue)) { .ghost { background: var(--card); } }
.ghost:hover { border-color: var(--accent); }
.ghost svg { font-size: 1.15rem; }
@media (max-width: 420px) { .share span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } .share { padding: 0; width: 46px; } }

.deck-controls { display: grid; gap: 10px 28px; margin-top: 12px; }
@media (min-width: 720px) { .deck-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: end; } }
.ctl-label { display: flex; align-items: center; gap: 7px; min-height: 22px; margin: 0 0 4px; font-size: 0.84rem; font-weight: 650; letter-spacing: 0.02em; color: var(--ink-2); }
.ctl-label svg { font-size: 1.05rem; color: var(--muted); }
.countdown { margin-left: auto; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: 0; }

/* Segmented sleep timer */
.seg { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 14px; background: color-mix(in srgb, var(--card) 70%, transparent); border: 1px solid var(--card-edge); }
@supports not (background: color-mix(in srgb, red, blue)) { .seg { background: var(--card); } }
.seg label { position: relative; display: block; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span { display: block; text-align: center; line-height: 40px; border-radius: 10px; font-size: 0.9rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; transition: background-color .15s, color .15s; }
.seg small { font-size: 0.78em; font-weight: 500; opacity: 0.8; }
@media (max-width: 400px) { .seg small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } }
.seg input:checked + span { background: var(--accent); color: var(--on-accent); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.seg label:hover input:not(:checked) + span { background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* Range sliders */
.range {
  --pct: 50%; --fill: var(--accent);
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 40px; margin: 0; background: transparent; cursor: pointer; border-radius: 10px;
}
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: linear-gradient(to right, var(--fill) 0 var(--pct), var(--track) var(--pct) 100%); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: var(--card); border: 2px solid var(--fill); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
.range::-moz-range-track { height: 6px; border-radius: 99px; background: var(--track); }
.range::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--fill); }
.range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--card); border: 2px solid var(--fill); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
.range:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (min-width: 720px) { #master { height: 48px; } } /* same height as the timer control so the two line up */

/* Presets */
.label-h { margin: 26px 0 10px; font: 700 0.78rem/1 var(--font); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 16px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--card-edge); background: var(--card); color: var(--ink); font-weight: 600; font-size: 0.93rem;
  transition: background-color .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip-quiet { background: transparent; color: var(--muted); border-style: dashed; }

/* Channel cards */
.channels { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 620px) { .channels { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .channels { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; } }
.ch {
  --tint: hsl(var(--h) var(--on-ink-s) var(--on-ink-l));
  display: flex; flex-direction: column; justify-content: space-between;
  border: 1px solid var(--card-edge); border-radius: 16px; background: var(--card);
  padding: 6px 10px 4px; transition: background-color .2s, border-color .2s;
}
.ch.on { background: hsl(var(--h) var(--on-bg-s) var(--on-bg-l)); border-color: hsl(var(--h) 30% var(--on-edge-l)); }
.ch-btn {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 48px; padding: 4px 2px; margin: 0;
  border: 0; background: none; cursor: pointer; text-align: left; border-radius: 10px;
}
.ch-ic { font-size: 26px; color: var(--muted); transition: color .2s; }
.ch-ic .blade path { fill: currentColor; fill-opacity: 0.14; }
.ch-ic .grain circle { fill: currentColor; stroke: none; opacity: 0.45; }
.ch.on .ch-ic { color: var(--tint); }
.ch-name { flex: 1; min-width: 0; font-weight: 600; font-size: 0.95rem; line-height: 1.2; color: var(--ink-2); }
.ch.on .ch-name { color: var(--ink); }
/* on/off switch; the knob position (not only colour) shows the state */
/* off: a --sw-edge outline (3:1+ against the card in both themes) so the control is visible, not just a pale pill */
.sw { position: relative; width: 28px; height: 17px; flex: none; border-radius: 99px; background: var(--track); box-shadow: inset 0 0 0 1px var(--sw-edge); transition: background-color .2s, box-shadow .2s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 11px; height: 11px; border-radius: 50%; background: var(--sw-edge); transition: transform .2s, background-color .2s; }
.ch.on .sw { background: var(--tint); box-shadow: none; }
.ch.on .sw::after { background: var(--card); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.ch.on .sw::after { transform: translateX(11px); }
.ch-vol { --fill: var(--muted); height: 36px; }
.ch.on .ch-vol { --fill: var(--tint); }
.ch:not(.on) .ch-vol { opacity: 0.7; }
@media (max-width: 400px) {
  .ch { padding: 6px 8px 4px; }
  .ch-btn { gap: 7px; }
  .ch-ic { font-size: 22px; }
  .ch-name { font-size: 0.9rem; }
}

.note { margin: 14px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--card-edge); color: var(--ink-2); }

/* Guide */
.guide { max-width: 700px; margin-top: 56px; }
.guide h2 { font: 600 1.55rem/1.2 var(--serif); letter-spacing: -0.01em; margin: 36px 0 12px; }
.guide ol, .guide ul { padding-left: 1.3em; margin: 0; }
.guide li { margin: 0 0 8px; color: var(--ink-2); }
.guide li strong { color: var(--ink); }
.guide details { border-top: 1px solid var(--line); }
.guide details:last-of-type { border-bottom: 1px solid var(--line); }
.guide summary { cursor: pointer; padding: 13px 0; font-weight: 600; list-style-position: outside; min-height: 44px; }
.guide details p { margin: 0 0 16px; color: var(--ink-2); }

.foot { margin-top: 64px; padding-top: 8px; padding-bottom: 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.foot p { margin: 0; }
.foot a { color: var(--muted); display: inline-block; padding: 13px 0; } /* 44px-tall tap target */
.foot a:hover { color: var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 16px);
  padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 0.92rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .play.cue::after { opacity: 0.5; transform: scale(1.12); }
}
