/* sing — tokens + base styles. docs/DESIGN.md is the authoritative visual spec. */

:root {
  --bg: #0F1115;        /* page background, near-black blue */
  --surface: #171A21;   /* cards */
  --surface-2: #1E2230; /* raised elements, chips */
  --line: #2A2F3D;      /* hairline borders */
  --text: #E8EAF0;
  --text-dim: #9AA1B5;
  --text-faint: #6B7288;
  --amber: #F5B84C;     /* THE accent: target notes, structure, metronome, brand */
  --mint: #5EE0A0;      /* your voice when on-pitch / good */
  --coral: #FF8A7A;     /* flat / late */
  --peri: #8FA8FF;      /* sharp / early */
  --danger: #FF6B6B;
  --ok: var(--mint);
  --radius-card: 12px;
  --radius-chip: 8px;
  --radius-pill: 999px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body:has(.practice) { overflow: hidden; }

:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; }

.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.amber { color: var(--amber); }

.label {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.screen { max-width: 720px; margin: 0 auto; padding: 16px; }

/* ---- buttons, chips, cards ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-chip);
  font-weight: 600;
  text-decoration: none;
  transition: filter .15s ease, background-color .15s ease;
}
.btn:active { filter: brightness(.88); }
.btn.primary { background: var(--amber); color: #0F1115; }
.btn.outline { border: 1px solid var(--amber); color: var(--amber); background: transparent; }
.btn.text { color: var(--text-dim); padding: 10px 8px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.on { color: var(--amber); }

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}
.chip.selectable { min-height: 44px; padding: 8px 14px; color: var(--text); }
.chip.selectable.selected {
  background: var(--amber);
  border-color: var(--amber);
  color: #0F1115;
  font-weight: 600;
}
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* ---- song list (DESIGN §1) ---- */

.songs-head { padding: 24px 0 16px; }
.wordmark { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -.01em; }
.tagline { margin: 4px 0 14px; color: var(--text-dim); }
.mic-chip {
  background: transparent;
  border: 1px solid var(--amber);
  border-radius: var(--radius-pill);
  color: var(--amber);
  font-size: 12px;
}

.song-list { display: flex; flex-direction: column; gap: 12px; }
.song-card {
  display: flex;
  gap: 14px;
  align-items: center;
  text-decoration: none;
  transition: background-color .15s ease;
}
.song-card:active { background: var(--surface-2); }

.glyph {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
}
.glyph svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: var(--amber);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.song-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.song-title { font-size: 17px; font-weight: 600; }
.song-origin { font-size: 13px; color: var(--text-dim); }
.meta-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }

.dots { display: inline-flex; gap: 3px; align-items: center; margin-left: 2px; }
.dot { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--text-faint); }
.dot.on { background: var(--amber); border-color: var(--amber); }

.songs-foot { padding: 24px 0 40px; font-size: 12px; color: var(--text-faint); }

/* ---- setup sheet (DESIGN §2) ---- */

.setup { padding-bottom: 96px; }
.back { margin-left: -12px; }
.setup-head { margin: 4px 0 16px; }
.setup-title { margin: 0; font-size: 22px; font-weight: 600; }
.origin { margin: 2px 0 0; font-size: 13px; color: var(--text-dim); }
.setup .card { margin-bottom: 12px; }

.readout { margin: 12px 0 0; font-size: 15px; }
.readout.big { font-size: 28px; font-weight: 600; }
.hint { margin: 8px 0 0; font-size: 13px; color: var(--text-dim); }
.latency { margin: 12px 0 0; font-size: 13px; color: var(--text-dim); }
.setup [data-mic] { margin-top: 2px; }

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  margin: 4px 0 0;
  background: transparent;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--line);
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--amber);
  border: none;
  box-shadow: var(--shadow);
}
input[type='range']::-moz-range-track {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--line);
}
input[type='range']::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: var(--amber);
}

.sticky-cta {
  position: sticky;
  bottom: 0;
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 65%, transparent);
}
.sticky-cta .btn.primary { width: 100%; height: 52px; font-size: 17px; }

/* ---- practice (DESIGN §3) ---- */

.practice {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px calc(8px + env(safe-area-inset-bottom));
  overflow: hidden;
}

.practice-top { display: flex; align-items: center; gap: 8px; height: 48px; flex: none; }
.practice-title {
  flex: 1;
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.beat-dots { display: flex; justify-content: center; gap: 14px; align-items: center; height: 20px; flex: none; }
.beat-dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform .15s ease, background-color .15s ease;
}
.beat-dots i.on { transform: scale(1.5); background: var(--amber); }

.lane-wrap { position: relative; flex: 1; min-height: 0; margin: 6px 0; }
.lane-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.cents-meter { display: flex; align-items: center; gap: 12px; height: 64px; flex: none; }
.cents-scale {
  position: relative;
  flex: 1;
  height: 36px;
  border-radius: var(--radius-chip);
  background:
    linear-gradient(to right, rgba(255, 138, 122, .16), rgba(255, 138, 122, 0) 50%),
    linear-gradient(to left, rgba(143, 168, 255, .16), rgba(143, 168, 255, 0) 50%);
}
.cents-scale .tick { position: absolute; top: 30%; bottom: 30%; width: 1px; background: var(--line); }
.cents-scale .t50 { left: 25%; }
.cents-scale .p50 { left: 75%; }
.cents-scale .t0 { left: 50%; top: 0; bottom: 0; width: 2px; background: var(--amber); }
.cents-scale .needle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--mint);
  transition: opacity .2s ease;
}
.cents-scale .needle::after {
  content: '';
  position: absolute;
  top: 0;
  left: -4px;
  border: 5px solid transparent;
  border-top-color: var(--mint);
  border-bottom: none;
}
.cents-readout { width: 76px; text-align: right; font-size: 22px; color: var(--text-dim); }

.practice-bottom { display: flex; align-items: center; gap: 12px; height: 64px; flex: none; }
.elapsed { width: 48px; font-size: 14px; color: var(--text-dim); }
.syl-pill {
  flex: 1;
  min-height: 32px;
  padding: 6px 0;
  text-align: center;
  font-size: 16px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
}
.mic-bars {
  display: inline-flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 2px;
  width: 80px;
  height: 24px;
}
.mic-bars i { width: 4px; height: 30%; background: var(--mint); border-radius: 2px; opacity: .8; }

/* ---- scrims (count-in / take end) ---- */

.scrim {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 17, 21, .92);
  transition: opacity .2s ease;
}
.scrim.fade { opacity: 0; pointer-events: none; }
.scrim-title { position: absolute; top: 22%; margin: 0; font-size: 16px; color: var(--text-dim); }
.count-num { font-size: 128px; font-weight: 700; line-height: 1; color: var(--amber); }
.scrim-label {
  margin: 12px 0 0;
  font-size: 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.scrim.analyzing p {
  margin: 0;
  font-size: 18px;
  background: linear-gradient(90deg, var(--text-dim) 25%, var(--text) 50%, var(--text-dim) 75%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ---- results placeholder ---- */

.results-placeholder { padding-top: 48px; }
.placeholder-card { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.placeholder-msg { margin: 0; color: var(--text-dim); }

/* ---- motion ---- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
