/* =====================================================
   Groovepath — Entrenador de Bajo Eléctrico
   Paleta: oscura inspirada en caoba + electrónica
   Fuentes: Rajdhani (display) + Inter (body)
   ===================================================== */

/* ===== TOKENS ===== */
:root {
  /* Dark theme (default) */
  --bg:          #0D0D0D;
  --bg-surface:  #141414;
  --bg-raised:   #1C1C1C;
  --bg-panel:    #111111;
  --border:      #2A2A2A;
  --border-fret: #8B6914;

  --text-primary:   #F0EAD6;
  --text-secondary: #A09880;
  --text-muted:     #5A5548;

  --accent:        #E84560;   /* tónica / neon rojo */
  --accent-glow:   rgba(232, 69, 96, 0.35);
  --scale-note:    #4EC9B0;   /* notas de escala */
  --scale-glow:    rgba(78, 201, 176, 0.30);
  --detected:      #F5C518;   /* nota detectada */
  --detected-glow: rgba(245, 197, 24, 0.40);
  --off-scale:     #3A3530;
  --arpeggio:      #A855F7;   /* arpegio */
  --arpeggio-glow: rgba(168, 85, 247, 0.35);

  --chord-tone:      #2ecc71;
  --scale-passing:   #3498db;
  --out-scale:       #e74c3c;

  /* Fretboard materials */
  --wood:         #1A1208;
  --wood-light:   #241A0C;
  --nut:          #D4B483;
  --fret-wire:    #C0A060;
  --string-1:     #9090A0;   /* G — más delgada */
  --string-2:     #808090;   /* D */
  --string-3:     #706A7A;   /* A */
  --string-4:     #604D60;   /* E — más gruesa */
  --marker:       #2E2E2E;
  --marker-glow:  rgba(192, 160, 96, 0.20);

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;

  --shadow-card: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-glow-accent: 0 0 16px var(--accent-glow);
  --shadow-glow-scale:  0 0 14px var(--scale-glow);

  --transition: 200ms ease;
  --transition-slow: 400ms ease;
}

/* Light theme overrides */
.light {
  --bg:          #F4F1EB;
  --bg-surface:  #FFFDF8;
  --bg-raised:   #EEEBDF;
  --bg-panel:    #FAF8F2;
  --border:      #DDD8CC;
  --border-fret: #9B7A1A;

  --text-primary:   #1A1510;
  --text-secondary: #5A5040;
  --text-muted:     #9A9080;

  --accent:        #C0253A;
  --accent-glow:   rgba(192, 37, 58, 0.25);
  --scale-note:    #1A8F7A;
  --scale-glow:    rgba(26, 143, 122, 0.22);
  --detected:      #B5860A;
  --detected-glow: rgba(181, 134, 10, 0.30);
  --off-scale:     #D8D4C8;
  --arpeggio:      #9333EA;
  --arpeggio-glow: rgba(147, 51, 234, 0.25);

  --chord-tone:      #27ae60;
  --scale-passing:   #2980b9;
  --out-scale:       #c0392b;

  --wood:       #3B2408;
  --wood-light: #4E3012;
  --nut:        #C8A860;
  --fret-wire:  #A08030;
  --string-1:   #707080;
  --string-2:   #606070;
  --string-3:   #505060;
  --string-4:   #403650;
  --marker:     #C0B8A0;
  --marker-glow: rgba(160, 128, 48, 0.15);

  --shadow-card: 0 4px 24px rgba(0,0,0,0.12);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background var(--transition-slow), color var(--transition-slow);
}

/* ===== HEADER ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-primary);
  text-decoration: none;
}

.brand-icon {
  height: 28px;
  width: auto;
  flex-shrink: 0;
}
.brand-name {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.5px;
  color: var(--accent);
}
.brand-lab {
  color: var(--scale-note);
}

.header-controls { display: flex; align-items: center; gap: 0.75rem; }

.header-stats-summary {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  padding: 0 2px;
  background: none;
  border: none;
  outline: none;
  line-height: inherit;
}
.header-stats-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.header-stats-summary:hover { color: var(--text-primary); }
.header-stats-summary .hss-strong { color: var(--text-primary); }
.header-stats-summary .hss-icon { margin: 0 2px; }

.volume-label {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

#volumeSlider {
  appearance: none;
  width: 80px;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  vertical-align: middle;
}
#volumeSlider::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: box-shadow var(--transition);
}
#volumeSlider::-webkit-slider-thumb:hover {
  box-shadow: var(--shadow-glow-accent);
}
#volumeSlider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}
#volumeSlider::-moz-range-track {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.btn-icon:hover { color: var(--text-primary); border-color: var(--accent); }
.btn-icon svg { width: 18px; height: 18px; }

.help-btn {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
}

/* ===== MOBILE HEADER ===== */
.desktop-only { display: inline-flex; }
.mobile-only { display: none; }
.mobile-control { display: none; }

.volume-mobile-wrap { position: relative; display: none; }
.volume-mobile-wrap.active { display: inline-flex; }

.mobile-menu {
  display: none;
  position: fixed;
  top: 56px;
  right: 0;
  width: 220px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow-card);
  z-index: 200;
  flex-direction: column;
  padding: 0.5rem 0;
}
.mobile-menu.active { display: flex; }
.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.65rem 1rem;
  background: none;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.mobile-menu-item:hover { background: var(--bg-raised); color: var(--accent); }
.mobile-menu-item i { width: 1.1rem; text-align: center; color: var(--text-muted); }

.volume-popover {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow-card);
  z-index: 200;
}
.volume-mobile-wrap.active .volume-popover { display: block; }
.volume-popover input[type="range"] {
  appearance: none;
  width: 120px;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  writing-mode: horizontal-tb;
}
.volume-popover input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

@media (max-width: 640px) {
  .brand-icon { height: 22px; width: auto; }
  .brand-name { font-size: 1.1rem; }
  .header-inner { padding: 0 0.5rem; }
}

/* ===== SECTION COLLAPSE ===== */
.section-header {
  display: none;
}
.section-header-title {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.section-collapse-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: color 0.2s;
  display: flex;
  align-items: center;
}
.section-collapse-btn:hover {
  color: var(--text-primary);
}
.section-chevron {
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.tab-panel.collapsed .section-chevron {
  transform: rotate(-90deg);
}

@media (min-width: 601px) {
  .section-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    user-select: none;
    padding: 0.2rem 0 0.3rem;
    margin-bottom: 0.1rem;
  }
  .tab-panel.collapsed > *:not(.section-header) {
    display: none;
  }
}

/* ===== MAIN LAYOUT ===== */
.app-main {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ===== FOOTER ===== */
.app-footer {
  text-align: center;
  padding: 1.25rem 1rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}
.footer-text {
  color: var(--text-secondary);
}
.footer-sep {
  margin: 0 0.4rem;
  color: var(--border);
}
.footer-heart {
  color: var(--accent);
}

/* ===== MOBILE TABS ===== */
.mobile-tabs {
  display: none;
  gap: 0.35rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.mobile-tabs::-webkit-scrollbar { display: none; }

.mobile-tab {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.5rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.mobile-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tab-panel { display: block; }

/* ===== CONTROLS PANEL ===== */
.controls-panel {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 1.25rem;
  align-items: start;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-card);
}

.control-group { display: flex; flex-direction: column; gap: 0.5rem; }

.control-label {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Note grid (root selector) */
.note-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}

.note-btn {
  padding: 5px 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  white-space: nowrap;
}
.note-btn:hover { border-color: var(--scale-note); color: var(--scale-note); }
.note-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-glow-accent);
}

