/* ===== Screen-reader-only utility (used by aria-live announcer & skip link) ===== */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Skip-to-content link — visible only when keyboard-focused */
.skip-link {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 10000;
  padding: 10px 16px;
  background: var(--accent, #f7d486);
  color: #07080c;
  font-weight: 700;
  border-radius: 8px;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform 0.18s ease;
}
.skip-link:focus { transform: translateY(0); outline: 2px solid #fff; outline-offset: 2px; }

/* ===== Foundations ===== */
:root {
  --bg-0: #07080c;
  --bg-1: #0d1018;
  --bg-2: #131826;
  --surface: rgba(255,255,255,0.04);
  --surface-strong: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.09);
  --border-strong: rgba(255,255,255,0.18);
  --text: #f3f1ec;
  --text-dim: #a8a39b;
  --text-mute: #9a948c;
  --accent: #f7d486;       /* warm gold */
  --accent-2: #c47cff;     /* electric violet */
  --accent-3: #5cd1ff;     /* sky */
  --danger: #ff5d6c;
  --good: #4ade80;
  --shadow-deep: 0 30px 80px -20px rgba(0,0,0,0.8);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Manrope', system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse at top, #1a1430 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, #0a2030 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 60%, #050608 100%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

/* Animated background orbs */
.bg-orbs { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.orb {
  position: absolute; border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: orbFloat 18s ease-in-out infinite;
}
.orb-1 { width: 480px; height: 480px; background: radial-gradient(circle, var(--accent-2) 0%, transparent 70%); top: -100px; left: -120px; }
.orb-2 { width: 600px; height: 600px; background: radial-gradient(circle, var(--accent) 0%, transparent 70%); top: 30%; right: -200px; animation-delay: -6s; }
.orb-3 { width: 420px; height: 420px; background: radial-gradient(circle, var(--accent-3) 0%, transparent 70%); bottom: -120px; left: 35%; animation-delay: -12s; }

@keyframes orbFloat {
  0%, 100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.05); }
  66% { transform: translate(-30px, 30px) scale(0.95); }
}

/* ===== Topbar ===== */
.topbar {
  position: relative; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px 36px;
  width: 100%;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 44px; height: 44px;
  filter: drop-shadow(0 8px 20px rgba(196,124,255,0.35));
}
.brand-text h1 {
  font-family: 'Manrope', system-ui, sans-serif;
  font-style: normal;
  font-weight: 800;
  font-size: 26px;
  line-height: 1.05;
  margin: 0;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 60%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.025em;
}
.brand-text p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-mute); letter-spacing: 0.01em; }

.topnav { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  backdrop-filter: blur(10px);
}
.chip:hover { background: var(--surface-strong); color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }

/* ===== Stage ===== */
.stage {
  position: relative; z-index: 5;
  width: 100%;
  padding: 12px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ===== Control Panel ===== */
.control-panel {
  display: grid;
  grid-template-columns: auto auto auto 1fr auto;
  gap: 28px;
  align-items: end;
  padding: 22px 26px;
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-deep);
}
.control-group { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.control-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* Instrument select dropdown */
.select-wrap {
  position: relative;
  display: inline-block;
  min-width: 220px;
}
.instrument-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 10px 36px 10px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  outline: none;
}
.instrument-select:hover { background: rgba(0,0,0,0.4); border-color: var(--border-strong); }
.instrument-select:focus-visible { border-color: var(--accent); }
.instrument-select option,
.instrument-select optgroup {
  background: #14171f;
  color: var(--text);
  font-weight: 500;
}
.instrument-select optgroup {
  font-style: italic;
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.select-caret {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-mute);
  pointer-events: none;
}

/* Slider */
.slider-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  min-width: 200px;
}
.slider-wrap input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) var(--val,75%), rgba(255,255,255,0.1) var(--val,75%));
  border-radius: 2px;
  outline: none;
}
.slider-wrap input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: linear-gradient(135deg, #fff, #e0d8c8);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 3px rgba(247,212,134,0.15);
}
.slider-wrap input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border: 0;
  background: linear-gradient(135deg, #fff, #e0d8c8);
  border-radius: 50%;
  cursor: grab;
}
.slider-value {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  min-width: 24px;
  text-align: right;
}

/* Octave controls */
.octave-controls {
  display: inline-flex;
  align-items: center;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}
.octave-display {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-weight: 700;
  font-size: 13px;
  padding: 0 14px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  min-width: 50px;
  text-align: center;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }

.transpose-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 38px; height: 30px;
  padding: 0 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
  font: inherit;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  transition: all 0.15s;
}
.transpose-btn:hover {
  background: rgba(255,255,255,0.10);
  border-color: var(--border-strong);
  color: var(--accent);
}
.transpose-btn:active { transform: translateY(1px); }

/* Toggles */
.toggles { flex-direction: row !important; flex-wrap: wrap; gap: 16px !important; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track {
  position: relative;
  width: 36px; height: 20px;
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), background 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.toggle input:checked + .toggle-track {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(16px);
}
.toggle-text { font-size: 13px; color: var(--text-dim); font-weight: 500; }
.toggle:hover .toggle-text { color: var(--text); }

/* Recorder */
.recorder-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rec-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}
.rec-btn:hover:not(:disabled) {
  background: var(--surface-strong);
  border-color: var(--border-strong);
}
.rec-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.rec-btn.ghost { background: transparent; }
.rec-dot {
  width: 10px; height: 10px;
  background: var(--danger);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(255,93,108,0.5);
}
.rec-btn.recording { border-color: var(--danger); color: var(--danger); }
.rec-btn.recording .rec-dot { animation: pulse 1.2s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,93,108,0.6); }
  100% { box-shadow: 0 0 0 12px rgba(255,93,108,0); }
}
.rec-time {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-mute);
  margin-left: 4px;
  font-weight: 600;
}

