/* ===== Design tokens ===== */
:root {
  --bg: #0a0c0f;
  --bg-alt: #101317;
  --surface: #171b20;
  --surface-2: #1e232a;
  --border: #2a3038;
  --text: #eef1f4;
  --text-muted: #9aa5b1;
  --text-faint: #6b7480;
  --blue: #4c8dff;
  --blue-strong: #7aabff;
  --blue-dim: #2450a3;
  --blue-wash: rgba(76, 141, 255, 0.1);
  --green: #3ecf8e;
  --green-wash: rgba(62, 207, 142, 0.1);
  --amber: #e8b34a;
  --amber-wash: rgba(232, 179, 74, 0.1);
  --red: #ef5b5b;
  --red-wash: rgba(239, 91, 91, 0.1);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
  --container: 1080px;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

html { overflow-x: hidden; }

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

img, svg { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}

p { margin: 0 0 1em; color: var(--text-muted); }

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Background texture ===== */
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(700px 400px at 85% -10%, var(--blue-wash), transparent 60%),
    radial-gradient(600px 500px at -10% 30%, rgba(76,141,255,0.05), transparent 60%),
    var(--bg);
}

/* ===== Install banner (PWA) ===== */
.install-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 16px;
  padding: 10px 16px;
  background: var(--blue-wash);
  border-bottom: 1px solid rgba(76, 141, 255, 0.25);
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.install-banner.status-hidden { display: none !important; }

.install-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-sm {
  padding: 8px 18px;
  font-size: 0.85rem;
}

.install-dismiss {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
}

.install-dismiss:hover { color: var(--text); }

/* ===== Header / Nav ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 12, 15, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  max-width: var(--container);
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 4vw, 1.05rem);
  font-weight: 600;
  color: var(--text);
  min-width: 0;
  white-space: nowrap;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: #05070a;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 2px;
  align-items: center;
  flex-shrink: 1;
  min-width: 0;
}

.nav-links a {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 8px 10px;
  border-radius: 999px;
  transition: color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.nav-links a:hover { color: var(--text); background: var(--surface); }

.nav-links a.active {
  color: var(--blue-strong);
  background: var(--blue-wash);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 14px 26px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  text-align: center;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--blue), #3a6fe0);
  color: #04070c;
  box-shadow: 0 10px 30px -8px rgba(76, 141, 255, 0.55);
}

.btn-primary:hover { box-shadow: 0 12px 34px -6px rgba(76, 141, 255, 0.7); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover { border-color: var(--blue-dim); color: var(--blue-strong); }

.btn-block { width: 100%; }

/* ===== Hero ===== */
.hero {
  padding: 64px 0 48px;
  text-align: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue-strong);
  background: var(--blue-wash);
  border: 1px solid rgba(76, 141, 255, 0.25);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 22px;
}

.eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 8px var(--blue);
}

.hero h1 {
  font-size: clamp(2.1rem, 8vw, 3.6rem);
  margin-bottom: 0.4em;
}

.hero h1 span { color: var(--blue-strong); }

.hero-sub {
  font-size: 1.05rem;
  max-width: 560px;
  margin: 0 auto 32px;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  max-width: 340px;
  margin: 0 auto;
}

/* ===== Sections ===== */
.section { padding: 56px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.section-head { text-align: center; max-width: 560px; margin: 0 auto 40px; }
.section-head h2 { font-size: clamp(1.6rem, 5vw, 2.2rem); }

/* ===== Cards / grid ===== */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--blue-wash);
  color: var(--blue-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.card h3 { font-size: 1.1rem; margin-bottom: 8px; }
.card p { margin-bottom: 0; font-size: 0.94rem; }

/* ===== CTA banner ===== */
.cta-banner {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background:
    radial-gradient(500px 220px at 100% 0%, var(--blue-wash), transparent 70%),
    var(--surface);
  padding: 40px 28px;
  text-align: center;
  box-shadow: var(--shadow);
}

.cta-banner h2 { font-size: clamp(1.4rem, 5vw, 1.9rem); margin-bottom: 0.35em; }
.cta-banner p { max-width: 480px; margin: 0 auto 24px; }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0 40px;
  text-align: center;
}

.site-footer p { color: var(--text-faint); font-size: 0.85rem; margin: 0; }

/* ===== Audio check page ===== */
.upload-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 42px 20px;
  text-align: center;
  background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-zone.drag-over {
  border-color: var(--blue);
  background: var(--blue-wash);
}

.upload-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border-radius: 16px;
  background: var(--blue-wash);
  color: var(--blue-strong);
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-zone h3 { font-size: 1.05rem; margin-bottom: 6px; }
.upload-zone p { font-size: 0.9rem; margin-bottom: 20px; }
.upload-hint { font-size: 0.78rem; color: var(--text-faint); margin-top: 16px; }

.file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 16px;
  max-width: 100%;
  min-width: 0;
}

.file-chip svg { flex-shrink: 0; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.status-box {
  margin-top: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.status-hidden { display: none !important; }

.status-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 24px;
}

.status-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-header h3 { margin: 0 0 2px; font-size: 1.1rem; }
.status-header p { margin: 0; font-size: 0.88rem; }

.status-box.state-good .status-icon { background: var(--green-wash); color: var(--green); }
.status-box.state-good { border-color: rgba(62, 207, 142, 0.35); }
.status-box.state-low .status-icon { background: var(--amber-wash); color: var(--amber); }
.status-box.state-low { border-color: rgba(232, 179, 74, 0.35); }
.status-box.state-bad .status-icon { background: var(--red-wash); color: var(--red); }
.status-box.state-bad { border-color: rgba(239, 91, 91, 0.35); }

.status-body {
  padding: 0 24px 24px;
}

.waveform-wrap {
  margin-bottom: 18px;
}

.waveform-canvas {
  display: block;
  width: 100%;
  height: 100px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.waveform-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  color: var(--text-faint);
  margin-top: 8px;
}

.waveform-legend .dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.waveform-legend .dot-clip { background: var(--red); }

.metrics-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.metric {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.metric .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.metric .value {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--text);
}

.tips {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tips li {
  display: flex;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--text-muted);
  align-items: flex-start;
}

.tips li::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  margin-top: 8px;
  flex-shrink: 0;
}

.progress-box {
  margin-top: 20px;
  padding: 20px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 14px;
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  margin-top: 20px;
  padding: 18px 22px;
  border-radius: var(--radius);
  border: 1px solid rgba(239, 91, 91, 0.35);
  background: var(--red-wash);
  color: #f7b8b8;
  font-size: 0.9rem;
}

.privacy-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 24px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.83rem;
  color: var(--text-faint);
}

.privacy-note svg { flex-shrink: 0; margin-top: 2px; color: var(--blue-strong); }

input[type="file"] { display: none; }

/* ===== Tool page: compact intro, tabs, player, calibrator ===== */
.tool-intro {
  padding: 36px 0 20px;
  text-align: center;
}

.tool-intro h1 {
  font-size: clamp(1.6rem, 6vw, 2.1rem);
  margin-bottom: 0.35em;
}

.tool-intro p {
  max-width: 480px;
  margin: 0 auto;
  font-size: 0.95rem;
}

.tool-container {
  max-width: 640px;
  padding-bottom: 60px;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 18px;
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-btn.active {
  background: var(--blue);
  color: #04070c;
}

.tab-panel.status-hidden { display: none !important; }

/* Compact result card */
.metrics-row-2 {
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 8px;
}

.metrics-caption {
  font-size: 0.8rem;
  color: var(--text-faint);
  margin: 0 0 16px;
}

/* Waveform + playback */
.waveform-canvas-holder {
  position: relative;
}

.waveform-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--text);
  pointer-events: none;
  opacity: 0;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.player-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.player-btn:active { transform: scale(0.94); }

.player-time {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.player-hint {
  font-size: 0.74rem;
  color: var(--text-faint);
  margin-left: auto;
  text-align: right;
}

/* Live calibrator */
.calibrate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.calibrate-card h3 { font-size: 1.05rem; margin-bottom: 6px; }
.calibrate-card > p { font-size: 0.9rem; margin-bottom: 22px; }

.field-label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.mic-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-2) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="%239aa5b1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>') no-repeat right 14px center;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 12px 40px 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.mic-select:focus { outline: none; border-color: var(--blue-dim); }

.mic-waveform-canvas {
  display: block;
  width: 100%;
  height: 90px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.meter-wrap { margin-bottom: 16px; }

.meter-track {
  position: relative;
  height: 28px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
}

.meter-zone { height: 100%; }
.meter-zone-green { width: 62%; background: rgba(62, 207, 142, 0.18); }
.meter-zone-yellow { width: 23%; background: rgba(232, 179, 74, 0.2); }
.meter-zone-red { width: 15%; background: rgba(239, 91, 91, 0.22); }

.meter-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--green) 62%, var(--amber) 80%, var(--red) 100%);
  border-radius: 999px;
  transition: width 0.05s linear;
}

.meter-peak-hold {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--text);
  left: 0%;
  opacity: 0;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-faint);
  margin-top: 6px;
}

.meter-readout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.meter-status {
  font-weight: 600;
  font-size: 0.95rem;
}

.meter-db {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

#micStopBtn { margin-top: 10px; }
#micErrorBox { margin-top: 16px; }

/* .mic-result reuses .status-box styling directly (same card treatment as
   the file-check result), so no extra rules are needed here. */

/* ===== Responsive breakpoints ===== */
@media (min-width: 480px) {
  .hero-actions { flex-direction: row; justify-content: center; max-width: none; }
  .metrics-row { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 720px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .hero { padding: 96px 0 64px; }
  .section { padding: 80px 0; }
}

@media (min-width: 480px) {
  .nav { padding: 16px 20px; gap: 12px; }
  .nav-links { gap: 4px; }
  .nav-links a { font-size: 0.9rem; padding: 8px 14px; }
}

@media (min-width: 960px) {
  .nav-links a { font-size: 0.95rem; }
}
