/* TV hours: one warm night palette, Sentient for the signature lines, the system face for everything else. */
@font-face { font-family: "Sentient"; src: url("/static/fonts/sentient-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Sentient"; src: url("/static/fonts/sentient-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Sentient"; src: url("/static/fonts/sentient-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #14100c;
  --bg-2: #1c1712;
  --bg-3: #262019;
  --bg-4: #30281f;
  --lip: rgba(255, 238, 214, 0.06);
  --ink: #f2e8da;
  --ink-2: #bcae99;
  --ink-3: #928571;
  --ember: #c98b57;
  --ember-dim: #6e4a2c;
  --sage: #a3b693;
  --alert: #dc8f7d;
  --radius: 16px;
  --display: "Sentient", "Iowan Old Style", Georgia, serif;
  --body: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font-family: var(--body); font-size: 16px; line-height: 1.4; color: var(--ink);
  background-color: var(--bg);
  /* fine grain on the substrate only, never over text */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .92 0 0 0 0 .82 0 0 0 .035 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
                    linear-gradient(180deg, #19130e 0%, var(--bg) 46%, #110d0a 100%);
  background-attachment: scroll;
}
button, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.num { font-variant-numeric: tabular-nums; }

.shell { max-width: 520px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 28px); }

/* top line */
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.mark { font-family: var(--display); font-weight: 500; font-size: 22px; letter-spacing: 0.01em; }
.health { font-size: 13px; color: var(--ink-3); text-align: right; }
.health.bad { color: var(--alert); }

/* the dial */
.dial-wrap { position: relative; margin: 10px auto 2px; width: min(330px, 86vw); aspect-ratio: 1; }
.dial { width: 100%; height: 100%; display: block; }
.dial .ring { fill: none; stroke: var(--bg-4); stroke-width: 22; }
.dial .band { fill: none; stroke: var(--ember-dim); stroke-width: 22; stroke-linecap: round; transition: stroke 400ms ease; }
.dial .band.live { stroke: var(--ember); }
.dial .tick { stroke: var(--ink-3); stroke-width: 1.4; stroke-linecap: round; }
.dial .tick.major { stroke: var(--ink-2); stroke-width: 2; }
.dial .hour { fill: var(--ink-3); font-size: 11px; font-family: var(--body); text-anchor: middle; dominant-baseline: central; }
.dial .now-dot { fill: var(--ink); stroke: var(--bg); stroke-width: 3; }
.dial .now-line { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; opacity: 0.55; }
.dial-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; padding: 0 22%; }
.state-word { font-family: var(--display); font-weight: 500; font-size: clamp(30px, 9vw, 40px); line-height: 1.05; }
.state-word.slowed { color: var(--ember); }
.state-word.full { color: var(--sage); }
.state-when { margin-top: 6px; font-size: 15px; color: var(--ink-2); }
.state-cap { margin-top: 2px; font-size: 13px; color: var(--ink-3); }
.hours-line { text-align: center; font-size: 13px; color: var(--ink-3); margin: 4px 0 22px; line-height: 1.55; }
.hours-line span { display: block; white-space: nowrap; }

/* rooms */
.rooms { display: grid; gap: 10px; }
.room {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--lip);
  background: var(--bg-2); box-shadow: inset 0 1px 0 rgba(255, 240, 220, 0.04);
  transition: background-color 160ms ease;
}
.room:active { background: var(--bg-3); }
.room-name { font-family: var(--display); font-size: 21px; font-weight: 500; line-height: 1.15; }
.room-state { font-size: 14px; color: var(--ink-2); margin-top: 3px; }
.room-state.slowed { color: var(--ember); }
.room-state.full { color: var(--sage); }
.room-state.off { color: var(--ink-3); }
.room-speed { text-align: right; min-width: 92px; }
.speed { font-size: 22px; font-weight: 600; line-height: 1; }
.speed small { font-size: 12px; font-weight: 500; color: var(--ink-3); margin-left: 3px; }
.spark { display: block; width: 92px; height: 22px; margin-top: 6px; }
.spark polyline { fill: none; stroke: var(--ink-2); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark line { stroke: var(--ember-dim); stroke-width: 1; stroke-dasharray: 2 3; }

/* sections */
.block { margin-top: 30px; }
.block-title { font-family: var(--display); font-size: 19px; font-weight: 500; margin: 0 0 10px; }
.line { font-size: 15px; color: var(--ink-2); margin: 0 0 12px; }
.panel { background: var(--bg-2); border: 1px solid var(--lip); border-radius: var(--radius); padding: 14px 16px; }
.panel + .panel { margin-top: 10px; }

/* toggle (track + knob; the real checkbox is hidden but keeps state, focus and keyboard) */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.toggle-row .label { font-size: 16px; }
.toggle-row .sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.toggle { position: relative; width: 52px; height: 32px; flex: none; }
.toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.toggle .track { position: absolute; inset: 0; border-radius: 16px; background: var(--bg-4); transition: background-color 180ms ease; }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: var(--ink-2); transition: transform 200ms cubic-bezier(.3,.7,.4,1), background-color 180ms ease; }
.toggle input:checked + .track { background: var(--ember); }
.toggle input:checked + .track + .knob { transform: translateX(20px); background: var(--bg); }
.toggle input:focus-visible + .track { outline: 2px solid var(--ink-2); outline-offset: 2px; }

/* segmented choices */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--bg); border-radius: 12px; padding: 4px; margin-top: 12px; }
.seg[hidden] { display: none; }
.seg button { border: 0; background: transparent; padding: 10px 4px; border-radius: 9px; color: var(--ink-2); font-size: 14px; font-weight: 500; transition: background-color 140ms ease, color 140ms ease; }
.seg button[aria-pressed="true"] { background: var(--bg-4); color: var(--ink); }
.seg button:active { background: var(--bg-3); }

/* hours */
.hours-grid { display: grid; grid-template-columns: auto 1fr auto 1fr; align-items: center; gap: 10px 8px; }
.hours-grid .who { font-size: 15px; color: var(--ink-2); grid-column: 1 / -1; margin-top: 4px; }
.hours-grid .to { color: var(--ink-3); font-size: 14px; text-align: center; }
select { appearance: none; -webkit-appearance: none; width: 100%; background: var(--bg-3); border: 1px solid var(--lip); border-radius: 10px; padding: 10px 12px; font-size: 16px; }
.hours-grid select { grid-column: span 2; }
.hours-grid .pair { display: contents; }
.act { margin-top: 14px; width: 100%; border: 0; border-radius: 12px; padding: 13px 16px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 16px; transition: background-color 140ms ease; }
.act:active { background: var(--ink-2); }
.act:disabled { background: var(--bg-4); color: var(--ink-3); }

.note { font-size: 13px; color: var(--ink-3); margin-top: 10px; min-height: 1.2em; }
.note.err { color: var(--alert); }
.foot { margin-top: 34px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--ink-3); }
.link { border: 0; background: none; padding: 6px 0; color: var(--ink-2); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

/* sheet */
.scrim { position: fixed; inset: 0; background: rgba(8, 6, 4, 0.6); opacity: 0; pointer-events: none; transition: opacity 200ms ease; }
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 520px;
  background: var(--bg-2); border-top: 1px solid var(--lip); border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 18px);
  transform: translateY(105%); visibility: hidden;
  transition: transform 260ms cubic-bezier(.2,.8,.2,1), visibility 0s linear 260ms;
}
.sheet.open { transform: translateY(0); visibility: visible; transition: transform 260ms cubic-bezier(.2,.8,.2,1), visibility 0s; }
.grip { width: 38px; height: 5px; border-radius: 3px; background: var(--bg-4); margin: 0 auto 12px; }
.sheet h2 { font-family: var(--display); font-weight: 500; font-size: 24px; margin: 0; }
.sheet .now { font-size: 14px; color: var(--ink-2); margin: 4px 0 6px; }
.sheet .group { font-size: 14px; color: var(--ink-3); margin: 16px 0 0; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.choice { border: 1px solid var(--lip); border-radius: 12px; background: var(--bg-3); padding: 13px 10px; font-size: 15px; font-weight: 500; transition: background-color 140ms ease; }
.choice:active { background: var(--bg-4); }
.choices.full .choice { color: var(--sage); }
.choices.slow .choice { color: var(--ember); }
.sheet .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.plain { border: 1px solid var(--lip); border-radius: 12px; background: transparent; padding: 13px 10px; font-size: 15px; color: var(--ink-2); }
.plain:disabled { opacity: 0.4; }

/* auth pages */
.auth { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
.auth .dial-wrap { width: min(220px, 60vw); }
.auth h1 { font-family: var(--display); font-weight: 500; font-size: 34px; text-align: center; margin: 14px 0 6px; }
.auth p { text-align: center; color: var(--ink-2); margin: 0 auto 22px; max-width: 30ch; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
.field input { width: 100%; background: var(--bg-3); border: 1px solid var(--lip); border-radius: 10px; padding: 12px; font-size: 17px; color: var(--ink); }
.field input:focus { outline: 2px solid var(--ink-3); outline-offset: 1px; }
.center { text-align: center; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
