/* VoxTuner design system
   Ink #111111 · Paper #F8F8F6 · Tuning green #0A7D55 · Key yellow #F2C230 · Signal red #C8352B
   UI: Bricolage Grotesque · Long-form: Source Serif 4 */
:root {
  --bg: #F8F8F6;
  --surface: #FFFFFF;
  --surface-2: #EEEEEA;
  --text: #111111;
  --muted: #5C5C57;
  --border: #D6D6D0;
  --accent: #0A7D55;
  --accent-ink: #FFFFFF;
  --good: #0A7D55;
  --warn: #A86400;
  --bad: #C8352B;
  --mark: #F2C230;
  --btn-bg: #111111;
  --btn-ink: #FFFFFF;
  --key-white: #FFFFFF;
  --key-black: #161616;
  --radius: 6px;
  --ui: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --read: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131313;
    --surface: #1B1B1B;
    --surface-2: #262626;
    --text: #F1F1EC;
    --muted: #A6A6A0;
    --border: #34342F;
    --accent: #3CC48E;
    --accent-ink: #0B0B0B;
    --good: #3CC48E;
    --warn: #E5A23C;
    --bad: #F0675A;
    --btn-bg: #F1F1EC;
    --btn-ink: #111111;
    --key-white: #E9E9E4;
    --key-black: #0A0A0A;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.6 var(--ui); font-optical-sizing: auto; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
img, svg, canvas { max-width: 100%; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header / footer ---------- */
.site-header { border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 8px 24px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: -.02em; color: var(--text); text-decoration: none; }
.logo svg { width: 26px; height: 26px; }
.nav { display: flex; gap: 2px 18px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; font-size: 15px; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.site-footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 32px 0; font-size: 15px; color: var(--muted); }
.site-footer .wrap { display: flex; gap: 24px 56px; flex-wrap: wrap; align-items: flex-start; }
.footer-tools { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
.footer-tools b { color: var(--text); font-weight: 700; margin-bottom: 4px; }
.footer-tools a { color: var(--muted); text-decoration: none; }
.footer-tools a:hover { color: var(--text); text-decoration: underline; }
.footer-copy { margin-top: 24px; display: block !important; font-size: 14px; }

/* ---------- page intro ---------- */
.crumbs { font-size: 14px; color: var(--muted); margin: 22px 0 0; }
.crumbs a { color: var(--muted); }
h1 { font-size: clamp(32px, 5.4vw, 52px); line-height: 1.04; font-weight: 800; letter-spacing: -.035em; margin: 18px 0 12px; max-width: 18ch; }
.lede { color: var(--muted); font-size: 19px; margin: 0 0 28px; max-width: 62ch; }

/* ---------- tool panel ---------- */
.tool { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
@media (max-width: 600px) { .tool { padding: 18px 14px; } }
.tool-top { display: grid; grid-template-columns: 1.15fr 1fr; gap: 32px; align-items: start; }
@media (max-width: 760px) { .tool-top { grid-template-columns: 1fr; gap: 20px; } }

/* The signature element: the note, set huge. */
.readout { min-height: 260px; display: flex; flex-direction: column; justify-content: flex-start; }
.readout .label { font-size: 15px; color: var(--muted); }
.note { font-size: clamp(104px, 21vw, 200px); font-weight: 800; line-height: .86; letter-spacing: -.06em; font-variant-numeric: tabular-nums; margin: 6px 0 4px; }
.note sub { font-size: .3em; font-weight: 600; letter-spacing: 0; color: var(--muted); vertical-align: baseline; margin-left: 4px; }
.freq { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cents-text { font-size: 15px; color: var(--muted); min-height: 1.5em; margin-top: 4px; }
.readout.in-tune .note { color: var(--good); }
.readout.off .note { color: var(--warn); }
.readout.idle .note { color: var(--border); }
.note { min-height: .86em; }

.meter { position: relative; height: 56px; margin: 18px 0 2px; }
.meter-scale { position: absolute; left: 0; right: 0; top: 18px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, var(--bad) 0 22%, var(--warn) 22% 40%, var(--good) 40% 60%, var(--warn) 60% 78%, var(--bad) 78% 100%); }
.meter-needle { position: absolute; top: 6px; left: 50%; width: 4px; height: 32px; margin-left: -2px; background: var(--text); border-radius: 2px; transition: left .08s linear; }
.meter-ticks { position: absolute; top: 34px; left: 0; right: 0; display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.controls { display: flex; flex-direction: column; gap: 14px; }
.btn { appearance: none; border: 1px solid var(--btn-bg); border-radius: var(--radius); padding: 13px 20px; min-height: 50px; font: 600 17px var(--ui);
  background: var(--btn-bg); color: var(--btn-ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.btn:hover { filter: brightness(1.25); }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { border-color: var(--text); filter: none; }
.btn.live, .test-card .btn.on { background: var(--bad); border-color: var(--bad); color: var(--btn-ink); }
.btn .dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.btn.live .dot { animation: pulse 1s infinite; }
.btn[disabled] { opacity: .4; cursor: not-allowed; filter: none; }
@keyframes pulse { 50% { opacity: .25; } }

.status { font-size: 15px; color: var(--muted); min-height: 1.5em; margin: 0; }
.status.error { color: var(--bad); }
.level { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.level > i { display: block; height: 100%; width: 0; background: var(--good); transition: width .05s; }

.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.settings label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--muted); }
.settings select, .settings input:not([type=range]) { font: 16px var(--ui); padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); width: 100%; }
.settings output { float: right; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* Stats: plain figures on a rule, not boxes */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); }
.stat b { display: block; font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 14px; color: var(--muted); }

.history { margin-top: 22px; }
.history canvas { width: 100%; height: 200px; display: block; background: var(--surface-2); border-radius: var(--radius); }
.caption { font-size: 14px; color: var(--muted); margin: 8px 0 0; }

/* Piano strip */
.piano { position: relative; height: 104px; margin-top: 22px; display: flex; user-select: none; overflow: hidden; border: 1px solid var(--text); border-radius: 4px; }
.piano .wk { flex: 1; background: var(--key-white); border-right: 1px solid var(--border); position: relative; }
.piano .wk:last-child { border-right: 0; }
.piano .wk span { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: 11px; color: #6a6a64; }
.piano .bk { position: absolute; top: 0; height: 60%; background: var(--key-black); border-radius: 0 0 3px 3px; z-index: 2; }
.piano .on { background: var(--accent) !important; }
.piano .wk.on span { color: #fff; }
.piano .target { background: var(--mark) !important; }

/* Pitch-matching practice */
.practice { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.practice h2 { font-size: 20px; margin: 0 0 12px; letter-spacing: -.01em; }
.practice-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.practice-row select { font: 16px var(--ui); padding: 11px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.feedback { font-weight: 700; font-size: 18px; margin: 12px 0 0; min-height: 1.6em; }
.feedback.good { color: var(--good); }
.feedback.warn { color: var(--warn); }
.file-btn { cursor: pointer; min-height: 44px; padding: 9px 16px; font-size: 15px; }
.file-btn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- guided tests (range / voice Hz) ---------- */
.steps-bar { display: flex; gap: 24px; list-style: none; padding: 0; margin: 0 0 20px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.steps-bar li { padding: 0 0 10px; color: var(--muted); font-size: 15px; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.steps-bar li.on { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
.instr { background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px; }
.big-note { min-height: .9em; font-size: clamp(88px, 18vw, 160px); font-weight: 800; line-height: .9; letter-spacing: -.05em; font-variant-numeric: tabular-nums; margin: 8px 0 4px; }
.big-sub { font-size: 20px; font-weight: 600; color: var(--muted); min-height: 1.4em; font-variant-numeric: tabular-nums; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.btn-row .btn { flex: 1; min-width: 170px; }
.result-hero { padding: 4px 0 8px; }
.result-hero .label { font-size: 15px; color: var(--muted); }
.result-hero .value { font-size: clamp(52px, 11vw, 96px); font-weight: 800; letter-spacing: -.045em; line-height: 1; margin: 6px 0 8px; font-variant-numeric: tabular-nums; }
.result-hero .sub { color: var(--muted); font-size: 17px; }
.result-hero .sub span { display: block; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin: 20px 0; padding-top: 16px; border-top: 1px solid var(--border); }
.result-grid .stat b { font-size: 22px; }
.result-grid .stat span { display: block; }

.vr-axis, .vr-row { display: grid; grid-template-columns: 116px 1fr; align-items: center; gap: 10px; }
.vr-axis > div { position: relative; height: 20px; }
.vr-axis i { position: absolute; transform: translateX(-50%); font-style: normal; font-size: 12px; color: var(--muted); }
.vr-row { margin: 7px 0; font-size: 15px; }
.vr-row.best span { font-weight: 800; }
.vr-track { position: relative; height: 22px; background: var(--surface-2); border-radius: 3px; }
.vr-track b { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.vr-type { background: var(--border); }
.vr-row.best .vr-type { background: var(--mark); }
.vr-you { top: 7px !important; bottom: 7px !important; background: var(--text); }
.vr-key { display: inline-block; width: 14px; height: 8px; border-radius: 2px; vertical-align: middle; }
.vr-key.you { background: var(--text); }
.vr-key.type { background: var(--border); }
@media (max-width: 480px) { .vr-axis, .vr-row { grid-template-columns: 86px 1fr; } }

.passage { font: 20px/1.7 var(--read); background: var(--surface-2); border-radius: var(--radius); padding: 18px 20px; margin: 0 0 16px; }
.progress { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--text); }
.hz-canvas { width: 100%; height: 190px; display: block; background: var(--surface-2); border-radius: var(--radius); margin-top: 14px; }

/* ---------- tone generator ---------- */
.tg-freq { display: flex; align-items: baseline; gap: 10px; }
.tg-freq input { font: 800 clamp(72px, 15vw, 132px) var(--ui); letter-spacing: -.05em; width: 3.3ch; max-width: 100%; border: 0; border-bottom: 2px solid var(--border); background: transparent; color: var(--text); padding: 0; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.tg-freq input:focus { border-bottom-color: var(--accent); outline: none; }
.tg-freq input::-webkit-outer-spin-button, .tg-freq input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tg-unit { font-size: 32px; font-weight: 700; color: var(--muted); }
.tg-freq + .big-sub { margin-top: 4px; }
.tg-slider { margin-top: 18px; height: 28px; }
.tg-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 7px 12px; font: 600 14px var(--ui); cursor: pointer; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--text); }
.chip.on { background: var(--btn-bg); color: var(--btn-ink); border-color: var(--btn-bg); }
.seg { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; }
.seg legend { font-size: 14px; color: var(--muted); margin-bottom: 5px; width: 100%; }
.seg label { flex-direction: row !important; align-items: center; gap: 6px !important; padding: 7px 11px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text) !important; font-size: 14px !important; cursor: pointer; }
.seg label:has(input:checked) { border-color: var(--text); background: var(--surface-2); font-weight: 600; }
.seg input { width: auto !important; accent-color: var(--accent); }
.sweep-row { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 10px; align-items: end; }
.sweep-row label { display: flex; flex-direction: column; font-size: 14px; color: var(--muted); gap: 5px; }
.sweep-row input { font: 16px var(--ui); padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); width: 100%; }
@media (max-width: 560px) { .sweep-row { grid-template-columns: 1fr 1fr 1fr; } .sweep-row .btn { grid-column: 1 / -1; } }

/* ---------- sound / headphone tests: rows, not a card grid ---------- */
.chan-viz { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 4px 0 18px; }
.spk { width: 56px; height: 56px; border-radius: var(--radius); border: 2px solid var(--text); display: grid; place-items: center; font-weight: 800; font-size: 20px; transition: background .1s, color .1s; }
.spk.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pan-track { flex: 1; height: 2px; background: var(--border); position: relative; }
.pan-dot { position: absolute; top: 50%; left: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--accent); opacity: 0; transition: opacity .2s; }
.pan-dot.on { opacity: 1; }
.test-grid { display: block; }
.test-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 0 28px; align-items: start; padding: 20px 0; border-top: 1px solid var(--border); }
.tc-head { grid-column: 1; grid-row: 1 / span 6; }
.test-card > :not(.tc-head) { grid-column: 2; }
.test-card > :not(.tc-head) ~ :not(.tc-head) { margin-top: 10px; }
@media (max-width: 680px) { .tc-head { margin-bottom: 12px; } }
.test-card h2 { font-size: 19px; margin: 0 0 4px; letter-spacing: -.01em; }
.tc-head p { font-size: 15px; color: var(--muted); margin: 0; }
.test-card .caption { margin: 0; min-height: 0; }
.test-card .btn { width: 100%; min-height: 46px; font-size: 16px; }
@media (max-width: 680px) { .test-card { grid-template-columns: 1fr; } .tc-head, .test-card > * { grid-column: 1 !important; grid-row: auto !important; } }
.lr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.lr .btn { min-width: 0; padding: 12px 6px; }
.readout-line { font-size: 28px; font-weight: 700; min-height: 1.3em; font-variant-numeric: tabular-nums; }

/* ---------- ads: reserved space, no layout shift ---------- */
.ad { margin: 32px auto; min-height: 280px; display: flex; align-items: center; justify-content: center; }
.ad[data-placeholder]::before { content: "Advertisement"; font-size: 13px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); width: 100%; min-height: 280px; display: flex; align-items: center; justify-content: center; }

/* ---------- long-form guide: a reading column, not a card ---------- */
.content { margin: 40px 0 0; max-width: 720px; }
.content h2 { font-size: clamp(26px, 3.4vw, 32px); line-height: 1.15; letter-spacing: -.025em; font-weight: 800; margin: 52px 0 12px; }
.content h2:first-child { margin-top: 0; }
.content h3 { font-size: 20px; letter-spacing: -.01em; margin: 30px 0 6px; }
.content p, .content li { font: 19px/1.7 var(--read); }
.content p { margin: 0 0 16px; }
.content ul, .content ol { padding-left: 1.3em; margin: 0 0 16px; }
.content li { margin: 4px 0; }
.content code { font-size: .88em; background: var(--surface-2); padding: 1px 5px; border-radius: 3px; }
.table-scroll { overflow-x: auto; margin: 18px 0 22px; }
.content table { width: 100%; border-collapse: collapse; font: 15px/1.45 var(--ui); }
.content th, .content td { border-bottom: 1px solid var(--border); padding: 9px 10px 9px 0; text-align: left; vertical-align: top; }
.content th { font-weight: 700; border-bottom: 2px solid var(--text); }
.content td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.callout { background: var(--surface-2); padding: 16px 18px; border-radius: var(--radius); margin: 20px 0; font: 17px/1.6 var(--ui); }
.steps { padding-left: 1.3em; }
.faq details { border-top: 1px solid var(--border); padding: 14px 0; }
.faq details:last-child { border-bottom: 1px solid var(--border); }
.faq summary { font-weight: 700; cursor: pointer; font-size: 18px; list-style-position: outside; }
.faq details p { margin: 10px 0 0; }

.diagram { margin: 26px 0; }
.diagram img { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.diagram figcaption { font-size: 15px; color: var(--muted); margin-top: 8px; }

/* Related tools: a plain list */
.related { margin: 48px 0 0; max-width: 720px; border-top: 2px solid var(--text); }
.related::before { content: "More tools"; display: block; font-weight: 800; font-size: 20px; letter-spacing: -.01em; padding: 16px 0 4px; }
.related a { display: grid; grid-template-columns: minmax(0, 220px) 1fr; gap: 4px 20px; padding: 14px 0; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.related a b { font-weight: 700; }
.related a span { color: var(--muted); font-size: 15px; }
.related a:hover b { color: var(--accent); text-decoration: underline; }
@media (max-width: 560px) { .related a { grid-template-columns: 1fr; } }

/* ---------- phone layout: keep the main action on the first screen ---------- */
@media (max-width: 640px) {
  .site-header .wrap { flex-wrap: nowrap; flex-direction: column; align-items: stretch; gap: 4px; min-height: 0; padding-top: 10px; padding-bottom: 0; }
  .nav { flex-wrap: nowrap; overflow-x: auto; gap: 18px; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 8px 0 10px; }
  h1 { font-size: 31px; margin-top: 14px; }
  .crumbs { margin-top: 14px; }
  .lede { font-size: 17px; margin-bottom: 18px; }
  .readout { min-height: 0; }
  .note { font-size: 112px; }
  .meter { margin-top: 10px; }
}
#resetStats { min-height: 36px !important; padding: 6px 14px !important; font-size: 14px !important; }