/* Select */
.styled-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-raised) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A09880' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 7px 32px 7px 10px;
  cursor: pointer;
  transition: border-color var(--transition);
  width: 100%;
}
.styled-select:focus { outline: none; border-color: var(--accent); }
.styled-select option { background: var(--bg-raised); color: var(--text-primary); }

.custom-tuning-notes {
  display: flex;
  gap: 4px;
  margin-top: 5px;
}
.custom-note-input {
  width: 42px;
  padding: 3px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-primary);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  text-align: center;
  text-transform: uppercase;
}
.custom-note-input:focus {
  outline: none;
  border-color: var(--scale-note);
  box-shadow: 0 0 6px var(--scale-glow);
}

/* Toggle */
.toggle-group { justify-content: center; }
.toggle-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.toggle-switch { position: relative; width: 38px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-knob {
  position: absolute;
  inset: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all var(--transition);
}
.toggle-knob::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  top: 3px;
  left: 3px;
  transition: all var(--transition);
}
.toggle-switch input:checked + .toggle-knob { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-knob::before { transform: translateX(16px); background: #fff; }
.toggle-switch input:disabled + .toggle-knob { opacity: 0.35; cursor: not-allowed; }
.toggle-switch input:disabled + .toggle-knob::before { background: var(--border); }

/* ===== FRET RANGE CONTROLS ===== */
.range-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.range-select {
  width: 58px;
  padding-left: 6px;
  padding-right: 6px;
  text-align: center;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
}
.range-sep {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
}
.preset-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.preset-btn {
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.preset-btn:hover { border-color: var(--scale-note); color: var(--scale-note); }
.preset-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===== OFF-RANGE CELLS ===== */
.fret-cell.off-range {
  opacity: 0.25;
  pointer-events: none;
}
.fret-cell.off-range .string-line { opacity: 0.25; }
.fret-cell.off-range .note-dot { opacity: 0 !important; }
.fret-cell.off-range .fret-marker { opacity: 0.3; }
.fret-num.off-range {
  opacity: 0.25;
}

/* ===== FRETBOARD ===== */
.fretboard-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem 0.75rem;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  z-index: 20;
}
.fretboard-section.fixed {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: var(--shadow-card), 0 4px 24px rgba(0,0,0,0.35);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.fretboard-spacer {
  visibility: hidden;
  pointer-events: none;
}

.fretboard-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.fretboard-scroll {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.fretboard-scroll::-webkit-scrollbar { height: 4px; }
.fretboard-scroll::-webkit-scrollbar-track { background: var(--bg-raised); border-radius: 2px; }
.fretboard-scroll::-webkit-scrollbar-thumb { background: var(--border-fret); border-radius: 2px; }

/* The actual fretboard */
.fretboard {
  display: grid;
  /* 25 columns: nut + 24 frets */
  grid-template-columns: 38px repeat(24, 1fr);
  grid-template-rows: repeat(4, 52px);
  min-width: 900px;
  background: var(--wood);
  border-radius: var(--radius-md);
  position: relative;
  border: 2px solid var(--nut);
  overflow: hidden;
}

/* Wood grain lines between strings */
.fretboard::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 12px,
    rgba(255,255,255,0.012) 12px,
    rgba(255,255,255,0.012) 13px
  );
  pointer-events: none;
}

/* Fret cell */
.fret-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-right: 2px solid var(--fret-wire);
  border-bottom: none;
  transition: background var(--transition);
  background: transparent;
}
.fret-cell:hover { background: rgba(192,160,96,0.06); }

/* Nut (column 0) */
.fret-cell.nut {
  border-right: 6px solid var(--nut);
  background: var(--wood-light);
  cursor: default;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
}

/* String line */
.string-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 1;
}
/* String thickness per row */
.string-row-0 .string-line { height: 1px;  background: var(--string-1); }
.string-row-1 .string-line { height: 2px;  background: var(--string-2); }
.string-row-2 .string-line { height: 3px;  background: var(--string-3); }
.string-row-3 .string-line { height: 4px;  background: var(--string-4); }

/* Fretboard markers */
.fret-marker {
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--marker);
  box-shadow: 0 0 6px var(--marker-glow);
  pointer-events: none;
  z-index: 0;
  transition: background var(--transition), box-shadow var(--transition);
}
.fret-marker.double {
  width: 6px;
  height: 6px;
}
.fret-marker.double + .fret-marker-2 {
  top: 3px;
  bottom: auto;
}

/* Note dot on fretboard */
.note-dot {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  z-index: 3;
  pointer-events: none;
  transition: all var(--transition);
  box-shadow: none;
  opacity: 0;
  transform: scale(0.7);
}
.note-dot.visible {
  opacity: 1;
  transform: scale(1);
}
.note-dot.tonic {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-glow-accent);
}
.note-dot.scale-note {
  background: var(--scale-note);
  color: #0D1A18;
  box-shadow: var(--shadow-glow-scale);
}
.note-dot.off-scale {
  background: var(--off-scale);
  color: var(--text-muted);
  opacity: 0.55;
  transform: scale(0.85);
}
.note-dot.detected {
  background: var(--detected) !important;
  color: #0D0C00 !important;
  box-shadow: 0 0 18px var(--detected-glow), 0 0 36px var(--detected-glow) !important;
  animation: detected-pulse 1s ease-in-out infinite;
}

@keyframes detected-pulse {
  0%, 100% { box-shadow: 0 0 14px var(--detected-glow), 0 0 28px var(--detected-glow); }
  50%       { box-shadow: 0 0 22px var(--detected-glow), 0 0 44px var(--detected-glow); }
}

.note-dot.playing {
  animation: note-tap 0.2s ease-out;
}
@keyframes note-tap {
  0%   { filter: brightness(1.8); }
  100% { filter: brightness(1); }
}

/* Arpeggio dot — diamond shape */
.note-dot.arpeggio {
  border-radius: 5px;
  transform: rotate(45deg) scale(1);
  background: var(--arpeggio);
  color: #fff;
  box-shadow: 0 0 12px var(--arpeggio-glow);
}
.note-dot.arpeggio .dot-text {
  display: block;
  transform: rotate(-45deg);
  font-size: 0.62rem;
}
.note-dot.arpeggio.visible {
  opacity: 1;
}
.note-dot.arpeggio.detected {
  background: var(--detected) !important;
  color: #0D0C00 !important;
  box-shadow: 0 0 18px var(--detected-glow), 0 0 36px var(--detected-glow) !important;
}

/* Fret numbers row */
.fret-numbers {
  display: grid;
  grid-template-columns: 38px repeat(24, 1fr);
  min-width: 900px;
  padding: 0 2px;
}
.fret-num {
  text-align: center;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 3px 0;
  letter-spacing: 0.04em;
}
.fret-num.marker-fret { color: var(--border-fret); }

/* ===== TUNER PANEL ===== */
.tuner-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-card);
}

