:root {
  --bg: #0d1020;
  --panel: #161a30;
  --line: #2a3050;
  --text: #e6e8f2;
  --muted: #9aa1bf;
  --accent: #8fa8ff;
  --accent-text: #0d1020;
  --error: #ff9a9a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: linear-gradient(180deg, #070916 0%, var(--bg) 40%, #10142a 100%) fixed;
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main, .top, footer { max-width: 44rem; margin: 0 auto; padding: 0 16px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; }
h1 { font-size: 1.4rem; margin: 0; letter-spacing: .02em; }
.brand {
  display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none;
  font-weight: 800; font-size: 1.15rem; letter-spacing: .02em;
}
.brand img { border-radius: 7px; }
h2 { font-size: 1.1rem; margin: 28px 0 10px; }
section { margin-bottom: 8px; }
footer { padding-top: 32px; padding-bottom: 32px; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: .88rem; }
.error, .status.error { color: var(--error); }
.status { min-height: 1.2em; margin: 6px 0; }
.hint { color: var(--muted); margin-top: -4px; }

.button, button.icon, .link {
  font: inherit; cursor: pointer; border-radius: 10px;
}
.button {
  background: var(--accent); color: var(--accent-text); border: 0; padding: 8px 14px; font-weight: 600;
  white-space: nowrap;
}
.button.quiet { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 400; }
.button.small { padding: 5px 10px; font-size: .88rem; }
.button:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }
button.icon { background: none; border: 0; color: var(--muted); font-size: 1rem; padding: 4px 8px; margin-left: auto; }

.player {
  display: flex; align-items: center; gap: 16px; margin-top: 16px; padding: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  position: sticky; top: 8px; z-index: 2;
}
.play {
  font: 700 1.1rem system-ui, sans-serif; min-width: 6.5rem; padding: 14px 20px; border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-text); cursor: pointer;
}
.slider { display: grid; grid-template-columns: 7.5rem 1fr auto; align-items: center; gap: 10px; margin: 4px 0; }
.slider.master { flex: 1; grid-template-columns: auto 1fr; }
.slider .value { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .88rem; min-width: 3.2em; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.track {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; margin-bottom: 10px;
}
.track-head { display: flex; align-items: center; gap: 8px; }
.track-play {
  flex: none; width: 2.2rem; height: 2.2rem; border-radius: 50%; border: 1px solid var(--line);
  background: none; color: var(--text); font-size: .8rem; cursor: pointer;
}

/* The loop bar: two range inputs stacked on one track, only their handles
   taking the pointer, with the looped part filled and a moving playhead.
   The track is inset by half a handle so percentages line up with handles. */
.range2 { position: relative; height: 28px; }
.range2-track {
  position: absolute; left: 8px; right: 8px; top: 50%; height: 6px; margin-top: -3px;
  background: var(--line); border-radius: 3px;
}
.range2-fill { position: absolute; top: 0; bottom: 0; background: var(--accent); opacity: .45; border-radius: 3px; }
.range2-head {
  position: absolute; top: -7px; bottom: -7px; width: 2px; margin-left: -1px;
  background: var(--text); border-radius: 1px; pointer-events: none;
}
.range2 input {
  position: absolute; left: 0; top: 0; width: 100%; height: 28px; margin: 0;
  background: none; pointer-events: none; -webkit-appearance: none; appearance: none;
}
.range2 input::-webkit-slider-runnable-track { background: none; }
.range2 input::-moz-range-track { background: none; }
.range2 input::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}
.range2 input::-moz-range-thumb {
  pointer-events: auto; width: 16px; height: 16px; border: 0; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}
.range2-labels {
  display: flex; justify-content: space-between; color: var(--muted); font-variant-numeric: tabular-nums;
}
.range2-labels .now { color: var(--text); }

