:root {
  --ground: #0E1623;
  --surface: #141E2D;
  --surface-2: #182334;
  --border: #26324A;
  --border-soft: #1E2A3D;
  --text: #F2F5FA;
  --text-2: #9AAAC2;
  --text-3: #7F90AA;
  --amber: #F5B544;
  --cyan: #5EC8E5;
  --slate: #2E3C54;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'Space Grotesk', system-ui, sans-serif; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.spacer { flex: 1; }

/* ── views ─────────────────────────────────────────────────────────── */
.view { min-height: 100vh; }
.view[hidden] { display: none; }

.view-centred {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
}

h1 {
  margin: 0 0 8px;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

h2 {
  margin: 0 0 18px;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

h3 {
  margin: 26px 0 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.lede {
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-2);
}

/* ── form ──────────────────────────────────────────────────────────── */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--ground);
  border: 1px solid var(--border);
  border-radius: 13px;
}

.seg {
  flex: 1;
  height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
}

.seg:hover { color: var(--text); }

.seg.is-active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

input[type="text"] {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 16px;
  letter-spacing: 0.01em;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--amber);
}

.hint {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
}

.hint-muted { color: var(--text-3); }

.hint code {
  font-family: 'Space Grotesk', ui-monospace, monospace;
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--ground);
  color: #C8D3E4;
}

.hint.is-error { color: #F0C9A8; }

/* ── saved sequences ───────────────────────────────────────────────── */
.save-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.save-row[hidden] { display: none; }

.save-row input[type="text"] {
  flex: 1;
  height: 44px;
  font-family: Inter, system-ui, sans-serif;
  font-size: 14px;
}

.save-row .secondary { flex: 0 0 auto; }

.saved-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.saved-list:empty { display: none; }

.saved {
  display: flex;
  align-items: stretch;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.saved-load,
.saved-delete {
  border: 0;
  background: transparent;
  color: #C8D3E4;
  font-family: inherit;
}

.saved-load {
  min-height: 40px;
  padding: 0 11px;
  font-size: 13px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-load:hover { color: var(--amber); }

.saved-delete {
  width: 32px;
  color: var(--text-3);
  font-size: 17px;
  line-height: 1;
  border-left: 1px solid var(--border);
}

.saved-delete:hover { color: #F0A882; background: #2A1E16; }

.rule {
  height: 1px;
  border: 0;
  background: var(--border-soft);
  margin: 22px 0;
}

.retry-options {
  margin-top: 4px;
  margin-bottom: 20px;
  padding: 14px;
  border-radius: 12px;
  background: var(--ground);
  border: 1px solid var(--border-soft);
}

.retry-options[hidden] { display: none; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 7px; }

.field label {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

select {
  height: 44px;
  padding: 0 12px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

.field-tempo { margin-top: 18px; }

input[type="range"] {
  width: 100%;
  height: 44px;
  accent-color: var(--amber);
  background: transparent;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 22px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  min-height: 44px;
}

.checkbox input {
  width: 20px;
  height: 20px;
  accent-color: var(--amber);
}

button {
  font-family: inherit;
  cursor: pointer;
}

.primary {
  width: 100%;
  height: 56px;
  border: 0;
  border-radius: 14px;
  background: var(--amber);
  color: var(--ground);
  font-size: 16px;
  font-weight: 600;
}

.primary:hover { background: #FFC45C; }

.secondary {
  height: 44px;
  padding: 0 20px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid #2A3850;
  color: #E4EAF4;
  font-size: 14px;
  font-weight: 500;
}

.secondary:hover { border-color: #3C4C6B; }

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
}

.icon-button:hover { color: var(--text); background: var(--surface-2); }

.error {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 11px;
  background: #2A1E16;
  border: 1px solid #5C3A22;
  color: #F0C9A8;
  font-size: 13px;
  line-height: 1.5;
}

.footnote {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

/* ── practice ──────────────────────────────────────────────────────── */
.view-practice {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
}

.bar-top {
  height: 56px;
  border-bottom: 1px solid var(--border-soft);
}

.bar-bottom {
  height: 96px;
  border-top: 1px solid var(--border-soft);
}

.bar-top strong { font-size: 15px; font-weight: 500; }
.bar-top .muted { font-size: 14px; }

.level {
  width: 54px;
  height: 6px;
  border-radius: 3px;
  background: var(--border-soft);
  overflow: hidden;
}

.level-fill {
  width: 0;
  height: 100%;
  background: var(--amber);
  transition: width 60ms linear;
}

/* ── retry drill banner ────────────────────────────────────────────── */
.drill {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 18px;
  background: #16222F;
  border-bottom: 1px solid #2F5468;
}

.drill[hidden] { display: none; }

/* The moment the drill is cleared. */
.drill.is-done {
  background: #221C10;
  border-bottom-color: #5C4A22;
}

.drill-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan);
}

.drill.is-done .drill-tag { color: var(--amber); }
.drill.is-done .pip.is-filled { background: var(--amber); }

.drill-note {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 17px;
  font-weight: 700;
}

.pips { display: flex; gap: 5px; }

.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px #3A4A66;
}

.pip.is-filled {
  background: var(--cyan);
  box-shadow: none;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 18px 24px;
}

#ribbon {
  display: block;
  width: 100%;
  height: 100%;
}

.arm-hint {
  position: absolute;
  inset: auto 0 50%;
  margin: 0;
  text-align: center;
  font-size: 15px;
  color: var(--text-2);
  pointer-events: none;
}

.arm-hint[hidden] { display: none; }

.now-playing {
  display: flex;
  align-items: center;
  gap: 14px;
}

.target-note {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  min-width: 74px;   /* holds "F♯4" without shifting the row */
}

.cents {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 3px;
}

.cents.good { color: var(--amber); }
.cents.off { color: var(--cyan); }
.cents.idle { color: var(--text-3); }

.divider {
  width: 1px;
  height: 44px;
  background: var(--border-soft);
}

/* ── results ───────────────────────────────────────────────────────── */
.score {
  display: flex;
  align-items: baseline;
  gap: 11px;
  margin-bottom: 6px;
}

.score-good {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.score-total {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--text-3);
}

.score + .small { margin: 0; }

.recovered {
  margin: 12px 0 0;
  padding: 10px 13px;
  border-radius: 10px;
  background: #16222F;
  border: 1px solid #2F5468;
  font-size: 13px;
  line-height: 1.45;
  color: #CFE6F0;
}

.recovered[hidden] { display: none; }

.problem-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.problem {
  display: flex;
  gap: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.problem-chip {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--slate);
  border: 1px solid #475C7C;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 16px;
  font-weight: 700;
  line-height: 38px;
  text-align: center;
}

.problem-body { flex: 1; min-width: 0; }

.problem-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 9px;
}

.problem-head .muted { font-size: 12px; font-weight: 400; }

.deviation {
  position: relative;
  height: 18px;
}

.deviation::before {
  content: '';
  position: absolute;
  inset: 6px 0 auto;
  height: 5px;
  border-radius: 3px;
  background: var(--border-soft);
}

.deviation::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 2px;
  width: 2px;
  height: 13px;
  margin-left: -1px;
  background: #3A4A66;
}

.deviation-marker {
  position: absolute;
  top: 0;
  width: 4px;
  height: 18px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--cyan);
}

.problem-hint {
  margin: 9px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-2);
}

.results .primary { margin-top: 24px; }

/* ── narrow screens ────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .bar-top .muted { display: none; }
  .bar-bottom { height: 88px; }
  .target-note { font-size: 28px; min-width: 62px; }
  .stage { padding: 12px 14px; }
}
