/* Pitch Detector — deep night design system
   Archivo (display) + IBM Plex Sans (body)
   #0b1120 bg / #22d3ee accent / #e2e8f0 text
   4px radius, flat fills, no shadows */

:root {
  --bg: #0b1120;
  --bg-2: #0e1628;
  --panel: #101a30;
  --panel-2: #142038;
  --line: #1e2a44;
  --line-2: #29385c;
  --text: #e2e8f0;
  --muted: #94a6bf;
  --faint: #64748b;
  --accent: #22d3ee;
  --accent-dim: rgba(34, 211, 238, 0.12);
  --accent-ink: #06222b;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 4px;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --body: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: var(--display);
  letter-spacing: -0.01em;
  line-height: 1.15;
}

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

code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.05em 0.35em;
  font-size: 0.9em;
}

.num { font-variant-numeric: tabular-nums; }

/* ---------- Split layout ---------- */

.split { display: grid; grid-template-columns: 1fr; min-height: 100vh; }

.tool-pane {
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  padding: 16px 16px 28px;
}

.content-pane { padding: 28px 16px 40px; max-width: 760px; }

@media (min-width: 980px) {
  .split { grid-template-columns: minmax(440px, 46%) 1fr; }
  .tool-pane {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-bottom: none;
    border-right: 1px solid var(--line);
    padding: 20px 24px 40px;
  }
  .content-pane { padding: 44px 48px 64px; }
}

/* ---------- Tool header ---------- */

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.brand svg { flex: 0 0 auto; }
.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}
.brand-sub { font-size: 0.78rem; color: var(--muted); margin-top: 1px; }

/* ---------- Mode tabs ---------- */

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 9px 0;
  cursor: pointer;
  text-align: center;
}
.tab[aria-selected="true"] {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.tab:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.mode { display: none; }
.mode.active { display: block; }

/* ---------- Readout ---------- */

.readout {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px 14px;
  text-align: center;
  margin-bottom: 10px;
}
.readout.idle .note-name, .readout.idle .hz-val { color: var(--faint); }

.note-row { display: flex; align-items: baseline; justify-content: center; gap: 4px; min-height: 92px; }
.note-name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 5.2rem;
  line-height: 1;
  color: var(--text);
}
.note-oct { font-family: var(--display); font-weight: 600; font-size: 2rem; color: var(--muted); }
.readout.locked .note-name { color: var(--accent); }

.hz-row { margin-top: 6px; font-size: 1.15rem; color: var(--text); }
.hz-row .unit { color: var(--muted); font-size: 0.85rem; margin-left: 3px; }
.cents-label { font-size: 0.85rem; color: var(--muted); margin-top: 2px; min-height: 1.3em; }
.cents-label.sharp { color: var(--warn); }
.cents-label.flat { color: var(--warn); }
.cents-label.in-tune { color: var(--accent); }

/* cents meter */
.meter-wrap { margin-top: 10px; }
.meter-wrap svg { width: 100%; height: auto; display: block; }

