/* ══════════════════════════════════════════════════════
   PiaQuest — Modern Design System
══════════════════════════════════════════════════════ */

/* ── Dark Theme ── */
:root {
  --bg:       #07090f;
  --surface:  #0e1320;
  --surface2: #141b2d;
  --surface3: #1c2540;
  --border:   #1e2d47;
  --border2:  #2e4468;
  /* Accent colors */
  --accent:   #4f8ef7;
  --accent2:  rgba(79,142,247,.14);
  --orange:   #f5a623;
  --orange2:  rgba(245,166,35,.14);
  --green:    #27d98a;
  --green2:   rgba(39,217,138,.14);
  --red:      #f44f5e;
  --red2:     rgba(244,79,94,.14);
  --purple:   #b06ef7;
  --purple2:  rgba(176,110,247,.14);
  --text:     #e8eeff;
  --text2:    #6a85a8;
  --text3:    #3a4f6a;
  /* Aliases for backwards compat */
  --card:     var(--surface);
  --card2:    var(--surface2);
  --blue:     var(--accent);
  --muted:    var(--text2);
  /* Shared */
  --r-sm: 6px; --r-md: 9px; --r-lg: 13px; --r-xl: 18px;
  --shadow:    0 8px 32px rgba(0,0,0,.55);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.35);
}
/* ── Light Theme ── */
html.light {
  --bg:       #f0f4fb;
  --surface:  #ffffff;
  --surface2: #edf0f8;
  --surface3: #e2e7f3;
  --border:   #cdd5e8;
  --border2:  #a5b4cf;
  --accent:   #2563eb;
  --accent2:  rgba(37,99,235,.1);
  --orange:   #d97706;
  --orange2:  rgba(217,119,6,.1);
  --green:    #059669;
  --green2:   rgba(5,150,105,.1);
  --red:      #dc2626;
  --red2:     rgba(220,38,38,.1);
  --purple:   #7c3aed;
  --purple2:  rgba(124,58,237,.1);
  --text:     #0f172a;
  --text2:    #5a6e8a;
  --text3:    #94a3b8;
  --shadow:    0 4px 16px rgba(0,0,0,.1);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
}
html.light #panel-notation .notation-area { background: #f8faff; }

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* ── Global Reset ── */
html, body { overflow: hidden !important; }
@supports (height: 100dvh) { body { height: 100dvh !important; } }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 13px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* min-height:0 needed for flex children to shrink below content */
.min-h-0 { min-height: 0 !important; }

/* ── Theme Button ── */
#theme-btn {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text2);
  font-size: .78rem; padding: 5px 10px; cursor: pointer;
  transition: all .15s; white-space: nowrap; font-family: inherit;
}
#theme-btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border2); }

/* ══ LAYOUT (visual styles only — layout via Bootstrap classes) ══ */

/* Panel 1: Header */
#panel-header {
  border-bottom: 2px solid transparent;
  background: linear-gradient(var(--surface), var(--surface)) padding-box,
              linear-gradient(90deg, var(--accent), var(--purple)) border-box;
  z-index: 100;
}
#panel-header.scrolled {
  box-shadow: 0 2px 12px rgba(0,0,0,.35);
}
#header-logo {
  width: 90px; height: 90px; border-radius: 10px;
}
@media (min-width: 992px) {
  #header-logo { width: 135px; height: 135px; }
}
#panel-header h1 {
  font-size: 1rem; font-weight: 700; letter-spacing: -.2px; white-space: nowrap;
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
#piece-title { font-size: 1.4rem; font-weight: 600; padding: 4px 12px; }
#header-right {
  gap: 4px;
}
/* Normalize header button heights */
#header-right .btn,
#header-right #theme-btn,
#header-right .midi-badge,
#header-right .user-widget { height: 36px; min-width: 36px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; font-size: .82rem; }

/* Header Nav */
#header-nav {
  display: flex; align-items: center; gap: 1px;
  flex: 1; justify-content: center;
}
.nav-btn {
  background: none; border: 1px solid transparent;
  color: var(--text2); font-size: .85rem; font-weight: 500;
  padding: 0 12px; height: 36px;
  border-radius: var(--r-md); cursor: pointer;
  transition: all .15s; font-family: inherit;
}
.nav-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border); }
.nav-btn.active { background: var(--surface2); color: var(--text); border-color: var(--border2); }

