/*
 * DrumPitch — free, open-source drum tuner PWA.
 * Copyright (c) 2026 DrumPitch contributors
 * SPDX-License-Identifier: MIT
 * See LICENSE for the full licence text.
 *
 * Mobile-first dark theme (stage-friendly) with an optional light theme.
 * Large touch targets, safe-area insets for notched phones, and
 * prefers-reduced-motion respected.
 */

/* ============================== THEME TOKENS ============================= */
/* Cassette-futurism: warm beige plastic, yellow accent, ink-black detail */
:root {
  --bg: #e9e4d6;
  --surface: #f4f0e4;
  --surface-2: #ddd7c6;
  --surface-3: #cfc8b4;
  --border: #1c1a16;
  --text: #1c1a16;
  --text-dim: #5e5948;
  --accent: #ffc400;
  --accent-ink: #1c1a16;
  --accent-soft: rgba(255, 196, 0, 0.28);
  --blue: #2a5fa8;
  --blue-soft: rgba(42, 95, 168, 0.16);
  --red: #d8402a;
  --red-soft: rgba(216, 64, 42, 0.16);
  --amber: #c27a00;
  --amber-soft: rgba(255, 196, 0, 0.3);
  --green: #3a7d44;
  --green-soft: rgba(58, 125, 68, 0.2);
  --shadow: 4px 4px 0 rgba(28, 26, 22, 0.9);
  --lcd: #c9d36b;
  --lcd-ink: #26301a;
  --font-display: "Eurostile", "Bank Gothic", "Orbitron", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
  --tabbar-h: calc(64px + env(safe-area-inset-bottom, 0px));
  --topbar-h: calc(54px + env(safe-area-inset-top, 0px));
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #1b1913;
  --surface: #26231a;
  --surface-2: #322e22;
  --surface-3: #413c2c;
  --border: #ffc400;
  --text: #f1ead2;
  --text-dim: #a59f88;
  --accent: #ffc400;
  --accent-ink: #1c1a16;
  --accent-soft: rgba(255, 196, 0, 0.2);
  --blue: #6aa5ee;
  --blue-soft: rgba(106, 165, 238, 0.18);
  --red: #ff6a52;
  --red-soft: rgba(255, 106, 82, 0.18);
  --amber: #ffc400;
  --amber-soft: rgba(255, 196, 0, 0.2);
  --green: #7fd18b;
  --green-soft: rgba(127, 209, 139, 0.2);
  --shadow: 4px 4px 0 rgba(255, 196, 0, 0.5);
  --lcd: #2a3118;
  --lcd-ink: #d6e37a;
  color-scheme: dark;
}

/* ============================== BASE ===================================== */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled { opacity: 0.45; cursor: not-allowed; }

input, select {
  font: inherit;
  color: inherit;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  min-height: 42px;
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

select {
  appearance: auto;
}

h1, h2 { margin: 0 0 8px; font-weight: 700; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1rem; }

/* ============================== TOP BAR ================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  padding: env(safe-area-inset-top, 0px) 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3ee3b5, #129c78 70%);
  box-shadow: 0 0 10px rgba(45, 212, 167, 0.55);
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--text-dim);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ============================== BUTTONS ================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-weight: 600;
  transition: transform 0.06s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-lg { min-height: 52px; padding: 12px 26px; font-size: 1.05rem; }
.btn-small { min-height: 38px; padding: 6px 12px; font-size: 0.9rem; border-radius: 10px; }

/* ============================== SCREENS ================================== */
#screens {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px calc(var(--tabbar-h) + 24px);
}

.screen { display: none; }
.screen.is-active { display: block; }

.screen-title { margin-bottom: 4px; }
.subtitle { color: var(--text-dim); margin: 0 0 14px; font-size: 0.92rem; }
.block-title { margin: 18px 0 8px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }

/* ============================== CHIPS / SEGMENTS ========================= */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
}

.chip {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-weight: 600;
}
.chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
}
.seg-btn {
  min-height: 42px;
  padding: 8px 12px;
  color: var(--text-dim);
  font-weight: 600;
  border-right: 1px solid var(--border);
}
.seg-btn:last-child { border-right: none; }
.seg-btn.is-active { background: var(--accent); color: var(--accent-ink); }

.tuner-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.field {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 600;
}
.field select, .field input { font-size: 1rem; color: var(--text); }
.field-label { font-size: 0.8rem; color: var(--text-dim); font-weight: 600; }
.flex1 { flex: 1; }

/* ============================== READOUT / GAUGE ========================== */
.readout-panel {
  text-align: center;
  padding: 10px 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  margin-bottom: 12px;
}

.gauge {
  position: relative;
  width: 210px;
  height: 118px;
  margin: 4px auto 6px;
}

