/* ===================================================================
   Harmonic Stereo Tuning — Styles
   =================================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg:        #0b0e17;
  --surface:   #141928;
  --surface2:  #1c2238;
  --glass:     rgba(22, 30, 52, 0.72);
  --glass-b:   rgba(80, 110, 200, 0.08);
  --border:    rgba(100, 140, 255, 0.12);
  --accent:    #6c8cff;
  --accent-g:  linear-gradient(135deg, #6c8cff 0%, #a78bfa 100%);
  --green:     #34d399;
  --red:       #f87171;
  --orange:    #fbbf24;
  --text:      #e2e8f0;
  --text-dim:  #7987a8;
  --font:      'Outfit', system-ui, sans-serif;
  --mono:      'JetBrains Mono', monospace;
  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 8px 32px rgba(0,0,0,.45);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; }
input[type=range] { -webkit-appearance: none; appearance: none; background: none; }

/* ---------- Splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg);
  transition: opacity .6s ease, visibility .6s ease;
}
.splash.hide { opacity: 0; visibility: hidden; pointer-events: none; }

.splash-ring {
  position: absolute;
  width: 160px; height: 160px;
  border: 3px solid transparent;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.splash-logo {
  font-size: 56px; font-weight: 700;
  background: var(--accent-g); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative; z-index: 1;
}
.splash-title {
  margin-top: 28px; font-size: 22px; font-weight: 600;
  letter-spacing: .5px;
}
.splash-sub { color: var(--text-dim); margin-top: 6px; font-size: 14px; }

/* ---------- App wrapper ---------- */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.app.hidden { display: none; }

/* ---------- Header ---------- */
.header {
  display: flex; align-items: center; justify-content: center;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-icon {
  font-size: 24px; font-weight: 700;
  background: var(--accent-g); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-name { font-weight: 600; font-size: 16px; letter-spacing: .3px; }

/* ---------- Tabs ---------- */
.tab-nav {
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.tab-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 18px; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-dim);
  font-size: 11px; font-weight: 500;
  transition: all .25s ease;
}
.tab-btn svg { transition: stroke .25s; }
.tab-btn.active,
.tab-btn:hover {
  color: var(--accent);
  background: rgba(108,140,255,.1);
}

/* ---------- Tab panels ---------- */
.tab-panel { display: none; flex: 1; padding: 16px; animation: fadeUp .35s ease; }
.tab-panel.active { display: block; }
@keyframes fadeUp { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }

/* ---------- Glass card ---------- */
.glass-card {
  background: var(--glass);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  max-width: 480px;
  margin: 0 auto;
}

/* ---------- Section ---------- */
.section-title {
  font-size: 20px; font-weight: 600;
  background: var(--accent-g); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}
.section-desc { font-size: 13px; color: var(--text-dim); margin-bottom: 20px; }

/* =================  TUNER  ================= */
.tuner-card { text-align: center; }

.gauge-wrap { position: relative; margin: 0 auto 12px; width: 300px; height: 200px; }
#gauge-canvas { width: 100%; height: 100%; }
.gauge-note {
  position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%);
  font-size: 56px; font-weight: 700; font-family: var(--mono);
  transition: color .15s;
}
.gauge-freq {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-size: 13px; color: var(--text-dim); font-family: var(--mono);
}
.gauge-cents {
  position: absolute; bottom: 8px; right: 20px;
  font-size: 13px; font-family: var(--mono); color: var(--text-dim);
}

.note-bar { display: flex; justify-content: center; gap: 32px; margin-bottom: 16px; }
.note-bar-item { font-size: 18px; font-family: var(--mono); font-weight: 500; }
.note-bar-item.dim { color: var(--text-dim); }
.note-bar-item.current { color: var(--accent); font-size: 22px; }

.wave-section { margin-bottom: 20px; border-radius: var(--radius-sm); overflow: hidden; }
#waveform { width: 100%; height: 80px; display: block; background: var(--surface2); border-radius: var(--radius-sm); }

/* =================  STEREO  ================= */
.stereo-card { text-align: center; }

.stereo-visual {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-bottom: 20px;
}
.speaker-box {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; color: var(--text-dim);
  position: relative; transition: all .3s;
}
.speaker-box.playing { color: var(--accent); box-shadow: 0 0 24px rgba(108,140,255,.35); }
.speaker-ring {
  position: absolute; inset: -6px;
  border: 2px solid var(--border); border-radius: 50%;
  transition: border-color .3s;
}
.speaker-box.playing .speaker-ring {
  border-color: var(--accent);
  animation: pulse-ring 1s ease infinite;
}
@keyframes pulse-ring {
  0%,100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.12); opacity: .5; }
}

.balance-slider-wrap { flex: 1; max-width: 200px; }
.balance-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-dim); margin-top: 4px; }

.stereo-btns { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

/* =================  TONE GEN  ================= */
.tones-card { text-align: center; }

.tone-freq-display {
  margin-bottom: 12px;
}
.tone-freq-display #tone-freq-value {
  font-size: 52px; font-weight: 700; font-family: var(--mono);
  background: var(--accent-g); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tone-freq-unit { font-size: 18px; color: var(--text-dim); margin-left: 4px; }

.freq-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-dim); margin-top: 4px; margin-bottom: 16px; }

.wave-select { display: flex; justify-content: center; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.wave-btn {
  padding: 6px 14px; border-radius: 20px;
  background: var(--surface2); color: var(--text-dim);
  font-size: 12px; font-weight: 500;
  transition: all .2s;
}
.wave-btn.active, .wave-btn:hover { background: rgba(108,140,255,.18); color: var(--accent); }

.presets { display: flex; justify-content: center; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.preset-btn {
  padding: 6px 16px; border-radius: 8px;
  background: var(--surface2); color: var(--text-dim);
  font-size: 13px; font-weight: 600; font-family: var(--mono);
  transition: all .2s;
}
.preset-btn:hover { background: rgba(108,140,255,.15); color: var(--accent); }

.tone-btns { display: flex; justify-content: center; gap: 10px; margin-bottom: 16px; }

/* =================  Shared controls  ================= */
.volume-control {
  display: flex; align-items: center; gap: 10px;
  justify-content: center;
  font-size: 13px; color: var(--text-dim);
}

/* ---------- Buttons ---------- */
.btn-primary {
  padding: 12px 28px; border-radius: 12px;
  background: var(--accent-g); color: #fff;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 4px 18px rgba(108,140,255,.35);
  transition: transform .15s, box-shadow .15s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(108,140,255,.5); }
.btn-primary:active { transform: scale(.97); }

.btn-secondary {
  padding: 10px 22px; border-radius: 12px;
  background: var(--surface2); color: var(--text);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border);
  transition: all .2s;
}
.btn-secondary:hover { background: rgba(108,140,255,.12); border-color: var(--accent); color: var(--accent); }

.btn-outline {
  padding: 10px 22px; border-radius: 12px;
  background: transparent; color: var(--text-dim);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border);
  transition: all .2s;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { border-color: rgba(248,113,113,.3); color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: rgba(248,113,113,.08); }

/* ---------- Sliders ---------- */
.balance-slider, .freq-slider, .volume-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--surface2);
  outline: none;
}
.balance-slider::-webkit-slider-thumb,
.freq-slider::-webkit-slider-thumb,
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(108,140,255,.5);
  cursor: pointer;
  transition: transform .15s;
}
.balance-slider::-webkit-slider-thumb:hover,
.freq-slider::-webkit-slider-thumb:hover,
.volume-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* ---------- Utility ---------- */
.in-tune .gauge-note { color: var(--green) !important; }
.sharp .gauge-note   { color: var(--red) !important; }
.flat .gauge-note     { color: var(--orange) !important; }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .glass-card { padding: 16px; }
  .gauge-wrap { width: 260px; height: 174px; }
  .gauge-note { font-size: 44px; }
  .stereo-visual { gap: 10px; }
  .speaker-box { width: 52px; height: 52px; font-size: 16px; }
}
