/* ===================================================================== Themes */
:root,
[data-theme='neon'] {
  --bg: #070a17;
  --bg-2: #0d1226;
  --panel: rgba(20, 26, 52, 0.82);
  --panel-solid: #141a34;
  --panel-border: rgba(120, 140, 255, 0.18);
  --text: #e8ecff;
  --muted: #8d96c2;
  --accent: #22d3ee;
  --accent-2: #a855f7;
  --good: #34d399;
  --bad: #fb4d6d;
  --warn: #fbbf24;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --glow: 0 0 18px rgba(34, 211, 238, 0.45);

  --stage-top: #070a17;
  --stage-bottom: #10163a;
  --lane-black: rgba(255, 255, 255, 0.025);
  --lane-c: rgba(34, 211, 238, 0.22);
  --lane-f: rgba(255, 255, 255, 0.06);
  --grid-bar: rgba(168, 85, 247, 0.28);
  --grid-beat: rgba(255, 255, 255, 0.05);
  --hit-line: #a855f7;
  --note-label: rgba(5, 8, 20, 0.85);
  --note-sat: 85;
  --note-light: 62;
  --note-light-black: 48;

  --key-bed: #05070f;
  --key-felt: #7c2d3b;
  --key-white: #f7f8ff;
  --key-white-top: #dfe3f5;
  --key-black: #0b0d18;
  --key-black-top: #2a2f4a;
  --key-border: #9aa2c4;
  --key-label: #8790b5;
  --key-label-active: #0b1020;

  --sheet-bg: #f8f6ef;
  --sheet-line: #6b6f80;
  --sheet-note: #151827;
  color-scheme: dark;
}

[data-theme='light'] {
  --bg: #eef1f8;
  --bg-2: #ffffff;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --panel-border: rgba(30, 41, 80, 0.12);
  --text: #141a33;
  --muted: #5d6585;
  --accent: #2563eb;
  --accent-2: #9333ea;
  --good: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --shadow: 0 8px 24px rgba(30, 41, 80, 0.12);
  --glow: 0 0 12px rgba(37, 99, 235, 0.3);

  --stage-top: #f5f7ff;
  --stage-bottom: #dde3f5;
  --lane-black: rgba(20, 30, 70, 0.04);
  --lane-c: rgba(37, 99, 235, 0.25);
  --lane-f: rgba(20, 30, 70, 0.07);
  --grid-bar: rgba(147, 51, 234, 0.25);
  --grid-beat: rgba(20, 30, 70, 0.06);
  --hit-line: #9333ea;
  --note-label: rgba(255, 255, 255, 0.95);
  --note-sat: 75;
  --note-light: 50;
  --note-light-black: 38;

  --key-bed: #1d2235;
  --key-felt: #9f1239;
  --key-white: #ffffff;
  --key-white-top: #e9ecf6;
  --key-black: #12141f;
  --key-black-top: #3a3f58;
  --key-border: #aab1cc;
  --key-label: #7b84a6;
  --key-label-active: #0b1020;

  --sheet-bg: #ffffff;
  --sheet-line: #6b6f80;
  --sheet-note: #151827;
  color-scheme: light;
}

/* ===================================================================== Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(168, 85, 247, 0.16), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(34, 211, 238, 0.12), transparent 60%),
    var(--bg);
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

h1, h2, h3 { margin: 0 0 0.4rem; line-height: 1.2; }
h1 { font-size: clamp(1.4rem, 2.6vw, 2rem); }
h2 { font-size: clamp(1.15rem, 2vw, 1.4rem); }
h3 { font-size: 1rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 0.3rem 0 0.8rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }
.accent-text { color: var(--accent); text-shadow: var(--glow); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }

svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ===================================================================== Controls */
button, select, input { font: inherit; color: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel-solid);
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.08s ease, box-shadow 0.2s ease, background 0.2s ease;
  touch-action: manipulation;
  user-select: none;
}
.btn:hover { box-shadow: var(--glow); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; }
.btn-small { min-height: 34px; padding: 0.3rem 0.7rem; font-size: 0.85rem; border-radius: 10px; }
.btn-big { min-height: 54px; font-size: 1.1rem; padding: 0.7rem 1.6rem; margin-top: 0.6rem; }
.btn.danger, .icon-btn.danger { color: var(--bad); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel-solid);
  cursor: pointer;
  touch-action: manipulation;
}
.icon-btn:hover { box-shadow: var(--glow); }

select, input[type='text'] {
  min-height: 44px;
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--bg-2);
  width: 100%;
}