/* ===== Visualizer ===== */
.visualizer {
  position: relative;
  height: 140px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: linear-gradient(180deg, rgba(0,0,0,0.4), rgba(0,0,0,0.1));
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
#vizCanvas { width: 100%; height: 100%; display: block; }

/* ===== Piano ===== */
.piano-container {
  position: relative;
  padding: 0;
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.piano-container::-webkit-scrollbar { height: 8px; }
.piano-container::-webkit-scrollbar-track { background: transparent; }
.piano-container::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
}
.piano {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 1500px;
  height: clamp(190px, 24vh, 290px);
  border-radius: 12px 12px 6px 6px;
  /* Deep, almost pure black piano body — onlinepianist-style depth */
  background:
    radial-gradient(ellipse 120% 60% at 50% 0%, rgba(255,255,255,0.04), transparent 70%),
    linear-gradient(180deg, #14171c 0%, #07090d 55%, #020306 100%);
  padding: 14px 16px 22px;
  box-shadow:
    /* Big, profound drop shadow that lifts the whole instrument */
    0 80px 140px -28px rgba(0,0,0,1),
    0 36px 64px -18px rgba(0,0,0,0.88),
    0 12px 24px -10px rgba(0,0,0,0.55),
    /* Crisp 1px outer rim */
    0 0 0 1px rgba(255,255,255,0.07),
    /* Inner top highlight + nesting shadow for keys to sit in */
    inset 0 1px 0 rgba(255,255,255,0.11),
    inset 0 10px 18px -12px rgba(0,0,0,0.95),
    inset 0 -4px 0 rgba(0,0,0,0.7);
}
.piano::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    rgba(247,212,134,0) 0%,
    rgba(247,212,134,0.85) 22%,
    rgba(196,124,255,0.85) 50%,
    rgba(92,209,255,0.85) 78%,
    rgba(92,209,255,0) 100%);
  border-radius: 14px 14px 0 0;
  opacity: 0.85;
  filter: saturate(1.15);
}
.piano .keys { width: 100%; }
.piano-shadow {
  position: absolute;
  bottom: -20px;
  left: 5%; right: 5%;
  height: 30px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.7) 0%, transparent 70%);
  filter: blur(10px);
  z-index: -1;
}

.keys {
  position: relative;
  display: flex;
  height: 100%;
  width: 100%;
  align-items: stretch;
}

.key {
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  /* Snap-in on press, gentle "afterglow" fade-out on release */
  transition:
    transform 0.04s cubic-bezier(.2,.8,.2,1),
    box-shadow 0.18s cubic-bezier(.2,.8,.2,1),
    background 0.18s cubic-bezier(.2,.8,.2,1);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 14px;
}

.key.white {
  flex: 1 1 0;
  min-width: 0;
  /* PURE WHITE — clean, neutral, like a real concert piano */
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 60%, #ececec 100%);
  border-radius: 0 0 6px 6px;
  /* Hairline neutral separation between keys */
  border-right: 1px solid rgba(0,0,0,0.10);
  box-shadow:
    /* Bottom thickness lip — clean, no warm tint */
    inset 0 -9px 0 -4px rgba(0,0,0,0.08),
    inset 0 -2px 5px -2px rgba(0,0,0,0.10),
    /* Pure-white specular highlight at the very top */
    inset 0 1px 0 #ffffff,
    /* Crisp left-edge hairline for visible separation */
    inset 1px 0 0 rgba(255,255,255,0.65),
    /* Profound ground shadow */
    0 2px 0 rgba(0,0,0,0.22),
    0 6px 8px -3px rgba(0,0,0,0.32);
  z-index: 1;
}
.key.white:last-child { border-right: 0; }

.key.white:hover {
  background: linear-gradient(180deg, #ffffff 0%, #fcfcfc 60%, #efefef 100%);
  box-shadow:
    inset 0 -9px 0 -4px rgba(0,0,0,0.08),
    inset 0 -2px 5px -2px rgba(0,0,0,0.10),
    inset 0 1px 0 #ffffff,
    inset 1px 0 0 rgba(255,255,255,0.65),
    inset 0 -3px 8px rgba(247,212,134,0.16),
    0 2px 0 rgba(0,0,0,0.22),
    0 6px 8px -3px rgba(0,0,0,0.32);
}

.key.black {
  position: absolute;
  top: 0;
  height: 62%;
  /* Deep piano-black, almost pure */
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 8%, transparent 92%, rgba(0,0,0,0.5) 100%),
    linear-gradient(180deg, #16181c 0%, #08090c 55%, #000000 100%);
  border-radius: 0 0 4px 4px;
  box-shadow:
    /* Top-edge highlight catching light */
    inset 0 2px 0 rgba(255,255,255,0.13),
    inset 0 1px 0 rgba(255,255,255,0.05),
    /* Inner bottom lip */
    inset 0 -4px 0 -1px rgba(255,255,255,0.07),
    inset 0 -1px 0 rgba(0,0,0,0.7),
    /* Crisp outline */
    inset 0 0 0 1px rgba(0,0,0,0.85),
    /* Profound lifted shadow */
    0 10px 14px rgba(0,0,0,0.6),
    0 4px 5px rgba(0,0,0,0.75);
  z-index: 2;
}

.key.black:hover {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.07) 0%, transparent 10%, transparent 92%, rgba(0,0,0,0.4) 100%),
    linear-gradient(180deg, #20242d 0%, #11141a 55%, #07090e 100%);
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.18),
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 -4px 0 -1px rgba(255,255,255,0.10),
    inset 0 -1px 0 rgba(0,0,0,0.6),
    inset 0 0 0 1px rgba(0,0,0,0.7),
    0 8px 12px rgba(0,0,0,0.55),
    0 3px 4px rgba(0,0,0,0.7);
}