.tuner-display {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex: 1;
  flex-wrap: wrap;
}

.detected-note-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}
.detected-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.detected-note {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 3rem;
  line-height: 1;
  color: var(--detected);
  text-shadow: 0 0 20px var(--detected-glow);
  letter-spacing: 0.02em;
  transition: color var(--transition);
  min-width: 56px;
  text-align: center;
}
.detected-octave {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Tuner meter */
.tuner-meter-wrap { flex: 1; min-width: 200px; max-width: 400px; }
.tuner-meter { display: flex; flex-direction: column; gap: 6px; }

.meter-track {
  position: relative;
  height: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.meter-fill {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 0;
  background: var(--scale-note);
  transition: width 0.12s ease-out, left 0.12s ease-out, background-color 0.15s ease;
  border-radius: 999px;
}
.meter-fill.flat  { background: #E84560; transform-origin: right; }
.meter-fill.sharp { background: #F5C518; transform-origin: left; }
.meter-fill.in-tune { background: var(--scale-note); }

.meter-center-line {
  position: absolute;
  top: -2px; bottom: -2px;
  left: 50%;
  width: 2px;
  background: var(--text-muted);
  transform: translateX(-50%);
}
.meter-needle {
  position: absolute;
  top: -4px; bottom: -4px;
  width: 3px;
  background: var(--detected);
  border-radius: 999px;
  left: 50%;
  transform: translateX(-50%);
  transition: left 0.12s ease-out;
  box-shadow: 0 0 6px var(--detected-glow);
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.tuner-status {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  transition: color var(--transition);
}
.tuner-status.in-tune { color: var(--scale-note); }
.tuner-status.flat    { color: var(--accent); }
.tuner-status.sharp   { color: var(--detected); }

.tuner-freq {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Mic button */
.tuner-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.btn-mic {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 24px;
  background: var(--bg-raised);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-mic svg { width: 28px; height: 28px; }
.btn-mic:hover { border-color: var(--accent); color: var(--accent); }
.btn-mic.active {
  background: rgba(232, 69, 96, 0.12);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

.mic-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.mic-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition), box-shadow var(--transition);
}
.mic-dot.active {
  background: var(--scale-note);
  box-shadow: 0 0 8px var(--scale-glow);
  animation: micPulse 1.4s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 4px var(--scale-glow); }
  50%      { box-shadow: 0 0 14px var(--scale-glow); }
}

.mic-error-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-top: 0.5rem;
  border: 1px solid rgba(232, 69, 96, 0.3);
  border-radius: var(--radius-sm);
  background: rgba(232, 69, 96, 0.06);
  font-size: 0.72rem;
  color: var(--accent);
  line-height: 1.4;
}
.mic-error-icon {
  font-size: 1rem;
  flex-shrink: 0;
}
@keyframes dot-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ===== TRAINING PANEL ===== */
.training-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  min-height: 120px;
  position: relative;
  overflow: visible;
}

.training-countdown {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 4rem;
  color: var(--accent);
  text-shadow: 0 0 32px var(--accent-glow);
  display: none;
  align-items: center;
  justify-content: center;
  animation: count-pop 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.training-countdown.n3 { color: #ff7676; text-shadow: 0 0 28px rgba(255,118,118,0.45); }
.training-countdown.n2 { color: #ff9f43; text-shadow: 0 0 28px rgba(255,159,67,0.45); }
.training-countdown.n1 { color: #ffcc00; text-shadow: 0 0 28px rgba(255,204,0,0.45); }
.training-countdown.go {
  color: var(--scale-note);
  text-shadow: 0 0 36px var(--scale-glow);
  font-size: 5rem;
}
@keyframes count-pop {
  0%  { transform: scale(1.6); opacity: 0.3; }
  100% { transform: scale(1); opacity: 1; }
}

.training-target {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
}
.target-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.target-note {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 4rem;
  line-height: 1;
  color: var(--detected);
  text-shadow: 0 0 24px var(--detected-glow);
  transition: color 0.2s ease, text-shadow 0.2s ease;
}
.target-note.pop {
  animation: target-pop 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes target-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.training-target.correct-flash .target-note {
  color: var(--scale-note);
  text-shadow: 0 0 40px var(--scale-glow);
}
.training-target.wrong-flash .target-note {
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent-glow);
}
.training-target.shake {
  animation: target-shake 0.45s ease-in-out;
}
@keyframes target-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-5px); }
  40%      { transform: translateX(5px); }
  60%      { transform: translateX(-3px); }
  80%      { transform: translateX(3px); }
}

.training-stats {
  display: flex;
  gap: 2rem;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.stat-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.stat-value {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text-primary);
  transition: color 0.25s ease, text-shadow 0.25s ease, transform 0.25s ease;
}
.stat-value.fast { color: #4caf50; }
.stat-value.ok   { color: #ffcc00; }
.stat-value.slow { color: var(--text-muted); }
#trainingStreak.streak-warm {
  color: #ffcc00;
  text-shadow: 0 0 12px rgba(255,204,0,0.35);
}
#trainingStreak.streak-hot {
  color: #ff9f43;
  text-shadow: 0 0 14px rgba(255,159,67,0.45);
}
#trainingStreak.streak-fire {
  color: var(--accent);
  text-shadow: 0 0 16px var(--accent-glow);
}
#trainingStreak.streak-pop {
  animation: streak-pop 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes streak-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.training-feedback {
  display: none;
  align-items: center;
  justify-content: center;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  padding: 6px 20px;
  border-radius: 999px;
  transition: transform 0.2s ease;
}
.training-feedback.correct {
  color: var(--scale-note);
  background: rgba(78, 201, 176, 0.12);
}
.training-feedback.wrong {
  color: var(--accent);
  background: rgba(232, 69, 96, 0.12);
}
.training-feedback.pop {
  animation: feedback-pop 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes feedback-pop {
  0%   { transform: scale(0.85); opacity: 0.4; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

.training-floats {
  position: relative;
  height: 0;
  pointer-events: none;
}
.training-float {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  pointer-events: none;
  animation: float-up 0.95s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  white-space: nowrap;
}
.training-float.float-correct { color: var(--scale-note); }
.training-float.float-perfect {
  color: #ffcc00;
  text-shadow: 0 0 16px rgba(255,204,0,0.55);
  font-size: 1.4rem;
}
.training-float.float-wrong { color: var(--accent); }
.training-float.float-streak {
  color: #ff9f43;
  text-shadow: 0 0 14px rgba(255,159,67,0.5);
  font-size: 1.3rem;
}
@keyframes float-up {
  0%   { opacity: 0; transform: translate(-50%, 6px) scale(0.9); }
  20%  { opacity: 1; transform: translate(-50%, -2px) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -32px) scale(1); }
}

.training-silence {
  text-align: center;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  margin-top: 8px;
  animation: pulse-border 1.2s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--border); }
  50% { border-color: var(--text-muted); }
}

.training-progress {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}
.training-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--scale-note), #ffcc00);
  border-radius: 2px;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}
.training-progress-fill.indeterminate {
  width: 30% !important;
  animation: progress-indet 1.6s ease-in-out infinite;
}
@keyframes progress-indet {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(360%); }
}