input[type='range'] { width: 100%; accent-color: var(--accent); min-height: 32px; }

label { display: flex; flex-direction: column; gap: 0.3rem; margin: 0.5rem 0; font-size: 0.92rem; }
label output { color: var(--accent); font-weight: 700; }

.switch { flex-direction: row; align-items: center; gap: 0.7rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .slider {
  position: relative;
  width: 46px;
  height: 26px;
  flex: none;
  border-radius: 99px;
  background: var(--panel-border);
  transition: background 0.2s;
}
.switch .slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::after { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.6rem; }

/* ===================================================================== Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--panel-border);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 1.2rem; white-space: nowrap; }

.tabs { display: flex; gap: 0.25rem; margin: 0 auto; }
.tab {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 42px;
  padding: 0.4rem 0.85rem;
  border-radius: 12px;
  border: 1px solid transparent;
  background: none;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.tab:hover { color: var(--text); }
.tab span { white-space: nowrap; }
.tab.active { color: var(--text); background: var(--panel-solid); border-color: var(--panel-border); box-shadow: var(--glow); }
.tab.active svg { color: var(--accent); }

.top-actions { display: flex; align-items: center; gap: 0.5rem; }
.mic-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.65rem;
  border-radius: 12px;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  min-height: 44px;
}
.mic-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.mic-status.on .mic-dot { background: var(--good); box-shadow: 0 0 10px var(--good); animation: pulse 1.6s infinite; }
.mic-note { min-width: 2.6em; font-weight: 800; font-variant-numeric: tabular-nums; text-align: center; }
.meter { width: 54px; height: 6px; border-radius: 3px; background: var(--panel-border); overflow: hidden; }
.meter div { height: 100%; width: 0; background: linear-gradient(90deg, var(--good), var(--warn), var(--bad)); transition: width 0.05s linear; }
.btn-mic.on { background: linear-gradient(135deg, var(--good), var(--accent)); color: #04121a; border: none; }

@keyframes pulse { 50% { opacity: 0.45; } }

.banner { padding: 0.6rem 1rem; background: rgba(251, 191, 36, 0.15); border-bottom: 1px solid var(--warn); color: var(--text); font-size: 0.9rem; }

/* ===================================================================== Views */
main { flex: 1; min-height: 0; position: relative; }
.view { display: none; height: 100%; overflow: auto; padding: 1rem clamp(0.75rem, 2.5vw, 2rem) 1.5rem; -webkit-overflow-scrolling: touch; }
.view.active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.view-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; }
.section-title { margin-top: 2rem; }
.profile-chip { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.5rem 0.4rem 0.9rem; border-radius: 14px; background: var(--panel); border: 1px solid var(--panel-border); flex-wrap: wrap; }

/* Song catalogue */
.song-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 0.9rem; }
.song-card {
  position: relative;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--panel-border);
  background: linear-gradient(160deg, var(--panel), color-mix(in srgb, var(--accent-2) 10%, var(--panel)));
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s;
  min-height: 140px;
}
.song-card:hover { transform: translateY(-3px); box-shadow: var(--shadow), var(--glow); }
.song-card h3 { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 1.1rem; margin: 0; padding-right: 2rem; }
.song-card .meta { display: flex; flex-wrap: wrap; gap: 0.4rem; font-size: 0.8rem; color: var(--muted); margin-top: auto; }
.song-card .pill { padding: 0.15rem 0.5rem; border-radius: 99px; background: var(--panel-border); }
.song-card .best { color: var(--warn); font-weight: 700; font-size: 0.85rem; }
.song-card .del { position: absolute; top: 0.6rem; right: 0.6rem; width: 34px; height: 34px; }
.diff { color: var(--accent); letter-spacing: 2px; }

.midi-drop {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem;
  margin-bottom: 1rem;
  border: 2px dashed var(--panel-border);
  border-radius: 18px;
  transition: border-color 0.2s, background 0.2s;
}
.midi-drop.drag { border-color: var(--accent); background: rgba(34, 211, 238, 0.08); }

/* ===================================================================== Play view */
#view-play.active { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.play-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 0.5rem clamp(0.5rem, 2vw, 1rem);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--panel-border);
}
.song-title { display: flex; flex-direction: column; min-width: 0; flex: 1 1 140px; }
.song-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-title small { font-size: 0.8rem; }
.controls { display: flex; gap: 0.4rem; }
.tempo { display: flex; flex-direction: column; min-width: 150px; flex: 0 1 220px; }
.tempo label { margin: 0; flex-direction: row; gap: 0.3rem; font-size: 0.85rem; }
.tempo input { min-height: 26px; }
.toggles { display: flex; align-items: center; gap: 0.8rem; }
.toggles .switch { margin: 0; font-size: 0.9rem; white-space: nowrap; }
.toggles select { width: auto; min-height: 40px; }