/* Pressed states — fast IN, slow afterglow OUT handled by .key transition */
.key.white.active {
  background: linear-gradient(180deg, #fff5d6 0%, #ffe2a0 55%, #f0c976 100%);
  /* Snap-in fast; matched by faster transition for active */
  transition:
    transform 0.04s cubic-bezier(.2,.8,.2,1),
    box-shadow 0.04s cubic-bezier(.2,.8,.2,1),
    background 0.04s cubic-bezier(.2,.8,.2,1);
  transform: translateY(3px);
  box-shadow:
    /* Lit-from-inside top-edge highlight */
    inset 0 2px 0 rgba(255,245,214,0.95),
    inset 0 -3px 0 rgba(247,212,134,0.55),
    inset 0 0 22px rgba(247,212,134,0.55),
    /* Outer warm glow */
    0 0 10px rgba(247,212,134,0.85),
    0 0 28px rgba(247,212,134,0.55),
    0 1px 0 rgba(0,0,0,0.10);
}
.key.black.active {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 12%, transparent 92%, rgba(0,0,0,0.35) 100%),
    linear-gradient(180deg, #3a2872 0%, #281a55 55%, #1a0e3d 100%);
  transition:
    transform 0.04s cubic-bezier(.2,.8,.2,1),
    box-shadow 0.04s cubic-bezier(.2,.8,.2,1),
    background 0.04s cubic-bezier(.2,.8,.2,1);
  transform: translateY(3px);
  box-shadow:
    /* Lit-from-inside top edge */
    inset 0 2px 0 rgba(214,170,255,0.55),
    inset 0 -3px 0 rgba(196,124,255,0.50),
    inset 0 0 18px rgba(196,124,255,0.55),
    /* Outer purple glow */
    0 0 10px rgba(196,124,255,0.85),
    0 0 28px rgba(196,124,255,0.55),
    0 2px 3px rgba(0,0,0,0.5);
}

/* Key labels */
.key-label {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 700;
  color: rgba(0,0,0,0.5);
  letter-spacing: 0.02em;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}

.key-hint {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-style: normal;
  font-size: clamp(11px, 0.85vw, 14px);
  font-weight: 700;
  color: rgba(0,0,0,0.55);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
  pointer-events: none;
}
.key.black .key-hint { color: rgba(255,255,255,0.78); font-size: clamp(9px, 0.7vw, 12px); }

/* Ear-training: highlight active range with visible note labels */
.key.eartrain-show .key-label {
  font-size: 11px;
  font-weight: 800;
  color: rgba(0,0,0,0.7);
}
.key.black.eartrain-show .key-label {
  color: rgba(255,255,255,0.85);
  font-size: 9px;
}
.key.white.eartrain-show {
  background: linear-gradient(180deg, #fff 0%, #f5fafe 60%, #d6ecff 100%);
  box-shadow:
    inset 0 -8px 0 -3px rgba(92,209,255,0.18),
    inset 0 1px 0 rgba(255,255,255,0.95),
    inset 2px 0 0 rgba(92,209,255,0.5),
    0 2px 0 rgba(0,0,0,0.12);
}
.key.black.eartrain-show {
  background: linear-gradient(180deg, #2c3548 0%, #15192c 55%, #060814 100%);
  box-shadow:
    inset 0 -4px 0 -1px rgba(92,209,255,0.20),
    inset 0 1px 0 rgba(255,255,255,0.10),
    inset 0 0 0 1px rgba(92,209,255,0.45),
    0 6px 8px rgba(0,0,0,0.55);
}

/* C-keys as orientation landmarks — pure white with subtle blue accent line */
.key.is-c {
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 60%, #ececec 100%);
  box-shadow:
    inset 0 -9px 0 -4px rgba(0,0,0,0.08),
    inset 0 -2px 5px -2px rgba(0,0,0,0.10),
    inset 0 1px 0 #ffffff,
    inset 2px 0 0 rgba(92,209,255,0.55),
    0 2px 0 rgba(0,0,0,0.22),
    0 6px 8px -3px rgba(0,0,0,0.32);
}
.key.is-c .key-label {
  color: rgba(40,80,140,0.7);
  font-weight: 800;
}

.piano.no-labels .key-label { display: none; }
.piano.no-hints .key-hint { display: none; }

/* ===== MIDI status indicator ===== */
.midi-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(126,231,135,0.12);
  border: 1px solid rgba(126,231,135,0.35);
  border-radius: 999px;
  color: var(--good);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  animation: pulse-soft 2s ease-in-out infinite;
}
@keyframes pulse-soft {
  0%, 100% { box-shadow: 0 0 0 0 rgba(126,231,135,0.4); }
  50% { box-shadow: 0 0 0 5px rgba(126,231,135,0); }
}

/* ===== Language picker ===== */
.lang-picker {
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 24px 8px 12px;
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='none' stroke='%23a8a39b' stroke-width='1.5' d='M2 4l3 3 3-3'/></svg>") no-repeat right 8px center;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font: inherit;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.15s;
  min-width: 60px;
  backdrop-filter: blur(10px);
}
.lang-picker:hover { background-color: var(--surface-strong); color: var(--text); border-color: var(--border-strong); }
.lang-picker option { background: #14171f; color: var(--text); font-family: 'Manrope', sans-serif; }

/* ===== Scale & chord highlighter ===== */
.highlighter-bar {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}
.highlighter {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015));
  border: 1px solid var(--border);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
  justify-content: center;
}
.hl-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.hl-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.hl-mode {
  display: inline-flex;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
}
.hl-tab {
  padding: 5px 12px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}
.hl-tab:hover { color: var(--text); }
.hl-tab.active {
  background: linear-gradient(135deg, rgba(247,212,134,0.18), rgba(196,124,255,0.18));
  color: var(--text);
}
.hl-root, .hl-type {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 24px 6px 10px;
  background: rgba(0,0,0,0.3) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='none' stroke='%23a8a39b' stroke-width='1.5' d='M2 4l3 3 3-3'/></svg>") no-repeat right 8px center;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
.hl-root option, .hl-type option { background: #14171f; color: var(--text); }

/* Highlight overlay on keys */
.key.hl-match.white::after,
.key.hl-match.black::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(92,209,255,0.0), rgba(92,209,255,0.45));
  pointer-events: none;
}
.key.hl-root.white::after,
.key.hl-root.black::after {
  background: linear-gradient(180deg, rgba(247,212,134,0.0), rgba(247,212,134,0.65));
  box-shadow: inset 0 -8px 18px rgba(247,212,134,0.4);
}

/* ===== Metronome ===== */
.metronome-bar {
  display: flex;
  justify-content: center;
}
.metronome {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015));
  border: 1px solid var(--border);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
  justify-content: center;
}
.metro-play {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all 0.15s;
}
.metro-play:hover { background: rgba(255,255,255,0.08); border-color: var(--border-strong); }
.metro-play.active {
  background: linear-gradient(135deg, rgba(247,212,134,0.18), rgba(196,124,255,0.18));
  color: var(--accent);
  border-color: rgba(247,212,134,0.35);
}
.metro-bpm {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.metro-step {
  width: 26px;
  height: 26px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
  font: inherit;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.metro-step:hover { background: rgba(255,255,255,0.10); color: var(--accent); }
.metro-step:active { transform: scale(0.92); }
.metro-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: center;
}
.metro-unit {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.metro-beats {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 4px;
}
.beat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  transition: background 0.08s ease, transform 0.08s ease, box-shadow 0.08s ease;
}
.beat-dot.accent { background: rgba(247,212,134,0.35); }
.beat-dot.active {
  background: var(--accent);
  transform: scale(1.4);
  box-shadow: 0 0 12px rgba(247,212,134,0.7);
}
.beat-dot.accent.active {
  background: var(--accent-2);
  box-shadow: 0 0 14px rgba(196,124,255,0.8);
}
.metro-sig {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 24px 6px 10px;
  background: rgba(0,0,0,0.3) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='none' stroke='%23a8a39b' stroke-width='1.5' d='M2 4l3 3 3-3'/></svg>") no-repeat right 8px center;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
.metro-sig:hover { border-color: var(--border-strong); }
.metro-sig option { background: #14171f; color: var(--text); }

/* ===== Hint Bar =====
   Hidden on touch-only devices (phones/tablets) where QWERTY keyboard isn't usable.
   Shown on devices with fine pointer (mouse + physical keyboard). */
@media (pointer: coarse) and (hover: none) {
  .hint-bar { display: none; }
}
.hint-bar {
  display: flex; justify-content: center;
  margin-top: 8px;
}
.hint {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-mute);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
  justify-content: center;
}
.hint-sep { width: 1px; height: 14px; background: var(--border); }
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.04));
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 1px 0 rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.2);
  text-align: center;
  line-height: 1.4;
}

