:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #0b1120;
  --border: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #0284c7;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

header {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.nav-wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand span { color: var(--accent); }

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.92rem;
}
.nav-links a { color: var(--text-muted); font-weight: 500; }
.nav-links a:hover, .nav-links a[aria-current="page"] {
  color: var(--text);
  text-decoration: none;
}

.hero {
  padding: 32px 0 20px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin-bottom: 10px;
}
.hero p {
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto;
  font-size: 0.98rem;
}

.status-banner {
  display: none;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid var(--bad);
  color: #fecaca;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin: 14px auto 0;
  max-width: 560px;
  text-align: center;
}
.status-banner.visible { display: block; }

/* Hub Cards */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin: 24px 0 32px;
}

.hub-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.15s, transform 0.15s;
}
.hub-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.hub-card h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--text);
}
.hub-card p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 18px;
}
.hub-card .card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-nav-pills {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 22px;
  flex-wrap: wrap;
}

.pill-link {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  transition: all 0.15s ease;
}
.pill-link:hover {
  border-color: var(--accent);
  color: var(--text);
  text-decoration: none;
}
.pill-link.active {
  background: var(--accent);
  color: #0f172a;
  border-color: var(--accent);
}

.workspace-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35);
}

.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #0f172a;
  border: none;
  padding: 11px 22px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.96rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  color: #fff;
  text-decoration: none;
}
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary.recording, .btn-primary.playing { background: var(--bad); color: #fff; }

.btn-secondary {
  display: inline-block;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--accent); text-decoration: none; }
.btn-secondary.active {
  background: var(--accent);
  color: #0f172a;
  border-color: var(--accent);
  font-weight: 600;
}

/* Readout & Meter */
.readout-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin: 20px 0;
}

.note-display {
  font-size: 4.2rem;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1.1;
  color: var(--text);
}
.note-display.in-tune { color: var(--good); }

.freq-cents {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 8px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 1rem;
}

.meter-track {
  position: relative;
  height: 14px;
  background: #1e293b;
  border-radius: 999px;
  max-width: 440px;
  margin: 20px auto 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.meter-center-mark {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--good);
  transform: translateX(-50%);
  z-index: 2;
}

.meter-needle {
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: 12px;
  border-radius: 999px;
  background: var(--accent);
  left: 50%;
  transform: translateX(-50%);
  transition: left 0.06s linear, background-color 0.15s;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  max-width: 440px;
  margin: 0 auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.preset-row, .string-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.string-btn {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-family: var(--font-mono);
  cursor: pointer;
  min-width: 74px;
}
.string-btn:hover { border-color: var(--accent); }
.string-btn.matched {
  border-color: var(--good);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

canvas#pitch-canvas {
  width: 100%;
  height: 110px;
  background: var(--surface-alt);
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-top: 16px;
  display: block;
}

/* Metronome */
.bpm-header { text-align: center; margin-bottom: 16px; }
.bpm-number {
  font-size: 3.8rem;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1;
}
.bpm-label {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}
.meter-hint {
  color: var(--text-muted);
  font-size: 0.84rem;
  margin-top: 4px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 480px;
  margin: 16px auto;
}
input[type="range"] { flex: 1; accent-color: var(--accent); cursor: pointer; }

.beat-lights {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 22px 0;
  flex-wrap: wrap;
}
.beat-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-alt);
  border: 2px solid var(--border);
  transition: transform 0.05s, background-color 0.05s;
}
.beat-dot.active {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.18);
}
.beat-dot.accent.active {
  background: var(--good);
  border-color: var(--good);
}

.metro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.control-group {
  background: var(--surface-alt);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.control-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.control-group select {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 6px;
  font-size: 0.92rem;
}

/* Editorial Content & Policy */
.guide-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 32px;
}
.guide-section h2 {
  font-size: 1.32rem;
  margin: 24px 0 10px;
  color: var(--text);
}
.guide-section h2:first-child { margin-top: 0; }
.guide-section p { color: #cbd5e1; margin-bottom: 12px; }
.guide-section ul { margin: 0 0 16px 20px; color: #cbd5e1; }
.guide-section li { margin-bottom: 6px; }

table.ref-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.92rem;
}
table.ref-table th, table.ref-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
}
table.ref-table th {
  background: var(--surface-alt);
  color: var(--accent);
}

.badge-pass {
  display: inline-block;
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  border: 1px solid var(--good);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

.badge-fail {
  display: inline-block;
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid var(--bad);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

.privacy-badge {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 14px;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

footer {
  border-top: 1px solid var(--border);
  padding: 24px 0 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}
footer nav {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