/* App Pages */
.app-page { display: none; flex-direction: column; flex: 1; min-height: 0; }
.app-page.active { display: flex; }
#page-train { overflow: hidden; }
#page-stats, #page-settings, #page-admin { overflow-y: auto; padding: 28px; gap: 20px; }
.page-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 20px 24px;
}
.page-section h3 {
  font-size: .72rem; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: .8px; margin-bottom: 14px;
}
/* Stats page */
#page-stats .stats-grid {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 12px;
}
#page-stats .stat {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
#page-stats .stat-val { font-size: 1.7rem; font-weight: 700; }
#page-stats .stat-lbl { font-size: .72rem; color: var(--text2); }
/* Settings page */
#page-settings .controls { display: flex; gap: 8px; flex-wrap: wrap; }
#page-settings .mode-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#page-settings .mode-bar > span { color: var(--text2); font-size: .82rem; min-width: 90px; }

/* Panel 2: Ad-Slot */
#panel-ad {
  flex: 0 0 auto;
  padding: 4px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface); text-align: center;
  position: relative;
  transition: max-height .4s ease, padding .4s ease, opacity .3s ease;
  max-height: 200px; overflow: hidden;
}
#panel-ad.collapsed {
  max-height: 22px; padding: 0 14px; overflow: hidden;
}
#panel-ad.collapsed .ad-slot-inner { display: none; }
#ad-mini-bar {
  display: none; align-items: center; justify-content: center; gap: 8px;
  height: 22px; font-size: .7rem; color: var(--text2);
}
#ad-mini-bar a { color: var(--accent); cursor: pointer; font-weight: 600; text-decoration: none; }
#ad-collapse-btn {
  position: absolute; top: 2px; right: 6px; z-index: 2;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text3);
  font-size: .65rem; cursor: pointer; padding: 1px 6px;
  transition: all .15s; font-family: inherit; line-height: 1.3;
}
#ad-collapse-btn:hover { color: var(--text2); background: var(--surface3); }
.ad-slot-inner {
  background: var(--surface2); border: 1px dashed var(--border2);
  border-radius: var(--r-md); padding: 6px 12px;
  font-size: .75rem; color: var(--text2);
}