/* ===== Lessons & Ear Training modals ===== */
.modal-card.lessons-modal { width: min(880px, 100%); max-height: 90vh; }
.modal-card.eartrain-modal { width: min(560px, 100%); }
.lessons-body { padding: 18px 22px 22px; }
.lessons-intro { color: var(--text-dim); font-size: 14px; margin: 0 0 16px; }
.song-list { display: flex; flex-direction: column; gap: 18px; }
.song-cat-head {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
}
.song-cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.song-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.015));
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: all 0.18s;
}
.song-card:hover { background: rgba(255,255,255,0.08); border-color: var(--accent); transform: translateY(-2px); }
.song-difficulty {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.1em;
}
.song-title { font-weight: 700; font-size: 15px; }
.song-composer { font-size: 12px; color: var(--text-mute); }
.song-duration {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 2px;
}
.lessons-player-head {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.lessons-player-head h3 {
  margin: 0; flex: 1; font-size: 17px; font-weight: 700;
  color: var(--text);
}
.lessons-player-ctrl {
  display: inline-flex; align-items: center; gap: 10px;
}
.lessons-speed {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim);
}
.lessons-speed select {
  appearance: none; -webkit-appearance: none;
  padding: 5px 22px 5px 10px;
  background: rgba(0,0,0,0.3) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='none' stroke='%23a8a39b' stroke-width='1.5' d='M2 4l3 3 3-3'/></svg>") no-repeat right 6px center;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
.lessons-speed select option { background: #14171f; color: var(--text); }
#lessonsPlay.playing { background: rgba(255,93,108,0.15); color: var(--danger); border-color: rgba(255,93,108,0.4); }
.staff-area {
  position: relative;
  height: 90px;
  background: linear-gradient(180deg, rgba(247,242,228,0.95), rgba(238,229,202,0.95));
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
#staffCanvas { width: 100%; height: 100%; display: block; }
.fall-area {
  position: relative;
  height: clamp(240px, 44vh, 400px);
  background: linear-gradient(180deg, rgba(0,0,0,0.4), rgba(0,0,0,0.15));
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}
#fallCanvas { width: 100%; height: 100%; display: block; }

/* Ear training */
.eartrain-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-bottom: 18px;
}
.eartrain-stats .stat {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.stat-label {
  font-size: 10.5px; font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.stat-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}
.eartrain-controls {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.eartrain-diff-wrap {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-dim);
}
.eartrain-diff-wrap select {
  appearance: none; -webkit-appearance: none;
  padding: 6px 22px 6px 10px;
  background: rgba(0,0,0,0.3) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='none' stroke='%23a8a39b' stroke-width='1.5' d='M2 4l3 3 3-3'/></svg>") no-repeat right 6px center;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
.eartrain-diff-wrap select option { background: #14171f; color: var(--text); }
#eartrainPlay.playing { background: rgba(255,93,108,0.15); color: var(--danger); border-color: rgba(255,93,108,0.4); }
.eartrain-msg {
  padding: 14px 16px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text-dim);
  text-align: center;
  min-height: 50px;
  display: flex; align-items: center; justify-content: center;
}
.eartrain-msg.ok { color: var(--good); border-color: rgba(126,231,135,0.4); background: rgba(126,231,135,0.08); }
.eartrain-msg.bad { color: var(--danger); border-color: rgba(255,93,108,0.4); background: rgba(255,93,108,0.08); }
.eartrain-msg.hint { color: var(--accent); border-color: rgba(247,212,134,0.4); background: rgba(247,212,134,0.06); }

/* ===== Inline feature sections (Ear Training, Theory — below piano) ===== */
.feature-section {
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.012));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-deep);
  overflow: hidden;
  animation: floatIn 0.25s cubic-bezier(.2,.8,.2,1);
}
.feature-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
}
.feature-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.005em;
}
.feature-body { padding: 18px 22px 20px; }
.feature-section .theory-tabs { padding: 0 22px; }