.training-actions {
  display: flex;
  gap: 0.75rem;
}
.btn-training {
  padding: 10px 28px;
  background: var(--accent);
  border: 2px solid var(--accent);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-glow-accent);
}
.btn-training:hover { opacity: 0.85; }
.btn-training:active { transform: scale(0.97); }
.btn-training.stop {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: none;
}

.training-results {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}
.results-header {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-primary);
  letter-spacing: 0.06em;
  animation: result-in 0.4s ease-out;
}
.results-rank {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 3rem;
  line-height: 1;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-muted);
  animation: result-in 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.results-rank[data-rank="S"] {
  color: #ffcc00;
  border-color: rgba(255,204,0,0.55);
  text-shadow: 0 0 18px rgba(255,204,0,0.45);
  box-shadow: 0 0 24px rgba(255,204,0,0.18);
}
.results-rank[data-rank="A"] {
  color: #4caf50;
  border-color: rgba(76,175,80,0.5);
  text-shadow: 0 0 14px rgba(76,175,80,0.35);
}
.results-rank[data-rank="B"] {
  color: #4ec9b0;
  border-color: rgba(78,201,176,0.5);
}
.results-rank[data-rank="C"] {
  color: var(--text-muted);
}
.results-grid {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}
.result-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transform: translateY(10px);
  animation: result-in 0.4s ease-out forwards;
}
.result-item:nth-child(1) { animation-delay: 0.10s; }
.result-item:nth-child(2) { animation-delay: 0.18s; }
.result-item:nth-child(3) { animation-delay: 0.26s; }
.result-item:nth-child(4) { animation-delay: 0.34s; }
.result-item:nth-child(5) { animation-delay: 0.42s; }
.result-item:nth-child(6) { animation-delay: 0.50s; }
@keyframes result-in {
  to { opacity: 1; transform: translateY(0); }
}
.result-val {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--detected);
}
.result-lbl {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Target highlight on fretboard */
.note-dot.target {
  animation: target-glow 1.2s ease-in-out infinite alternate !important;
  transition: filter 0.25s ease;
}
@keyframes target-glow {
  0%   { filter: brightness(1.15) drop-shadow(0 0 4px var(--scale-glow)); }
  100% { filter: brightness(1.45) drop-shadow(0 0 10px var(--scale-glow)); }
}
.note-dot.target-hit {
  animation: target-hit 0.6s ease-out !important;
}
@keyframes target-hit {
  0%   { transform: scale(1); filter: brightness(1.5); }
  50%  { transform: scale(1.25); filter: brightness(1.9) drop-shadow(0 0 14px var(--scale-glow)); }
  100% { transform: scale(1); filter: brightness(1.2); }
}

/* ===== BACKING TRACK PANEL ===== */
.backing-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.backing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.backing-title {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 0;
}
.track-file {
  font-size: 0.65rem;
  color: var(--text-muted);
  max-width: 160px;
}
.track-file-wrap {
  cursor: pointer;
  position: relative;
}
.track-file-wrap input[type="file"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  overflow: hidden;
}
.track-file-btn {
  display: inline-block;
  padding: 3px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 0.65rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}
.track-file-btn:hover {
  border-color: var(--arpeggio);
  color: var(--arpeggio);
}
.track-file-wrap.has-file .track-file-btn {
  border-color: var(--scale-note);
  color: var(--scale-note);
  background: rgba(78, 201, 176, 0.1);
}

.backing-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.btn-backing-play {
  width: 44px;
  height: 44px;
  border: 2px solid var(--scale-note);
  border-radius: 50%;
  background: rgba(78, 201, 176, 0.12);
  color: var(--scale-note);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  line-height: 1;
}
.btn-backing-play:hover { background: rgba(78, 201, 176, 0.25); }
.btn-backing-play.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-glow-accent);
}

.bpm-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.backing-vol-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
#backingVolume {
  appearance: none;
  width: 80px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  cursor: pointer;
}
#backingVolume::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--scale-note);
  cursor: pointer;
}
.bpm-label {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
#bpmSlider {
  appearance: none;
  width: 90px;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
#bpmSlider::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--scale-note);
  cursor: pointer;
}
#bpmSlider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--scale-note);
  border: none;
  cursor: pointer;
}
.bpm-value {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--scale-note);
  min-width: 32px;
  text-align: center;
}