/* Panel 3: Settings */
#panel-settings { flex: 0 0 auto; border-top: 1px solid var(--border); background: var(--surface); touch-action: none; }
#settings-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 8px 2px 12px; gap: 8px; user-select: none;
}
#settings-tab-btns { display: flex; gap: 2px; }
#settings-tab-btns button {
  background: none; border: 1px solid transparent;
  color: var(--text2); font-size: .72rem; font-weight: 500;
  padding: 3px 10px; border-radius: var(--r-sm); cursor: pointer;
  transition: all .15s; font-family: inherit; letter-spacing: .1px;
}
#settings-tab-btns button.active {
  background: var(--surface2); color: var(--text); border-color: var(--border2);
}
#settings-tab-btns button:not(.active):hover { color: var(--text); background: var(--surface2); }
#settings-toggle-btn {
  background: none; border: none; color: var(--text3);
  cursor: pointer; font-size: .85rem; padding: 4px 8px;
  border-radius: var(--r-sm); transition: all .15s; font-family: inherit;
}
#settings-toggle-btn:hover { color: var(--text2); background: var(--surface2); }
#settings-body {
  overflow: hidden; max-height: 0; position: relative;
  transition: max-height .3s cubic-bezier(.4,0,.2,1);
}
#settings-body.open { max-height: 130px; height: 130px; }
.settings-tab {
  position: absolute; top: 0; left: 0; right: 0; height: 130px;
  box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  padding: 4px 12px; flex-direction: column; gap: 3px;
  transition: transform .42s cubic-bezier(.4,0,.2,1); will-change: transform;
}
.settings-tab .stats-grid { gap: 3px; width: 100%; flex: 1; grid-template-columns: repeat(4,1fr); grid-template-rows: repeat(2,1fr); }
.settings-tab .stat { padding: 4px 5px; border-radius: var(--r-md); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.settings-tab .stat-val { font-size: 1rem; }
.settings-tab .stat-lbl { font-size: .6rem; }

/* Panel 4: Feedback */
#panel-feedback {
  flex: 0 0 auto; border-bottom: 1px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column; overflow: hidden;
}
#panel-feedback.hidden-mode { display: none; }
#panel-feedback.collapsed #feedback-main { display: none; }
#panel-feedback.collapsed #hold-bar-wrap { height: 0; }
#panel-feedback.collapsed { min-height: 0; border-bottom-color: transparent; }
#feedback-main {
  display: flex; align-items: center; gap: 7px;
  padding: 3px 12px; min-height: 40px; flex-wrap: wrap;
}
#hold-bar-wrap { display: none; }
.feedback { position: relative; overflow: hidden; }
#hold-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%; background: rgba(99,140,255,.15);
  transition: background .15s; pointer-events: none; z-index: 0;
  border-radius: var(--r-md);
}
#hold-tol-marker {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: rgba(255,255,255,.06); pointer-events: none; z-index: 0;
  border-radius: var(--r-md);
}
.feedback .feed-icon, .feedback .feed-msg, .feedback .feed-time { position: relative; z-index: 1; }
@keyframes feedFlashOk {
  0%   { background: rgba(39,217,138,.45); color: #fff; box-shadow: 0 0 24px rgba(39,217,138,.45); }
  40%  { background: rgba(39,217,138,.2); }
  100% { box-shadow: none; }
}
@keyframes feedFlashErr {
  0%   { background: rgba(244,79,94,.4); color: #fff; box-shadow: 0 0 24px rgba(244,79,94,.45); }
  100% { box-shadow: none; }
}
.feedback.flash-ok  { animation: feedFlashOk  .5s ease forwards; }
.feedback.flash-err { animation: feedFlashErr .4s ease; }

/* Feedback field blink when hold-bar is in tolerance window */
@keyframes holdBlink {
  0%, 100% { box-shadow: inset 0 0 20px rgba(39,217,138,.3); }
  50%      { box-shadow: inset 0 0 6px rgba(39,217,138,.1); }
}
.feedback.hold-ready {
  animation: holdBlink .4s ease infinite;
}
#hold-bar.ready {
  background: rgba(39,217,138,.25) !important;
}

/* Panel 5: Notation — layout via Bootstrap, visual only here */
#panel-notation {
  padding: 4px 8px; background: var(--bg);
}
#panel-notation .notation-area {
  background: linear-gradient(180deg, #fefcf8 0%, #f9f5ee 100%);
  border-radius: var(--r-lg);
  padding: 2px 0 2px 8px;
  box-shadow:
    0 1px 2px rgba(0,0,0,.08),
    0 4px 12px rgba(0,0,0,.12),
    0 12px 36px rgba(0,0,0,.18),
    inset 0 1px 0 rgba(255,255,255,.9);
  border: 1px solid rgba(0,0,0,.06);
}
/* Notation scrollbar styling */
#notation-el { z-index: 1; }
#notation-el::-webkit-scrollbar { height: 4px; }
#notation-el::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 2px; }
#notation-el::-webkit-scrollbar-track { background: transparent; }
/* Notenblatt-Modus: vertikal scrollend, mehrzeilig, mehr Höhe */
.notation-area.sheet-mode {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  flex: 3 1 0 !important;
  min-height: 300px !important;
}
/* Im Blattmodus: Notation-Panel maximieren, Keyboard minimieren */
.notation-area.sheet-mode ~ * { /* nichts — Regeln via JS auf Panels */ }
#panel-notation.sheet-active { flex: 5 1 0 !important; }
#panel-kbd.sheet-active { flex: 0 0 auto !important; }
.notation-area.sheet-mode #notation-el {
  height: auto !important;
  overflow: visible !important;
  display: block !important;
}
.notation-area.sheet-mode #notation-scroll {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  margin: 0 !important;
  transform: none !important;
  transition: none !important;
}
.notation-area.sheet-mode #notation-scroll svg {
  width: 100% !important;
  height: auto !important;
}
/* Ladeanimation mit Piano-Logo */
.notation-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%; gap: 4px;
  background: inherit; border-radius: inherit;
}
.notation-loading img {
  width: 150px; height: 150px; object-fit: contain;
  animation: logoBreath 1.8s ease-in-out infinite;
}
.notation-loading .load-title {
  display: none;
}
.notation-loading .load-dots {
  display: flex; gap: 6px; margin-top: -10px;
}
.notation-loading .load-dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); opacity: 0.3;
  animation: dotPulse 1.2s ease-in-out infinite;
}
.notation-loading .load-dots span:nth-child(2) { animation-delay: 0.2s; }
.notation-loading .load-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes logoBreath {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50%      { transform: scale(1.08); opacity: 1; }
}
@keyframes dotPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1; transform: scale(1.2); }
}
#notation-scroll {
  display: inline-block;
  min-width: max-content;
  margin: auto 0;
}
#notation-el svg {
  display: block;
}
/* OSMD Cursor-Balken global verstecken — wir nutzen eigene Noten-Färbung */
#notation-scroll img[style*="position"] { display: none !important; }
/* Feedback-Animationen */
/* ── Note Animations ── */
@keyframes notePulse {
  0% { transform: scale(1); filter: none; }
  40% { transform: scale(1.35); filter: drop-shadow(0 0 8px rgba(39,217,138,.7)); }
  100% { transform: scale(1); filter: none; }
}
@keyframes noteShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px) rotate(-2deg); }
  30% { transform: translateX(6px) rotate(2deg); }
  45% { transform: translateX(-4px) rotate(-1deg); }
  60% { transform: translateX(4px) rotate(1deg); }
  80% { transform: translateX(-2px); }
}
@keyframes comboFloat {
  0% { opacity: 1; transform: translateY(0) scale(0.5); }
  20% { opacity: 1; transform: translateY(-10px) scale(1.3); }
  100% { opacity: 0; transform: translateY(-60px) scale(1); }
}
@keyframes impactFlash {
  0% { opacity: .7; transform: scale(0.3); }
  50% { opacity: .3; transform: scale(1.5); }
  100% { opacity: 0; transform: scale(2); }
}
@keyframes speedLine {
  0% { opacity: .8; width: 0; }
  30% { opacity: .6; width: 40px; }
  100% { opacity: 0; width: 60px; }
}
@keyframes particleBurst {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--px), var(--py)) scale(0); }
}
@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-3px, 2px); }
  30% { transform: translate(3px, -2px); }
  45% { transform: translate(-2px, 1px); }
  60% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, 1px); }
}
.note-pulse { animation: notePulse 0.25s ease; }
.note-shake { animation: noteShake 0.2s ease; }
.notation-shake { animation: screenShake 0.3s ease; }
/* OSMD Cursor-Balken visuell verstecken — im DOM aktiv lassen damit GNotesUnderCursor() funktioniert */
#osmd-container img, #osmd-pattern-container img { opacity: 0 !important; pointer-events: none !important; }
/* Fruit-Ninja Slash */
@keyframes fruitNinjaSlash {
  0% { clip-path: inset(0 100% 0 0); opacity: 1; transform: scale(0.7) rotate(-8deg); }
  30% { clip-path: inset(0 0 0 0); opacity: 1; transform: scale(1) rotate(0deg); }
  60% { opacity: 0.8; transform: scale(1.1) rotate(2deg); }
  100% { clip-path: inset(0 0 0 0); opacity: 0; transform: scale(1.5) rotate(5deg); }
}
@keyframes slashGlow {
  0% { opacity: 0; transform: scale(0.5); }
  30% { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0; transform: scale(2); }
}
.ninja-slash {
  position: absolute; pointer-events: none; z-index: 30;
  width: 90px; height: 90px;
  --slash-angle: 135deg;
  background:
    linear-gradient(var(--slash-angle), transparent 35%, rgba(255,255,255,.15) 42%, rgba(255,255,255,.95) 49%, rgba(255,255,255,.15) 56%, transparent 63%),
    linear-gradient(var(--slash-angle), transparent 38%, rgba(39,217,138,.7) 46%, transparent 50%, rgba(79,195,247,.7) 54%, transparent 62%);
  filter: blur(0.5px);
  animation: fruitNinjaSlash 0.45s cubic-bezier(.25,.46,.45,.94) forwards;
}
.ninja-slash::after {
  content: ''; position: absolute; inset: -10px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, transparent 60%);
  animation: slashGlow 0.4s ease-out forwards;
}
/* Streak Glow — intensiver je höher der Streak */
.note-glow-1 { filter: drop-shadow(0 0 4px rgba(245,166,35,.5)); }
.note-glow-2 { filter: drop-shadow(0 0 8px rgba(245,166,35,.7)) drop-shadow(0 0 2px rgba(255,100,0,.3)); }
.note-glow-3 { filter: drop-shadow(0 0 12px rgba(255,180,0,.8)) drop-shadow(0 0 4px rgba(255,80,0,.5)); }
.note-glow-4 { filter: drop-shadow(0 0 18px rgba(255,200,50,1)) drop-shadow(0 0 6px rgba(255,60,0,.7)) drop-shadow(0 0 30px rgba(255,200,50,.4)); }
/* Aktive Note: leichter 3D-Schatten damit sie "schwebt" */
.note-active-3d { filter: drop-shadow(2px 3px 2px rgba(0,0,0,.2)); }
/* Partikel — leuchtende Funken */
.note-particle {
  position: absolute; width: 5px; height: 5px; border-radius: 50%;
  pointer-events: none; z-index: 25;
  box-shadow: 0 0 6px currentColor, 0 0 12px currentColor;
  animation: particleBurst 0.6s ease-out forwards;
}
/* Combo-Glow bei Streak >= 3 */
@keyframes comboGlow {
  0%,100% { box-shadow: inset 0 0 20px rgba(245,166,35,0), 0 1px 2px rgba(0,0,0,.08); }
  50% { box-shadow: inset 0 0 40px rgba(245,166,35,0.25), 0 0 20px rgba(245,166,35,0.15); }
}
.notation-area.combo-glow { animation: comboGlow 1.5s ease-in-out infinite; }
/* Screen-Flash bei richtiger Note */
.note-flash {
  position: absolute; inset: 0; pointer-events: none; z-index: 20;
  background: radial-gradient(circle, rgba(255,255,255,0.5) 0%, transparent 70%);
  animation: flashFade 0.2s ease-out forwards;
}
@keyframes flashFade { 0% { opacity: 1; } 100% { opacity: 0; } }
#combo-popup {
  position: absolute; top: 10%; left: 50%; z-index: 20;
  transform: translateX(-50%);
  font-size: 1.4rem; font-weight: 800; color: var(--orange);
  text-shadow: 0 0 12px rgba(245,166,35,.5);
  pointer-events: none; opacity: 0;
}
#combo-popup.show { animation: comboFloat 0.8s ease-out forwards; }
#notation-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 8px 4px; gap: 6px 10px; flex-shrink: 0; flex-wrap: wrap;
}
/* Einheitliche Höhe/Style für ALLE Toolbar-Buttons */
#notation-toolbar .btn,
#notation-toolbar .play-btn {
  height: 28px; padding: 0 10px; font-size: .76rem;
  display: inline-flex; align-items: center; box-sizing: border-box;
}
#mode-bar-train {
  display: flex; gap: 4px; align-items: center;
}
#notation-left { display: flex; align-items: center; gap: 5px; flex: 1; flex-wrap: wrap; }
#notation-tempo { display: flex; align-items: center; gap: 5px; font-size: .76rem; color: var(--text2); }
#notation-tempo input[type=range] { width: 90px; accent-color: var(--accent); height: 3px; cursor: pointer; }
#notation-tempo span:last-child {
  min-width: 48px; font-size: .76rem; color: var(--text);
  font-variant-numeric: tabular-nums; font-weight: 500;
}
#notation-dur-wrap { display: flex; align-items: center; gap: 5px; font-size: .76rem; color: var(--text2); }
#notation-dur-wrap select {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 3px 7px; font-size: .76rem; cursor: pointer; font-family: inherit;
}
#notation-focus-btn {
  display: flex; align-items: center; gap: 5px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text2);
  font-size: .76rem; padding: 4px 10px; cursor: pointer;
  transition: all .15s; white-space: nowrap; flex-shrink: 0; font-family: inherit;
}
#notation-focus-btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border2); }
#notation-focus-btn.focus-active { background: var(--accent2); color: var(--accent); border-color: var(--accent); }
#focus-icon { font-size: .9rem; line-height: 1; }

