:root {
  --bg: #0e1116;
  --fg: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --panel: #161b22;
  --border: #30363d;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

header h1 {
  font-size: 1.75rem;
  margin: 0 0 0.25rem;
  letter-spacing: -0.01em;
}

.lede {
  margin: 0 0 2rem;
  color: var(--muted);
}

a {
  color: var(--accent);
}

.control-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

button {
  font: inherit;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #0d1117;
}

label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

select {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  border-radius: 6px;
}

.readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.note-block, .freq-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.note-name {
  font-size: 4.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}

.octave {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 0.25rem;
  min-height: 1.5em;
}

.freq {
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.cents {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 0.5rem;
  min-height: 1.5em;
}

.needle-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.needle-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.needle-track {
  position: relative;
  height: 14px;
  background: var(--bg);
  border-radius: 7px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.needle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  background: var(--accent);
  transform: translateX(-50%);
  transition: left 60ms linear, background 120ms;
  border-radius: 2px;
}

.needle.in-tune { background: var(--good); }
.needle.flat   { background: var(--warn); }
.needle.sharp  { background: var(--warn); }
.needle.way-off { background: var(--bad); }

.needle-center {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: 50%;
  width: 1px;
  background: var(--muted);
  transform: translateX(-50%);
  pointer-events: none;
}

.target-label {
  margin-top: 0.6rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-height: 1.5em;
}

.waveform {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  margin-bottom: 1.5rem;
}

#wave {
  display: block;
  width: 100%;
  height: 120px;
  background: var(--bg);
  border-radius: 6px;
}

.status {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
  min-height: 1.5em;
}

footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

footer code {
  background: var(--panel);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

@media (max-width: 520px) {
  .readout { grid-template-columns: 1fr; }
  .note-name { font-size: 3.5rem; }
  .freq { font-size: 1.5rem; }
}