.hud {
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 2vw, 1.6rem);
  padding: 0.35rem clamp(0.5rem, 2vw, 1rem);
  position: relative;
  font-variant-numeric: tabular-nums;
}
.stat { display: flex; flex-direction: column; line-height: 1.1; }
.stat span { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat b { font-size: clamp(1rem, 2.4vw, 1.4rem); }
.stat.target b { color: var(--accent); text-shadow: var(--glow); }
.stat.streak-hot b { color: var(--warn); }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--panel-border); }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.stage { position: relative; flex: 1; min-height: 0; touch-action: none; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-overlay {
  position: absolute;
  inset: 0 0 30% 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.stage-overlay .overlay-card {
  pointer-events: auto;
  text-align: center;
  padding: 1.2rem 1.6rem;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow), var(--glow);
  max-width: min(92%, 420px);
}
.stage-overlay.compact .overlay-card { padding: 0.5rem 1rem; display: flex; align-items: center; gap: 0.8rem; }
.stage-overlay.compact .overlay-card h2 { margin: 0; font-size: 1rem; }
.stage-overlay.compact .overlay-card p { display: none; }
.stage-overlay.compact .overlay-card .btn-big { margin: 0; min-height: 44px; font-size: 1rem; padding: 0.4rem 1.2rem; }
.rotate-hint {
  display: none;
  position: absolute;
  top: 0.6rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.35rem 0.8rem;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 0.8rem;
  white-space: nowrap;
  pointer-events: none;
}
.rotate-hint.show { display: block; }

/* ===================================================================== Calibration */
.calib-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.calib-layout > .card:last-child { grid-column: 1 / -1; }
.steps { display: flex; gap: 0.4rem; list-style: none; padding: 0; margin: 0 0 1rem; counter-reset: s; flex-wrap: wrap; }
.steps li { counter-increment: s; flex: 1; min-width: 70px; padding: 0.4rem 0.5rem; border-radius: 10px; background: var(--panel-border); color: var(--muted); font-size: 0.85rem; font-weight: 600; text-align: center; }
.steps li::before { content: counter(s) '. '; }
.steps li.current { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.steps li.done { color: var(--good); }
.calib-step { display: none; }
.calib-step.active { display: block; animation: fade 0.25s ease; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.bar { height: 12px; border-radius: 6px; background: var(--panel-border); overflow: hidden; margin: 1rem 0; }
.bar div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.1s linear; }
.big-note {
  font-size: clamp(3.5rem, 12vw, 6rem);
  font-weight: 900;
  text-align: center;
  color: var(--accent);
  text-shadow: var(--glow);
  line-height: 1.1;
  margin: 0.3rem 0;
}
.calib-status { text-align: center; font-weight: 600; min-height: 1.5em; }
.calib-status.listening { color: var(--accent); }
.calib-status.good { color: var(--good); }
.calib-status.bad { color: var(--bad); }
.calib-list { list-style: none; padding: 0; margin: 0.6rem 0; display: grid; gap: 0.3rem; }
.calib-list li { display: flex; gap: 0.8rem; padding: 0.35rem 0.6rem; border-radius: 10px; background: var(--panel-border); font-variant-numeric: tabular-nums; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.5rem; margin: 0.6rem 0; }
.result-grid div { display: flex; flex-direction: column; padding: 0.5rem 0.7rem; border-radius: 12px; background: var(--panel-border); }
.result-grid span { font-size: 0.75rem; color: var(--muted); }
.advice { padding-left: 1.2rem; color: var(--muted); }
.live-note { display: flex; align-items: baseline; gap: 0.8rem; }
.live-note b { font-size: 2.2rem; color: var(--accent); }
.tuner-canvas { width: 100%; height: 150px; display: block; }
.harm-canvas { width: 100%; height: 110px; display: block; margin-bottom: 0.6rem; }
.mini-keyboard { width: 100%; height: 90px; display: block; border-radius: 8px; }
.profile-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 0.5rem; }
.profile-list li { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.6rem 0.8rem; border-radius: 12px; border: 1px solid var(--panel-border); }
.profile-list li.active { border-color: var(--accent); box-shadow: var(--glow); }
.profile-list li > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.profile-list small { color: var(--muted); }
.profile-list .row-actions { margin: 0; flex-wrap: nowrap; }

/* ===================================================================== Free play */
#view-free.active { display: flex; flex-direction: column; padding-bottom: 0; }
.free-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr); gap: 1rem; flex: 1; min-height: 0; }
.tuner-readout { display: flex; align-items: baseline; gap: 0.8rem; }
.tuner-readout b { font-size: clamp(2.4rem, 6vw, 3.4rem); color: var(--accent); text-shadow: var(--glow); }
.spectrum-canvas { width: 100%; height: 160px; display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; max-height: 170px; overflow: auto; }
.chips span { padding: 0.25rem 0.6rem; border-radius: 99px; background: var(--panel-border); font-weight: 700; font-size: 0.9rem; animation: fade 0.2s; }
.chips span.touch { color: var(--accent-2); }
.free-kb-bar { display: flex; justify-content: center; align-items: center; gap: 1rem; padding: 0.6rem 0; }
.free-keyboard { width: 100%; height: clamp(110px, 26vh, 220px); display: block; flex: none; touch-action: none; border-radius: 10px 10px 0 0; }