/* Panel 6: Keyboard — layout via Bootstrap, visual only here */
#panel-kbd { border-top: 1px solid var(--border); background: var(--surface); }
#kbd-toggle-row { padding: 2px 12px; }
#kbd-body .kbd-wrap { height: 100%; }
#kbd-body.collapsed { flex: 0 0 0 !important; }

/* Ad-Popup */
#ad-popup-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
}
#ad-popup-box {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r-xl); padding: 28px 32px;
  width: min(400px, 92vw); position: relative; text-align: center; box-shadow: var(--shadow);
}
#ad-popup-close {
  position: absolute; top: 12px; right: 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text2);
  font-size: .78rem; cursor: pointer; padding: 3px 9px;
  transition: all .15s; font-family: inherit;
}
#ad-popup-close:disabled { opacity: .3; cursor: not-allowed; }
#ad-popup-close:not(:disabled):hover { background: var(--surface3); color: var(--text); }
#ad-countdown { font-size: .72rem; color: var(--text2); margin-top: 14px; }
#ad-progress { height: 2px; background: var(--border); border-radius: 2px; margin-top: 8px; overflow: hidden; }
#ad-progress-bar { height: 100%; background: var(--accent); transition: width 1s linear; width: 100%; }

h1 {
  font-size: 1.7rem;
  background: linear-gradient(135deg, var(--accent), var(--orange));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
/* ══ BUTTONS ══ */
.btn {
  padding: 5px 12px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text);
  border-radius: var(--r-md); cursor: pointer; font-size: .78rem; font-weight: 500;
  font-family: inherit; transition: all .15s; white-space: nowrap; line-height: 1.4;
}
.btn:hover { border-color: var(--border2); background: var(--surface3); }
.btn:active { transform: scale(.97); }
.btn.ab { background: var(--green2); border-color: var(--green); color: var(--green); }
.btn.ab:hover { background: rgba(39,217,138,.22); }
.btn.ai { background: var(--orange2); border-color: var(--orange); color: var(--orange); }
.btn.ai:hover { background: rgba(245,166,35,.22); }
.btn.ap { background: var(--purple2); border-color: var(--purple); color: var(--purple); }
.btn.ap:hover { background: rgba(176,110,247,.22); }
.btn.ma { background: var(--accent2); border-color: var(--accent); color: var(--accent); }
.btn.ma:hover { background: rgba(79,142,247,.22); }
.btn.metro-on { background: var(--accent2); border-color: var(--accent); color: var(--accent); }