.backing-styles {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.style-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.style-btn:hover { border-color: var(--scale-note); color: var(--scale-note); }
.style-btn.active {
  background: var(--scale-note);
  border-color: var(--scale-note);
  color: #0D1A18;
}
.style-btn.style-free {
  border-color: var(--detected);
  color: var(--detected);
  font-weight: 600;
}
.style-btn.style-free:hover {
  background: var(--detected);
  color: #0D1A18;
  border-color: var(--detected);
}
.style-btn.free-active {
  background: var(--detected);
  border-color: var(--detected);
  color: #0D1A18;
}
.style-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}
.impro-panel {
  display: none;
  flex-direction: column;
  gap: 0.35rem;
}
.impro-panel.active { display: flex; }
.impro-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.impro-chord-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.impro-chord {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--detected);
  transition: color 200ms ease, text-shadow 200ms ease;
}
.impro-chord.countdown {
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
  animation: countdownPulse 350ms ease-in-out;
}
@keyframes countdownPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.impro-beats {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-left: auto;
}
.impro-beats .beat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  transition: background 80ms ease, transform 80ms ease, box-shadow 80ms ease;
}
.impro-beats .beat-dot.on {
  background: var(--scale-note);
  border-color: var(--scale-note);
  transform: scale(1.4);
  box-shadow: 0 0 6px var(--scale-glow);
}
.impro-beats .beat-dot.downbeat.on {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.impro-timeline-wrap {
  position: relative;
  width: 100%;
  padding: 0 4px;
}
.impro-timeline-progress {
  height: 2px;
  background: var(--scale-note);
  border-radius: 1px;
  width: 0%;
  margin-top: -1px;
  transition: width 80ms linear;
  opacity: 0.7;
}
.impro-upcoming.countdown {
  color: var(--accent);
  font-weight: 700;
  animation: countdownPulse 350ms ease-in-out;
}
.impro-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.impro-stat-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.impro-stat-val {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}
.impro-feedback {
  display: none;
  text-align: center;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 3px 12px;
  border-radius: 999px;
}
.impro-feedback.correct { color: var(--scale-note); }
.impro-feedback.wrong   { color: var(--accent); }

.impro-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0;
}
.impro-result-score {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 2.6rem;
  line-height: 1;
  color: var(--detected);
  text-shadow: 0 0 18px var(--detected-glow);
}
.impro-result-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.impro-result-grid {
  display: flex;
  gap: 0.9rem;
  justify-content: center;
  flex-wrap: wrap;
}
.impro-result-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.impro-result-val {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}
.impro-result-lbl {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.45rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.impro-res-detail {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.6rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
}
.impro-res-chords {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  margin: 0.15rem 0;
}
.impro-res-chords-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}
.impro-res-chord {
  display: grid;
  grid-template-columns: 40px 1fr 36px auto;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.6rem;
}
.impro-res-chord-name {
  color: var(--text-primary);
  font-weight: 600;
}
.impro-res-chord-bar {
  height: 5px;
  background: var(--bg-raised);
  border-radius: 3px;
  overflow: hidden;
}
.impro-res-chord-fill {
  display: block;
  height: 100%;
  background: var(--scale-note);
  border-radius: 3px;
  transition: width 400ms ease;
}
.impro-res-chord-acc {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
}
.impro-res-chord-detail {
  color: var(--text-muted);
  font-size: 0.55rem;
}
.impro-res-tip {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.6rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 0.2rem 0.4rem;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--scale-note);
  line-height: 1.4;
}
.impro-res-buttons {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  flex-wrap: wrap;
}
.impro-result-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 14px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.impro-result-secondary:hover {
  color: var(--scale-note);
  border-color: var(--scale-note);
}
.impro-challenge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.6rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--detected);
  flex-wrap: wrap;
}
.impro-challenge.completed {
  border-left-color: var(--scale-note);
  background: rgba(78, 201, 176, 0.08);
}
.impro-challenge-label {
  font-weight: 700;
  color: var(--detected);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.impro-challenge-text {
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}
.impro-challenge-progress {
  color: var(--text-secondary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.impro-daily-streak {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.6rem;
  color: var(--text-secondary);
  padding: 0.1rem 0.4rem;
}
.impro-daily-streak .streak-fire {
  color: var(--detected);
  font-size: 0.85rem;
  animation: streakPulse 1.4s ease-in-out infinite;
}
@keyframes streakPulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; transform: scale(1.08); }
}
.impro-heatmap {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.5rem;
  background: var(--bg-raised);
  border-radius: var(--radius-md);
  margin-top: 0.4rem;
  width: 100%;
}
.impro-heatmap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.impro-heatmap-title {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-primary);
}
.impro-heatmap-close {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}
.impro-heatmap-close:hover { color: var(--accent); }
.impro-heatmap-legend {
  display: flex;
  gap: 0.8rem;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.55rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.hm-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.hm-cold { background: #3498db; }
.hm-warm { background: var(--detected); }
.hm-hot { background: #e74c3c; box-shadow: 0 0 6px #e74c3c; }
.hm-miss { background: transparent; border: 1px dashed var(--text-muted); }
.impro-heatmap-stats {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
}
.note-dot.heatmap-cold { background: #3498db !important; border-color: #3498db !important; }
.note-dot.heatmap-warm { background: var(--detected) !important; border-color: var(--detected) !important; }
.note-dot.heatmap-hot { background: #e74c3c !important; border-color: #e74c3c !important; box-shadow: 0 0 8px #e74c3c; }
.note-dot.heatmap-miss { background: transparent !important; border: 1px dashed var(--text-muted) !important; opacity: 0.6; }
.impro-result-close {
  margin-top: 0.3rem;
  background: var(--bg-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 18px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.impro-result-close:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}

.impro-divider {
  border-top: 1px solid var(--border);
  margin: 0.25rem 0 0.1rem;
}
.impro-config-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.impro-diff-desc {
  font-size: 0.55rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.impro-select {
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
}
.impro-select:focus { border-color: var(--accent); }
.impro-diff-desc {
  font-size: 0.52rem;
  color: var(--text-muted);
  font-family: 'Rajdhani', sans-serif;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.impro-target {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 1px 0;
}
.impro-target .target-label {
  font-size: 0.55rem;
}
.impro-target .target-note {
  font-size: 1.6rem;
  color: var(--detected);
  text-shadow: 0 0 14px var(--detected-glow);
}
.impro-upcoming {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.03em;
  padding: 1px 0;
}

.impro-timeline {
  display: flex;
  gap: 3px;
  justify-content: center;
  padding: 2px 0;
}
.impro-timeline .tl-bar {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 3px 2px;
  border-radius: 4px;
  background: var(--bg-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.impro-timeline .tl-bar.active {
  background: var(--chord-tone, #2ecc71);
  color: #0D0D0D;
  border-color: var(--chord-tone, #2ecc71);
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.4);
}

.impro-help {
  margin-top: 0.35rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.65rem;
  color: var(--text-secondary);
}
.impro-help summary {
  cursor: pointer;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 2px 0;
}
.impro-help summary:hover { color: var(--text-primary); }
.impro-help p { margin: 0.25rem 0; }
.impro-help ul {
  margin: 0.2rem 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.impro-help li { line-height: 1.35; }
.impro-help code {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 0.6rem;
  color: var(--text-primary);
}

/* Fretboard improvisation colours */
.note-dot.chord-tone.visible {
  background: var(--chord-tone, #2ecc71);
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.3);
  color: #fff;
  opacity: 0.75;
}
.note-dot.chord-tone.detected,
.note-dot.scale-passing.detected {
  opacity: 1;
}
.note-dot.scale-passing.visible {
  background: var(--scale-passing, #3498db);
  box-shadow: 0 0 8px rgba(52, 152, 219, 0.25);
  color: #fff;
  opacity: 0.55;
}
.note-dot.out-scale.visible {
  background: var(--out-scale, #e74c3c);
  opacity: 0.35;
  color: #fff;
}
.note-dot.guided-target {
  box-shadow: 0 0 0 2px #ffcc00, 0 0 10px rgba(255,204,0,0.5) !important;
  animation: guided-pulse 1s ease-in-out infinite alternate !important;
  z-index: 3;
}
@keyframes guided-pulse {
  0%   { box-shadow: 0 0 0 2px #ffcc00, 0 0 8px rgba(255,204,0,0.4); }
  100% { box-shadow: 0 0 0 3px #ffcc00, 0 0 16px rgba(255,204,0,0.55); }
}

/* Guided target ring */
.impro-target {
  position: relative;
  padding: 4px 0;
}
.impro-target-ring {
  position: relative;
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.impro-target-ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.impro-ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.07);
  stroke-width: 2.5;
}
.impro-ring-fill {
  fill: none;
  stroke: var(--detected);
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke 0.3s ease;
}
.impro-ring-fill.urgent {
  stroke: var(--accent);
}
.impro-ring-fill.building {
  stroke: #ffcc00;
  transition: opacity 0.15s ease;
}
.impro-target-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  z-index: 1;
}
.impro-target.entering .impro-target-content {
  animation: guided-enter 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes guided-enter {
  0%   { opacity: 0; transform: translateY(6px) scale(0.92); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.impro-target.shake {
  animation: guided-shake 0.45s ease-in-out;
}
@keyframes guided-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-4px); }
  40%      { transform: translateX(4px); }
  60%      { transform: translateX(-3px); }
  80%      { transform: translateX(3px); }
}

/* Feedback glow by type */
.impro-feedback.pop {
  animation: feedback-pop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.impro-feedback.target-glow { text-shadow: 0 0 14px rgba(255,204,0,0.5); }
.impro-feedback.chord-glow  { text-shadow: 0 0 10px var(--scale-glow); }
.impro-feedback.scale-glow  { text-shadow: 0 0 10px rgba(52, 152, 219, 0.4); }
@keyframes feedback-pop {
  0%   { transform: scale(0.85); opacity: 0.5; }
  50%  { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}

/* Floating texts */
.impro-floats {
  position: relative;
  height: 0;
  pointer-events: none;
}
.impro-float {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  pointer-events: none;
  animation: float-up 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  white-space: nowrap;
}
.impro-float.float-target { color: #ffcc00; text-shadow: 0 0 12px rgba(255,204,0,0.45); }
.impro-float.float-chord  { color: var(--scale-note); }
.impro-float.float-scale  { color: #D4A017; }
.impro-float.float-streak { color: #ff9f43; text-shadow: 0 0 12px rgba(255,159,67,0.4); font-size: 1.15rem; }

/* Streak colors */
#improStreak.streak-warm {
  color: #ffcc00;
  text-shadow: 0 0 10px rgba(255,204,0,0.3);
}
#improStreak.streak-hot {
  color: #ff9f43;
  text-shadow: 0 0 12px rgba(255,159,67,0.4);
}
#improStreak.streak-fire {
  color: var(--accent);
  text-shadow: 0 0 14px var(--accent-glow);
}
#improStreak.streak-pop {
  animation: streak-pop 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes streak-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* Timeline past/next */
.impro-timeline .tl-bar.past {
  opacity: 0.45;
  background: var(--bg-raised);
  color: var(--text-muted);
  border-color: var(--border);
}
.impro-timeline .tl-bar.next {
  border-color: #ffcc00;
  color: #ffcc00;
  box-shadow: 0 0 6px rgba(255,204,0,0.2);
}

/* Results rank */
.impro-res-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-right: 1px;
}
.impro-res-rank[data-rank="S"] {
  color: #ffcc00;
  border-color: rgba(255,204,0,0.5);
  box-shadow: 0 0 8px rgba(255,204,0,0.2);
}
.impro-res-rank[data-rank="A"] {
  color: #4caf50;
  border-color: rgba(76,175,80,0.5);
}
.impro-res-rank[data-rank="B"] {
  color: #4ec9b0;
  border-color: rgba(78,201,176,0.5);
}
.impro-res-rank[data-rank="C"] {
  color: var(--text-muted);
}

/* ===== TRAINING + STATS LAYOUT ===== */
.training-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
  align-items: start;
}
.training-layout.full-width {
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
}
.training-layout.full-width .training-panel {
  min-height: auto;
}

.training-panel {
  min-height: 0;
}

/* ===== STATS PANEL ===== */
.stats-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.stats-title {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 0;
}
.stats-filter {
  width: 150px;
  font-size: 0.75rem;
  padding-top: 4px;
  padding-bottom: 4px;
}

.stats-type-tabs {
  display: flex;
  gap: 3px;
}
.stats-tab {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 0.62rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.stats-tab:hover { border-color: var(--scale-note); color: var(--scale-note); }
.stats-tab.active {
  background: var(--scale-note);
  border-color: var(--scale-note);
  color: #0D1A18;
}

.stats-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 2rem 0;
}

/* Calendar & streaks */
.stats-daily {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--bg-surface);
}
.streak-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
}
.streak-card {
  text-align: center;
  min-width: 64px;
}
.streak-val {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--scale-note);
  display: block;
}
.streak-lbl {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.goal-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.goal-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
#dailyGoalInput {
  width: 46px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-primary);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  text-align: center;
}
#dailyGoalInput:focus { outline: none; border-color: var(--scale-note); }

.goal-meter {
  flex: 1;
  min-width: 60px;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.goal-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--scale-note);
  transition: width 0.5s ease;
}
.goal-text {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
.goal-text.done { color: var(--scale-note); }

/* Heatmap */
.heatmap-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.heatmap-header {
  display: flex;
  gap: 2px;
  align-items: flex-end;
}
.heatmap-months {
  display: flex;
  gap: 2px;
  margin-left: 0;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.5rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
  height: 14px;
  align-items: flex-end;
}
.hm-cell {
  width: 10px;
  min-width: 10px;
  flex-shrink: 0;
}
.hm-label {
  min-width: 10px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: visible;
  position: relative;
  z-index: 1;
}
.heatmap-grid {
  display: flex;
  gap: 2px;
}
.heatmap-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.heatmap-cell {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.15s;
}
.heatmap-cell[data-level="1"] { background: #1A4A3A; }
.heatmap-cell[data-level="2"] { background: #218060; }
.heatmap-cell[data-level="3"] { background: #2EAD80; }
.heatmap-cell[data-level="4"] { background: #4EC9B0; }
.heatmap-cell.hm-empty-cell { background: transparent; }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.5rem;
  color: var(--text-muted);
}
.heatmap-legend-cell {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.stats-empty {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 1rem 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.stat-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.sc-val {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--detected);
}
.sc-lbl {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Chart */
.chart-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 90px;
  padding: 0 2px;
}
.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}
.chart-bar {
  width: 100%;
  max-width: 28px;
  border-radius: 3px 3px 0 0;
  transition: height 0.3s ease;
  min-height: 4px;
}
.chart-label {
  font-size: 0.52rem;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
}

/* History */
.history-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 180px;
  overflow-y: auto;
}
.history-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  color: var(--text-secondary);
  padding: 3px 4px;
  border-radius: 4px;
  background: var(--bg-raised);
}
.hr-date { color: var(--text-muted); font-size: 0.62rem; min-width: 36px; }
.hr-mode { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hr-score { color: var(--detected); font-weight: 600; font-size: 0.72rem; }
.hr-acc { color: var(--text-muted); font-size: 0.62rem; }

.btn-stats-clear {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.65rem;
  cursor: pointer;
  transition: all var(--transition);
  align-self: center;
}
.btn-stats-clear:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== LEGEND ===== */
.legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem 0;
}
.legend-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.legend-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 80px;
}
.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-dot.tonic     { background: var(--accent); box-shadow: var(--shadow-glow-accent); }
.legend-dot.scale-note{ background: var(--scale-note); }
.legend-dot.detected  { background: var(--detected); }
.legend-dot.off-scale { background: var(--off-scale); border: 1px solid var(--border); transform: scale(0.85); }
.legend-dot.arpeggio { background: var(--arpeggio); border-radius: 2px; transform: rotate(45deg) scale(0.85); }
.legend-dot.chord-tone { background: var(--chord-tone, #2ecc71); box-shadow: 0 0 6px rgba(46,204,113,0.4); }
.legend-dot.scale-passing { background: var(--scale-passing, #3498db); box-shadow: 0 0 4px rgba(52,152,219,0.3); }
.legend-dot.out-scale { background: var(--out-scale, #e74c3c); opacity: 0.6; }

/* ===== TOOLTIP ===== */
.note-tooltip {
  position: fixed;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 200;
  display: none;
  white-space: nowrap;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 800px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: inline-flex; }
  .mobile-control { display: none; }
  .mobile-control.active { display: inline-flex; }
  .header-controls { gap: 0.35rem; position: relative; }
  #volumeSlider { display: none; }
  .volume-mobile-wrap { display: inline-flex; position: relative; }
  .volume-mobile-wrap:not(.active) .volume-popover { display: none; }
  .volume-mobile-wrap.active { display: inline-flex; }
  .volume-mobile-wrap.active .volume-popover { display: block; }
  .training-layout.full-width { grid-template-columns: 1fr; }
  .training-layout { grid-template-columns: 1fr; }
  .controls-panel {
    grid-template-columns: 1fr;
    padding: 1rem;
    width: 100%;
    box-sizing: border-box;
  }
  .control-group:first-child { grid-column: 1; }
  .app-main { width: 100%; box-sizing: border-box; padding: 1rem 0.75rem 2rem; gap: 1rem; margin: 0; }
  .app-main > * { min-width: 0; }
  .tuner-panel { grid-template-columns: 1fr; }
  .tuner-display { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .tuner-meter-wrap { width: 100%; max-width: 100%; }
  .tuner-actions { flex-direction: row; align-items: center; gap: 1rem; }
  .btn-mic { flex-direction: row; padding: 10px 16px; }
  .fretboard-section { padding: 1rem 0.25rem 0.5rem; width: 100%; box-sizing: border-box; position: static; }
  .fretboard { min-width: 0; grid-template-columns: 28px repeat(24, 1fr); grid-template-rows: repeat(4, 42px); }
  .fretboard-scroll { overflow-x: visible; }
  .fretboard-scroll::-webkit-scrollbar { display: none; }
  .note-dot { width: 22px; height: 22px; font-size: 0.55rem; }
}

@media (max-width: 600px) {
  .mobile-tabs {
    display: flex;
    padding: 0.5rem 0.75rem;
    position: sticky;
    top: 56px;
    z-index: 90;
    background: var(--bg);
    margin-bottom: 0;
    max-width: 100%;
    gap: 0.35rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-tabs::-webkit-scrollbar { display: none; }
  .mobile-tab { min-width: 0; }
  .tab-panel { display: none; width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; overflow-x: hidden; }
  .tab-panel.active { display: block; }
  .app-main { padding: 0.5rem 0.75rem 1.5rem; gap: 0.5rem; max-width: 100%; }
  .app-main > * { min-width: 0; max-width: 100%; }
  .controls-panel { max-width: 100%; }
  .control-group { min-width: 0; }
  .fretboard-section { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .fretboard-wrapper { min-width: 600px; width: 100%; }
  .fretboard { min-width: 0; width: 100%; }
  .fretboard-scroll { overflow-x: visible; }
  .fret-numbers { min-width: 0; width: 100%; }
  .styled-select { max-width: 100%; }
  .impro-diff-desc { white-space: normal; }
  .training-layout { overflow-x: hidden; }
  .note-grid { grid-template-columns: repeat(3, 1fr); max-width: 100%; }
  .note-btn { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .routine-card { flex-wrap: wrap; max-width: 100%; }
  .routine-actions { flex-basis: 100%; justify-content: flex-end; margin-top: 4px; }
}

@media (max-width: 400px) {
  .note-grid { grid-template-columns: repeat(4, 1fr); }
  .range-select { width: 50px; }
  .custom-note-input { width: 36px; font-size: 0.7rem; }
  .mobile-tab { font-size: 0.68rem; padding: 0.4rem 0.35rem; }
}

/* ===== STATS MODAL ===== */
.stats-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1100;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.stats-modal-backdrop.active {
  display: flex;
}
.stats-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  position: relative;
}
.stats-modal-close {
  position: absolute;
  top: 8px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  z-index: 2;
  line-height: 1;
  padding: 0;
}
.stats-modal-close:hover { color: var(--accent); }
.stats-modal-scroll {
  overflow-y: auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.stats-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.stats-modal-header h2 {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.stats-overview {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.stats-overview .stat-card {
  flex: 1;
  min-width: 100px;
}
.stats-sources {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.stats-source-bar {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 10px;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.stats-source-bar .ssb-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.stats-source-bar .ssb-value {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}
.stats-source-bar .ssb-bar-bg {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}
.stats-source-bar .ssb-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--scale-note);
}
.stats-overview .stat-card .sc-lvl {
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--detected);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ===== HELP MODAL ===== */
.help-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.help-modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.help-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 680px;
  width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem 1.75rem;
  position: relative;
  transform: scale(0.95);
  transition: transform 0.25s ease;
  box-shadow: 0 0 60px rgba(0,0,0,0.5);
  color: var(--text-primary);
}
.help-modal-backdrop.active .help-modal { transform: scale(1); }

.help-modal h2 {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  margin: 0 0 1.25rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.help-section {
  margin-bottom: 1.25rem;
}
.help-section h3 {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--scale-note);
  margin: 0 0 0.35rem;
}
.help-section p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 0 0 0.35rem;
  line-height: 1.5;
}
.help-section ul {
  margin: 0.25rem 0 0 1.2rem;
  padding: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.55;
}
.help-section ul ul { margin-left: 1.2rem; }
.help-section li { margin-bottom: 3px; }
.help-section strong { color: var(--text-primary); }
.help-section em { color: var(--text-muted); font-style: italic; }

.help-modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), border-color var(--transition);
  line-height: 1;
}
.help-modal-close:hover { color: var(--accent); border-color: var(--accent); }

/* ===== NEWS MODAL & BADGE ===== */
.news-btn { position: relative; }
.news-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background: #ff4444;
  border-radius: 50%;
  display: none;
  pointer-events: none;
}
.news-badge-mobile {
  display: none;
  width: 8px;
  height: 8px;
  background: #ff4444;
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 2px;
}

.news-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.news-tab {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.news-tab.active {
  color: var(--scale-note);
  border-bottom-color: var(--scale-note);
}
.news-tab:hover { color: var(--text-primary); }

.news-entry {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.news-entry:last-child { border-bottom: none; }

.news-entry-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}
.news-entry-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
}
.news-entry-version {
  font-size: 0.625rem;
  font-weight: 600;
  background: var(--scale-note);
  color: #0f0f19;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'Rajdhani', sans-serif;
}
.news-entry-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.news-entry-body {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0.15rem 0 0;
}

/* ===== ROUTINES ===== */
.routine-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.routine-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  cursor: pointer;
  transition: border-color var(--transition);
}
.routine-card:hover { border-color: var(--scale-note); }
.routine-card.builtin { border-style: dashed; }
.routine-info { display: flex; flex-direction: column; min-width: 0; }
.routine-name {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.routine-card.builtin .routine-name { color: var(--scale-note); }
.routine-desc {
  font-size: 0.6rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.routine-actions { display: flex; gap: 2px; flex-shrink: 0; }
.routine-actions button {
  width: 22px; height: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), border-color var(--transition);
}
.routine-actions button:hover { color: var(--scale-note); border-color: var(--scale-note); }
.routine-del-btn:hover { color: var(--accent); border-color: var(--accent); }

.routine-toolbar {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.routine-tool-btn {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.62rem;
  cursor: pointer;
  transition: all var(--transition);
}
.routine-tool-btn:hover { border-color: var(--scale-note); color: var(--scale-note); }
.routines-empty {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.75rem 0;
}

/* Routine player modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.active { display: flex; }

/* Routine player modal — no backdrop, floats at top */
.player-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.player-overlay.active {
  display: flex;
}
.player-overlay .routine-player-modal {
  pointer-events: auto;
}

.routine-player-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 2rem 1rem;
  min-width: 280px;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 4px 32px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
}
.rp-close {
  position: absolute;
  top: 4px; right: 8px;
  width: 28px; height: 28px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.rp-close:hover { color: var(--accent); border-color: var(--accent); }
.rp-title {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  margin: 0;
  padding-right: 24px;
}
.rp-desc {
  font-size: 0.7rem;
  color: var(--scale-note);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  line-height: 1.3;
}
.rp-step {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.06em;
}
.rp-timer {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 3rem;
  color: var(--scale-note);
  line-height: 1;
}
.rp-next {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: 'Rajdhani', sans-serif;
}
.rp-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}
.rp-btn {
  width: 44px; height: 44px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.rp-btn:hover { border-color: var(--scale-note); color: var(--scale-note); }
.rp-stop { border-color: var(--accent); color: var(--accent); }
.rp-stop:hover { background: rgba(232,69,96,0.1); }
.rp-result { font-size: 0.82rem; color: var(--scale-note); font-weight: 600; }

/* Routine editor modal */
.routine-editor-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  max-width: 580px;
  width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 0 50px rgba(0,0,0,0.5);
}
.routine-editor-modal h3 {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--text-primary);
}
.re-field-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.re-field-row label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 60px;
  flex-shrink: 0;
}
.re-input {
  flex: 1;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
}
.re-input:focus { outline: none; border-color: var(--scale-note); }

.re-steps-title {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin: 0.75rem 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.re-add-step {
  width: 20px; height: 20px;
  border: 1px solid var(--scale-note);
  border-radius: 50%;
  background: transparent;
  color: var(--scale-note);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.re-steps {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 300px;
  overflow-y: auto;
}
.re-step-row {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  padding: 3px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
}
.re-step-num {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.6rem;
  color: var(--text-muted);
  width: 16px;
  text-align: center;
}
.re-field {
  padding: 2px 3px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-panel);
  color: var(--text-secondary);
  font-size: 0.6rem;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  width: 48px;
  text-align: center;
}
.re-field:focus { outline: none; border-color: var(--scale-note); }
.re-check {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.55rem;
  color: var(--text-muted);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
}
.re-del-step {
  width: 18px; height: 18px;
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.re-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}
.re-btn {
  padding: 5px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all var(--transition);
}
.re-btn:hover { border-color: var(--scale-note); color: var(--scale-note); }
.re-save { background: var(--scale-note); border-color: var(--scale-note); color: #0D1A18; }
.re-save:hover { opacity: 0.85; }

/* Import modal */
.routine-import-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  max-width: 400px;
  width: 90vw;
  box-shadow: 0 0 50px rgba(0,0,0,0.5);
}
.routine-import-modal h3 {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--text-primary);
}
.routine-import-modal p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0 0 0.5rem;
}
.ri-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.7rem;
  resize: vertical;
}
.ri-textarea:focus { outline: none; border-color: var(--scale-note); }
.ri-buttons {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

/* ===== INTERVAL TRAINER ===== */
.it-divider {
  border-top: 1px solid var(--border);
  margin: 0.75rem 0 0.5rem;
}
.interval-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.it-header { display: flex; align-items: center; gap: 0.5rem; }
.it-title {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.it-config-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.it-cfg-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.it-select {
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 0.6rem;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
}
.it-select:focus { outline: none; border-color: var(--scale-note); }

.it-mode-info {
  text-align: center;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--detected);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.it-target-wrap {
  text-align: center;
  padding: 0.2rem 0;
}
.it-target {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--scale-note);
}

.it-stats {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
}
.it-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-family: 'Rajdhani', sans-serif;
}
.it-stat-label {
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.it-stat-item span:last-child {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}

.it-feedback {
  text-align: center;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 2px 12px;
  border-radius: 999px;
  align-self: center;
}
.it-feedback.correct { color: var(--scale-note); }
.it-feedback.wrong   { color: var(--accent); }

.it-silence {
  text-align: center;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  margin-top: 6px;
  animation: pulse-border 1.2s ease-in-out infinite;
}

.it-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}
.it-choice-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.65rem;
  cursor: pointer;
  transition: all var(--transition);
}
.it-choice-btn:hover { border-color: var(--scale-note); color: var(--scale-note); }
.it-choice-btn:active { background: var(--scale-note); color: #0D1A18; border-color: var(--scale-note); }

.it-actions {
  display: flex;
  justify-content: center;
}

.it-results { text-align: center; }
.it-results-title {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.it-results-grid {
  display: flex;
  gap: 1rem;
  justify-content: center;
}
.it-res-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.6rem;
  color: var(--text-muted);
  font-family: 'Rajdhani', sans-serif;
}
.it-res-val {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--scale-note);
}

/* ===== METRONOME WIDGET ===== */
.metronome-widget {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
}

.metro-toggle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: all var(--transition);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  padding: 0;
  font-family: inherit;
}
.metro-toggle:hover {
  border-color: var(--scale-note);
  color: var(--scale-note);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 0 12px var(--scale-glow);
}
.metro-icon {
  font-size: 1rem;
  line-height: 1;
}
.metro-mini-bpm {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.7rem;
  line-height: 1;
}
.metro-mini-status {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.5rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1;
  display: none;
}
.metro-mini-status.active {
  display: block;
  color: var(--scale-note);
  animation: micPulse 1.4s ease-in-out infinite;
}
.metronome-widget.expanded .metro-mini-status { display: none; }

.metro-panel {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  min-width: 220px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  margin-bottom: 0.5rem;
}
.metronome-widget.expanded .metro-panel { display: flex; }

.metro-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.metro-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--scale-note);
  background: rgba(78, 201, 176, 0.1);
  color: var(--scale-note);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  line-height: 1;
  flex-shrink: 0;
}
.metro-play:hover { background: rgba(78, 201, 176, 0.2); }
.metro-play.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.metro-bpm-control {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
}
#metroBpmSlider {
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  cursor: pointer;
  min-width: 60px;
}
#metroBpmSlider::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--scale-note);
  cursor: pointer;
}
.metro-bpm-display {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  min-width: 30px;
  text-align: right;
}
.metro-bpm-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.metro-tap {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.68rem;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: all var(--transition);
  flex-shrink: 0;
}
.metro-tap:hover { border-color: var(--scale-note); color: var(--scale-note); }
.metro-tap:active { background: var(--scale-note); color: #0D1A18; border-color: var(--scale-note); }

.metro-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.metro-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  width: 36px;
  flex-shrink: 0;
}

#metroVolume {
  appearance: none;
  width: 80px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  cursor: pointer;
}
#metroVolume::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--scale-note);
  cursor: pointer;
}

.metro-btn-group {
  display: flex;
  gap: 3px;
}
.metro-sub-btn,
.metro-ts-btn {
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.6rem;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.4;
}
.metro-sub-btn:hover,
.metro-ts-btn:hover { border-color: var(--scale-note); color: var(--scale-note); }
.metro-sub-btn.active,
.metro-ts-btn.active { background: var(--scale-note); border-color: var(--scale-note); color: #0D1A18; }

.metro-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.metro-check input { accent-color: var(--scale-note); }

@media (max-width: 520px) {
  .help-modal, .news-modal { width: 96vw; padding: 1.25rem 1rem; }
  .help-modal h2, .news-modal h2 { font-size: 1.25rem; }
  .news-tab { font-size: 0.8rem; padding: 0.4rem 0.75rem; }
  .metronome-widget { bottom: 0.5rem; right: 0.5rem; }
  .metro-panel { min-width: 200px; padding: 0.6rem 0.75rem; }
}

/* ===== SCROLLBAR GLOBAL ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }