/* ============================================================
   StrobeTuner — modern, elegant, mobile-first UI
   Modern light theme with optional dark mode auto-switch
   ============================================================ */

/* ---- Design tokens ---- */
:root {
  /* Surfaces (light) */
  --bg-0:      #f6f7f9;
  --bg-1:      #ffffff;
  --bg-2:      #f1f3f6;
  --bg-3:      #e7eaf0;

  /* Lines & shadows */
  --line:        rgba(15, 23, 42, 0.06);
  --line-strong: rgba(15, 23, 42, 0.10);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.6) inset, 0 1px 2px rgba(15,23,42,0.04), 0 8px 24px rgba(15,23,42,0.06);
  --shadow-soft: 0 2px 8px rgba(15,23,42,0.05);
  --shadow-pop:  0 4px 16px rgba(15,23,42,0.08);

  /* Accents */
  --accent:      #2563eb;
  --accent-2:    #10b981;
  --accent-3:    #f59e0b;
  --warn:        #ef4444;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --good-soft:   rgba(16, 185, 129, 0.10);
  --warn-soft:   rgba(239, 68, 68, 0.10);
  --amber-soft:  rgba(245, 158, 11, 0.10);

  /* Glows */
  --glow-good:   0 0 24px rgba(16, 185, 129, 0.25);
  --glow-bad:    0 0 24px rgba(239, 68, 68, 0.20);
  --glow-amber:  0 0 18px rgba(245, 158, 11, 0.22);
  --glow-blue:   0 0 18px rgba(37, 99, 235, 0.20);

  /* Text */
  --text:   #0f172a;
  --text-2: #475569;
  --dim:    #64748b;
  --faint:  #94a3b8;

  /* Radii */
  --r-sm:   8px;
  --r:      14px;
  --r-lg:   20px;
  --r-pill: 999px;

  /* Motion */
  --ease:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast:  140ms;
  --t:       220ms;
  --t-slow:  420ms;

  /* Type scale */
  --fs-display: clamp(96px, 22vw, 160px);
  --fs-octave:  clamp(20px, 4.5vw, 32px);
  --fs-cents:   clamp(36px, 7vw, 56px);
  --fs-status:  clamp(13px, 2.4vw, 15px);
  --fs-btn:     15px;
  --fs-label:   11px;

  /* Layout */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* Auto dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-0:      #0b1020;
    --bg-1:      #131a2c;
    --bg-2:      #1a2238;
    --bg-3:      #232c44;
    --line:        rgba(255,255,255,0.06);
    --line-strong: rgba(255,255,255,0.10);
    --shadow-card: 0 1px 0 rgba(255,255,255,0.04) inset, 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.5);
    --shadow-soft: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-pop:  0 4px 16px rgba(0,0,0,0.4);
    --accent-soft: rgba(96, 165, 250, 0.16);
    --good-soft:   rgba(52, 211, 153, 0.18);
    --warn-soft:   rgba(248, 113, 113, 0.18);
    --amber-soft:  rgba(251, 191, 36, 0.18);
    --text:   #f1f5f9;
    --text-2: #cbd5e1;
    --dim:    #94a3b8;
    --faint:  #64748b;
    --accent:      #60a5fa;
    --accent-2:    #34d399;
    --accent-3:    #fbbf24;
    --warn:        #f87171;
  }
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: "ss01", "cv11", "tnum";
  background: var(--bg-0);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
}

button { font-family: inherit; cursor: pointer; }
input  { font-family: inherit; }

/* ---- App shell ---- */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-top:    var(--safe-t);
  padding-bottom: var(--safe-b);
}

/* ---- Top bar ---- */
/* Topbar: two-row layout on mobile (brand+mic row, modes row below) */
.topbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 12px;
  align-items: center;
  padding: 10px clamp(14px, 4vw, 24px) 8px;
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text-2); min-width: 0; }
.brand h1 {
  font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin: 0;
  color: var(--text);
}
.brand .logo {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 70%, white));
  color: #fff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