.play-btn {
  padding: 5px 12px; border-radius: var(--r-md);
  border: 1px solid var(--green); background: var(--green2); color: var(--green);
  cursor: pointer; font-size: .78rem; font-weight: 600; font-family: inherit;
  transition: all .15s; white-space: nowrap;
}
.play-btn:hover { background: rgba(39,217,138,.25); }

/* ══ MIDI Badge ══ */
.midi-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 0 14px;
  height: 30px; box-sizing: border-box;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: .76rem; color: var(--text2);
  cursor: pointer; transition: all .15s; font-family: inherit;
  white-space: nowrap;
}
.midi-badge:hover { border-color: var(--border2); background: var(--surface3); color: var(--text); }
.dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--red); box-shadow: 0 0 6px var(--red);
  transition: background .3s, box-shadow .3s;
}
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 2s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.35} }

/* ══ Controls ══ */
.controls { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
input[type=range] { accent-color: var(--accent); }
select {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 4px 9px; font-size: .78rem; font-family: inherit; cursor: pointer;
}
select:focus { outline: none; border-color: var(--border2); }

/* ══ Settings bar ══ */
.settings-bar {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 8px 14px; margin-bottom: 10px;
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: center;
}
.sctl { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--text2); }
.sctl input[type=range] { width: 90px; }

/* ══ Sections ══ */
.section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 12px 14px; margin-bottom: 10px;
}
.sec-title { font-size: .7rem; color: var(--text2); text-transform: uppercase; letter-spacing: 1.2px; font-weight: 600; margin-bottom: 8px; }

/* ══ Feedback ══ */
.feedback {
  flex: 1; min-width: 0;
  padding: 8px 12px; border-radius: var(--r-md);
  font-weight: 600; font-size: .85rem;
  display: flex; align-items: center; gap: 9px;
  border-left: 3px solid transparent;
  transition: background .2s, border-color .2s;
}
.feedback .feed-icon { font-size: 1rem; flex-shrink: 0; }
.feedback .feed-msg  { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feedback .feed-time { font-size: .72rem; opacity: .6; white-space: nowrap; font-weight: 400; }
.feedback.ok   { background: var(--green2); color: var(--green); border-left-color: var(--green); }
.feedback.err  { background: var(--red2);   color: var(--red);   border-left-color: var(--red); }
.feedback.hold { background: transparent;   color: var(--green); border-left-color: var(--accent); }
.feedback.idle { background: transparent;   color: var(--text2); border-left-color: var(--text3); }

/* ══ Exercise label ══ */
.ex-label { text-align: center; font-size: .8rem; color: var(--text2); }
.rh { color: var(--orange); font-weight: 600; }
.lh { color: var(--accent); font-weight: 600; }

/* ══ Keyboard ══ */
.legend { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; font-size: .74rem; color: var(--text2); }
.leg { display: flex; align-items: center; gap: 4px; }
.leg-sq { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.kbd-wrap { overflow-x: auto; text-align: center; touch-action: none; padding: 0 8px; display: flex; align-items: center; justify-content: center; }

/* ══ Stats ══ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 7px; }
.stat { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 8px; text-align: center; transition: border-color .15s; }
.stat:hover { border-color: var(--border2); }
.stat-val { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.stat-lbl { font-size: .66rem; color: var(--text2); margin-top: 3px; }

.hidden { display: none !important; }

/* ══ Mode bar ══ */
.mode-bar { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; align-items: center; }

/* ══ Kadenz progress ══ */
.cad-prog { display: flex; gap: 7px; justify-content: center; align-items: center; }
.cad-step {
  min-width: 24px; padding: 2px 7px; border-radius: 12px;
  border: 1.5px solid var(--border); font-size: .7rem; font-weight: 600;
  text-align: center; color: var(--text2);
}
.cad-step.done    { background: var(--green2);  border-color: var(--green);  color: var(--green); }
.cad-step.current { background: var(--orange2); border-color: var(--orange); color: var(--orange); }

/* ══ Metronome ══ */
.metro-beats { display: flex; gap: 6px; align-items: center; }
.beat-dot {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--surface2);
  transition: background .05s, border-color .05s, transform .05s;
}
.beat-dot.beat-1 { border-color: var(--red); }
.beat-dot.active { transform: scale(1.3); }
.beat-dot.active.beat-1 { background: var(--red); border-color: var(--red); }
.beat-dot.active:not(.beat-1) { background: var(--accent); border-color: var(--accent); }
#metro-popup-wrap { position: relative; flex-shrink: 0; }
#metro-popup {
  display: none; position: absolute; top: calc(100% + 8px); left: 0;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r-lg); padding: 12px 14px; z-index: 100;
  min-width: 220px; box-shadow: var(--shadow);
  flex-direction: column; gap: 10px;
}
#metro-popup.open { display: flex; }
#metro-popup-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .78rem; color: var(--text2); }