/* ===== Theory modal ===== */
.modal-card.theory-modal { width: min(720px, 100%); max-height: 90vh; overflow-y: auto; }
.theory-tabs {
  display: flex;
  gap: 0;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
}
.theory-tab {
  padding: 12px 20px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.theory-tab:hover { color: var(--text); }
.theory-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.theory-pane { display: none; padding: 22px; }
.theory-pane.active { display: block; }
.theory-intro { color: var(--text-dim); font-size: 13.5px; margin: 0 0 16px; line-height: 1.55; }
.theory-controls { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
#intStart.playing, #progPlay.playing {
  background: rgba(255,93,108,0.15); color: var(--danger); border-color: rgba(255,93,108,0.4);
}

.int-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.int-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  transition: all 0.15s;
}
.int-btn:hover { background: rgba(255,255,255,0.08); border-color: var(--accent); transform: translateY(-1px); }
.int-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
}
.int-name {
  font-size: 10.5px;
  color: var(--text-mute);
}

.prog-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 14px;
}
.prog-field {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.prog-field select {
  appearance: none; -webkit-appearance: none;
  padding: 8px 24px 8px 12px;
  background: rgba(0,0,0,0.3) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='none' stroke='%23a8a39b' stroke-width='1.5' d='M2 4l3 3 3-3'/></svg>") no-repeat right 8px center;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  text-transform: none;
  letter-spacing: normal;
}
.prog-field select option { background: #14171f; color: var(--text); }

.prog-display {
  min-height: 110px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(0,0,0,0.4), rgba(0,0,0,0.15));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 14px;
}
.prog-current {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 42px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
  text-shadow: 0 0 30px rgba(247,212,134,0.4);
}

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
/* Floating modal: top-aligned, no blocking backdrop — piano stays visible & clickable */
.modal.modal-floating {
  align-items: flex-start;
  padding: 80px 20px 20px;
  pointer-events: none;
}
.modal.modal-floating .modal-backdrop {
  display: none;
}
.modal.modal-floating .modal-card {
  pointer-events: auto;
  width: min(520px, 100%);
  max-height: 65vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px -10px rgba(0,0,0,0.7);
  animation: floatIn 0.25s cubic-bezier(.2,.8,.2,1);
}
@keyframes floatIn {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease;
}
.modal-card {
  position: relative;
  width: min(640px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #1a1d28, #0f1219);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 40px 80px -20px rgba(0,0,0,0.9);
  animation: slideUp 0.25s cubic-bezier(.2,.8,.2,1);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  margin: 0;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-body { padding: 26px; }

.shortcut-grid {
  display: grid; gap: 22px;
}
.shortcut-section h3 {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
}
.kbd-row {
  display: flex; flex-wrap: wrap; gap: 12px;
}
.kbd-row span {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}
.kbd-row .hint-mute {
  font-style: italic;
  color: var(--text-mute);
  font-size: 12px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Content pages (privacy / about / terms) ===== */
.content-body { min-height: 100vh; display: flex; flex-direction: column; }
.brand-link { text-decoration: none; color: inherit; }
.content {
  position: relative; z-index: 5;
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 28px 60px;
}
.prose {
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.012));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 44px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-deep);
}
.prose h1 {
  font-size: 30px;
  font-weight: 800;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.prose h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 36px 0 12px;
  color: var(--accent);
  letter-spacing: -0.01em;
}
.prose h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 22px 0 8px;
  color: var(--text);
}
.prose p, .prose li {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-dim);
}
.prose .lead { font-size: 16px; color: var(--text); margin-bottom: 8px; }
.prose .meta {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 28px;
}
.prose ul { padding-left: 22px; margin: 10px 0; }
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--text); font-weight: 600; }
.prose a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(247,212,134,0.25);
  transition: border-color 0.15s;
}
.prose a:hover { border-color: var(--accent); }

.page-footer {
  padding: 24px 28px 32px;
  text-align: center;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  position: relative;
  z-index: 5;
}
.page-footer.compact {
  background: transparent;
  border-top: 0;
  padding: 8px 28px 32px;
}
.page-footer.compact .footer-nav { font-size: 12px; }
.footer-nav {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 8px;
}
.footer-nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}
.footer-nav a:hover, .footer-nav a[aria-current="page"] { color: var(--accent); }
.footer-nav .dot { color: var(--text-mute); }
.footer-credit {
  font-size: 12px;
  color: var(--text-mute);
  margin: 4px 0 0;
}