/* Top-right cluster: mic button */
.topbar-end {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

/* Mic button (prominent, in topbar) */
.mic-btn {
  appearance: none; border: 0;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px 8px 8px;
  border-radius: var(--r-pill);
  background: var(--bg-1);
  color: var(--text-2);
  border: 1px solid var(--line-strong);
  font-size: 13px; font-weight: 700; letter-spacing: 0.1px;
  min-height: 40px;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  box-shadow: var(--shadow-soft);
}
.mic-btn:active { transform: scale(0.97); }
.mic-btn:hover  { background: var(--bg-2); }
.mic-dot {
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--bg-3);
  color: var(--dim);
  transition: background var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.mic-dot svg { width: 12px; height: 12px; }
.mic-btn.active {
  background: var(--accent-2);
  color: #ffffff;
  border-color: var(--accent-2);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.30);
}
.mic-btn.active .mic-dot {
  background: rgba(255,255,255,0.2);
  color: #ffffff;
  animation: micpulse 1.6s var(--ease-io) infinite;
}
.mic-btn .mic-label {
  display: inline-block;
  white-space: nowrap;
}
@keyframes micpulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0.45); }
  70%  { box-shadow: 0 0 0 10px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

/* Hide mic label on very narrow screens to save space */
@media (max-width: 380px) {
  .mic-btn .mic-label { display: none; }
  .mic-btn { padding: 8px; }
}

/* Segmented mode control — full-width row on mobile */
.modes {
  grid-column: 1 / -1;
  display: flex;
  padding: 3px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-soft);
}
.mode-btn {
  appearance: none; border: 0; background: transparent;
  color: var(--dim);
  font-size: 13px; font-weight: 600; letter-spacing: 0.1px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  min-height: 32px;
  flex: 1 1 0;
  text-align: center;
}
.mode-btn:hover { color: var(--text-2); }
.mode-btn:active { transform: scale(0.97); }
.mode-btn.active {
  background: var(--bg-1);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}

/* ---- Stage (hero) ---- */
.stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px clamp(14px, 4vw, 24px) 16px;
  display: flex; flex-direction: column; gap: 14px;
}

/* Readout: note name is the focal point */
.readout {
  display: flex; align-items: baseline; justify-content: center;
  gap: 6px;
  padding: clamp(8px, 2vw, 16px) 0 4px;
  text-align: center;
}
.note-name {
  font-size: var(--fs-display);
  line-height: 0.9;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: color var(--t) var(--ease);
  will-change: color;
}
.note-name.good { color: var(--accent-2); }
.note-name.close{ color: var(--accent-3); }
.note-name.off  { color: var(--warn); }
.note-octave {
  font-size: var(--fs-octave);
  font-weight: 600;
  color: var(--dim);
  align-self: flex-start;
  transform: translateY(-0.2em);
}
.target-note { position: absolute; }