/* ══ Auth / Modal overlay ══ */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(6px);
  padding: 48px 24px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r-xl); padding: 30px 34px;
  width: min(420px, 92vw); position: relative; box-shadow: var(--shadow);
  max-height: 65vh; overflow-y: auto;
}
/* Pricing modal: compact, no scroll */
#pricing-overlay .modal {
  width: min(620px, 94vw); margin: auto;
  padding: 20px 24px 18px;
}
.overlay .modal {
  flex-shrink: 0;
  display: block !important; /* Override Bootstrap .modal { display: none } */
}
@media (max-width: 480px) {
  #pricing-overlay .modal { padding: 16px 14px 14px; }
  #pricing-overlay .modal > div[style*="repeat(3"] { grid-template-columns: 1fr !important; }
}
.modal h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.modal p  { font-size: .8rem; color: var(--text2); margin-bottom: 18px; }
.modal input {
  width: 100%; padding: 8px 12px; margin-bottom: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text); font-size: .86rem;
  font-family: inherit; transition: border-color .15s;
}
.modal input:focus { outline: none; border-color: var(--accent); }
.modal .btn-row { display: flex; gap: 8px; margin-top: 6px; }
.modal .btn-primary {
  flex: 1; padding: 9px; background: var(--accent); color: #fff; border: none;
  border-radius: var(--r-md); font-weight: 700; cursor: pointer;
  font-size: .86rem; font-family: inherit; transition: opacity .15s;
}
.modal .btn-primary:hover { opacity: .88; }
.modal .btn-ghost {
  flex: 1; padding: 9px; background: transparent; color: var(--text2);
  border: 1px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; font-size: .86rem; font-family: inherit; transition: all .15s;
}
.modal .btn-ghost:hover { background: var(--surface2); color: var(--text); }
.modal .auth-switch { text-align: center; margin-top: 12px; font-size: .78rem; color: var(--text2); }
.modal .auth-switch a { color: var(--accent); cursor: pointer; text-decoration: underline; }
.modal-err { color: var(--red); font-size: .78rem; min-height: 18px; margin-bottom: 4px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text2);
  font-size: .8rem; cursor: pointer; padding: 3px 8px;
  transition: all .15s; font-family: inherit;
}
.modal-close:hover { background: var(--surface3); color: var(--text); }