/* ===================================================================== Settings */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 1rem; }

/* ===================================================================== Dialogs / toast */
.dialog {
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: var(--shadow), var(--glow);
  padding: 1.4rem;
  width: min(94vw, 480px);
  max-height: 90vh;
}
.dialog::backdrop { background: rgba(3, 5, 12, 0.6); backdrop-filter: blur(4px); }
.dialog h2 { text-align: center; }
.stars { text-align: center; font-size: 2.6rem; letter-spacing: 0.3rem; color: var(--warn); text-shadow: 0 0 16px rgba(251, 191, 36, 0.6); }
.stars .off { color: var(--panel-border); text-shadow: none; }
.record { text-align: center; font-weight: 800; color: var(--warn); font-size: 1.2rem; }
.track-list { display: grid; gap: 0.3rem; max-height: 40vh; overflow: auto; margin: 0.5rem 0; }
.track-list label { flex-direction: row; align-items: center; gap: 0.6rem; margin: 0; padding: 0.4rem 0.6rem; border-radius: 10px; background: var(--panel-border); }
.track-list input { width: 20px; height: 20px; accent-color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.2rem + env(safe-area-inset-bottom));
  transform: translate(-50%, 150%);
  padding: 0.7rem 1.1rem;
  border-radius: 14px;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s;
  z-index: 100;
  max-width: 92vw;
  text-align: center;
  opacity: 0;
  visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

/* ===================================================================== Account & Premium */
.pro-badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #1b1200;
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
  vertical-align: middle;
}
.premium-tag { font-size: 0.7rem; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 99px; background: rgba(245, 158, 11, 0.18); color: var(--warn); vertical-align: middle; }
.song-card.locked { opacity: 0.8; }
.song-card.locked:hover { opacity: 1; }
.song-card .lock { position: absolute; top: 0.7rem; right: 0.8rem; font-size: 1.1rem; }
.premium-pill { color: var(--warn); }

