/* Say the Note — styles. Tokens and components follow DESIGN.md (NumberPace visual language). */
@font-face {
  font-family: "Noto Music";
  src: url("fonts/NotoMusic-music.woff2") format("woff2");
  font-display: block;
}

:root {
  --paper: #F6FAF7;
  --card: #FFFFFF;
  --ink: #1B2A40;
  --ink-2: #36465E;
  --ink-3: #67738E;
  --ink-4: #A6AEC0;
  --outline: #DDE6DE;
  --outline-strong: #B7C5BA;
  --green: #3FC65A;
  --green-press: #2EAB4F;
  --green-text: #1F8A45;
  --green-deep: #0F5A2A;
  --green-soft: #D5F4DE;
  --green-mid: #A3E6B5;
  --sky: #29B6E8;
  --sky-text: #1391C2;
  --sky-deep: #08628A;
  --sky-soft: #D4EFFA;
  --sun: #FFC93C;
  --sun-soft: #FFF1C9;
  --sun-text: #7A5800;
  --red: #E55A5A;
  --red-text: #B8302B;
  --red-soft: #FCE3E3;

  --shadow-card: 0 1px 0 0 rgba(27, 42, 64, .04), 0 6px 16px -6px rgba(27, 42, 64, .10);
  --press-green: 0 4px 0 0 var(--green-press);
  --press-ghost: 0 4px 0 0 var(--outline-strong);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --fast: 160ms;
  --med: 240ms;

  --font-display: Fredoka, Nunito, system-ui, sans-serif;
  --font-ui: Nunito, system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-ui); -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--green-text); outline-offset: 4px; border-radius: 4px; }
[hidden] { display: none !important; }

.ms {
  font-family: 'Material Symbols Rounded'; font-weight: 400; font-style: normal; font-size: 24px; line-height: 1;
  letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; direction: ltr;
  font-feature-settings: 'liga'; -webkit-font-smoothing: antialiased; user-select: none;
}
.ms.filled { font-variation-settings: 'FILL' 1; }

.app { max-width: 480px; margin: 0 auto; padding: 20px 20px calc(28px + env(safe-area-inset-bottom)); }
.view { display: flex; flex-direction: column; }
.practice { min-height: calc(100dvh - 48px); gap: 20px; }
.settings { gap: 32px; padding-bottom: 20px; }

/* ---------- App bar ---------- */
.appbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.appbar h1 { margin: 0; font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }

/* ---------- Buttons ---------- */
.icon-btn {
  width: 48px; height: 48px; border-radius: 9999px; background: var(--card); border: 2px solid var(--outline-strong);
  box-shadow: var(--press-ghost); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 56px; padding: 0 28px;
  border: 0; border-radius: 9999px; background: var(--green); color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: var(--press-green); cursor: pointer; transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast);
}
.btn-primary:hover { background: #5CCE73; }
.btn-primary:disabled { opacity: .38; box-shadow: none; cursor: not-allowed; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px; height: 52px; padding: 0 24px; border-radius: 9999px;
  background: transparent; border: 2px solid var(--outline-strong); box-shadow: var(--press-ghost);
  font-weight: 800; font-size: 15px; cursor: pointer; transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.btn-ghost.danger { color: var(--red-text); }
.btn-tonal {
  height: 48px; padding: 0 22px; border-radius: 9999px; border: 0; background: var(--green-soft); color: var(--green-deep);
  font-weight: 800; font-size: 15px; cursor: pointer;
}
.icon-btn:active, .btn-primary:active:not(:disabled), .btn-ghost:active { transform: translateY(4px); box-shadow: none; }

/* ---------- Run progress ---------- */
.progress { display: flex; flex-direction: column; gap: 8px; }
.progress-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.run-label { font-size: 13px; font-weight: 800; }
.summary-link { background: none; border: 0; padding: 6px 0; font-size: 13px; font-weight: 700; color: var(--ink-2); cursor: pointer; text-align: right; min-height: 32px; }
.summary-link:hover { color: var(--green-text); }
.dots { display: grid; gap: 6px; }
.dots span { height: 10px; border-radius: 9999px; background: var(--outline); transition: background var(--med) var(--ease); }
.dots span.done { background: var(--green); }
.dots span.now { background: var(--green-mid); }

/* ---------- Staff card ---------- */
.staff-card {
  background: var(--card); border-radius: 28px; box-shadow: var(--shadow-card); padding: 16px 10px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.staff-card.nudge { animation: nudge 200ms var(--ease); }
@keyframes nudge { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
#staff, #rangePreview { width: 100%; height: auto; display: block; }
svg .staff-line, svg .ledger, svg .barline { stroke: var(--ink); stroke-width: 1.3; }
svg .brace { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
svg .clef { fill: var(--ink); font-family: "Noto Music", "Apple Symbols", "Segoe UI Symbol", serif; }
svg .head { fill: var(--ink); }
svg .stem { stroke: var(--ink); stroke-width: 1.6; }
svg .done .head { fill: var(--green-text); }
svg .done .stem { stroke: var(--green-text); }
svg .now .head { fill: var(--sky-text); }
svg .now .stem { stroke: var(--sky-text); }
svg .now-column { fill: var(--sky-soft); opacity: .6; }
svg .guide-ledger { stroke: var(--ink-4); stroke-width: 1.2; }
svg .guide-head { fill: var(--card); stroke: var(--ink-3); stroke-width: 1.4; }
svg .guide-label { fill: var(--ink-3); font: 800 10px var(--font-ui); text-anchor: end; }
svg .guide-divider { stroke: var(--outline); stroke-width: 1.2; stroke-dasharray: 3 4; }
svg .range-band { fill: var(--sky-soft); opacity: .7; }
svg .range-head { fill: var(--card); stroke: var(--sky-text); stroke-width: 2.6; }
svg .range-label { fill: var(--sky-deep); font: 800 13px var(--font-ui); }

.chips { display: grid; gap: 8px; padding: 0 6px; }
.chip {
  height: 44px; border-radius: 12px; border: 2px solid var(--outline); background: var(--card);
  display: flex; align-items: center; justify-content: center; transition: background var(--med) var(--ease), border-color var(--med) var(--ease);
}
.chip.done { background: var(--green-soft); border-color: var(--green); color: var(--green-deep); }
.chip.now { background: var(--sky-soft); border-color: var(--sky); color: var(--sky-deep); }
.chip.retry { background: var(--red-soft); border-color: var(--red); color: var(--red-text); }
.chip.pop { animation: pop var(--med) var(--ease); }
@keyframes pop { 50% { transform: scale(1.08); } }

.session-done { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px 12px 16px; text-align: center; }
.session-done h2 { margin: 0; font-family: var(--font-display); font-size: 28px; font-weight: 600; }
.session-done p { margin: 0 0 8px; color: var(--ink-2); font-weight: 600; }

/* ---------- Feedback toast ---------- */
.toast { border-radius: 20px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; min-height: 64px; visibility: hidden; }
.toast.ok, .toast.retry { visibility: visible; }
.toast.ok { background: var(--green-soft); }
.toast.retry { background: var(--red-soft); }
.toast .ms { font-size: 28px; }
.toast.ok .ms { color: var(--green-text); font-variation-settings: 'FILL' 1; }
.toast.retry .ms { color: var(--red-text); }
.toast-text { display: flex; flex-direction: column; gap: 2px; }
.toast-text strong { font-size: 17px; font-weight: 800; }
.toast.ok strong { color: var(--green-deep); }
.toast.retry strong { color: var(--red-text); }
.toast-text span { font-size: 13px; font-weight: 600; color: var(--ink-2); }

/* ---------- Mic ---------- */
.mic-area { margin-top: auto; display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.support { margin: 0; text-align: center; color: var(--red-text); font-size: 14px; font-weight: 600; }

/* Status line above the button (DESIGN.md §7 Mic button + status line) */
.mic-status { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 24px; font-size: 14px; font-weight: 700; color: var(--ink-2); }
.mic-status .dot { width: 10px; height: 10px; border-radius: 9999px; background: var(--ink-4); flex-shrink: 0; }
.mic-status.wait { color: var(--sky-deep); } .mic-status.wait .dot { background: var(--sky); }
.mic-status.live { color: var(--green-deep); } .mic-status.live .dot { background: var(--green); animation: live-ring 1.4s ease-out infinite; }
.mic-status.sun { color: var(--sun-text); } .mic-status.sun .dot { background: var(--sun); }
.mic-status.blocked { color: var(--red-text); } .mic-status.blocked .dot { background: var(--red); }
@keyframes live-ring { 0% { box-shadow: 0 0 0 0 rgba(63, 198, 90, .55); } 100% { box-shadow: 0 0 0 10px rgba(63, 198, 90, 0); } }

.mic-btn {
  width: 100%; height: 64px; border-radius: 9999px; border: 2px solid transparent; padding: 0 20px;
  display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 17px; font-weight: 800; cursor: pointer;
  transition: background var(--med) var(--ease), color var(--med) var(--ease), border-color var(--med) var(--ease), box-shadow var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.mic-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.mic-btn:disabled { opacity: .38; box-shadow: none; cursor: not-allowed; }
.mic-badge { width: 40px; height: 40px; border-radius: 9999px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mic-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.mic-text small { font-size: 12px; font-weight: 700; opacity: .85; }
.mic-bars { display: none; align-items: center; gap: 3px; height: 22px; margin-left: auto; margin-right: 10px; }
.mic-bars i { width: 4px; height: 6px; border-radius: 2px; background: rgba(255, 255, 255, .8); animation: bars-idle 1.6s ease-in-out infinite; }
.mic-bars i:nth-child(2) { animation-delay: .2s; } .mic-bars i:nth-child(3) { animation-delay: .4s; }
.mic-bars i:nth-child(4) { animation-delay: .6s; } .mic-bars i:nth-child(5) { animation-delay: .8s; }
@keyframes bars-idle { 50% { height: 10px; } }
@keyframes bars-talk { 0%, 100% { height: 6px; } 50% { height: 22px; } }
@keyframes spin { to { transform: rotate(360deg); } }

.mic-btn.off { background: var(--card); color: var(--ink); border-color: var(--outline-strong); box-shadow: var(--press-ghost); }
.mic-btn.off .mic-badge { background: var(--green); color: #fff; }
.mic-btn.starting, .mic-btn.reconnect { box-shadow: 0 4px 0 0 var(--sky); background: var(--sky-soft); color: var(--sky-deep); border-color: var(--sky); }
.mic-btn.reconnect { box-shadow: 0 4px 0 0 var(--sun); background: var(--sun-soft); color: var(--sun-text); border-color: var(--sun); }
.mic-btn.starting .mic-badge, .mic-btn.reconnect .mic-badge { width: 30px; height: 30px; margin: 0 5px; border: 3px solid var(--sky); border-top-color: transparent; animation: spin .8s linear infinite; }
.mic-btn.reconnect .mic-badge { border-color: var(--sun); border-top-color: transparent; }
.mic-btn.starting .mic-badge .ms, .mic-btn.reconnect .mic-badge .ms { display: none; }
.mic-btn.on, .mic-btn.hearing { justify-content: flex-start; padding-left: 12px; background: var(--green-text); color: #fff; box-shadow: 0 4px 0 0 var(--green-deep), 0 0 0 6px var(--green-soft); }
.mic-btn.hearing { box-shadow: 0 4px 0 0 var(--green-deep), 0 0 0 6px var(--green-mid); }
.mic-btn.on .mic-badge, .mic-btn.hearing .mic-badge { background: #fff; color: var(--green-text); }
.mic-btn.on .mic-bars, .mic-btn.hearing .mic-bars { display: flex; }
.mic-btn.hearing .mic-bars i { background: #fff; animation: bars-talk .45s ease-in-out infinite; }
.mic-btn.blocked { background: var(--card); color: var(--red-text); border-color: var(--red); box-shadow: 0 4px 0 0 var(--red); }
.mic-btn.blocked .mic-badge { background: var(--red-soft); color: var(--red-text); }
.mic-btn:focus-visible { outline-offset: 6px; }
.staff-card.live { box-shadow: var(--shadow-card), 0 0 0 3px var(--green-mid); }

/* ---------- Settings ---------- */
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.group { display: flex; flex-direction: column; gap: 12px; }
.subgroup { display: flex; flex-direction: column; gap: 6px; }
.section-label { margin: 0 0 10px; padding: 0; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
h2.section-label { margin: 0; }
.field-label { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 800; }
.help { margin: 0; font-size: 13px; font-weight: 500; color: var(--ink-2); text-align: justify; }
.help.error { color: var(--red-text); font-weight: 700; }

.pills { display: grid; gap: 8px; }
.pills-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pills-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pills-wrap { display: flex; flex-wrap: wrap; }
.pill {
  height: 52px; border-radius: 9999px; background: var(--card); border: 2px solid var(--outline);
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 16px;
  font-weight: 700; font-size: 15px; cursor: pointer; transition: background var(--fast), border-color var(--fast);
}
.pill-sm { height: 44px; font-size: 14px; }
.pill input { accent-color: var(--green-text); margin: 0; }
.pill:has(input:checked) { background: var(--green-soft); border-color: var(--green); font-weight: 800; }
.pill:has(input:focus-visible) { outline: 3px solid var(--green-text); outline-offset: 2px; }

.card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow-card); }
.preview-card { padding: 10px 8px 6px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 800; }
.field select {
  height: 56px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--outline); background: var(--card);
  font-size: 16px; font-weight: 700; color: var(--ink);
}
.field select[aria-invalid="true"] { border-color: var(--red); }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding: 12px 18px;
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow-card); cursor: pointer;
}
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-title { font-size: 16px; font-weight: 700; }
.switch-help { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.switch-row input { width: 24px; height: 24px; flex-shrink: 0; accent-color: var(--green-text); margin: 0; }

.streak-card { border-radius: 20px; background: var(--sun-soft); padding: 16px 20px; display: flex; align-items: center; gap: 14px; }
.streak-star { width: 48px; height: 48px; border-radius: 9999px; background: var(--sun); display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 900; }
.streak-card > div:last-child { display: flex; flex-direction: column; }
.streak-num { font-family: var(--font-display); font-size: 34px; font-weight: 700; color: var(--sun-text); line-height: 1; font-variant-numeric: tabular-nums; }
.streak-label { font-size: 13px; font-weight: 800; color: var(--sun-text); }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; }
.stat-num { display: block; font-family: var(--font-display); font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat small { color: var(--ink-2); font-size: 13px; font-weight: 700; }
.confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-weight: 800; }

@media (prefers-reduced-motion: reduce) {
  .staff-card.nudge, .chip.pop, .mic-status .dot, .mic-bars i { animation: none; }
  .mic-btn .mic-badge { animation: none !important; }
  * { transition-duration: 0ms !important; }
}