/* strobe view */
.strobe-wrap { margin-top: 10px; display: none; }
.strobe-wrap canvas {
  width: 100%;
  height: 56px;
  display: block;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.view-toggle { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.view-toggle .chip { padding: 4px 12px; font-size: 0.72rem; }

/* ---------- Scope + level ---------- */

.scope-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 10px;
}
.scope-wrap canvas { width: 100%; height: 64px; display: block; }
.level-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.level-track {
  flex: 1; height: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.level-fill { height: 100%; width: 0%; background: var(--accent); }
.level-db { font-size: 0.72rem; color: var(--muted); width: 64px; text-align: right; }

/* ---------- Controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  padding: 12px 18px;
  width: 100%;
  cursor: pointer;
}
.btn:hover { background: #4adef4; }
.btn.stop { background: transparent; color: var(--accent); }
.btn.stop:hover { background: var(--accent-dim); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--text);
  border-radius: var(--radius);
  font-family: var(--body);
  font-size: 0.82rem;
  padding: 7px 12px;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost:disabled { opacity: 0.4; cursor: default; }
.btn-ghost:disabled:hover { border-color: var(--line-2); color: var(--text); }

.hint { font-size: 0.78rem; color: var(--muted); margin: 8px 0 0; text-align: center; }
.err {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid var(--bad);
  border-radius: var(--radius);
  color: var(--bad);
  font-size: 0.85rem;
  padding: 9px 12px;
  margin-top: 10px;
  display: none;
}
.err.show { display: block; }

/* field groups */
.field-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.field-row label { font-size: 0.8rem; color: var(--muted); white-space: nowrap; min-width: 88px; }
.field-row input[type="range"] { flex: 1; accent-color: var(--accent); min-width: 0; }
.field-row input[type="number"], .field-row select {
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--body);
  font-size: 0.9rem;
  padding: 6px 8px;
  width: 82px;
}
.field-row select { width: auto; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.8rem;
  padding: 6px 11px;
  cursor: pointer;
}
.chip[aria-pressed="true"] {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.strings { display: flex; gap: 5px; margin-top: 10px; flex-wrap: wrap; }
.string-pill {
  flex: 1;
  min-width: 44px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: var(--muted);
  padding: 7px 2px;
  cursor: pointer;
}
.string-pill .f { display: block; font-size: 0.66rem; color: var(--faint); }
.string-pill.near { border-color: var(--accent); color: var(--accent); }

/* ---------- Panels / sections in tool pane ---------- */

.tool-section {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 12px;
}
.tool-section h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 600;
}

details.device-report { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
details.device-report summary {
  cursor: pointer;
  padding: 9px 12px;
  font-size: 0.82rem;
  color: var(--muted);
  list-style: none;
  display: flex;
  justify-content: space-between;
}
details.device-report summary::after { content: "+"; color: var(--faint); }
details.device-report[open] summary::after { content: "–"; }
.report-body { padding: 0 12px 10px; font-size: 0.8rem; color: var(--muted); }
.report-body table { width: 100%; border-collapse: collapse; }
.report-body td { padding: 3px 0; border-top: 1px solid var(--line); vertical-align: top; }
.report-body td:last-child { text-align: right; color: var(--text); }
.report-note { margin: 8px 0 0; color: var(--faint); font-size: 0.75rem; }
.flag-ok { color: var(--accent); }
.flag-warn { color: var(--warn); }

/* history */
.history-list { list-style: none; margin: 0; padding: 0; font-size: 0.82rem; max-height: 150px; overflow-y: auto; }
.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 2px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.history-list li b { color: var(--text); font-weight: 600; }
.history-empty { color: var(--faint); font-size: 0.8rem; padding: 4px 2px; }
.row-btns { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- File mode ---------- */

.dropzone {
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: center;
  padding: 26px 14px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}
.dropzone.drag { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.dropzone input { display: none; }
.dz-name { color: var(--text); font-weight: 600; display: block; margin-bottom: 3px; }

.progress-track {
  height: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 12px;
  display: none;
}
.progress-track.show { display: block; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); }

.track-wrap { margin-top: 12px; display: none; }
.track-wrap.show { display: block; }
.track-wrap canvas {
  width: 100%;
  height: 180px;
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-top: 10px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.stat .k { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); }
.stat .v { font-size: 1.05rem; font-family: var(--display); font-weight: 700; margin-top: 2px; }
.stat .v small { font-size: 0.72rem; color: var(--muted); font-family: var(--body); font-weight: 400; }

/* ---------- Tone mode ---------- */

.tone-freq-row { display: flex; align-items: baseline; justify-content: center; gap: 6px; padding: 14px 0 4px; }
.tone-freq-row input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-2);
  color: var(--text);
  font-family: var(--display);
  font-weight: 800;
  font-size: 2.6rem;
  width: 190px;
  text-align: center;
  padding: 0 0 2px;
}
.tone-freq-row .unit { color: var(--muted); font-size: 1rem; }
.tone-note-hint { text-align: center; color: var(--muted); font-size: 0.85rem; min-height: 1.4em; }

/* keyboard hints */
.kbd-hints { font-size: 0.74rem; color: var(--faint); margin-top: 14px; text-align: center; }
kbd {
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 1px 5px;
  font-family: var(--body);
  font-size: 0.72rem;
  color: var(--muted);
}

/* ---------- Content pane ---------- */

.content-pane h1 { font-size: 2rem; font-weight: 800; margin: 0 0 10px; }
.content-pane h2 { font-size: 1.35rem; font-weight: 700; margin: 40px 0 12px; }
.content-pane > p, .content-pane section > p { color: var(--muted); }
.lede { font-size: 1.05rem; color: var(--text); }

.spec-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 8px;
  padding: 0;
  list-style: none;
}
.spec-strip li {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.78rem;
  color: var(--muted);
  padding: 5px 10px;
}
.spec-strip b { color: var(--accent); font-weight: 600; }