.account-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 1rem; align-items: start; margin-bottom: 1rem; }
.premium-card { border-color: rgba(245, 158, 11, 0.45); background: linear-gradient(160deg, var(--panel), color-mix(in srgb, #f59e0b 9%, var(--panel))); }
.premium-status { font-weight: 800; font-size: 1.05rem; margin: 0.2rem 0; }
.user-row { display: flex; align-items: center; gap: 0.8rem; margin: 0.4rem 0 0.8rem; }
.avatar { width: 52px; height: 52px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 1.4rem; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.user-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-row { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; padding: 0.5rem 0.7rem; border-radius: 12px; background: var(--panel-border); font-size: 0.9rem; flex-wrap: wrap; }
.feature-list { list-style: none; padding: 0; margin: 0.6rem 0 1rem; display: grid; gap: 0.4rem; }
.feature-list li::before { content: '✓'; color: var(--good); font-weight: 800; margin-right: 0.5rem; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.7rem; margin: 0.6rem 0; }
.plan {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 2px solid var(--panel-border);
  background: var(--panel-solid);
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s, box-shadow 0.2s, border-color 0.2s;
}
.plan:hover { border-color: var(--accent); box-shadow: var(--glow); }
.plan:active { transform: scale(0.98); }
.plan:disabled { opacity: 0.6; cursor: progress; }
.plan.featured { border-color: #f59e0b; }
.plan-name { font-weight: 700; display: flex; gap: 0.5rem; align-items: center; }
.plan-price { font-size: 1.35rem; font-weight: 800; }
.save { font-size: 0.7rem; padding: 0.1rem 0.45rem; border-radius: 99px; background: var(--good); color: #04120a; }
.compare { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.compare th, .compare td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--panel-border); text-align: center; }
.compare th:first-child, .compare td:first-child { text-align: left; }
.compare td:nth-child(3) { color: var(--good); font-weight: 700; }
.form-error { color: var(--bad); min-height: 1.2em; margin: 0.3rem 0; font-size: 0.9rem; }
.form-error a, .auth-links a { color: var(--accent); }
.auth-links { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.9rem; font-size: 0.9rem; }
.btn-danger { background: var(--bad); color: #fff; border: none; }
.btn.loading { opacity: 0.7; cursor: progress; }
input[type='email'], input[type='password'] {
  min-height: 44px;
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--bg-2);
  width: 100%;
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
code { font-size: 0.85em; padding: 0.1em 0.35em; border-radius: 6px; background: var(--panel-border); }

/* ===================================================================== Legal pages & footer links */
.legal-page { height: auto; min-height: 100%; }
.legal { max-width: 760px; margin: 0 auto; padding: calc(1.5rem + env(safe-area-inset-top)) 1.2rem 3rem; line-height: 1.6; }
.legal h1 { margin: 1rem 0 0.2rem; }
.legal h2 { margin: 1.8rem 0 0.5rem; font-size: 1.2rem; }
.legal h3 { margin: 1.1rem 0 0.3rem; }
.legal ul { padding-left: 1.3rem; }
.legal li { margin: 0.25rem 0; }
.legal a, .about-links a, .terms-check a { color: var(--accent); }
.legal .highlight { padding: 0.9rem 1rem; border-radius: 14px; border: 1px solid var(--accent); background: var(--panel); margin: 1rem 0; }
.legal .missing, .missing { color: var(--warn); font-weight: 700; }
.back-link { display: inline-block; color: var(--muted); text-decoration: none; padding: 0.4rem 0; }
.legal-footer { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--panel-border); color: var(--muted); }
.about-links { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin: 0.4rem 0; }
.legal-note { margin-top: 0.6rem; }
.legal-note a { color: var(--muted); }
.terms-check {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel-solid);
  font-size: 0.86rem;
  line-height: 1.45;
  cursor: pointer;
}
.terms-check input { width: 20px; height: 20px; flex: none; margin-top: 0.1rem; accent-color: var(--accent); }
.terms-check.attention { border-color: var(--warn); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.25); animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ===================================================================== Admin */
.segmented { display: inline-flex; gap: 0.25rem; padding: 0.25rem; border-radius: 12px; background: var(--panel); border: 1px solid var(--panel-border); }
.seg { min-height: 36px; padding: 0.3rem 0.9rem; border-radius: 9px; border: none; background: none; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg.active { background: var(--panel-solid); color: var(--text); box-shadow: var(--glow); }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.6rem; margin-bottom: 1rem; }
.stat-card { display: flex; flex-direction: column; padding: 0.7rem 0.9rem; border-radius: 14px; background: var(--panel); border: 1px solid var(--panel-border); }
.stat-card span { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-card b { font-size: 1.5rem; }
.admin-toolbar { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; margin-bottom: 0.8rem; }
.admin-toolbar input[type='search'] { flex: 1 1 260px; max-width: 420px; }
input[type='search'], input[type='number'], textarea {
  min-height: 44px;
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--bg-2);
  width: 100%;
  font: inherit;
  color: inherit;
}
textarea { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 0.9rem; resize: vertical; line-height: 1.5; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.admin-table th { text-align: left; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 0.5rem; border-bottom: 1px solid var(--panel-border); }
.admin-table td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--panel-border); vertical-align: middle; }
.admin-table tr.group td { padding-top: 1rem; font-weight: 700; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: none; }
.admin-table td.actions { text-align: right; white-space: nowrap; }
.admin-table td.actions .btn { margin-left: 0.25rem; }
.nowrap { white-space: nowrap; }
.badge { display: inline-block; padding: 0.1rem 0.5rem; margin: 0.1rem 0; border-radius: 99px; font-size: 0.75rem; font-weight: 700; background: var(--panel-border); }
.badge.good { color: var(--good); }
.badge.warn { color: var(--warn); }
.badge.accent { color: var(--accent); }
.badge.premium { color: #b45309; background: rgba(245, 158, 11, 0.2); }
[data-theme='neon'] .badge.premium { color: var(--warn); }
.badge.muted-badge { color: var(--muted); }
.dialog-wide { width: min(96vw, 760px); }
.song-form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 0.8rem; }
.song-form-grid .span-2 { grid-column: span 2; }
.song-form-grid .align-end { align-self: end; min-height: 44px; }
.source-switch { margin: 0.6rem 0 0.2rem; }
.song-summary { font-weight: 600; margin: 0.4rem 0; }
.push-right { margin-left: auto; }
@media (max-width: 640px) {
  .song-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-table td.actions { white-space: normal; }
}

/* ===================================================================== Language & home page */
/* Hidden until i18n.js has applied the language (avoids a flash of the wrong language). */
.i18n-pending #app, .i18n-pending .legal { visibility: hidden; animation: i18n-reveal 0s 1.5s forwards; }
@keyframes i18n-reveal { to { visibility: visible; } }
.noscript { padding: 1rem; text-align: center; }

a.brand { color: inherit; text-decoration: none; border-radius: 10px; }
a.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.lang-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--panel-solid); border: 1px solid var(--panel-border); flex: none; }
.lang-switch button {
  min-width: 38px;
  min-height: 36px;
  padding: 0 0.55rem;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  touch-action: manipulation;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.lang-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

#view-home.active { padding: 0; }
.home { max-width: 1180px; margin: 0 auto; padding: clamp(1.2rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) 2rem; }

.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 3.5rem); align-items: center; min-height: min(70vh, 620px); }
.eyebrow { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.85rem; border-radius: 99px; border: 1px solid var(--panel-border); background: var(--panel); color: var(--accent); font-weight: 700; font-size: 0.85rem; }
.hero-title { font-size: clamp(2.2rem, 5.2vw, 4rem); line-height: 1.05; letter-spacing: -0.02em; margin: 1rem 0; font-weight: 850; }
.grad { background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-lead { font-size: clamp(1.05rem, 1.6vw, 1.22rem); color: var(--muted); max-width: 36rem; line-height: 1.55; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.6rem 0 1.2rem; }
.hero-cta .btn-big { margin: 0; }
.btn-ghost { background: transparent; }
.hero-points { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.3rem; color: var(--muted); font-size: 0.92rem; }
.hero-points li::before { content: '✓'; color: var(--good); font-weight: 800; margin-right: 0.4rem; }

/* Animated falling-notes demo (pure CSS; CSP forbids inline styles, so lanes are configured with nth-child). */
.hero-visual { position: relative; padding: 1rem 0; }
.demo-screen {
  position: relative;
  aspect-ratio: 4 / 3.3;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  background: linear-gradient(180deg, var(--stage-top), var(--stage-bottom));
  box-shadow: var(--shadow), 0 0 70px rgba(168, 85, 247, 0.22);
  transform: perspective(1200px) rotateY(-7deg) rotateX(3deg);
}
.demo-lanes {
  position: absolute;
  inset: 0 0 26% 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  overflow: hidden;
  background: repeating-linear-gradient(90deg, transparent 0 calc(12.5% - 1px), var(--lane-f) calc(12.5% - 1px) 12.5%);
}
.fn { position: relative; --len: 18%; --dur: 4.8s; }
.fn::before {
  content: '';
  position: absolute;
  left: 14%;
  right: 14%;
  height: var(--len);
  top: calc(-1 * var(--len));
  border-radius: 8px;
  background: hsl(var(--hue) 85% 62%);
  box-shadow: 0 0 16px hsl(var(--hue) 85% 62% / 0.55);
  animation: demo-fall var(--dur) linear infinite;
  animation-delay: var(--delay);
}
@keyframes demo-fall { to { top: 100%; } }
.demo-hitline { position: absolute; left: 0; right: 0; bottom: 26%; height: 3px; background: var(--hit-line); box-shadow: 0 0 14px var(--hit-line); }
.demo-keys { position: absolute; inset: auto 0 0 0; height: 26%; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 4px 2px 0; background: var(--key-bed); }
.wk { --dur: 4.8s; border-radius: 0 0 6px 6px; background: linear-gradient(var(--key-white-top), var(--key-white)); animation: demo-press var(--dur) linear infinite; animation-delay: var(--delay); }
/* The bar's bottom edge reaches the hit line at 100 / (100 + 18) ≈ 85 % of the cycle. */
@keyframes demo-press {
  0%, 84% { background: linear-gradient(var(--key-white-top), var(--key-white)); }
  86%, 98% { background: hsl(var(--hue) 85% 62%); box-shadow: 0 0 18px hsl(var(--hue) 85% 62% / 0.8); }
}
.bk { position: absolute; top: 4px; width: 7%; height: 58%; border-radius: 0 0 4px 4px; background: linear-gradient(var(--key-black-top), var(--key-black)); }
.bk:nth-child(9) { left: 9%; }
.bk:nth-child(10) { left: 21.5%; }
.bk:nth-child(11) { left: 46.5%; }
.bk:nth-child(12) { left: 59%; }
.bk:nth-child(13) { left: 71.5%; }
.fn:nth-child(1), .wk:nth-child(1) { --hue: 190; --delay: 0s; }
.fn:nth-child(2), .wk:nth-child(2) { --hue: 215; --delay: -3.6s; }
.fn:nth-child(3), .wk:nth-child(3) { --hue: 250; --delay: -0.6s; }
.fn:nth-child(4), .wk:nth-child(4) { --hue: 280; --delay: -3s; }
.fn:nth-child(5), .wk:nth-child(5) { --hue: 310; --delay: -1.2s; }
.fn:nth-child(6), .wk:nth-child(6) { --hue: 340; --delay: -2.4s; }
.fn:nth-child(7), .wk:nth-child(7) { --hue: 30; --delay: -4.2s; }
.fn:nth-child(8), .wk:nth-child(8) { --hue: 160; --delay: -1.8s; }
.demo-chip {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 0.9rem;
  white-space: nowrap;
}
.demo-chip-mic { top: 4%; left: -3%; }
.demo-chip-mic .mic-dot { background: var(--good); box-shadow: 0 0 10px var(--good); animation: pulse 1.6s infinite; }
.demo-chip-score { bottom: 36%; right: -3%; color: var(--good); font-weight: 800; animation: floaty 3s ease-in-out infinite; }
@keyframes floaty { 50% { transform: translateY(-8px); } }

.home-section { margin-top: clamp(3rem, 7vw, 5rem); }
.home-h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); letter-spacing: -0.01em; }
.home-sub { margin-top: 0; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 1rem; margin-top: 1.4rem; }
.feature { padding: 1.3rem; border-radius: 18px; background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow), var(--glow); }
.feature h3, .how-steps h3 { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 1.1rem; margin: 0.85rem 0 0.35rem; }
.feature p, .how-steps p { color: var(--muted); margin: 0; line-height: 1.5; }
.feature-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  color: var(--accent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, transparent), color-mix(in srgb, var(--accent-2) 22%, transparent));
}
.feature-icon svg { width: 24px; height: 24px; }
.how-steps { list-style: none; padding: 0; margin: 1.4rem 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.how-steps li { padding: 1.3rem; border-radius: 18px; border: 1px dashed color-mix(in srgb, var(--accent) 40%, var(--panel-border)); background: color-mix(in srgb, var(--panel) 50%, transparent); }
.how-num { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 800; }
.home-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.home-songs { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.2rem; }
.song-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: 99px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.song-chip:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--glow); }
.song-chip .diff { font-size: 0.6rem; letter-spacing: 1px; }
.song-chip.locked { color: var(--muted); }
.song-chip .premium-pill { font-size: 0.72rem; font-weight: 700; }
.premium-teaser {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  padding: clamp(1.3rem, 3vw, 2rem);
  border-radius: 22px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(168, 85, 247, 0.14));
}
.premium-teaser p { max-width: 44rem; color: var(--muted); margin-bottom: 0; }
.faq { display: grid; gap: 0.6rem; margin-top: 1.2rem; max-width: 820px; }
.faq details { border-radius: 14px; background: var(--panel); border: 1px solid var(--panel-border); padding: 0 1.1rem; }
.faq summary { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 0; font-weight: 700; cursor: pointer; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; color: var(--accent); font-size: 1.4rem; line-height: 1; transition: transform 0.2s ease; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: 0 0 1rem; color: var(--muted); line-height: 1.55; }
.home-final {
  margin-top: clamp(3rem, 7vw, 5rem);
  padding: clamp(2rem, 5vw, 3.5rem) 1rem;
  text-align: center;
  border-radius: 26px;
  border: 1px solid var(--panel-border);
  background: radial-gradient(600px 220px at 50% 0%, color-mix(in srgb, var(--accent) 20%, transparent), transparent), var(--panel);
}
.home-final h2 { font-size: clamp(1.4rem, 3vw, 2rem); margin-bottom: 0.6rem; }
.home-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; margin-top: 3rem; padding: 1.5rem 0 1rem; border-top: 1px solid var(--panel-border); }
.home-footer .brand { font-size: 1rem; }
.home-footer-links { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; }
.home-footer-links a { color: var(--muted); text-decoration: none; }
.home-footer-links a:hover { color: var(--text); }
.home-footer .lang-switch { margin-left: auto; }
.home-footer p { width: 100%; margin: 0; }