.row-item {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.row-item .grow { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }

input[type=text], input[type=email], input[type=search], textarea, input[type=file] {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; width: 100%;
}
input[type=search] { margin-bottom: 6px; }
label { display: block; margin: 10px 0 4px; }
label.check { display: flex; gap: 8px; align-items: baseline; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row label { margin: 0; }
.row input[type=text] { flex: 1; width: auto; min-width: 10rem; }
.upload { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px 10px; margin-bottom: 12px; }
.upload input { background: var(--bg); }
.code { font-size: 1.4rem; letter-spacing: .2em; max-width: 12rem; }

dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px;
  width: min(30rem, calc(100vw - 32px)); padding: 16px 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin-top: 0; }

@media (max-width: 30rem) {
  .slider { grid-template-columns: 1fr auto; }
  .slider > span:first-child { grid-column: 1 / -1; margin-bottom: -6px; }
  .slider.master { grid-template-columns: 1fr; }
  .slider.master > span:first-child { display: none; }
}

.mix-pick select {
  flex: 1; min-width: 10rem; font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.track .actions { margin-top: 6px; }
.range2-head.paused { opacity: .55; }
.range2 { cursor: pointer; touch-action: pan-y; }
#who { text-align: right; }

/* --- the night sky and the opening section ---------------------------------- */
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .7;
  background-image:
    radial-gradient(1px 1px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 90px 110px, #cfd8ff, transparent),
    radial-gradient(1.5px 1.5px at 160px 60px, #fff, transparent),
    radial-gradient(1px 1px at 230px 170px, #dfe6ff, transparent),
    radial-gradient(1px 1px at 300px 40px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 350px 220px, #cfd8ff, transparent);
  background-size: 380px 260px;
  animation: twinkle 9s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .45; } to { opacity: .8; } }
@media (prefers-reduced-motion: reduce) { .sky { animation: none; } }

.hero {
  position: relative; max-width: 44rem; margin: 0 auto; padding: 40px 16px 8px;
}
.moon {
  position: absolute; right: 16px; top: 18px; width: 92px; height: 92px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffbe8, #e9dfb8 55%, #c9bd92);
  box-shadow: 0 0 60px 18px rgba(255, 244, 200, .18), 0 0 140px 50px rgba(143, 168, 255, .12);
}
.kicker { color: var(--accent); font-weight: 600; font-size: .9rem; margin: 0 0 10px; max-width: 30rem; }
.hero h1 {
  font-size: clamp(2rem, 7vw, 3.2rem); line-height: 1.08; margin: 0 0 16px; font-weight: 800;
  letter-spacing: -.01em; max-width: 34rem;
}
.hero h1 span {
  background: linear-gradient(90deg, #b7c6ff, #d9b8ff 55%, #ffd9a8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { font-size: 1.1rem; color: #cfd3e6; max-width: 36rem; margin: 0 0 22px; }
.button.big {
  display: inline-block; text-decoration: none; font-size: 1.05rem; padding: 12px 22px; border-radius: 999px;
  box-shadow: 0 6px 30px rgba(143, 168, 255, .35);
}
#hero-count { margin: 12px 0 0; min-height: 1.2em; }

.why { display: grid; grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr)); gap: 14px; margin: 30px 0 8px; }
.card {
  margin: 0; padding: 14px; border-radius: 16px; border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(30, 36, 70, .75), rgba(22, 26, 48, .75));
}
.card svg { width: 100%; height: 56px; display: block; margin-bottom: 8px; }
.card figcaption { font-size: .95rem; color: #cfd3e6; }
.card strong { color: var(--text); display: block; margin-bottom: 2px; }
.wave-quiet { stroke: var(--muted); stroke-width: 2; opacity: .6; }
.wave-busy { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; opacity: .8; }
.spike { fill: none; stroke: #ff9a9a; stroke-width: 2.5; stroke-linejoin: round; }
.spike.soft { stroke-width: 2; opacity: .55; }
.track-line { stroke: var(--line); stroke-width: 4; stroke-linecap: round; }
.knob { fill: var(--accent); }

/* --- polish on the player ------------------------------------------------------ */
.player {
  background: linear-gradient(135deg, rgba(38, 46, 92, .92), rgba(22, 26, 48, .92));
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35); backdrop-filter: blur(6px);
}
.play { box-shadow: 0 0 0 0 rgba(143, 168, 255, .5); transition: box-shadow .3s; }
.play[aria-pressed="true"] { animation: breathe 4s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(143, 168, 255, .45); }
  50% { box-shadow: 0 0 0 12px rgba(143, 168, 255, 0); }
}
@media (prefers-reduced-motion: reduce) { .play[aria-pressed="true"] { animation: none; } }
.track { background: linear-gradient(180deg, rgba(30, 36, 70, .8), rgba(22, 26, 48, .8)); }
main h2 { font-size: 1.2rem; letter-spacing: .01em; }
.footer-brag { color: #cfd3e6; font-size: .95rem; }

@media (max-width: 30rem) {
  .moon { width: 64px; height: 64px; top: 22px; }
  .hero { padding-top: 28px; }
  .hero h1, .kicker { padding-right: 72px; }
}

/* --- the night clock and volume plans (specs/timeline.md) ----------------------- */
.player { flex-wrap: wrap; }
.player .night { flex-basis: 100%; gap: 14px; flex-wrap: wrap; align-items: center; }
.night #clock { color: var(--text); font-variant-numeric: tabular-nums; }
.night input[type=time] { background: transparent; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 2px 6px; font: inherit; color-scheme: dark; }
.plan select, .plan-point select, .plan-point input { background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; font: inherit; font-size: .88rem; }
.plan-graph svg { display: block; width: 100%; height: 44px; margin-top: 4px; }
.plan-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.plan-100 { stroke: var(--line); stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.plan-wake { stroke: #ffd38a; stroke-width: 1; opacity: .7; vector-effect: non-scaling-stroke; }
.plan-now { stroke: var(--text); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.plan-points { margin: 6px 0 4px; }
.plan-point { display: flex; align-items: center; gap: 5px; margin: 4px 0; flex-wrap: wrap; }
.plan-point input[type=number] { width: 3.8em; }
.plan-point button.icon { margin-left: 0; }

/* --- the shared header (shared/js/nav.js) ---------------------------------------- */
header.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; max-width: 60rem; margin: 0 auto;
  padding: 12px 16px; }
header.top .apps { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
header.top .apps a { color: var(--muted); text-decoration: none; padding: 4px 10px; border-radius: 999px; font-size: .95rem; }
header.top .apps a.here { color: var(--text); background: var(--panel); border: 1px solid var(--line); }
header.top .who { color: var(--text); }
textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; width: 100%; }
select { font: inherit; }

/* --- night graphs and track colours (shared/js/night.js) --------------------------- */
.graph svg, .night-graph { display: block; width: 100%; height: auto; min-height: 40px; }
.graph-labels { display: flex; justify-content: space-between; color: var(--muted); font-variant-numeric: tabular-nums; }
.line-0 { stroke: #8fa8ff; } .line-1 { stroke: #ffb38a; } .line-2 { stroke: #8ae0c2; }
.line-3 { stroke: #e7a1ff; } .line-4 { stroke: #ffe28a; } .line-5 { stroke: #8ad4ff; }
.bg-0 { background: #8fa8ff; } .bg-1 { background: #ffb38a; } .bg-2 { background: #8ae0c2; }
.bg-3 { background: #e7a1ff; } .bg-4 { background: #ffe28a; } .bg-5 { background: #8ad4ff; }
.swatch { display: inline-block; width: 14px; height: 3px; border-radius: 2px; flex: none; }
.plan .slider select { min-width: 0; }
@media (max-width: 40rem) {
  header.top { gap: 8px; }
  header.top .brand { flex: 1; }
  header.top .apps { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; }
}