.feature-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 14px; }
@media (min-width: 640px) { .feature-grid { grid-template-columns: 1fr 1fr; } }
.feature {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
}
.feature h3 { font-size: 0.95rem; margin: 0 0 5px; font-weight: 700; }
.feature p { font-size: 0.85rem; color: var(--muted); margin: 0; }

ol.steps { counter-reset: s; list-style: none; margin: 14px 0 0; padding: 0; }
ol.steps li {
  counter-increment: s;
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}
ol.steps li::before {
  content: counter(s);
  font-family: var(--display);
  font-weight: 800;
  color: var(--accent);
  font-size: 1.1rem;
  min-width: 20px;
}
ol.steps b { color: var(--text); }

/* FAQ */
.faq details { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-top: 8px; }
.faq summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 0.95rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.faq summary::after { content: "+"; color: var(--accent); flex: 0 0 auto; }
.faq details[open] summary::after { content: "–"; }
.faq .a { padding: 0 14px 12px; color: var(--muted); font-size: 0.9rem; }
.faq .a p { margin: 0 0 8px; }

/* cards (related + blog) */
.card-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 14px; }
@media (min-width: 640px) { .card-grid { grid-template-columns: 1fr 1fr; } }
a.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--text);
}
a.card:hover { border-color: var(--accent); text-decoration: none; }
a.card h3 { font-size: 0.95rem; margin: 0 0 4px; font-weight: 700; }
a.card p { font-size: 0.83rem; color: var(--muted); margin: 0; }
a.card .tag { font-size: 0.7rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; }

/* footer */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 48px;
  padding-top: 18px;
  font-size: 0.8rem;
  color: var(--faint);
}
.site-footer p { margin: 0 0 6px; }

/* ---------- Blog pages ---------- */

.blog-wrap { max-width: 720px; margin: 0 auto; padding: 28px 18px 60px; }
.blog-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 26px;
  font-size: 0.85rem;
}
.blog-topbar .back { color: var(--muted); }
.blog-topbar .back:hover { color: var(--accent); }
.blog-wrap h1 { font-size: 1.85rem; font-weight: 800; margin: 0 0 6px; }
.blog-meta { color: var(--faint); font-size: 0.8rem; margin-bottom: 20px; }
.blog-wrap h2 { font-size: 1.25rem; font-weight: 700; margin: 32px 0 10px; }
.blog-wrap p { color: var(--muted); }
.blog-wrap p b, .blog-wrap li b { color: var(--text); }
.blog-wrap ul, .blog-wrap ol { color: var(--muted); }
.blog-illo {
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 10px;
}
.blog-illo svg { width: 100%; height: auto; display: block; }
.blog-cta {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 28px 0;
  font-size: 0.92rem;
}
.blog-cta a { font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