/* ===== Admin dashboard (only shown when ?admin=1) ===== */
#adminPanel {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 200;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: linear-gradient(180deg, #1a1d28, #0f1219);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px -10px rgba(0,0,0,0.85);
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--text);
  font-size: 13px;
  animation: floatIn 0.25s cubic-bezier(.2,.8,.2,1);
}
.adm-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.adm-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.01em;
}
.adm-close {
  background: transparent; border: 0; color: var(--text-mute);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
  transition: color 0.15s;
}
.adm-close:hover { color: var(--text); }
.adm-body { padding: 16px 20px 18px; }
.adm-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}
.adm-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.adm-card-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.adm-card-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.adm-card-unit {
  font-size: 11px;
  color: var(--text-mute);
  margin-left: 4px;
}
.adm-section-title {
  margin: 8px 0 10px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
}
.adm-features {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px;
}
.adm-row {
  display: grid;
  grid-template-columns: 1fr 80px 50px;
  align-items: center;
  gap: 8px;
}
.adm-label {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.adm-bar {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
}
.adm-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.3s;
}
.adm-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.adm-actions {
  display: flex; align-items: center; gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.adm-refresh {
  padding: 7px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.adm-refresh:hover { background: rgba(255,255,255,0.06); border-color: var(--accent); }
.adm-disable {
  color: var(--danger);
  border-color: rgba(255,93,108,0.35);
}
.adm-disable:hover {
  background: rgba(255,93,108,0.08);
  border-color: var(--danger);
}
.adm-banner {
  margin: 0 0 14px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mute);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 7px;
  letter-spacing: 0.02em;
}
.adm-note {
  flex: 1;
  font-size: 10px;
  color: var(--text-mute);
  line-height: 1.4;
}

/* ===== Visits corner (discreet, bottom-right) ===== */
.visits-corner {
  position: fixed;
  bottom: 10px;
  right: 14px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,0.22);
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  pointer-events: none;
  user-select: none;
  transition: color 0.3s ease;
}
.visits-corner:hover { color: rgba(255,255,255,0.45); }

/* ===== Accessibility ===== */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  /* Note: do NOT force a border-radius — keep the element's own shape */
}
button:focus-visible,
.chip:focus-visible,
.rec-btn:focus-visible,
.tuner-mode-btn:focus-visible,
.theory-tab:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(247,212,134,0.18);
}
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.key:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: -3px;
}
.piano-container:focus { outline: none; }
.piano-container:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
  border-radius: 8px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .orb { animation: none; }
}

/* ===== First-touch onboarding hint (above piano, fades after first interaction) ===== */
.piano-stack { position: relative; }
.first-touch-hint {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(247,212,134,0.95), rgba(196,124,255,0.95));
  color: #07080c;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.01em;
  border-radius: 999px;
  box-shadow: 0 8px 24px -4px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.18) inset;
  pointer-events: none;
  animation: firstTouchBob 1.6s ease-in-out infinite;
  white-space: nowrap;
}
.first-touch-hint svg { flex-shrink: 0; }
.first-touch-hint.is-dismissed {
  opacity: 0;
  transform: translateX(-50%) translateY(-6px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}
@keyframes firstTouchBob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(4px); }
}

/* ===== Recorder empty state hint =====
   Visually hidden — accessible to screen readers only. The disabled buttons
   + the 0:00 timer already convey "nothing recorded" visually. */