/* Strobe band */
.strobe-wrap {
  position: relative;
  height: clamp(40px, 7vh, 56px);
  border-radius: var(--r);
  background: var(--bg-1);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.strobe { display: block; width: 100%; height: 100%; }
.strobe-center-line {
  position: absolute; left: 50%; top: 0; bottom: 0; width: 2px;
  margin-left: -1px;
  background: linear-gradient(180deg, transparent, rgba(15,23,42,0.18), transparent);
  pointer-events: none;
}
@media (prefers-color-scheme: dark) {
  .strobe-center-line {
    background: linear-gradient(180deg, transparent, rgba(255,255,255,0.22), transparent);
  }
}

/* Meter card */
.meter-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(10px, 2vw, 16px);
  display: flex; flex-direction: column; gap: clamp(10px, 1.6vw, 14px);
  box-shadow: var(--shadow-card);
}
.gauge-wrap {
  position: relative; width: 100%;
  height: clamp(150px, 22vh, 200px);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.needle { display: block; width: 100%; height: 100%; }

.meter-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: clamp(12px, 2.4vw, 20px);
  align-items: center;
  padding-top: clamp(8px, 1.4vw, 12px);
  border-top: 1px solid var(--line);
}
.cents-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cents-readout {
  font-size: var(--fs-cents);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1;
  transition: color var(--t) var(--ease);
}
.cents-readout.good  { color: var(--accent-2); }
.cents-readout.close { color: var(--accent-3); }
.cents-readout.off   { color: var(--warn); }
.cents-sub {
  font-size: var(--fs-label);
  color: var(--dim);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.vu-cell { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.vu-label {
  font-size: var(--fs-label);
  color: var(--dim);
  font-weight: 700;
  letter-spacing: 1.4px;
}
.vu-track {
  position: relative;
  height: clamp(14px, 2.4vw, 20px);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.vu-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg,
    var(--accent-2) 0%, var(--accent-2) 55%,
    var(--accent-3) 75%, var(--warn) 100%);
  transition: width 60ms linear, opacity var(--t) var(--ease);
  border-radius: inherit;
}
.vu-peak {
  position: absolute; top: 0; bottom: 0; width: 2px; left: 0%;
  background: var(--text); box-shadow: 0 0 6px rgba(15,23,42,0.4);
  transition: left 250ms var(--ease-io), opacity var(--t) var(--ease);
  opacity: 0.85;
}
@media (prefers-color-scheme: dark) {
  .vu-peak { background: #fff; box-shadow: 0 0 6px rgba(255,255,255,0.55); }
}
.vu-scale {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--faint);
  font-weight: 600; letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
}

/* In-tune indicator */
.in-tune-indicator {
  align-self: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--dim);
  transition: color var(--t) var(--ease), background var(--t) var(--ease), border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.in-tune-indicator.good  {
  color: var(--accent-2); background: var(--good-soft);
  border-color: color-mix(in oklab, var(--accent-2) 30%, transparent);
  box-shadow: var(--glow-good);
}
.in-tune-indicator.close {
  color: var(--accent-3); background: var(--amber-soft);
  border-color: color-mix(in oklab, var(--accent-3) 30%, transparent);
  box-shadow: var(--glow-amber);
}
.in-tune-indicator.off   {
  color: var(--warn); background: var(--warn-soft);
  border-color: color-mix(in oklab, var(--warn) 30%, transparent);
  box-shadow: var(--glow-bad);
}

/* Mode panel */
.mode-panel { display: flex; flex-direction: column; gap: 12px; }
.mode-panel.hidden { display: none; }
.panel-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; gap: 14px;
}
.panel-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.panel-actions {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.panel-hint {
  font-size: 12px; color: var(--dim); line-height: 1.4;
}

.field, .panel-row label.field {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 130px;
}
.field-label {
  font-size: var(--fs-label); color: var(--dim);
  font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
}
select.field-select, input.field-input {
  appearance: none; -webkit-appearance: none;
  width: 100%;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: var(--fs-btn); font-weight: 600;
  min-height: 44px;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
select.field-select:focus, input.field-input:focus {
  outline: none; border-color: var(--accent); background: var(--bg-1);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select.field-select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
                    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

input[type="range"] {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 6px;
  background: var(--bg-3); border-radius: var(--r-pill);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg-1);
  box-shadow: 0 0 0 1px var(--line-strong), 0 4px 10px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease);
}
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.1); }
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg-1);
  box-shadow: 0 0 0 1px var(--line-strong), 0 4px 10px rgba(0,0,0,0.15);
  cursor: pointer;
}