.legal-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.legal [hidden] { display: none !important; }

/* Without animation the demo shows a still frame: E4 is being played. */
@media (prefers-reduced-motion: reduce) {
  .fn::before { top: var(--still); }
  .fn:nth-child(1) { --still: 50%; }
  .fn:nth-child(2) { --still: 8%; }
  .fn:nth-child(3) { --still: 82%; }
  .fn:nth-child(4) { --still: 30%; }
  .fn:nth-child(5) { --still: 62%; }
  .fn:nth-child(6) { --still: 14%; }
  .fn:nth-child(7) { --still: -6%; }
  .fn:nth-child(8) { --still: 40%; }
  .wk:nth-child(3) { background: hsl(var(--hue) 85% 62%); box-shadow: 0 0 18px hsl(var(--hue) 85% 62% / 0.8); }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .hero-visual { width: 100%; max-width: 520px; margin: 0 auto; }
  .demo-screen { transform: none; }
  .how-steps { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .topbar .lang-switch button { min-width: 32px; min-height: 34px; padding: 0 0.35rem; }
  .hero-cta .btn { flex: 1 1 100%; }
  .demo-chip-mic { left: 3%; }
  .demo-chip-score { right: 3%; }
  .home-footer .brand span { display: inline; }
  .home-footer .lang-switch { margin-left: 0; }
}

/* ===================================================================== Responsive */
@media (max-width: 1440px) {
  /* Keep the top bar on one line: icon-only microphone button, compact tabs. */
  #micBtnLabel { display: none; }
  .mic-status .meter { width: 40px; }
  .tab { padding: 0.4rem 0.6rem; }
}

@media (max-width: 1100px) {
  .free-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .history-card { grid-column: 1 / -1; }
  .tab span { display: none; }
}

@media (max-width: 860px) {
  .calib-layout { grid-template-columns: minmax(0, 1fr); }
  .account-layout { grid-template-columns: minmax(0, 1fr); }
}

/* Phones: navigation moves to a bottom bar. */
@media (max-width: 760px) {
  /* backdrop-filter would make the topbar the containing block of the fixed bottom nav */
  .topbar { gap: 0.5rem; padding: 0.4rem 0.6rem; backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .brand span { display: none; }
  .mic-status .meter { display: none; }
  #micBtnLabel { display: none; }
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    justify-content: space-around;
    padding: 0.3rem 0.3rem calc(0.3rem + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--panel-border);
    z-index: 20;
  }
  .tab { flex-direction: column; gap: 0.1rem; font-size: 0.62rem; padding: 0.3rem 0.15rem; flex: 1; min-width: 0; min-height: 52px; }
  .tab span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .brand .pro-badge { display: none; }
  .top-actions { margin-left: auto; }
  main { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  body.in-play .tabs { display: none; }
  body.in-play main { padding-bottom: env(safe-area-inset-bottom); }
  .free-layout { grid-template-columns: minmax(0, 1fr); flex: none; }
  .spectrum-canvas { height: 110px; }
  .tuner-canvas { height: 120px; }
  .toggles select { max-width: 150px; }
  .tempo { flex: 1 1 140px; }
}

/* Short landscape screens (phones turned sideways): maximise the stage. */
@media (max-height: 520px) and (orientation: landscape) {
  .topbar { padding: 0.25rem 0.6rem; }
  .brand span, #micBtnLabel, .tab span { display: none; }
  .tabs { position: static; flex-direction: row; background: none; border: none; padding: 0; margin: 0 auto; }
  .tab { flex-direction: row; min-height: 38px; flex: none; }
  main { padding-bottom: 0; }
  body.in-play .tabs { display: flex; }
  .play-toolbar { flex-wrap: nowrap; overflow-x: auto; padding: 0.25rem 0.5rem; gap: 0.6rem; }
  .play-toolbar .btn, .play-toolbar .icon-btn { min-height: 36px; height: 36px; }
  .song-title { flex: 0 1 140px; }
  .hud { padding: 0.15rem 0.6rem; }
  .stat b { font-size: 1rem; }
  .free-keyboard { height: 38vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
