/* sleepsounds — tokens from DESIGN.md. Dark is the default. */
@font-face { font-family: 'Figtree'; src: url(/s/fonts/figtree.woff2) format('woff2'); font-weight: 300 800; font-display: swap; }
@font-face { font-family: 'Fraunces'; src: url(/s/fonts/fraunces.woff2) format('woff2'); font-weight: 300 700; font-display: swap; }

:root {
  --bg: #0d1016; --surface: #151a23; --surface-2: #1d2430; --line: #273041;
  --fg: #dfe3ea; --fg-2: #9aa3b2; --fg-3: #6b7486;
  --accent: #e0a458; --accent-ink: #1a1206; --accent-soft: rgba(224,164,88,.14);
  --danger: #e07a6a;
  --t-s: .8125rem; --t-m: 1rem; --t-l: 1.25rem; --t-xl: 1.75rem;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-tile: 14px; --r-ctl: 8px; --r-sheet: 20px;
  --ease: cubic-bezier(.2,.7,.2,1); --dur: 160ms;
  --bar-h: 72px;
  --sans: 'Figtree', ui-sans-serif, sans-serif;
  --serif: 'Fraunces', Georgia, serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9; --surface: #ffffff; --surface-2: #e9edf3; --line: #d6dce5;
    --fg: #141922; --fg-2: #4c5566; --fg-3: #7d8697;
    --accent: #a8641a; --accent-ink: #ffffff; --accent-soft: rgba(168,100,26,.12);
    --danger: #b3412f;
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 var(--t-m)/1.55 var(--sans);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body:has(.bar) { padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom)); }
a { color: var(--accent); text-underline-offset: 3px; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { width: 24px; height: 24px; flex: none; }

/* Header */
.top { max-width: 960px; margin: 0 auto; padding: calc(var(--s4) + env(safe-area-inset-top)) var(--s4) 0; direction: ltr; }
.wordmark { font: 600 var(--t-l)/1 var(--serif); color: var(--fg); text-decoration: none; letter-spacing: -.01em; display: inline-block; padding: var(--s2) 0; min-height: 44px; }

/* Intro */
.app, .prose, .foot { max-width: 960px; margin: 0 auto; padding: 0 var(--s4); }
.intro h1 { font: 560 var(--t-xl)/1.15 var(--serif); letter-spacing: -.015em; margin: var(--s4) 0 var(--s2); text-wrap: balance; }
.lede { color: var(--fg-2); margin: 0 0 var(--s5); max-width: 36em; text-wrap: pretty; }

/* Mixes: squared chips, one row that scrolls sideways on a phone */
.mixes { display: flex; gap: var(--s2); overflow-x: auto; margin: 0 calc(-1 * var(--s4)) var(--s4); padding: 0 var(--s4) var(--s1); scrollbar-width: none; overscroll-behavior-x: contain; }
.mixes::-webkit-scrollbar { display: none; }
.mix {
  flex: none; min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-ctl);
  background: var(--surface); border: 1px solid var(--line); color: var(--fg-2); font-size: .9375rem; font-weight: 520;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.mix[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); }

/* Grid of tiles */
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.group-h { font: 560 var(--t-m)/1.3 var(--sans); color: var(--fg-2); margin: var(--s5) 0 var(--s3); }
.tile {
  position: relative; background: var(--surface); border-radius: var(--r-tile);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  display: flex; flex-direction: column; min-width: 0;
}
.tile-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2);
  width: 100%; min-height: 84px; padding: var(--s4) var(--s4) var(--s1); border: 0; background: none; text-align: left; border-radius: var(--r-tile);
}
.tile-btn .ic { width: 28px; height: 28px; color: var(--fg-2); transition: color var(--dur) var(--ease); }
.tile .name { font-size: .9375rem; line-height: 1.2; font-weight: 560; overflow-wrap: anywhere; }
.tile .status { font-size: var(--t-s); color: var(--fg-3); min-height: 1.2em; line-height: 1.2; }
.tile[data-state="on"], .tile[data-state="loading"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.tile[data-state="on"] .tile-btn .ic, .tile[data-state="loading"] .tile-btn .ic { color: var(--accent); }
.tile[data-state="error"] .status { color: var(--danger); }
.tile .status:empty { display: none; }

/* Volume slider inside an active tile: 44px hit area, 4px track. Its row is
   reserved on every tile (visibility, not display), so turning a sound on
   never moves the tiles under the thumb. */
.vol { display: block; padding: 0 var(--s4) var(--s2); }
.vol[hidden] { display: block; visibility: hidden; }
.vol input { width: 100%; height: 44px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; --p: 50%; }
.vol input::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--p), var(--line) var(--p)); }
.vol input::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%; background: var(--accent); border: 0; }
.vol input::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
.vol input::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.vol input::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 0; }

.nojs { color: var(--danger); }
.more { margin-top: var(--s6); }
.more h2, .prose h2 { font: 560 var(--t-l)/1.25 var(--serif); margin: var(--s6) 0 var(--s3); }
.links { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.links a { display: inline-block; padding: var(--s2) 0; min-height: 44px; line-height: 28px; }

/* Player bar */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bar-in { max-width: 960px; margin: 0 auto; height: var(--bar-h); padding: 0 var(--s4); display: flex; align-items: center; gap: var(--s3); }
.now { flex: 1; min-width: 0; margin: 0; font-size: .9375rem; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar[data-playing="true"] .now { color: var(--fg); }
.timer-btn {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s3);
  border-radius: var(--r-ctl); border: 1px solid var(--line); background: transparent; color: var(--fg-2);
  font-variant-numeric: tabular-nums; font-size: .9375rem;
}
.timer-btn[data-set="true"] { color: var(--accent); border-color: var(--accent); }
.timer-btn .ic { width: 20px; height: 20px; }
.play {
  width: 52px; height: 52px; border-radius: 50%; border: 0; flex: none;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  transition: opacity var(--dur) var(--ease);
}
.play:disabled { background: var(--surface-2); color: var(--fg-3); cursor: default; }
.play .ic-pause { display: none; }
.bar[data-playing="true"] .play .ic-play { display: none; }
.bar[data-playing="true"] .play .ic-pause { display: block; }

/* Timer sheet */
.sheet {
  margin: auto auto 0; width: 100%; max-width: 560px; padding: 0; border: 0;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0; background: var(--surface); color: var(--fg);
  max-height: 90dvh;
}
.sheet::backdrop { background: rgba(0,0,0,.55); }
.sheet[open] { animation: sheet-in 200ms var(--ease); }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
.sheet-in { padding: var(--s4) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { font: 560 var(--t-l)/1.2 var(--serif); margin: 0; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--fg-2); border-radius: var(--r-ctl); margin-right: calc(-1 * var(--s2)); }
.sheet-note { color: var(--fg-2); font-size: .9375rem; margin: var(--s1) 0 var(--s4); }
.timer-opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); }
.timer-opts button, .no-timer, .custom button, .primary {
  min-height: 48px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface-2); font-weight: 540;
}
.custom { margin-top: var(--s4); }
.custom label { display: block; font-size: .9375rem; color: var(--fg-2); margin-bottom: var(--s2); }
.custom-row { display: flex; gap: var(--s2); }
.custom input, .fb input[type=email], .fb textarea {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 var(--s3); border-radius: var(--r-ctl);
  border: 1px solid var(--line); background: var(--bg); font-size: 16px;
}
.custom button { padding: 0 var(--s5); }
.no-timer { width: 100%; margin-top: var(--s4); background: transparent; color: var(--fg-2); }

/* Prose pages */
.prose { padding-top: var(--s2); max-width: 720px; }
.prose h1 { font: 560 var(--t-xl)/1.15 var(--serif); letter-spacing: -.015em; margin: var(--s4) 0 var(--s3); }
.prose p, .prose li { color: var(--fg); max-width: 38em; }
.prose ul { padding-left: 1.2em; }
.prose li { margin: var(--s2) 0; }
.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--s4)); padding: 0 var(--s4); }
table { border-collapse: collapse; width: 100%; font-size: .9375rem; }
th, td { text-align: left; vertical-align: top; padding: var(--s2) var(--s3) var(--s2) 0; border-bottom: 1px solid var(--line); }
thead th { color: var(--fg-2); font-weight: 540; }
tbody th { font-weight: 560; white-space: nowrap; }
.ext { width: .75em; height: .75em; margin-left: .2em; vertical-align: baseline; }
.err { color: var(--danger); }

/* Feedback form */
.fb { display: flex; flex-direction: column; gap: var(--s2); max-width: 36em; }
.fb fieldset { border: 0; padding: 0; margin: 0 0 var(--s3); }
.fb legend { font-weight: 560; margin-bottom: var(--s2); }
.fb .radio { display: flex; align-items: center; gap: var(--s2); min-height: 44px; }
.fb .radio input { width: 20px; height: 20px; accent-color: var(--accent); }
.fb > label { font-weight: 560; margin-top: var(--s2); }
.fb textarea { padding: var(--s3); min-height: 140px; resize: vertical; }
.fb .hp { position: absolute; left: -9999px; }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; margin-top: var(--s3); align-self: flex-start; padding: 0 var(--s6); }

/* Footer */
.foot { margin-top: var(--s7); padding-top: var(--s4); padding-bottom: var(--s4); border-top: 1px solid var(--line); color: var(--fg-3); font-size: var(--t-s); }
.foot p { margin: 0 0 var(--s2); }
.foot nav { display: flex; gap: var(--s4); flex-wrap: wrap; }
.foot a { color: var(--fg-2); display: inline-block; min-height: 44px; line-height: 44px; }
.prose ~ .foot { margin-bottom: 0; }

@media (hover: hover) {
  .tile-btn:hover .ic { color: var(--fg); }
  .mix:hover { color: var(--fg); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