.action-btn {
  appearance: none; border: 1px solid var(--line-strong);
  background: var(--bg-2); color: var(--text);
  font-size: var(--fs-btn); font-weight: 600;
  padding: 10px 16px; border-radius: var(--r-pill);
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.action-btn:hover { background: var(--bg-3); }
.action-btn:active { transform: scale(0.97); }
.action-btn .ic { width: 16px; height: 16px; flex-shrink: 0; }
.action-btn.active {
  background: var(--accent-2); color: #ffffff; border-color: var(--accent-2);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}
.action-btn.warn { border-color: color-mix(in oklab, var(--warn) 35%, transparent); color: var(--warn); }
.action-btn.warn.active { background: var(--warn); color: #ffffff; border-color: var(--warn); box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25); }

.match-stats {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px;
  font-size: 13px; color: var(--text-2);
}
.match-stats .stat {
  display: inline-flex; align-items: baseline; gap: 8px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.match-stats .v {
  font-weight: 700; color: var(--text); font-size: 15px;
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.match-stats .v.good { color: var(--accent-2); }
.match-stats .v.warn { color: var(--warn); }
.match-stats .k {
  font-size: var(--fs-label); color: var(--dim);
  font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
}
.rec-tag {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--warn); font-size: 12px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 8px 12px;
  background: var(--warn-soft);
  border: 1px solid color-mix(in oklab, var(--warn) 25%, transparent);
  border-radius: var(--r-pill);
}
.rec-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn); box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
  animation: recblink 1s steps(2, end) infinite;
}
@keyframes recblink { 50% { opacity: 0.25; } }

.chart-wrap {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px;
  box-shadow: var(--shadow-card);
}
.chart-legend {
  font-size: var(--fs-label); color: var(--dim);
  font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  margin-bottom: 6px;
}

/* ---- Settings ---- */
.settings {
  flex: 0 0 auto;
  margin: 0 clamp(14px, 4vw, 24px);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.settings > summary {
  list-style: none; cursor: pointer;
  padding: 12px 16px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.2px;
  color: var(--text-2);
  display: flex; align-items: center; justify-content: space-between;
  user-select: none;
  transition: background var(--t-fast) var(--ease);
}
.settings > summary:hover { background: var(--bg-2); }
.settings > summary::-webkit-details-marker { display: none; }
.settings > summary::after {
  content: ""; width: 10px; height: 10px;
  border-right: 2px solid var(--text-2);
  border-bottom: 2px solid var(--text-2);
  transform: rotate(45deg) translateY(-3px);
  transition: transform var(--t) var(--ease);
}
.settings[open] > summary::after {
  transform: rotate(-135deg) translateY(-3px);
}
.settings-body {
  display: flex; flex-direction: column; gap: 14px;
  padding: 6px 16px 16px;
  border-top: 1px solid var(--line);
}
.settings-row {
  display: flex; flex-direction: column; gap: 8px;
}
.settings-label {
  font-size: var(--fs-label); color: var(--dim);
  font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
}

.profile-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.profile-btn {
  appearance: none; border: 1px solid var(--line-strong);
  background: var(--bg-2); color: var(--text-2);
  font-size: var(--fs-btn); font-weight: 600;
  padding: 10px 16px; border-radius: var(--r-pill);
  min-height: 40px;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.profile-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--bg-3); }
.profile-btn:active { transform: scale(0.97); }
.profile-btn.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.reference-editor { display: flex; flex-direction: column; gap: 10px; }
.ref-field { display: flex; flex-direction: column; gap: 6px; }

.a4-control {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  padding: 4px 12px 4px 4px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.a4-control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.a4-control input {
  width: 72px; background: transparent; border: 0; outline: none;
  color: var(--text); font-size: 16px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 8px 6px;
}
.a4-control span { color: var(--dim); font-size: 12px; font-weight: 600; }

/* ---- Status bar (replaces bottom dock) ---- */
.statusbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px clamp(14px, 4vw, 24px) calc(10px + var(--safe-b));
  font-size: var(--fs-status); color: var(--dim); line-height: 1.35;
}
.statusbar .status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--faint);
  transition: background var(--t) var(--ease), box-shadow var(--t) var(--ease);
  flex-shrink: 0;
}
.statusbar.live .status-dot {
  background: var(--accent-2);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.55);
  animation: statuspulse 1.8s var(--ease-io) infinite;
}
@keyframes statuspulse {
  0%   { box-shadow: 0 0 0 0   rgba(16, 185, 129, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0   rgba(16, 185, 129, 0); }
}

/* ---- Responsive: tablet ---- */
@media (min-width: 600px) {
  .stage { padding-left: clamp(20px, 4vw, 32px); padding-right: clamp(20px, 4vw, 32px); gap: 18px; }
  .settings-row { flex-direction: row; align-items: center; gap: 16px; }
  .reference-editor { flex-direction: row; gap: 14px; }
  .ref-field { flex: 1; }
  .profile-buttons { flex-wrap: nowrap; }
  .panel-actions { gap: 10px; }

  /* On tablet+, modes shrink to inline pill next to brand */
  .topbar { grid-template-columns: auto 1fr auto; gap: 10px 12px; }
  .modes {
    grid-column: 2 / 3;
    justify-self: center;
    display: inline-flex;
    width: auto;
  }
  .mode-btn { flex: 0 0 auto; }
}

/* ---- Responsive: desktop ---- */
@media (min-width: 900px) {
  #app { max-width: 880px; margin: 0 auto; }
  .meter-row { grid-template-columns: 1fr 1.6fr; gap: 28px; }
  .mode-panel { max-width: 720px; align-self: center; width: 100%; }
}

/* ---- Motion preferences ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
