:root {
  color-scheme: light dark;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #17181c;
  --muted: #6b7079;
  --line: #d9d7d2;
  --accent: #1f9d55;
  --accent-soft: rgba(31, 157, 85, 0.18);
  --needle: #17181c;
  --focus: #2f6fed;
  --warn: #c07a12;
  --warn-ink: #9a5f0a;
  --danger: #c0442f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #f2f2f0;
    --muted: #8a8f9a;
    --line: #2a2e37;
    --accent: #42c977;
    --accent-soft: rgba(66, 201, 119, 0.2);
    --needle: #f2f2f0;
    --focus: #7aa2ff;
    --warn: #f0b04a;
    --warn-ink: #f0b04a;
    --danger: #ff7a66;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.app {
  position: relative;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px 6px;
}
.brand { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 34px 8px 14px;
  font-size: 15px;
  line-height: 1.2;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  max-width: 220px;
  text-overflow: ellipsis;
}
.select-wide { max-width: none; width: 100%; }

.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 50%;
  padding: 0;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
}

.readout {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  gap: 4px;
}
.gauge { width: 100%; display: flex; justify-content: center; }
.gauge svg { width: min(100%, 420px); height: auto; display: block; overflow: visible; }
.gauge-arc { fill: none; stroke: var(--line); stroke-width: 3; }
.gauge-zone { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: butt; opacity: 0.35; transition: opacity 120ms; }
.gauge-ticks line { stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.gauge-ticks line.major { stroke: var(--text); }
.gauge-labels text { fill: var(--muted); font-size: 15px; font-weight: 500; text-anchor: middle; }
.needle line { stroke: var(--needle); stroke-width: 4; stroke-linecap: round; }
.hub { fill: var(--needle); }

.note {
  display: flex;
  align-items: baseline;
  font-size: clamp(96px, 26vmin, 168px);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.04em;
  margin-top: -18px;
  min-height: 1em;
  transition: color 120ms;
}
.note-acc { font-size: 0.42em; font-weight: 500; align-self: flex-start; margin-left: 0.04em; margin-top: 0.08em; }
.note-oct { font-size: 0.28em; font-weight: 500; color: var(--muted); margin-left: 0.12em; letter-spacing: 0; }

.cents {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-variant-numeric: tabular-nums;
  min-height: 46px;
}
.cents-value { font-size: 38px; font-weight: 500; min-width: 3.2ch; text-align: right; transition: color 120ms; }
.cents-word { font-size: 17px; color: var(--muted); min-width: 6ch; }
.hz { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 20px; }

.app.in-tune .note, .app.in-tune .cents-value { color: var(--accent); }
.app.in-tune .needle line, .app.in-tune .hub { stroke: var(--accent); fill: var(--accent); }
.app.in-tune .gauge-zone { opacity: 1; }
.app.is-idle .note, .app.is-idle .cents-value, .app.is-idle .hz { opacity: 0.35; }
.app.is-idle .needle { opacity: 0.35; }
.app.is-idle .gauge-zone { opacity: 0.35; }

.strings-wrap { padding: 8px 16px 4px; }
.strings {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.string {
  min-width: 48px;
  height: 54px;
  padding: 0 8px;
  border-radius: 27px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-weight: 600;
  font-size: 19px;
  transition: background-color 120ms, border-color 120ms, color 120ms;
}
@media (min-width: 420px) {
  .strings { gap: 8px; }
  .string { min-width: 56px; height: 56px; padding: 0 10px; border-radius: 28px; }
}
.string small { font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 4px; }
.string.is-near { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.string.is-locked { background: var(--text); border-color: var(--text); color: var(--bg); }
.string.is-locked small { color: var(--bg); opacity: 0.75; }
.app.in-tune .string.is-near, .app.in-tune .string.is-locked { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: none; }
.app.in-tune .string.is-near small, .app.in-tune .string.is-locked small { color: #fff; }

.controls { display: flex; justify-content: center; gap: 10px; padding: 12px 0 4px; min-height: 52px; }

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
}
.btn-ghost { background: transparent; }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-big { padding: 14px 24px; font-size: 17px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px 12px;
}
.status { font-size: 14px; color: var(--muted); }
.status.is-live::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  margin-right: 8px;
  vertical-align: 1px;
}

.start {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  z-index: 5;
}
.start-card { max-width: 380px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.start-title { margin: 0; font-size: 34px; font-weight: 600; letter-spacing: -0.02em; }
.start-text { margin: 0; font-size: 17px; line-height: 1.45; }
.start-fine { margin: 6px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.start-error { margin: 0; font-size: 14px; line-height: 1.45; color: var(--danger); }

.settings {
  border: 0;
  border-radius: 20px;
  padding: 0;
  width: min(92vw, 420px);
  max-height: 90dvh;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.settings::backdrop { background: rgba(0, 0, 0, 0.45); }
.settings-form { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 20px; }
.settings-head { display: flex; align-items: center; justify-content: space-between; }
.settings-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-inline-size: 0; }
.field-label { font-size: 14px; font-weight: 600; }
.field-help { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; width: fit-content; }
.stepper-btn { width: 44px; border: 0; background: transparent; font-size: 22px; line-height: 1; }
.stepper-btn:first-child { border-right: 1px solid var(--line); }
.stepper-btn:last-child { border-left: 1px solid var(--line); }
.stepper-input { width: 88px; border: 0; background: transparent; text-align: center; font-size: 18px; font-variant-numeric: tabular-nums; padding: 10px 6px; -moz-appearance: textfield; appearance: textfield; }
.stepper-input::-webkit-outer-spin-button, .stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.segment { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; width: fit-content; }
.segment-item { position: relative; }
.segment-item input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.segment-item span { display: block; padding: 9px 18px; font-size: 15px; }
.segment-item:not(:first-child) span { border-left: 1px solid var(--line); }
.segment-item input:checked + span { background: var(--text); color: var(--bg); }
.segment-item input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -2px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.about p { margin: 0 0 6px; font-size: 13px; line-height: 1.5; }
.muted { color: var(--muted); }

/* Metronome */
.metro {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 20px;
}

.beats { display: flex; align-items: center; gap: 10px; min-height: 16px; }
.beat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line);
  transition: transform 90ms ease-out, background-color 90ms;
}
.beat-dot.is-accent { width: 14px; height: 14px; }
.beat-dot.is-on { background: var(--text); transform: scale(1.3); }
.beat-dot.is-on.is-accent { background: var(--accent); }

.pad {
  width: min(58vw, 216px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 90ms ease-out, border-color 90ms, background-color 90ms;
}
.pad-bpm {
  font-size: clamp(44px, 13vmin, 66px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.pad-unit { font-size: 12px; letter-spacing: 0.14em; color: var(--muted); }
.pad-hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.pad.is-pulse { border-color: var(--text); transform: scale(1.025); }
.pad.is-pulse.is-accent-pulse { border-color: var(--accent); }
.pad:active { transform: scale(0.985); }

.tempo-name { margin: 0; font-size: 15px; color: var(--muted); }

.tempo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 340px;
}
.round-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.slider {
  flex: 1;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  height: 28px;
  background: transparent;
}
.slider::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px; margin-top: -10px;
  border-radius: 50%; background: var(--text); border: 0;
}
.slider::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
.slider::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: var(--text); }

.metro-options {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.metro-options .select { padding-right: 30px; padding-left: 12px; }
.opt { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.opt-label { font-size: 12px; color: var(--muted); }
.toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 15px;
  line-height: 1.2;
}
.toggle[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Voice */
.voice {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 20px 0;
  min-width: 0;
}
.voice > [hidden] { display: none !important; }
/* Phone sized targets inside the Voice view: 44 px everywhere. */
.voice .btn { min-height: 44px; }
.voice .icon-btn { width: 44px; height: 44px; flex: none; }
.voice .select { min-height: 44px; max-width: none; }
.voice .segment-item span { padding: 12px 18px; }
.voice .field-help { font-size: 14px; }
.voice .note { margin-top: 0; }
/* The tuner's idle and in-tune states must not dim the Voice readout. */
.app.is-idle .voice .note, .app.in-tune .voice .note { opacity: 1; color: var(--text); }

.v-home { flex: 1; display: flex; flex-direction: column; }
.v-stack { display: flex; flex-direction: column; gap: 22px; padding-bottom: 16px; }
.v-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.v-title { margin: 0; font-size: 20px; font-weight: 600; }
.v-note { margin: 4px 0 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.v-empty { margin: 0; padding: 10px 0; font-size: 15px; line-height: 1.45; color: var(--muted); }
.v-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.v-tested { margin: 0; font-size: 14px; color: var(--muted); }
.v-need { margin: 0; font-size: 14px; line-height: 1.45; color: var(--danger); }

/* Range card: the saved result, readable at a glance */
.range-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}
.range-eyebrow { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.range-big { margin: 4px 0 0; font-size: 34px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.range-line { margin: 0; font-size: 15px; line-height: 1.45; color: var(--muted); }
.range-line strong { color: var(--text); font-weight: 600; }
.range-estimate { margin: 0; font-size: 14px; line-height: 1.45; color: var(--warn-ink); font-weight: 600; }

/* Range bar: full range light, comfortable zone dark, voice flip tick, optional song span */
.range-bar { display: flex; flex-direction: column; gap: 8px; }
.range-track, .range-songrow { position: relative; height: 14px; border-radius: 999px; background: var(--line); }
.range-songrow { height: 8px; background: none; }
.range-seg { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.range-abs { background: var(--muted); opacity: 0.55; }
.range-comfy { background: var(--text); }
.range-song { background: var(--muted); }
.range-song[data-fit="fits"] { background: var(--accent); }
.range-song[data-fit="stretch"] { background: var(--warn); }
.range-song[data-fit="out"] { background: var(--danger); }
.range-flip { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--warn); }
.range-scale { position: relative; height: 16px; font-size: 12px; color: var(--muted); }
.range-scale span { position: absolute; transform: translateX(-50%); line-height: 1.3; }
.range-scale span:first-child { transform: none; }
.range-scale span:last-child { transform: translateX(-100%); }

/* Fit badge: colour and a word, never colour alone */
.badge {
  --tone: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  border-color: color-mix(in srgb, var(--tone) 45%, transparent);
  background: color-mix(in srgb, var(--tone) 12%, transparent);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tone); flex: none; }
.badge[data-fit="fits"] { --tone: var(--accent); }
.badge[data-fit="stretch"] { --tone: var(--warn); }
.badge[data-fit="out"] { --tone: var(--danger); }
.badge-big { font-size: 16px; padding: 6px 14px; }
.badge-big::before { width: 10px; height: 10px; }

/* Song list: one tappable row per song, rules only between rows */
.song-list { margin: 8px 0 0; padding: 0; list-style: none; }
.song-list > li + li { border-top: 1px solid var(--line); }
.song-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  min-height: 44px;
  padding: 10px 4px;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
}
.song-row-title { font-size: 18px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-row-end { display: flex; align-items: center; gap: 4px; }
.song-row-chev { width: 18px; height: 18px; color: var(--muted); }
.song-row-meta { grid-column: 1 / -1; margin-top: 2px; font-size: 14px; line-height: 1.4; color: var(--muted); }
.song-row-meta strong { color: var(--text); font-weight: 600; }
.song-row-room { color: var(--warn-ink); font-weight: 600; white-space: nowrap; }
.song-row .song-bar { grid-column: 1 / -1; margin: 8px 17px 0; }
@media (hover: hover) {
  .song-row:hover { background: var(--surface); }
}

/* Song bar: the sung range in the row's key; the comfortable zone shaded in the track */
.song-bar { position: relative; display: block; height: 8px; border-radius: 999px; background: var(--line); }
.song-bar span { position: absolute; border-radius: 999px; }
.song-bar-zone { top: 0; bottom: 0; background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.song-bar-song, .song-bar-over { top: 2px; bottom: 2px; }
.song-bar-song { background: var(--text); }
.song-bar-over { background: var(--warn); }
.song-bar-over[data-fit="out"] { background: var(--danger); }

/* Coach: the stepped range test and song check */
.coach { flex: 1; display: flex; flex-direction: column; gap: 18px; min-height: 0; }
.coach-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.coach-count { margin: 0; font-size: 14px; font-weight: 600; color: var(--muted); }
.coach-dots { display: flex; gap: 8px; margin-top: 8px; }
.coach-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.coach-dots span.is-done { background: var(--muted); }
.coach-dots span.is-now { background: var(--text); }
.coach-body { flex: 1; display: flex; flex-direction: column; }
.coach-nav {
  position: sticky;
  bottom: var(--tabs-h, 58px);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 -20px;
  padding: 12px 20px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.coach-nav > :last-child { margin-left: auto; }

.step { flex: 1; display: flex; flex-direction: column; gap: 18px; text-align: center; }
.step-start { text-align: left; }
.step-dense { gap: 14px; }
.step-title { margin: 0; font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.step-title:focus { outline: none; }
.step-lead { margin: 0 auto; max-width: 28em; font-size: 17px; line-height: 1.45; }
.step-start .step-lead { margin-left: 0; }
.step-note { margin: 0; font-size: 15px; line-height: 1.45; color: var(--muted); }
.go { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.step-start .go { justify-content: flex-start; }

.mic { display: flex; flex-direction: column; gap: 14px; }
.mic-ready, .mic-live { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.step-start .mic-ready { align-items: flex-start; }
.kept { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; }
.kept-text { margin: 0; font-size: 19px; line-height: 1.4; }
.kept-text:focus { outline: none; }
.mic-status { margin: 0; display: inline-flex; align-items: center; gap: 10px; font-size: 17px; }

.live { display: flex; align-items: center; justify-content: center; gap: 28px; min-height: 240px; }
.live-compact { min-height: 0; }
.live-wait { margin: 0; font-size: 17px; color: var(--muted); }
.live-sofar { margin: 0; font-size: 17px; }
.live-phase { margin: 0; font-size: 19px; font-weight: 600; }
.voice-note { font-size: clamp(72px, 20vmin, 112px); }
.voice-note[data-quiet] { opacity: 0.35; }
.app.is-idle .voice .voice-note[data-quiet] { opacity: 0.35; }

/* Pitch meter: vertical rail, live mark and the note kept so far */
.pitch-meter { position: relative; flex: none; width: 136px; height: 220px; }
.pitch-rail { position: absolute; top: 0; bottom: 0; left: calc(50% - 2px); width: 4px; border-radius: 2px; background: var(--line); }
.pitch-tick { position: absolute; right: calc(50% + 22px); transform: translateY(50%); font-size: 12px; line-height: 1; color: var(--muted); }
.pitch-live { position: absolute; left: calc(50% - 14px); width: 28px; height: 6px; border-radius: 3px; transform: translateY(50%); background: var(--text); transition: bottom 90ms linear; }
.pitch-kept { position: absolute; left: calc(50% + 20px); transform: translateY(50%); padding: 2px 8px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 13px; font-weight: 600; line-height: 1.3; white-space: nowrap; }

/* Countdown: a ring that empties, seconds in the middle */
.countdown { position: relative; flex: none; width: 150px; aspect-ratio: 1; display: grid; place-content: center; justify-items: center; margin: 0 auto; }
.countdown svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.countdown-track { fill: none; stroke: var(--line); stroke-width: 4; }
.countdown-ring { fill: none; stroke: var(--text); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 0; transition: stroke-dashoffset 200ms linear; }
.countdown-num { position: relative; font-size: 34px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.countdown-unit { position: relative; font-size: 12px; color: var(--muted); }
.countdown-small { width: 112px; margin: 0; }
.countdown-small .countdown-num { font-size: 28px; }

.tips { margin: 0 auto; padding: 0; list-style: none; width: min(100%, 24em); text-align: left; }
.tips li { display: grid; grid-template-columns: 7em minmax(0, 1fr); gap: 12px; padding: 10px 0; font-size: 15px; line-height: 1.4; }
.tips li + li { border-top: 1px solid var(--line); }
.tips strong { font-weight: 600; }
.tips span { color: var(--muted); }

/* Time histogram: one bar per semitone, weighted by time sung */
.hist { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.hist-plot { position: relative; display: flex; align-items: flex-end; gap: 1px; height: 96px; border-bottom: 1px solid var(--line); }
.hist-bar { position: relative; flex: 1; border-radius: 3px 3px 0 0; background: var(--muted); }
.hist-zone { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--accent-soft); }
.hist-scale { position: relative; height: 16px; font-size: 12px; color: var(--muted); }
.hist-scale span { position: absolute; transform: translateX(-50%); line-height: 1.3; }
.hist-caption { margin: 0; font-size: 14px; color: var(--muted); }

/* Note chips: the line, note by note, hit or missed in words */
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 48px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.chip-note { font-size: 17px; font-weight: 600; line-height: 1.2; }
.chip-mark { min-height: 16px; font-size: 12px; line-height: 1.3; color: var(--muted); }
.chip.is-now { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.is-now .chip-mark { color: var(--bg); }
.chip.is-hit { border-color: var(--accent); background: var(--accent-soft); }
.chip.is-miss { border-color: var(--danger); border-style: dashed; }
.chip.is-hit .chip-mark, .chip.is-miss .chip-mark { color: var(--text); font-weight: 600; }

/* Verdict: as written and the key to use on one line, then one reason */
.verdict { display: flex; flex-direction: column; gap: 14px; }
.verdict-line { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; gap: 28px; }
.verdict-cell { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.verdict-eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); }
.verdict-pair { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 40px; }
.verdict-key { font-size: 38px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.verdict-reason { margin: 0; font-size: 17px; line-height: 1.45; }
.facts { margin: 0; display: grid; }
.facts > div { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 12px; padding: 10px 0; font-size: 15px; line-height: 1.4; }
.facts > div + div { border-top: 1px solid var(--line); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.facts dd.is-warn { color: var(--warn-ink); }

/* Spin button: the app's stepper with the value as a WAI-ARIA spinbutton */
.stepper-value {
  min-width: 88px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: default;
}
.stepper-value:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.stepper-btn:disabled { opacity: 0.35; cursor: default; }
.key-try { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.v-sing { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.v-sing .field-help { max-width: 16em; }
.v-manage { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 4px; }
.btn.v-danger { color: var(--danger); }

/* Song form */
.song-form { display: flex; flex-direction: column; gap: 20px; }
.form-pair { display: flex; flex-wrap: wrap; gap: 20px; }
.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 16px;
}
.input[aria-invalid="true"] { border-color: var(--danger); }
.field-error { margin: 0; font-size: 14px; color: var(--danger); }

.feel { align-items: center; }
.step-start .feel { align-items: flex-start; }
.feel .segment { margin: 0 auto; }

/* Mic problem: blocked or nothing heard, and the way out */
.mic-problem {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  border: 1px solid var(--danger);
  border-radius: 20px;
  background: var(--surface);
}
.mic-problem-title { margin: 0; font-size: 20px; font-weight: 600; }
.mic-problem p { margin: 0; max-width: 26em; font-size: 15px; line-height: 1.45; }
.mic-problem .field-help { color: var(--muted); }

/* Choice sheet and confirm dialogs (built on .settings) */
.choices { display: flex; flex-direction: column; gap: 12px; }
.choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  min-height: 44px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
}
.choice.is-last { border-color: var(--text); }
.choice-title { font-size: 17px; font-weight: 600; }
.choice-text { font-size: 14px; line-height: 1.4; color: var(--muted); }
.choice-last { margin-top: 4px; padding: 1px 8px; border-radius: 999px; background: var(--bg); font-size: 12px; font-weight: 600; color: var(--muted); }
.v-dialog .settings-form { gap: 16px; }
.v-dialog-text { margin: 0; font-size: 15px; line-height: 1.45; }
.v-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.v-dialog .btn { min-height: 44px; }
.v-dialog .icon-btn { width: 44px; height: 44px; }

.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: v-spin 0.8s linear infinite;
}
@keyframes v-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-right-color: currentColor; opacity: 0.5; }
}

@media (min-width: 480px) {
  .form-pair > * { flex: 1; }
  .live { gap: 48px; }
}
@media (max-width: 359px) {
  .voice { padding-left: 16px; padding-right: 16px; }
  .coach-nav { margin: 0 -16px; padding: 12px 16px; }
  .verdict-line { gap: 16px; }
}

/* Warm up */
.warm {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 20px 16px;
  min-width: 0;
}
.warm .btn { min-height: 44px; }
/* Same height with or without Reset ticks, so the list never jumps. */
.warm .v-head { min-height: 44px; }
.warm-wait { display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 0; font-size: 15px; color: var(--muted); }
.warm-lock, .warm-home { display: flex; flex-direction: column; gap: 20px; }
.warm-lock { max-width: 380px; }
.warm-lock .btn { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; }
/* Password field with the show password eye inside its right edge */
.warm-pass { position: relative; }
.warm-pass .input { padding-right: 52px; }
.warm-eye {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0 12px 12px 0;
  background: none;
  color: var(--muted);
}
.warm-eye svg { width: 22px; height: 22px; }
.warm-eye[aria-pressed="true"] { color: var(--text); }
.warm-eye[aria-pressed="false"] .warm-eye-hide,
.warm-eye[aria-pressed="true"] .warm-eye-show { display: none; }
.warm-eye:focus-visible { outline-offset: -3px; }

/* Track list: rules only between rows */
.warm-list { margin: 0; padding: 0; list-style: none; }
.warm-list > li + li { border-top: 1px solid var(--line); }
.warm-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px 4px;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
}
.warm-icon {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
}
.warm-icon > * { display: none; }
.warm-icon svg { width: 18px; height: 18px; }
.warm-item:not([data-state="playing"]):not([data-state="loading"]) .warm-play,
.warm-item[data-state="playing"] .warm-pause { display: block; }
.warm-item[data-state="loading"] .warm-icon .spinner { display: inline-block; }
.warm-item[data-state="playing"] .warm-icon,
.warm-item[data-state="paused"] .warm-icon { background: var(--text); border-color: var(--text); color: var(--bg); }
.warm-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.warm-done { display: none; flex: none; width: 26px; height: 26px; color: var(--accent); }
.warm-item[data-done] .warm-done { display: block; }
.warm-done path { stroke: var(--bg); }
.warm-title { font-size: 17px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.warm-meta { font-size: 14px; line-height: 1.4; color: var(--muted); font-variant-numeric: tabular-nums; }
.warm-item[data-state="error"] .warm-meta { color: var(--danger); }
.warm-item[data-unavailable] .warm-title { color: var(--muted); }
.warm-player { padding: 0 4px 12px 62px; }
.warm-scrub { display: block; width: 100%; }
.warm-times { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.warm-score { font-size: 14px; line-height: 1.4; color: var(--text); }

/* Pitch check: live note and a six second line against the nearest notes */
.warm-pitch { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.warm-live { display: flex; align-items: baseline; gap: 10px; margin: 0; min-height: 26px; font-size: 15px; color: var(--muted); }
.warm-note { font-size: 22px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.warm-pitch[data-tune="in"] .warm-words { color: var(--accent); font-weight: 600; }
.warm-pitch[data-tune="off"] .warm-words { color: var(--warn-ink); font-weight: 600; }
.warm-trace { display: block; width: 100%; height: 120px; }
.warm-credit { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
@media (max-width: 359px) {
  .warm { padding-left: 16px; padding-right: 16px; }
  .warm-player { padding-left: 4px; }
}

/* Tabs */
/* Sticky so the tabs stay in reach when a view is taller than the screen. The
   safe area padding lives here rather than on .app so it moves with them. */
.tabs {
  display: flex;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  z-index: 6;
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
.tab[aria-selected="true"] { color: var(--text); }
.tab:focus-visible { outline-offset: -3px; }

@media (max-height: 700px) {
  .metro { gap: 12px; }
  .pad { width: min(48vw, 176px); }
  .pad-hint { margin-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media (max-height: 640px) {
  .note { font-size: clamp(72px, 20vmin, 120px); }
  .gauge svg { width: min(100%, 320px); }
}