/* ══ User widget ══ */
.user-widget {
  display: flex; align-items: center; gap: 7px; padding: 4px 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: .78rem; cursor: pointer;
  transition: all .15s;
}
.user-widget:hover { background: var(--surface3); border-color: var(--border2); }
.user-avatar {
  width: 25px; height: 25px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .72rem; color: #fff; flex-shrink: 0;
}
.user-name { color: var(--text); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.user-pro  { font-size: .63rem; color: #f59e0b; background: rgba(245,158,11,.15); padding: 1px 6px; border-radius: 10px; font-weight: 600; }

/* ══ Admin Panel ══ */
#page-admin .admin-tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
#page-admin .admin-tab {
  padding: 6px 16px; font-size: .8rem; border-radius: var(--r-md);
  background: var(--surface2); border: 1px solid var(--border); color: var(--text2); cursor: pointer;
}
#page-admin .admin-tab.active { background: var(--accent2); color: var(--accent); border-color: var(--accent); }
#page-admin .admin-panel { display: none; }
#page-admin .admin-panel.active { display: block; }
#page-admin table { width: 100%; border-collapse: collapse; font-size: .78rem; }
#page-admin th { text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--border); color: var(--text2); font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; }
#page-admin td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
#page-admin tr:hover td { background: var(--surface2); }
#page-admin .admin-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
#page-admin .admin-form input, #page-admin .admin-form select {
  padding: 6px 10px; font-size: .8rem; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-family: inherit;
}
#page-admin .admin-form input { flex: 1; min-width: 140px; }
#page-admin .admin-msg { margin-top: 8px; font-size: .8rem; padding: 8px 12px; border-radius: var(--r-md); }
#page-admin .admin-msg.ok { background: var(--green2); color: var(--green); }
#page-admin .admin-msg.err { background: var(--red2); color: var(--red); }
#page-admin .badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: .7rem; font-weight: 600; }
#page-admin .badge-active { background: var(--green2); color: var(--green); }
#page-admin .badge-expired { background: var(--red2); color: var(--red); }
#page-admin .badge-cancelled { background: var(--orange2); color: var(--orange); }
#page-admin .btn-sm { padding: 3px 10px; font-size: .72rem; }
#page-admin .stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
#page-admin .stat-card { flex: 1; min-width: 120px; padding: 12px 16px; background: var(--surface2); border-radius: var(--r-md); border: 1px solid var(--border); text-align: center; }
#page-admin .stat-card .val { font-size: 1.4rem; font-weight: 700; }
#page-admin .stat-card .lbl { font-size: .7rem; color: var(--text2); margin-top: 2px; }

.midi-timer { color: var(--orange); font-weight: 600; }
.midi-timer.warn { color: var(--red); }

/* ══ Profile modal ══ */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.profile-stat { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px; text-align: center; }
.profile-stat .val { font-size: 1.35rem; font-weight: 700; color: var(--accent); }
.profile-stat .lbl { font-size: .67rem; color: var(--text2); }
.chart-wrap { position: relative; height: 170px; margin-top: 12px; }

/* ══ License form ══ */
.license-form { margin-top: 10px; }
.license-form input { text-transform: uppercase; letter-spacing: 1px; }

/* ══ Legal modals (Impressum, Datenschutz, Widerruf) ══ */
#impressum-overlay .modal,
#datenschutz-overlay .modal,
#widerruf-overlay .modal { max-height: 65vh; overflow-y: auto; }
#impressum-overlay h3, #datenschutz-overlay h3, #widerruf-overlay h3 { font-size: .9rem; font-weight: 600; margin: 14px 0 4px; color: var(--text); }
#impressum-overlay p, #impressum-overlay address,
#datenschutz-overlay p, #datenschutz-overlay ul,
#widerruf-overlay p { font-size: .8rem; color: var(--text2); line-height: 1.7; font-style: normal; }
#impressum-overlay a, #datenschutz-overlay a, #widerruf-overlay a { color: var(--accent); }
#datenschutz-overlay code { font-size: .75rem; background: var(--surface3); padding: 1px 4px; border-radius: 3px; }