.gauge-arc {
  position: absolute;
  inset: 0 auto auto 0;
  width: 210px;
  height: 105px;
  border-radius: 210px 210px 0 0;
  border: 9px solid var(--surface-3);
  border-bottom: none;
}

.gauge-mark {
  position: absolute;
  width: 2px;
  height: 8px;
  background: var(--text-dim);
  top: -2px;
  opacity: 0.9;
}
.gauge-mark-green { left: 50%; transform: translateX(-50%); }
.gauge-mark-amber { left: 20%; transform: translateX(-50%); }
.gauge-mark-red { left: 80%; transform: translateX(-50%); }
[data-theme="light"] .gauge-mark { background: #8b95a3; }

.gauge-needle {
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: 4px;
  height: 78px;
  margin-left: -2px;
  transform-origin: 50% 100%;
  transform: rotate(0deg);
  transition: transform 0.25s cubic-bezier(0.34, 1.4, 0.64, 1);
  background: var(--needle-color, var(--text-dim));
  border-radius: 3px 3px 0 0;
}
.needle-tip {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom: 10px solid var(--needle-color, var(--text-dim));
}

.gauge-hub {
  position: absolute;
  left: 50%;
  bottom: 9px;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
}

.readout-hz {
  font-size: 3.1rem;
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.readout-note {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-dim);
}
.readout-cents { font-size: 1.1rem; font-weight: 600; margin-top: 2px; }
.readout-cue {
  font-size: 0.92rem;
  color: var(--text-dim);
  min-height: 1.4em;
  margin-top: 6px;
}

.status-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.status-led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 6px transparent;
}
.status-led.is-live { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: ledPulse 1.4s ease-in-out infinite; }

@keyframes ledPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ============================== RANGE BAR ================================ */
.range-block { margin-bottom: 12px; }

.range-bar {
  position: relative;
  height: 14px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: visible;
}

.range-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--green-soft);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--green);
}

.range-target {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  background: var(--amber);
  border-radius: 2px;
}

.range-marker {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--needle-color, var(--text-dim));
  border: 3px solid var(--bg);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.range-label-mid { color: var(--amber); font-weight: 700; }

/* ============================== SETTINGS GRID ============================ */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
}
.settings-grid .field { width: 100%; }
.settings-grid input[type="number"] { width: 100%; }
.settings-grid input[type="range"] { width: 100%; min-height: 34px; padding: 0; }
.settings-grid .checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text);
  min-height: 44px;
}
.checkbox input { min-height: auto; }

/* ============================== HISTORY ================================== */
.history-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.history-item {
  flex: 1 1 84px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 6px;
}
.history-item .h-freq { font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.history-item .h-note { font-size: 0.74rem; color: var(--text-dim); }

/* ============================== GENRES =================================== */
.genre-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.genre-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.genre-name { font-weight: 800; font-size: 1.05rem; margin: 0; }
.genre-actions { display: flex; gap: 6px; }
.genre-actions .icon-btn { width: 38px; height: 38px; }

.genre-desc { color: var(--text-dim); font-size: 0.9rem; margin: 6px 0; }
.genre-damping { font-size: 0.85rem; margin: 4px 0 10px; }
.genre-damping strong { color: var(--accent); }

.genre-ranges { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.genre-range-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.genre-range-row strong { color: var(--text); min-width: 58px; }
.genre-range-row input[type="number"] {
  width: 100%;
  min-height: 34px;
  padding: 4px 6px;
  font-size: 0.9rem;
}

/* ============================== LUGS ===================================== */
.lugs-map {
  display: flex;
  justify-content: center;
  margin: 10px 0 6px;
}
.lugs-map svg { max-width: 320px; width: 100%; height: auto; }

.lug-node {
  cursor: default;
}
.lug-node circle {
  fill: var(--surface-3);
  stroke: var(--border);
}
.lug-node text {
  fill: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}
.lug-node.is-current circle { stroke: var(--amber); stroke-width: 3px; fill: var(--amber-soft); }
.lug-node.is-recorded circle { fill: var(--green); stroke: var(--green); }
.lug-node.is-recorded text { fill: var(--accent-ink); }
.lug-node.is-flagged circle { fill: var(--red); stroke: var(--red); }
.lug-node.is-flagged text { fill: #fff; }

.lugs-status {
  text-align: center;
  font-weight: 700;
  min-height: 1.5em;
  margin-bottom: 8px;
}

.lugs-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

.lugs-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
}
.lugs-summary table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.lugs-summary th, .lugs-summary td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--border); }
.lug-ok { color: var(--green); font-weight: 700; }
.lug-warn { color: var(--amber); font-weight: 700; }
.lug-bad { color: var(--red); font-weight: 700; }

.guide {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px 12px 10px;
  font-size: 0.88rem;
  color: var(--text-dim);
}
.guide summary { color: var(--text); font-weight: 600; padding: 8px 0; cursor: pointer; }
.guide ul { margin: 4px 0 6px; padding-left: 18px; }

/* ============================== KIT ====================================== */
.kit-toms { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.kit-tom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
}
.kit-tom-row .tom-index { font-weight: 800; color: var(--text-dim); width: 22px; }

.kit-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.kit-result {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  flex-wrap: wrap;
}
.kit-result .res-name { font-weight: 700; min-width: 110px; }
.kit-result .res-note { font-variant-numeric: tabular-nums; font-weight: 700; margin-left: auto; }
.kit-result.res-out { border-color: var(--amber); background: var(--amber-soft); }
.kit-warning { color: var(--amber); font-size: 0.82rem; width: 100%; }

.kit-save-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 6px;
}
.kit-save-row .field { flex: 1; }

/* ============================== SAVED ==================================== */
.saved-current-row { display: flex; gap: 8px; margin-bottom: 6px; }
.saved-current-row input { flex: 1; }

.saved-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }

.saved-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  flex-wrap: wrap;
}
.saved-item .sv-name { font-weight: 700; flex: 1; min-width: 120px; }
.saved-item .sv-meta { font-size: 0.8rem; color: var(--text-dim); }
.saved-item .sv-actions { display: flex; gap: 6px; }

.backup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.privacy-note { font-size: 0.8rem; color: var(--text-dim); margin-top: 10px; }

/* ============================== LEARN ==================================== */
#learn-content h3 { margin: 16px 0 6px; font-size: 1rem; }
#learn-content p, #learn-content li { font-size: 0.92rem; color: var(--text-dim); }
#learn-content li { margin-bottom: 4px; }

.selftest-result {
  margin-top: 10px;
  font-size: 0.9rem;
  white-space: pre-line;
  color: var(--text-dim);
}
.selftest-result.ok { color: var(--green); }
.selftest-result.fail { color: var(--red); white-space: pre-wrap; }

/* ============================== TAB BAR ================================== */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  max-width: 560px;
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 30;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-dim);
  font-size: 0.66rem;
  font-weight: 600;
}
.tab.is-active { color: var(--accent); }
.tab.is-active svg { filter: drop-shadow(0 0 6px var(--accent)); }

/* ============================== TOAST & GATE ============================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 14px);
  transform: translateX(-50%);
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
}
.toast-actions { display: flex; gap: 8px; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate.hidden { display: none; }

.gate-card {
  max-width: 380px;
  width: 100%;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
}
.gate-logo { margin-bottom: 10px; }
.gate-card h2 { font-size: 1.5rem; margin-bottom: 6px; }
.gate-text { margin: 0 0 6px; }
.gate-sub { font-size: 0.82rem; color: var(--text-dim); margin: 0 0 18px; }
.gate-card .btn { width: 100%; margin-bottom: 8px; }

.noscript {
  position: fixed;
  inset: auto 0 0 0;
  background: var(--red);
  color: #fff;
  padding: 10px;
  text-align: center;
  z-index: 99;
}

/* ============================== MOTION =================================== */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .gauge-needle { transition: none; }
}


/* ===================== CASSETTE-FUTURISM LAYER ===================== */
body {
  font-family: var(--font-display);
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(0deg, rgba(28,26,22,0.035) 0 1px, transparent 1px 3px);
}
h1, h2, .brand-name, .block-title, .tab, .chip, .seg-btn, .btn, .field, .field-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
h1.screen-title {
  display: inline-block;
  background: var(--text);
  color: var(--accent);
  padding: 4px 12px;
  font-size: 1.05rem;
  transform: skewX(-8deg);
}
.subtitle, .sv-meta, .privacy-note { font-family: var(--font-mono); font-size: 0.78rem; }

.topbar {
  background: var(--accent);
  border-bottom: 3px solid var(--border);
  background-image: repeating-linear-gradient(135deg, rgba(28,26,22,0.9) 0 8px, transparent 8px 16px);
  background-size: 100% 6px;
  background-repeat: no-repeat;
  background-position: bottom;
  color: #1c1a16;
}
.brand-name { font-weight: 900; font-size: 1.15rem; color: #1c1a16; }
.brand-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #f4f0e4 0 22%, #1c1a16 24% 40%, #f4f0e4 42% 58%, #1c1a16 60%);
  box-shadow: none;
}
.icon-btn { color: #1c1a16; border: 2px solid #1c1a16; border-radius: 6px; }
.icon-btn:hover { background: #1c1a16; color: var(--accent); }

.btn, .chip, .seg, input, select, .genre-card, .saved-item, .kit-result, .kit-tom-row,
.settings-grid, .readout-panel, .guide, .lugs-summary, .history-item, .gate-card, .toast {
  border: 2px solid var(--border);
}
.btn {
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 3px 3px 0 var(--border);
  font-weight: 800;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--border); }
.btn-primary { background: var(--accent); color: #1c1a16; border: 2px solid var(--border); }
.btn-danger { background: var(--surface); color: var(--red); border: 2px solid var(--red); box-shadow: 3px 3px 0 var(--red); }
.btn-ghost { box-shadow: none; }

input, select { border-radius: 4px; background: var(--surface); font-family: var(--font-mono); }
.chip { border-radius: 6px; background: var(--surface); box-shadow: 2px 2px 0 var(--border); color: var(--text); }
.chip.is-active { background: var(--accent); color: #1c1a16; border-color: var(--border); box-shadow: inset 2px 2px 0 rgba(28,26,22,0.35); }
.seg { border-radius: 6px; background: var(--surface-2); }
.seg-btn { color: var(--text); border-right: 2px solid var(--border); }
.seg-btn.is-active { background: var(--text); color: var(--accent); }

.genre-card, .saved-item, .kit-result, .kit-tom-row, .settings-grid, .readout-panel,
.guide, .lugs-summary, .history-item, .gate-card {
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.genre-name { font-weight: 900; }
.genre-card { position: relative; border-top-width: 10px; border-top-color: var(--accent); }

/* Readout = LCD cassette deck display */
.readout-panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), transparent 40%),
    var(--lcd);
  color: var(--lcd-ink);
  font-family: var(--font-mono);
  position: relative;
}
.readout-panel::before {
  content: "DRUMPITCH  ///  FUNDAMENTAL";
  display: block;
  text-align: left;
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  padding: 0 8px 4px;
  border-bottom: 1px dashed rgba(38,48,26,0.5);
  margin-bottom: 6px;
  opacity: 0.75;
}
.readout-panel::after {
  content: "";
  position: absolute; inset: 0; border-radius: 6px; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.07) 0 1px, transparent 1px 3px);
}
.readout-hz { font-family: var(--font-mono); font-weight: 900; text-shadow: 2px 2px 0 rgba(38,48,26,0.18); }
.readout-note, .readout-cue, .status-line { color: var(--lcd-ink); opacity: 0.85; }
.gauge-arc { border-color: rgba(38,48,26,0.35); }
.gauge-mark { background: var(--lcd-ink); }
.gauge-hub { background: #1c1a16; border-color: var(--lcd); }
.gauge-needle { background: var(--needle-color, #1c1a16); }
.needle-tip { border-bottom-color: var(--needle-color, #1c1a16); }
.status-led.is-live { background: var(--red); box-shadow: 0 0 8px var(--red); }
.status-led { background: rgba(38,48,26,0.5); }
.readout-panel .btn { background: var(--accent); }

.range-bar { background: var(--surface-2); border: 2px solid var(--border); border-radius: 4px; height: 18px; }
.range-band { border-radius: 2px; background: var(--accent); box-shadow: none; opacity: 0.85; }
.range-target { background: var(--text); }
.range-marker { border-color: var(--surface); box-shadow: 0 0 0 2px var(--border); }
.range-label-mid { color: var(--text); }

/* Tab bar: cassette deck transport keys */
.tabbar {
  background: var(--surface-3);
  border-top: 3px solid var(--border);
  gap: 4px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  height: var(--tabbar-h);
}
.tab {
  border: 2px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
  box-shadow: 2px 2px 0 var(--border);
  font-size: 0.58rem; font-weight: 800;
}
.tab.is-active { background: var(--accent); color: #1c1a16; box-shadow: inset 2px 2px 0 rgba(28,26,22,0.35); transform: translate(1px, 1px); }
.tab.is-active svg { filter: none; }

.lug-node circle { fill: var(--surface); stroke: var(--border); stroke-width: 2px; }
.lug-node.is-current circle { fill: var(--accent); stroke: var(--border); stroke-width: 3px; }
.lug-node.is-recorded circle { fill: var(--green); stroke: var(--border); }
.lug-node.is-recorded text { fill: #fff; }
.lug-node.is-flagged circle { fill: var(--red); stroke: var(--border); }
.rim-outer { fill: var(--surface-2); stroke: var(--border); stroke-width: 3px; }

.gate { background: var(--bg); background-image: repeating-linear-gradient(135deg, rgba(28,26,22,0.06) 0 10px, transparent 10px 20px); }
.gate-card { border-top: 14px solid var(--accent); }
.toast { background: var(--accent); color: #1c1a16; border-radius: 6px; box-shadow: var(--shadow); font-weight: 700; }
.guide summary { text-transform: uppercase; letter-spacing: 0.06em; }
.lugs-summary th, .lugs-summary td { border-bottom: 1px solid var(--border); }
[data-theme="light"] .gauge-mark { background: var(--lcd-ink); }