.rec-empty-hint {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ===== Tuner: color-blind-friendly in-tune indicator ===== */
.tuner-cents {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tuner-cents-icon {
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s, transform 0.2s, color 0.2s;
  color: var(--good);
}
.tuner-cents.in-tune .tuner-cents-icon {
  opacity: 1;
  transform: scale(1);
}
.tuner-cents.in-tune .tuner-cents-text { color: var(--good); font-weight: 700; }

/* ===== Footer tagline ===== */
.footer-tagline {
  margin: 6px 0 0;
  font-size: 11.5px;
  color: var(--text-mute);
  letter-spacing: 0.01em;
  text-align: center;
}

/* ===== Install chip (PWA install prompt) =====
   Subtle accent so it reads as an affordance without screaming for attention. */
.chip-install {
  background: linear-gradient(135deg, rgba(247,212,134,0.18), rgba(196,124,255,0.18));
  border-color: rgba(247,212,134,0.45);
  color: var(--text);
}
.chip-install:hover {
  background: linear-gradient(135deg, rgba(247,212,134,0.28), rgba(196,124,255,0.28));
  border-color: var(--accent);
}

/* ===== Tuner reference-tone usage hint (above instrument selector) ===== */
.tuner-mode-hint {
  margin: 0 0 14px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
  background: rgba(92,209,255,0.06);
  border: 1px solid rgba(92,209,255,0.18);
  border-radius: 10px;
}

/* ===== Piano horizontal-scroll affordance =====
   Soft right-edge fade on the scroll container so phones / narrow viewports
   show users that the piano extends beyond the visible area. */
.piano-container {
  /* Scroll-snap is intentionally disabled — users frequently swipe across many
     keys; we only want a visual cue that there's more to the right. */
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
          mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
}
@media (min-width: 1600px) {
  /* Wide viewports rarely need the fade — the piano fits */
  .piano-container { -webkit-mask-image: none; mask-image: none; }
}

/* ===== Safe-area insets for notched devices (iPhone, foldables) ===== */
@supports (padding: max(0px)) {
  .topbar { padding-left: max(36px, env(safe-area-inset-left)); padding-right: max(36px, env(safe-area-inset-right)); }
  .stage { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
  .page-footer { padding-bottom: max(32px, env(safe-area-inset-bottom)); }
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .control-panel { grid-template-columns: 1fr 1fr; gap: 20px; }
  .control-panel > .recorder { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .topnav { justify-content: center; }
  .topnav .chip span { display: none; }  /* topbar chips become icon-only on small screens */
  .topnav .chip { padding: 9px 11px; }
  .midi-label { display: none; }
}
@media (max-width: 720px) {
  .topbar { padding: 16px 18px; }
  .brand-text h1 { font-size: 22px; }
  .brand-text p { font-size: 11px; }
  .stage { padding: 8px 12px 20px; gap: 14px; }
  .control-panel { grid-template-columns: 1fr; gap: 16px; padding: 18px; }
  .visualizer { height: 90px; }
  .piano { min-width: 1500px; height: 200px; padding: 10px 12px 16px; }
  .hint { font-size: 10px; padding: 8px 12px; gap: 8px; }
  .hint-sep { display: none; }

  /* Larger touch targets — WCAG 2.5.5 (44x44 min) */
  .chip { padding: 11px 13px; min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .transpose-btn { min-width: 44px; height: 44px; padding: 0 14px; }
  .metro-step { width: 40px; height: 40px; font-size: 18px; }
  .metro-play { padding: 11px 16px; min-height: 44px; }
  .rec-btn { padding: 11px 14px; min-height: 44px; }
  .lang-picker { padding: 11px 26px 11px 14px; min-height: 44px; }
  .toggle { min-height: 32px; }   /* increase tap zone for switches */
  .toggle-track { width: 42px; height: 24px; }
  .toggle-thumb { width: 20px; height: 20px; }
  .toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); }
  .footer-nav a { padding: 6px 4px; }

  /* First-touch hint: smaller on phones */
  .first-touch-hint { font-size: 12px; padding: 7px 12px; top: -8px; }

  /* Reduce expensive background blur on phones (low-end CPU/battery) */
  .orb { filter: blur(60px); opacity: 0.22; }
  .orb-2 { display: none; }
}

/* Hide background orbs entirely if user prefers reduced motion or on very small phones */
@media (max-width: 480px) {
  .bg-orbs { display: none; }
}

/* ===== Instrument Tuner ===== */
.tuner-mode-toggle {
  display: flex; gap: 6px;
  padding: 12px 22px 0;
}
.tuner-mode-btn {
  flex: 1;
  padding: 10px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.tuner-mode-btn:hover { color: var(--text); border-color: var(--border-strong); }
.tuner-mode-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(247,212,134,0.10), rgba(247,212,134,0.04));
  box-shadow: 0 0 18px -4px rgba(247,212,134,0.35);
}
.tuner-pane { display: none; }
.tuner-pane.active { display: block; }

/* Reference tone — instrument selector + string tiles */
.tuner-inst-select {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 16px;
}
.tuner-inst-btn {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.tuner-inst-btn:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.tuner-inst-btn.active {
  color: var(--text);
  border-color: var(--accent-2);
  background: linear-gradient(180deg, rgba(196,124,255,0.12), rgba(196,124,255,0.04));
}
.tuner-inst-tuning {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--text-mute);
  letter-spacing: 0.04em;
  font-weight: 500;
}

.tuner-strings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.tuner-string-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0.4), rgba(0,0,0,0.2));
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.tuner-string-btn:hover {
  background: rgba(255,255,255,0.06);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.tuner-string-name {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 24px; font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
  line-height: 1;
}
.tuner-string-oct {
  font-size: 14px;
  color: var(--text-dim);
  vertical-align: super;
  margin-left: 1px;
}
.tuner-string-hz {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-mute);
}
.tuner-string-btn.playing {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(247,212,134,0.18), rgba(247,212,134,0.05));
  box-shadow: 0 0 0 1px var(--accent), 0 0 24px -4px rgba(247,212,134,0.55);
}
.tuner-string-btn.playing .tuner-string-name {
  color: #fff;
  text-shadow: 0 0 14px rgba(247,212,134,0.8);
}

.tuner-status {
  min-height: 30px;
  font-size: 13px;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 8px;
}
.tuner-status.active { color: var(--text); }
.tuner-status .tuner-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--accent); }
.tuner-octave-hint {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  color: var(--text-mute);
  font-style: italic;
}
.tuner-status-pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  animation: tunerPulse 1.1s ease-in-out infinite;
}
@keyframes tunerPulse {
  0%, 100% { opacity: 0.45; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.1); }
}

/* Mic tuner */
.tuner-mic-display {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.45), rgba(0,0,0,0.15));
  margin-bottom: 14px;
}
.tuner-note {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 56px; font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  line-height: 1;
  transition: color 0.15s, text-shadow 0.15s;
}
.tuner-note.in-tune {
  color: var(--good);
  text-shadow: 0 0 22px rgba(74,222,128,0.55);
  animation: tunerInTune 0.9s ease-in-out infinite;
}
@keyframes tunerInTune {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
.tuner-freq {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 4px;
}

.tuner-needle-area {
  width: 100%; max-width: 320px;
  margin: 18px auto 6px;
}
.tuner-needle-bar {
  position: relative;
  height: 36px;
  background: linear-gradient(90deg,
    rgba(255,93,108,0.18) 0%,
    rgba(255,93,108,0.10) 20%,
    rgba(247,212,134,0.10) 40%,
    rgba(74,222,128,0.18) 50%,
    rgba(247,212,134,0.10) 60%,
    rgba(255,93,108,0.10) 80%,
    rgba(255,93,108,0.18) 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.tuner-tick {
  position: absolute; top: 0; bottom: 0;
  width: 1px;
  background: rgba(255,255,255,0.15);
}
.tuner-tick-50l { left: 0%; }
.tuner-tick-25l { left: 25%; }
.tuner-tick-10l { left: 40%; }
.tuner-tick-center { left: 50%; background: rgba(255,255,255,0.45); width: 2px; }
.tuner-tick-10r { left: 60%; }
.tuner-tick-25r { left: 75%; }
.tuner-tick-50r { left: 100%; }
.tuner-needle {
  position: absolute;
  left: 50%; top: 4px; bottom: 4px;
  width: 4px;
  border-radius: 2px;
  background: var(--text-dim);
  box-shadow: 0 0 12px rgba(255,255,255,0.3);
  transform: translateX(-50%);
  transition: transform 0.08s linear, background 0.15s, box-shadow 0.15s;
}
.tuner-needle.good { background: var(--good); box-shadow: 0 0 16px var(--good); }
.tuner-needle.ok   { background: var(--accent); box-shadow: 0 0 16px var(--accent); }
.tuner-needle.bad  { background: var(--danger); box-shadow: 0 0 16px var(--danger); }

.tuner-needle-labels {
  display: flex; justify-content: space-between;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--text-mute);
  margin-top: 4px;
  padding: 0 2px;
}
.tuner-cents {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 8px;
  letter-spacing: 0.02em;
}

.tuner-mic-controls {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  margin-bottom: 10px;
}
#tunerMicStart.playing {
  background: rgba(255,93,108,0.15); color: var(--danger); border-color: rgba(255,93,108,0.4);
}
.tuner-a4 {
  display: inline-flex; flex-direction: column; gap: 4px;
  font-size: 11px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.tuner-a4 select {
  appearance: none; -webkit-appearance: none;
  padding: 8px 24px 8px 12px;
  background: rgba(0,0,0,0.3) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='none' stroke='%23a8a39b' stroke-width='1.5' d='M2 4l3 3 3-3'/></svg>") no-repeat right 8px center;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  outline: none;
  text-transform: none;
  letter-spacing: normal;
}
.tuner-a4 select option { background: #14171f; color: var(--text); }

.tuner-mic-status {
  font-size: 12.5px;
  color: var(--text-dim);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0,0,0,0.25);
}
.tuner-mic-status.ok { color: var(--good); border-color: rgba(74,222,128,0.3); background: rgba(74,222,128,0.06); }
.tuner-mic-status.err { color: var(--danger); border-color: rgba(255,93,108,0.4); background: rgba(255,93,108,0.06); }

@media (max-width: 720px) {
  .tuner-note { font-size: 44px; }
  .tuner-strings { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 6px; }
  .tuner-string-btn { padding: 12px 6px; }
  .tuner-string-name { font-size: 20px; }
}

/* ===== Score Editor page (/editor) ===== */
.editor-body { min-height: 100vh; display: flex; flex-direction: column; }
.editor-stage {
  position: relative; z-index: 5;
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.editor-title {
  font-size: 26px;
  font-weight: 800;
  margin: 8px 0 0;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 60%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.editor-intro {
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.55;
}
.editor-intro kbd {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
}
.editor-intro strong { color: var(--text); font-weight: 600; }

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.012));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(20px);
}
.ed-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
.ed-field { display: flex; flex-direction: column; gap: 4px; }
.ed-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.ed-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 24px 6px 10px;
  background: rgba(0,0,0,0.3) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239a948c' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>") no-repeat right 8px center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit; font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  outline: none;
  min-width: 84px;
}
.ed-select:hover { border-color: var(--border-strong); background-color: rgba(0,0,0,0.4); }
.ed-select:focus-visible { border-color: var(--accent); }
.ed-select option { background: #14171f; color: var(--text); }

.ed-btn {
  display: inline-flex;
  align-items: center; justify-content: center;
  gap: 6px;
  min-width: 38px; min-height: 38px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ed-btn:hover { background: var(--surface-strong); color: var(--text); border-color: var(--border-strong); }
.ed-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ed-btn.active {
  background: rgba(247,212,134,0.18);
  border-color: var(--accent);
  color: var(--accent);
}
.ed-dur { font-family: serif; font-size: 22px; line-height: 1; padding: 4px 10px; }
.ed-acc { font-family: serif; font-size: 18px; padding: 4px 10px; min-width: 36px; }
.ed-rest { font-family: serif; font-size: 14px; padding: 6px 12px; }
.ed-dotted { font-size: 12px; }
.ed-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #e6b85e 100%);
  color: #07080c;
  border-color: transparent;
}
.ed-primary:hover { color: #07080c; filter: brightness(1.07); }
.ed-primary.playing,
.ed-primary:focus-visible { box-shadow: 0 0 0 3px rgba(247,212,134,0.35); }
.ed-danger {
  color: var(--danger);
  border-color: rgba(255,93,108,0.35);
}
.ed-danger:hover {
  background: rgba(255,93,108,0.12);
  color: #fff;
  border-color: var(--danger);
}

.staff-wrap {
  background: #fbf6e9;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  box-shadow: var(--shadow-deep);
  -webkit-overflow-scrolling: touch;
}
#scoreCanvas {
  display: block;
  width: 100%;
  height: 220px;
  border-radius: 8px;
  background: #fbf6e9;
  cursor: crosshair;
  touch-action: manipulation;
}
#scoreCanvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ed-status {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-mute);
  text-align: center;
  padding: 4px 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.editor-export {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.012));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.ed-export-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.editor-help {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 22px;
}
.editor-help h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 0 0 10px;
}
.editor-help ul {
  margin: 0;
  padding-left: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 4px 22px;
}
.editor-help li {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
}
.editor-help strong { color: var(--text); font-weight: 600; }
.editor-help kbd {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  padding: 1px 5px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}

@media (max-width: 720px) {
  .editor-stage { padding: 8px 14px 32px; gap: 12px; }
  .editor-title { font-size: 22px; }
  .editor-toolbar { padding: 10px 12px; gap: 8px 12px; }
  .ed-btn { min-width: 36px; min-height: 36px; padding: 4px 10px; font-size: 13px; }
  .ed-dur { font-size: 20px; }
  #scoreCanvas { height: 180px; }
  .editor-help { padding: 12px 16px; }
  .editor-help ul { grid-template-columns: 1fr; }
}
