/* ============================================================================
   VIVACE EAR TRAINING - STYLESHEET
   Organized by: Variables → Reset → Layout → Components → Utilities → Responsive
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1. CSS VARIABLES & DESIGN TOKENS
   ---------------------------------------------------------------------------- */
:root {
  /* Semantic color tokens */
  --ear-bg: var(--color-bg, #0e0f17);
  --ear-surface: rgba(255,255,255,0.06);
  --ear-surface-alt: rgba(255,255,255,0.1);
  --ear-border: rgba(255,255,255,0.18);
  --ear-accent: var(--accent-color, #ff6ec7);
  --ear-accent-glow: 0 0 0.6rem rgba(255,110,199,0.6);
  --ear-text: var(--color-text, #f5f7fa);
  --ear-text-secondary: rgba(245,247,250,0.7);
  --ear-danger: #ff3d5a;
  --ear-success: #3ddc97;
  --ear-warning: #ffb347;
  --ear-info: #7bb1ff;
  --ear-focus: #7bb1ff;

  /* Border radius */
  --ear-radius-sm: 6px;
  --ear-radius: 12px;
  --ear-radius-lg: 18px;

  /* Shadows */
  --ear-shadow: 0 4px 18px -4px rgba(0,0,0,0.5), 0 0 0 1px var(--ear-border);
  --ear-shadow-sm: 0 2px 8px -2px rgba(0,0,0,0.4), 0 0 0 1px var(--ear-border);
  --ear-glass: backdrop-filter: blur(16px) saturate(140%);

  /* Transitions */
  --ear-transition-fast: 120ms;
  --ear-transition: 200ms;
  --ear-transition-slow: 350ms;

  /* Typography */
  --ear-font-stack: 'Poppins', system-ui, -apple-system, sans-serif;
  
  /* Spacing scale */
  --ear-space-xs: 0.25rem;
  --ear-space-sm: 0.5rem;
  --ear-space-md: 1rem;
  --ear-space-lg: 1.5rem;
  --ear-space-xl: 2rem;

  /* Piano keyboard colors */
  --ear-keyboard-white: #fafafa;
  --ear-keyboard-black: #222;
  --ear-keyboard-highlight: var(--ear-accent);
}

/* Light Theme Overrides */
[data-theme="light"] {
  --ear-bg: var(--color-bg, #f8f9fa);
  --ear-surface: rgba(0,0,0,0.04);
  --ear-surface-alt: rgba(0,0,0,0.08);
  --ear-border: rgba(0,0,0,0.12);
  --ear-accent: var(--accent-color, #ff6ec7);
  --ear-accent-glow: 0 0 0.6rem rgba(255,110,199,0.3);
  --ear-text: var(--color-text, #1a1a1a);
  --ear-text-secondary: rgba(26,26,26,0.7);
  --ear-danger: #e63946;
  --ear-success: #06d6a0;
  --ear-warning: #f77f00;
  --ear-info: #3a86ff;
  --ear-focus: #3a86ff;
  
  /* Shadows for light mode */
  --ear-shadow: 0 4px 18px -4px rgba(0,0,0,0.15), 0 0 0 1px var(--ear-border);
  --ear-shadow-sm: 0 2px 8px -2px rgba(0,0,0,0.1), 0 0 0 1px var(--ear-border);
  --ear-glass: backdrop-filter: blur(16px) saturate(140%);
  
  /* Piano keyboard colors for light mode */
  --ear-keyboard-white: #ffffff;
  --ear-keyboard-black: #1a1a1a;
  --ear-keyboard-highlight: var(--ear-accent);
}

/* ----------------------------------------------------------------------------
   2. RESET & BASE STYLES
   ---------------------------------------------------------------------------- */

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

html.js body { visibility: visible; }
body { 
  font-family: var(--ear-font-stack); 
  background: var(--ear-bg); 
  color: var(--ear-text); 
  margin: 0; 
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link { 
  position: absolute; 
  left: -999px; 
  top: auto; 
  width: 1px; 
  height: 1px; 
  overflow: hidden; 
}
.skip-link:focus { 
  left: 0; 
  top: 0; 
  background: var(--ear-accent); 
  color: #000; 
  padding: var(--ear-space-sm) var(--ear-space-md); 
  z-index: 1000;
  width: auto;
  height: auto;
  box-shadow: var(--ear-shadow);
}

/* ----------------------------------------------------------------------------
   3. HEADER & NAVIGATION
   ---------------------------------------------------------------------------- */

.ear-header { 
  padding: var(--ear-space-lg) clamp(1rem, 4vw, 3rem) var(--ear-space-md); 
  border-bottom: 1px solid var(--ear-border); 
  background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02)); 
  min-height: auto !important; 
  margin-top: 0 !important;
  position: relative;
  z-index: 100;
}
.ear-header__inner { 
  max-width: 1200px; 
  margin: 0 auto; 
  display: grid; 
  gap: var(--ear-space-md); 
}
.ear-header h1 { 
  margin: 0; 
  font-size: clamp(1.8rem, 5vw, 2.8rem); 
  letter-spacing: 1px; 
  font-weight: 600;
  background: linear-gradient(135deg, var(--ear-accent), #ffd86b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle { 
  margin: 0; 
  opacity: 0.85; 
  max-width: 60ch; 
  color: var(--ear-text-secondary);
}
.status-row { 
  display: flex; 
  align-items: center; 
  gap: 0.75rem; 
  flex-wrap: wrap;
  position: relative;
  z-index: 200;
}

/* Instrument Status Badge */
.instrument-status { 
  font-size: 0.7rem; 
  letter-spacing: 0.8px; 
  padding: 0.35rem 0.6rem; 
  background: var(--ear-surface); 
  border: 1px solid var(--ear-border); 
  border-radius: var(--ear-radius-sm); 
  text-transform: uppercase; 
  opacity: 0.85;
  transition: all var(--ear-transition-fast) ease;
}
.instrument-status[data-state="piano"] { 
  background: linear-gradient(135deg, var(--ear-accent), #ffd86b); 
  color: #000; 
  box-shadow: var(--ear-accent-glow); 
  font-weight: 600;
}
.instrument-status[data-state="fallback"] { 
  background: #523b5b; 
  color: #fff; 
}
.instrument-status[data-state="sine"] { 
  background: #2e3d55; 
}

/* Language Selector - Inline Button Group */
.lang-selector-inline { 
  display: inline-flex;
  gap: 0.25rem;
  background: var(--ear-surface);
  padding: 0.25rem;
  border: 1px solid var(--ear-border);
  border-radius: var(--ear-radius);
}

.lang-btn-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: calc(var(--ear-radius) - 2px);
  color: var(--ear-text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all var(--ear-transition-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.lang-btn-inline:hover {
  background: var(--ear-bg-hover);
  border-color: var(--ear-border);
}

.lang-btn-inline:focus-visible {
  outline: 2px solid var(--ear-focus);
  outline-offset: 2px;
}

.lang-btn-inline:active {
  transform: scale(0.96);
}

.lang-btn-inline[aria-checked="true"] {
  background: var(--ear-accent);
  color: #000;
  border-color: var(--ear-accent);
  box-shadow: 0 2px 8px rgba(0, 242, 254, 0.3);
}

.lang-btn-inline .flag-svg {
  width: 20px;
  height: 14px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.lang-btn-inline .lang-label {
  line-height: 1;
}

/* Mobile: Hide labels, show only flags */
@media (max-width: 600px) {
  .lang-selector-inline {
    gap: 0.2rem;
    padding: 0.2rem;
  }
  
  .lang-btn-inline {
    padding: 0.35rem 0.45rem;
    gap: 0;
  }
  
  .lang-btn-inline .lang-label {
    display: none;
  }
  
  .lang-btn-inline .flag-svg {
    width: 24px;
    height: 16px;
  }
}


/* Brand Logo */
.brand { 
  display: inline-flex; 
  align-items: center; 
  gap: 0.6rem; 
  text-decoration: none; 
  font-weight: 600; 
  color: var(--ear-text);
  transition: transform var(--ear-transition-fast) ease;
}
.brand:hover {
  transform: translateY(-2px);
}
.brand img { 
  width: 48px; 
  height: 48px; 
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); 
}

/* Audio Enable Banner (deprecated but kept for compatibility) */
.enable-audio { 
  display: none; 
  padding: 0.75rem 1.25rem; 
  background: var(--ear-warning); 
  color: #000; 
  font-weight: 600; 
  text-align: center; 
}
.enable-audio.active { 
  display: block; 
  animation: pulse-bg 3s ease-in-out infinite; 
}
@media (prefers-reduced-motion: reduce) { 
  .enable-audio.active { animation: none; } 
}
@keyframes pulse-bg { 
  0%, 100% { filter: brightness(1); } 
  50% { filter: brightness(1.15); } 
}

/* Tab Navigation */
.tabs { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 0.4rem; 
  padding: 0.75rem clamp(1rem, 4vw, 3rem); 
  border-bottom: 1px solid var(--ear-border); 
  background: rgba(255,255,255,0.03); 
  position: sticky; 
  top: 0; 
  z-index: 1400;
  backdrop-filter: blur(8px);
}
.tab { 
  background: var(--ear-surface); 
  color: var(--ear-text); 
  border: 1px solid var(--ear-border); 
  padding: 0.55rem 0.9rem; 
  border-radius: var(--ear-radius-sm); 
  cursor: pointer; 
  font-size: 0.9rem; 
  letter-spacing: 0.5px; 
  position: relative;
  transition: all var(--ear-transition-fast) ease;
  font-weight: 500;
}
.tab:hover {
  transform: translateY(-1px);
  box-shadow: var(--ear-shadow-sm);
}
.tab[aria-selected="true"] { 
  background: var(--ear-accent); 
  color: #000; 
  box-shadow: var(--ear-accent-glow);
  font-weight: 600;
}
.tab:focus-visible { 
  outline: 2px solid var(--ear-focus); 
  outline-offset: 2px; 
}

/* ----------------------------------------------------------------------------
   4. MAIN LAYOUT & CONTENT AREAS
   ---------------------------------------------------------------------------- */

.view { 
  padding: 1.2rem clamp(1rem, 4vw, 3rem) 3rem; 
  min-height: 50vh; 
  opacity: 1 !important; 
  transform: none !important; 
  transition: none !important;
}
.ear-main { 
  display: flex; 
  flex-direction: column;
}
.ear-main .view:empty { 
  min-height: 120px; 
  position: relative; 
}
.ear-main .view:empty::before { 
  content: attr(data-loading-msg); 
  position: absolute; 
  inset: 0; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-size: 0.85rem; 
  opacity: 0.7; 
}

/* Section Card Container */
.section-card { 
  background: var(--ear-surface-alt); 
  border: 1px solid var(--ear-border); 
  padding: var(--ear-space-md) 1.2rem; 
  border-radius: var(--ear-radius); 
  box-shadow: var(--ear-shadow); 
  position: relative;
  transition: transform var(--ear-transition-fast) ease, box-shadow var(--ear-transition-fast) ease;
}
.section-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px -6px rgba(0,0,0,0.6), 0 0 0 1px var(--ear-border);
}
.section-card h2 { 
  margin-top: 0; 
}

/* Section Toolbar */
.section-toolbar { 
  display: flex; 
  justify-content: flex-end; 
  align-items: center; 
  gap: 0.5rem; 
  margin: 0.3rem 0 0.6rem; 
}

/* ----------------------------------------------------------------------------
   5. BUTTONS & INTERACTIVE ELEMENTS
   ---------------------------------------------------------------------------- */
.actions { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 0.6rem; 
  margin: 0.75rem 0 1rem; 
}

.btn-primary, 
.btn-secondary, 
.icon-btn { 
  font-family: inherit; 
  cursor: pointer; 
  border-radius: var(--ear-radius-sm); 
  border: 1px solid var(--ear-border); 
  font-weight: 600; 
  letter-spacing: 0.5px;
  transition: all var(--ear-transition-fast) ease;
  position: relative;
  overflow: hidden;
}

.btn-primary { 
  background: var(--ear-accent); 
  color: #000; 
  padding: 0.6rem 1.1rem; 
  box-shadow: var(--ear-accent-glow);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px -4px rgba(255,110,199,0.8);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary { 
  background: var(--ear-surface); 
  color: var(--ear-text); 
  padding: 0.6rem 0.95rem; 
}
.btn-secondary:hover { 
  background: var(--ear-accent); 
  color: #000;
  transform: translateY(-1px);
}

.icon-btn { 
  background: var(--ear-surface); 
  color: var(--ear-text); 
  padding: 0.35rem 0.7rem; 
  font-size: 1.1rem; 
}
.icon-btn:hover { 
  background: var(--ear-accent); 
  color: #000; 
}

/* Light mode: ensure buttons have proper contrast */
[data-theme="light"] .btn-secondary,
[data-theme="light"] .icon-btn,
[data-theme="light"] .ear-modal-header .btn-secondary,
[data-theme="light"] .ear-modal-header .icon-btn {
  background: #ffffff !important;
  color: #1a1a1a !important;
  border: 1px solid rgba(0,0,0,0.25) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
}

[data-theme="light"] .ear-modal-header .btn-secondary,
[data-theme="light"] .ear-modal-header .icon-btn {
  font-size: 1.3rem !important;
  font-weight: 600 !important;
}

[data-theme="light"] .btn-secondary:hover,
[data-theme="light"] .icon-btn:hover,
[data-theme="light"] .ear-modal-header .btn-secondary:hover,
[data-theme="light"] .ear-modal-header .icon-btn:hover {
  background: #f5f5f5 !important;
  color: #000 !important;
  border-color: rgba(0,0,0,0.35) !important;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15) !important;
}

.btn-primary:focus-visible, 
.btn-secondary:focus-visible, 
.icon-btn:focus-visible { 
  outline: 2px solid var(--ear-focus); 
  outline-offset: 2px; 
}

/* Disabled state */
.btn-primary:disabled,
.btn-secondary:disabled,
.icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ----------------------------------------------------------------------------
   6. FEEDBACK & NOTIFICATIONS
   ---------------------------------------------------------------------------- */

/* Toast Notifications */
.toast-container { 
  position: fixed; 
  bottom: 1rem; 
  right: 1rem; 
  display: grid; 
  gap: 0.6rem; 
  z-index: 1500; 
  max-width: 300px;
  pointer-events: none;
}
.toast { 
  background: var(--ear-surface); 
  border: 1px solid var(--ear-border); 
  padding: 0.7rem 0.9rem; 
  border-radius: var(--ear-radius-sm); 
  font-size: 0.85rem; 
  display: flex; 
  gap: 0.6rem; 
  align-items: flex-start; 
  animation: slideInRight var(--ear-transition) ease;
  box-shadow: var(--ear-shadow);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}
.toast[data-type="success"] { 
  border-color: var(--ear-success);
  background: rgba(61, 220, 151, 0.1);
}
.toast[data-type="error"] { 
  border-color: var(--ear-danger);
  background: rgba(255, 61, 90, 0.1);
}
.toast[data-type="info"] {
  border-color: var(--ear-info);
  background: rgba(123, 177, 255, 0.1);
}

@keyframes slideInRight { 
  from { 
    opacity: 0; 
    transform: translateX(100px); 
  } 
  to { 
    opacity: 1; 
    transform: translateX(0); 
  } 
}
@keyframes fade-in { 
  from { 
    opacity: 0; 
    transform: translateY(6px); 
  } 
  to { 
    opacity: 1; 
    transform: translateY(0); 
  } 
}

/* ----------------------------------------------------------------------------
   7. MODALS & OVERLAYS
   ---------------------------------------------------------------------------- */
/* Portal Container */
.ear-portal { 
  position: fixed; 
  inset: 0; 
  z-index: 100000; 
  pointer-events: none; 
}

/* Modal Backdrop */
.ear-modal-backdrop { 
  position: fixed; 
  inset: 0; 
  background: rgba(0,0,0,0.6); 
  backdrop-filter: blur(4px); 
  animation: fade-in var(--ear-transition-fast) ease; 
  pointer-events: auto; 
}

/* Modal Panel */
.ear-modal-panel { 
  position: fixed; 
  left: 50%; 
  top: 50%; 
  transform: translate(-50%, -50%) scale(0.96); 
  width: min(92vw, 960px); 
  max-height: 90vh; 
  overflow: hidden; 
  background: rgba(25,26,36,0.98); 
  border: 1px solid var(--ear-border); 
  border-radius: var(--ear-radius); 
  box-shadow: 0 20px 60px -10px rgba(0,0,0,0.8), 0 0 0 1px var(--ear-border); 
  z-index: 100001; 
  padding: 0; 
  display: grid; 
  grid-template-rows: auto 1fr; 
  gap: 0; 
  pointer-events: auto; 
  opacity: 0; 
  transition: transform var(--ear-transition-fast) ease, opacity var(--ear-transition-fast) ease; 
}
.ear-modal-panel.show { 
  transform: translate(-50%, -50%) scale(1); 
  opacity: 1; 
}
.ear-modal-sm {
  width: min(92vw, 480px);
}

/* Modal Header */
.ear-modal-header { 
  display: flex; 
  align-items: center; 
  gap: 0.6rem; 
  padding: 0.7rem 0.9rem; 
  border-bottom: 1px solid var(--ear-border); 
  position: sticky; 
  top: 0; 
  background: rgba(25,26,36,0.98); 
  z-index: 2;
  backdrop-filter: blur(8px);
}

/* Light mode: ensure modal header has light background */
[data-theme="light"] .ear-modal-header {
  background: rgba(255,255,255,0.98) !important;
  border-bottom-color: rgba(0,0,0,0.15) !important;
}

.ear-modal-header .spacer { 
  flex: 1; 
}
.ear-modal-title { 
  margin: 0; 
  font-size: 1rem; 
  letter-spacing: 0.4px;
  font-weight: 600;
}
.ear-modal-close { 
  margin-left: auto; 
}

/* Light mode: ensure modal close button is visible */
[data-theme="light"] .ear-modal-close {
  background: rgba(0,0,0,0.15) !important;
  color: #1a1a1a !important;
  border: 1px solid rgba(0,0,0,0.3) !important;
}

[data-theme="light"] .ear-modal-close:hover {
  background: rgba(0,0,0,0.25) !important;
  border-color: rgba(0,0,0,0.4) !important;
}

/* Modal Body */
.ear-modal-body { 
  padding: 0.8rem 0.9rem 0.9rem; 
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ear-surface) transparent;
}
.ear-modal-body::-webkit-scrollbar {
  width: 8px;
}
.ear-modal-body::-webkit-scrollbar-track {
  background: transparent;
}
.ear-modal-body::-webkit-scrollbar-thumb {
  background: var(--ear-surface);
  border-radius: 4px;
}
.ear-modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--ear-surface-alt);
}

.ear-modal-message {
  margin: 0 0 var(--ear-space-md);
  line-height: 1.6;
}

/* ============================================================================
   RESET CONFIRMATION MODAL - Beautiful & Fancy
   ============================================================================ */
.reset-confirmation-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.reset-confirmation-modal.active {
  opacity: 1;
}

.reset-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  animation: reset-overlay-fade 0.3s ease;
}

@keyframes reset-overlay-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.reset-modal-content {
  position: relative;
  background: linear-gradient(135deg, var(--ear-surface) 0%, var(--ear-bg) 100%);
  border: 2px solid var(--ear-accent);
  border-radius: var(--ear-radius-lg);
  padding: var(--ear-space-xl);
  max-width: 500px;
  width: 90%;
  box-shadow: 
    0 20px 60px -10px rgba(0, 0, 0, 0.8),
    0 0 100px -20px rgba(255, 110, 199, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: reset-modal-slide 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center center;
}

@keyframes reset-modal-slide {
  0% {
    opacity: 0;
    transform: scale(0.7) translateY(-30px) rotateX(20deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0) rotateX(0deg);
  }
}

.reset-modal-icon {
  font-size: 4rem;
  text-align: center;
  margin-bottom: var(--ear-space-md);
  animation: reset-icon-bounce 2s ease-in-out infinite;
}

@keyframes reset-icon-bounce {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-10px) rotate(-5deg);
  }
  75% {
    transform: translateY(-5px) rotate(5deg);
  }
}

.reset-modal-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--ear-accent);
  text-align: center;
  margin: 0 0 var(--ear-space-md);
  text-shadow: 0 2px 10px rgba(255, 110, 199, 0.3);
}

.reset-modal-message {
  font-size: 1rem;
  color: var(--ear-text-primary);
  text-align: center;
  margin: 0 0 var(--ear-space-md);
  line-height: 1.6;
}

.reset-modal-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--ear-space-lg);
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--ear-radius);
  padding: var(--ear-space-md);
}

.reset-modal-list li {
  padding: var(--ear-space-sm) 0;
  color: var(--ear-text-secondary);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: var(--ear-space-sm);
}

.reset-modal-list li:not(:last-child) {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.reset-modal-warning {
  text-align: center;
  color: #fbbf24;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 var(--ear-space-lg);
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.reset-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--ear-space-md);
}

.reset-modal-cancel,
.reset-modal-confirm {
  padding: var(--ear-space-md);
  border-radius: var(--ear-radius);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--ear-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--ear-space-sm);
  border: 2px solid;
}

.reset-modal-cancel {
  background: var(--ear-surface);
  border-color: var(--ear-border);
  color: var(--ear-text-primary);
}

.reset-modal-cancel:hover {
  background: var(--ear-surface-alt);
  border-color: var(--ear-text-secondary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.5);
}

.reset-modal-confirm {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-color: #b91c1c;
  color: #fff;
  font-weight: 700;
}

.reset-modal-confirm:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 
    0 4px 20px -2px rgba(239, 68, 68, 0.6),
    0 0 30px -5px rgba(239, 68, 68, 0.4);
}

.reset-modal-confirm:active,
.reset-modal-cancel:active {
  transform: translateY(0) scale(0.98);
}

@media (max-width: 600px) {
  .reset-modal-content {
    padding: var(--ear-space-lg);
  }
  
  .reset-modal-icon {
    font-size: 3rem;
  }
  
  .reset-modal-title {
    font-size: 1.5rem;
  }
  
  .reset-modal-actions {
    grid-template-columns: 1fr;
  }
}

/* Confirm Modal Actions */
.confirm-actions { 
  display: flex; 
  gap: 0.75rem; 
  justify-content: flex-end; 
  margin-top: 0.8rem; 
}
.confirm-actions .btn-primary, 
.confirm-actions .btn-secondary { 
  min-width: 96px; 
}
.rtl .confirm-actions { 
  flex-direction: row-reverse; 
}

/* Inline Confirm (for dictation reveal, etc.) */
.confirm-inline { 
  margin: 0.8rem 0 0.2rem; 
  padding: 0.75rem 0.85rem; 
  background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)); 
  border: 1px solid var(--ear-border); 
  border-radius: var(--ear-radius-sm); 
  display: grid; 
  gap: 0.6rem; 
  box-shadow: var(--ear-shadow-sm); 
  animation: fade-in var(--ear-transition-fast) ease; 
}
.confirm-inline .ci-text { 
  font-size: 0.8rem; 
  line-height: 1.4; 
}
.confirm-inline .ci-actions { 
  display: flex; 
  gap: 0.6rem; 
  justify-content: flex-end; 
}
.confirm-inline .btn-primary, 
.confirm-inline .btn-secondary { 
  min-width: 90px; 
}
.rtl .confirm-inline .ci-actions { 
  flex-direction: row-reverse; 
}

/* Settings Drawer */
.settings { 
  position: fixed; 
  top: 0; 
  right: 0; 
  width: min(420px, 100%); 
  height: 100dvh; 
  background: var(--ear-bg); 
  border-left: 1px solid var(--ear-border); 
  box-shadow: -4px 0 24px -4px rgba(0,0,0,0.7); 
  display: flex; 
  flex-direction: column; 
  padding: 0; 
  animation: slideInRight var(--ear-transition) ease; 
  z-index: 1600;
  backdrop-filter: blur(12px);
  color: var(--ear-text);
}
.settings[hidden] { 
  display: none !important; 
}
.settings-backdrop { 
  position: fixed; 
  inset: 0; 
  background: rgba(0,0,0,0.55); 
  backdrop-filter: blur(2px); 
  animation: fade-in var(--ear-transition-fast) ease; 
  z-index: 1500; 
}
.settings__header { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  padding: 0.9rem 1rem 0.6rem; 
  border-bottom: 1px solid var(--ear-border);
  color: var(--ear-text);
}
/* RTL: Add padding to avoid collision with theme toggle button */
[dir="rtl"] .settings__header {
  padding-right: 90px; /* Space for theme toggle button which is fixed at top-right */
}
.settings__content { 
  overflow-y: auto; 
  padding: 1rem 1.2rem 2.5rem; 
  display: grid; 
  gap: 1rem; 
}
.settings__group { 
  background: var(--ear-surface); 
  border: 1px solid var(--ear-border); 
  padding: 0.8rem 0.9rem; 
  border-radius: var(--ear-radius-sm); 
  display: grid; 
  gap: 0.55rem; 
  color: var(--ear-text);
}
.settings__group h3 { 
  margin: 0.2rem 0 0.35rem; 
  font-size: 0.9rem; 
  letter-spacing: 0.5px; 
  text-transform: uppercase; 
  opacity: 0.75; 
  color: var(--ear-text);
}
.settings__group label { 
  display: grid; 
  font-size: 0.8rem; 
  gap: 0.35rem; 
  color: var(--ear-text);
}
.settings__group input[type="number"], 
.settings__group select,
.settings__group input[type="text"] { 
  background: var(--ear-surface-alt); 
  border: 1px solid var(--ear-border); 
  color: var(--ear-text); 
  border-radius: var(--ear-radius-sm); 
  padding: 0.4rem 0.5rem; 
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color var(--ear-transition-fast) ease;
}
.settings__group select option {
  background: var(--ear-bg);
  color: var(--ear-text);
}
.settings__group input:focus-visible, 
.settings__group select:focus-visible { 
  outline: none;
  border-color: var(--ear-focus);
  box-shadow: 0 0 0 2px rgba(123, 177, 255, 0.2);
}
.inline-fields { 
  display: flex; 
  gap: 0.6rem; 
  flex-wrap: wrap; 
}
.inline-fields > * { 
  flex: 1 1 140px; 
}

/* Language selector buttons */
.lang-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.lang-btn {
  padding: 0.5rem 0.8rem;
  font-size: 1.2rem;
  background: var(--ear-surface);
  border: 2px solid var(--ear-border);
  border-radius: 0.3rem;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  color: var(--ear-text);
}
.lang-btn:hover {
  background: var(--ear-surface-alt);
  border-color: var(--ear-accent);
  transform: translateY(-1px);
}
.lang-btn.active {
  background: var(--ear-accent);
  border-color: var(--ear-accent);
  color: #000;
  box-shadow: 0 2px 8px rgba(255,110,199, 0.3);
}
.lang-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(123, 177, 255, 0.3);
}

/* ----------------------------------------------------------------------------
   8. COMPONENT-SPECIFIC STYLES
   ---------------------------------------------------------------------------- */

/* Piano Keyboard Visualizer */
.piano { 
  display: flex; 
  flex-direction: row-reverse;
  user-select: none; 
  touch-action: manipulation; 
  align-items: flex-start; 
  gap: 2px; 
  padding: 0.6rem 0.5rem; 
  background: var(--ear-surface); 
  border: 1px solid var(--ear-border); 
  border-radius: var(--ear-radius-sm); 
  max-width: 100%; 
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--ear-surface-alt) transparent;
  direction: ltr; /* Always LTR, even in RTL languages */
}
.piano::-webkit-scrollbar {
  height: 6px;
}
.piano::-webkit-scrollbar-track {
  background: transparent;
}
.piano::-webkit-scrollbar-thumb {
  background: var(--ear-surface-alt);
  border-radius: 3px;
}

.key { 
  position: relative; 
  display: flex; 
  align-items: flex-end; 
  justify-content: center; 
  padding-bottom: 0.4rem;
  font-size: 0.7rem; 
  font-weight: 700; 
  letter-spacing: 0.3px;
  transition: all var(--ear-transition-fast) ease;
  cursor: pointer;
}

.key.white { 
  width: 36px; 
  height: 160px; 
  background: var(--ear-keyboard-white); 
  color: #111; 
  border: 1px solid #bbb; 
  border-radius: 0 0 4px 4px;
  box-shadow: 0 2px 4px -2px rgba(0,0,0,0.2);
}
.key.white:hover {
  background: #fff;
  transform: translateY(-2px);
}
.key.black { 
  width: 26px; 
  height: 100px; 
  background: var(--ear-keyboard-black); 
  color: #eee; 
  margin-left: -13px; 
  margin-right: -13px; 
  z-index: 10; 
  border-radius: 0 0 4px 4px; 
  box-shadow: 0 3px 8px -2px rgba(0,0,0,0.8);
  white-space: pre-line; /* Allow line breaks */
  line-height: 1.2;
  font-size: 0.65rem;
  padding-top: 8px;
}
.key.black:hover {
  background: #333;
  transform: translateY(-1px);
}
.key.highlight { 
  background: var(--ear-keyboard-highlight) !important; 
  color: #000 !important; 
  box-shadow: 0 0 0 2px var(--ear-accent), 0 0 16px -2px var(--ear-accent) !important;
  transform: scale(1.05) !important;
}
.key:focus-visible { 
  outline: 2px solid var(--ear-focus); 
  outline-offset: -2px; 
  z-index: 11;
}
.key:active {
  transform: translateY(2px);
}

/* Piano Container with Octave Navigation */
.piano-container {
  width: 100%;
}

.piano-octave-nav {
  display: none; /* Hidden on desktop, shown on mobile */
  align-items: center;
  justify-content: space-between;
  gap: var(--ear-space-sm);
  padding: var(--ear-space-sm);
  background: var(--ear-surface);
  border: 1px solid var(--ear-border);
  border-bottom: none;
  border-radius: var(--ear-radius-sm) var(--ear-radius-sm) 0 0;
}

.piano-octave-label {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ear-text-primary);
  letter-spacing: 0.5px;
}

.piano-octave-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--ear-border);
  background: var(--ear-bg);
  color: var(--ear-text-primary);
  border-radius: var(--ear-radius-sm);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--ear-transition-fast) ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.piano-octave-btn:hover:not(:disabled) {
  background: var(--ear-surface);
  border-color: var(--ear-accent);
  color: var(--ear-accent);
  transform: scale(1.05);
}

.piano-octave-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.piano-octave-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.piano-octave-btn:focus-visible {
  outline: 2px solid var(--ear-focus);
  outline-offset: 2px;
}

/* Dictation Module */
.dictation-shell { 
  display: grid; 
  gap: var(--ear-space-md); 
}
.dictation-intro h2 { 
  margin: 0; 
}
.dictation-intro p {
  margin: var(--ear-space-sm) 0 0;
}

/* Dictation List Grid */
.dictation-list { 
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); 
  gap: 0.6rem; 
}
.dictation-card { 
  background: var(--ear-surface); 
  border: 1px solid var(--ear-border); 
  border-radius: var(--ear-radius-sm); 
  overflow: hidden; 
  cursor: pointer; 
  transition: transform var(--ear-transition-fast) ease, box-shadow var(--ear-transition-fast) ease;
}
.dictation-card:hover { 
  transform: translateY(-2px); 
  box-shadow: 0 6px 20px -8px rgba(0,0,0,0.6);
  border-color: var(--ear-accent);
}
.dictation-card .info { 
  padding: 0.6rem 0.7rem; 
  display: grid; 
  gap: 0.3rem; 
}
.dictation-card.text-only { 
  display: block; 
}
.dictation-card.text-only h4 { 
  margin: 0; 
  font-size: 0.95rem;
  color: var(--ear-accent);
}
.dictation-card.text-only p { 
  margin: 0; 
  font-size: 0.75rem;
  color: var(--ear-text-secondary);
}

/* Dictation Controls Bar */
.dictation-controls { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 0.6rem; 
  align-items: center; 
  background: var(--ear-surface-alt); 
  padding: 0.7rem 0.8rem; 
  border: 1px solid var(--ear-border); 
  border-radius: var(--ear-radius-sm); 
}
.dictation-controls input[type="search"], 
.dictation-controls select { 
  background: var(--ear-surface); 
  border: 1px solid var(--ear-border); 
  color: var(--ear-text); 
  padding: 0.45rem 0.6rem; 
  border-radius: var(--ear-radius-sm); 
  font-size: 0.75rem;
  font-family: inherit;
  transition: border-color var(--ear-transition-fast) ease;
}
.dictation-controls input[type="search"] {
  min-width: 200px;
  flex: 1;
}
.dictation-controls input:focus-visible, 
.dictation-controls select:focus-visible { 
  outline: none;
  border-color: var(--ear-focus);
  box-shadow: 0 0 0 2px rgba(123, 177, 255, 0.2);
}

.dc-clear {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  transition: opacity var(--ear-transition-fast), 
              background var(--ear-transition-fast);
}

.dc-clear:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.dc-clear:not(:disabled):hover {
  background: rgba(255, 61, 90, 0.15);
  border-color: var(--ear-danger);
  color: var(--ear-danger);
}

.dc-clear svg {
  width: 14px;
  height: 14px;
}

.dc-pager { 
  display: flex; 
  align-items: center; 
  gap: 0.5rem; 
  margin-left: auto; 
}
.dc-pager button { 
  padding: 0.45rem 0.7rem; 
}
.dc-page {
  font-size: 0.75rem;
  color: var(--ear-text-secondary);
  white-space: nowrap;
}

/* Dictation Loading Skeleton */
.dictation-card.skeleton { 
  position: relative; 
  animation: pulse 1.3s ease-in-out infinite;
  pointer-events: none;
}
.dictation-card.skeleton .thumb { 
  background: linear-gradient(90deg, #222, #333, #222);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
.dictation-card.skeleton .info { 
  display: grid; 
  gap: 0.4rem; 
}
.sk-line { 
  height: 12px; 
  background: #333; 
  border-radius: 4px;
  background: linear-gradient(90deg, #2a2a2a, #353535, #2a2a2a);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
.sk-line.small { 
  width: 60%; 
}

@keyframes pulse { 
  0%, 100% { opacity: 0.85; } 
  50% { opacity: 1; } 
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Dictation Detail View */
.dictation-detail { 
  background: var(--ear-surface-alt); 
  border: 1px solid var(--ear-border); 
  border-radius: var(--ear-radius); 
  padding: var(--ear-space-md); 
  box-shadow: var(--ear-shadow); 
}
.detail-header { 
  display: flex; 
  align-items: baseline; 
  gap: 0.8rem; 
  justify-content: space-between; 
}
.detail-actions { 
  display: flex; 
  gap: 0.6rem; 
  margin: 0.6rem 0 0; 
}

/* Dictation Video Player */
.dictation-video { 
  position: relative; 
  border-radius: 10px; 
  overflow: hidden; 
  border: 1px solid var(--ear-border); 
  margin-top: 0.6rem;
  background: #000;
  /* Add box-shadow to create dark frame around video in light mode */
  box-shadow: inset 0 0 0 8px rgba(0,0,0,0.9);
}

/* Light mode: add dark background for better iframe control visibility */
[data-theme="light"] .dictation-video {
  background: #1a1a1a;
  border: 2px solid #2a2a2a;
  box-shadow: 
    inset 0 0 0 8px #1a1a1a,
    0 4px 12px rgba(0,0,0,0.15);
}

.dictation-video .video-thumb { 
  aspect-ratio: 16/9; 
  background: center/cover no-repeat; 
  display: flex; 
  align-items: center; 
  justify-content: center;
  position: relative;
}
.dictation-video .video-thumb::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0,0,0,0.3), rgba(0,0,0,0.7));
}
.dictation-video iframe { 
  width: 100%; 
  height: calc(56.25vw); 
  max-height: 60vh; 
  border: 0; 
  display: block; 
  background: #000; 
}
.dictation-video .play-btn { 
  padding: 0.6rem 1rem;
  position: relative;
  z-index: 1;
}
.dictation-modal-body { 
  display: grid; 
  gap: 0.9rem; 
}
.dictation-meta { 
  margin: 0; 
}

/* ----------------------------------------------------------------------------
   9. PDF VIEWER
   ---------------------------------------------------------------------------- */
.pdf-viewer { 
  margin-top: var(--ear-space-md); 
  border: 1px solid var(--ear-border); 
  border-radius: var(--ear-radius-sm); 
  overflow: hidden; 
  background: var(--ear-surface); 
}
.pdf-toolbar { 
  display: flex; 
  align-items: center; 
  gap: 0.5rem; 
  padding: 0.5rem 0.6rem; 
  border-bottom: 1px solid var(--ear-border); 
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(4px);
}
.pdf-toolbar .spacer { 
  flex: 1; 
}
.pdf-toolbar .close { 
  width: 2rem; 
}

/* Light mode: ensure PDF toolbar buttons are visible */
[data-theme="light"] .pdf-toolbar {
  background: rgba(0,0,0,0.06) !important;
  border-bottom-color: rgba(0,0,0,0.15) !important;
}

[data-theme="light"] .pdf-toolbar .close,
[data-theme="light"] .pdf-toolbar .zoom-in,
[data-theme="light"] .pdf-toolbar .zoom-out,
[data-theme="light"] .pdf-toolbar .zoom-fs {
  background: rgba(0,0,0,0.15) !important;
  color: #1a1a1a !important;
  border: 1px solid rgba(0,0,0,0.3) !important;
}

[data-theme="light"] .pdf-toolbar .close:hover,
[data-theme="light"] .pdf-toolbar .zoom-in:hover,
[data-theme="light"] .pdf-toolbar .zoom-out:hover,
[data-theme="light"] .pdf-toolbar .zoom-fs:hover {
  background: rgba(0,0,0,0.25) !important;
  border-color: rgba(0,0,0,0.4) !important;
}
.pdf-frame { 
  width: 100%; 
  height: 70vh; 
  background: #1a1a1a; 
  overflow: auto; 
  overscroll-behavior: contain; 
  overflow-anchor: none;
  scrollbar-width: thin;
  scrollbar-color: var(--ear-surface) #1a1a1a;
}
.pdf-frame::-webkit-scrollbar {
  width: 10px;
}
.pdf-frame::-webkit-scrollbar-track {
  background: #1a1a1a;
}
.pdf-frame::-webkit-scrollbar-thumb {
  background: var(--ear-surface);
  border-radius: 5px;
}
.pdf-frame iframe, 
.pdf-frame object, 
.pdf-frame embed { 
  display: block; 
  width: 100%; 
  height: 100%; 
  border: 0; 
  background: #222; 
}

/* PDF.js canvas rendering */
.pdf-stack { 
  display: grid; 
  gap: 8px; 
  padding: 8px;
  contain: content;
}
.pdf-stack canvas { 
  display: block; 
  background: #fff; 
  width: 100% !important; 
  height: auto !important; 
  border-radius: 4px; 
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  max-width: 100%;
}
.pdf-panzoom { 
  touch-action: pan-y; 
  will-change: transform; 
}
.pdf-frame { 
  position: relative; 
}
.pdf-toolbar .zoom-in, 
.pdf-toolbar .zoom-out { 
  width: 34px; 
  padding: 0.45rem 0; 
  font-weight: 600; 
}
.pdf-toolbar .zoom-fs { 
  width: 40px; 
  padding: 0.45rem 0; 
  font-weight: 600; 
}
.pdf-toolbar .zoom-in:hover, 
.pdf-toolbar .zoom-out:hover, 
.pdf-toolbar .zoom-fs:hover { 
  background: var(--ear-accent); 
  color: #000; 
}
.pdf-frame-full { 
  position: fixed !important; 
  inset: 0; 
  z-index: 100000; 
  background: #111; 
  padding-top: 2.8rem; 
  width: 100vw; 
  height: 100vh; 
}
.pdf-frame-full .pdf-panzoom { 
  max-width: none; 
}

/* PDF loading and error states */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ----------------------------------------------------------------------------
   10. UTILITY CLASSES
   ---------------------------------------------------------------------------- */
.flex { display: flex; }
.grid { display: grid; }
.center { text-align: center; }
.muted { 
  opacity: 0.7; 
  color: var(--ear-text-secondary);
}
.small { 
  font-size: 0.75rem; 
}
.sep { 
  height: 1px; 
  background: var(--ear-border); 
  margin: 0.5rem 0; 
}

/* Dark scrollbars for body */
body::-webkit-scrollbar { 
  width: 10px; 
}
body::-webkit-scrollbar-track { 
  background: #111; 
}
body::-webkit-scrollbar-thumb { 
  background: var(--ear-surface); 
  border: 1px solid var(--ear-border); 
}
body::-webkit-scrollbar-thumb:hover { 
  background: var(--ear-accent); 
}

/* ----------------------------------------------------------------------------
   11. RESPONSIVE & MOBILE OPTIMIZATIONS
   ---------------------------------------------------------------------------- */
@media (max-width: 800px) {
  .tabs { 
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .piano { 
    justify-content: flex-start; 
  }
  .dictation-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .dictation-controls input[type="search"] {
    min-width: 100%;
  }
  .dc-pager {
    margin-left: 0;
    justify-content: center;
    width: 100%;
  }
}

@media (max-width: 768px) {
  /* Mobile: Show octave navigation and adjust piano */
  .piano-octave-nav {
    display: flex !important;
  }
  
  .piano-container .piano {
    border-radius: 0 0 var(--ear-radius-sm) var(--ear-radius-sm);
    justify-content: center; /* Center the keyboard on mobile */
  }
}

@media (max-width: 600px) {
  /* Mobile optimization: use more vertical space and ensure smooth scrolling */
  .pdf-frame { 
    height: calc(100dvh - 7rem); 
    -webkit-overflow-scrolling: touch; 
  }
  .ear-modal-panel { 
    width: 100vw; 
    max-height: 100dvh; 
    height: 100dvh; 
    left: 50%; 
    top: 50%; 
    transform: translate(-50%, -50%) scale(1);
    border-radius: 0;
  }
  .ear-modal-body { 
    padding-bottom: 2.4rem; 
  }
  .ear-header {
    padding: var(--ear-space-md) var(--ear-space-md) var(--ear-space-sm);
  }
  .ear-header h1 {
    font-size: 1.5rem;
  }
  
  /* Prevent horizontal scroll on mobile */
  html {
    overflow-x: hidden;
    width: 100%;
  }
  body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
  }
  .view {
    padding: var(--ear-space-md);
    max-width: 100%;
    overflow-x: hidden;
    width: 100%;
  }
  .view > * {
    max-width: 100%;
  }
  .ear-main {
    max-width: 100%;
    overflow-x: hidden;
    width: 100%;
  }
  .section-card {
    padding: var(--ear-space-sm) var(--ear-space-md);
    max-width: 100%;
    overflow-x: hidden;
  }
  .melody-pattern-grid {
    max-width: 100%;
    overflow-x: hidden;
  }
  
  /* Larger touch targets for mobile */
  .btn-primary,
  .btn-secondary {
    padding: 0.7rem 1.2rem;
    min-height: 44px;
  }
  .tab {
    padding: 0.65rem 1rem;
    min-height: 44px;
  }
  .key.white {
    width: 32px;
    height: 140px;
  }
  .key.black {
    width: 24px;
    height: 90px;
    margin-left: -12px;
    margin-right: -12px;
  }
}

/* ----------------------------------------------------------------------------
   12. ACCESSIBILITY & REDUCED MOTION
   ---------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) { 
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .tab, 
  .btn-primary, 
  .btn-secondary,
  .dictation-card,
  .key { 
    transition: none; 
  }
}

/* High contrast mode adjustments */
@media (prefers-contrast: high) {
  :root {
    --ear-border: rgba(255,255,255,0.4);
    --ear-surface: rgba(255,255,255,0.12);
  }
}

/* Print styles */
@media print {
  .ear-header,
  .tabs,
  .section-toolbar,
  .toast-container,
  .ear-portal,
  .settings {
    display: none !important;
  }
  body {
    background: white;
    color: black;
  }
  .section-card {
    border: 1px solid #ccc;
    box-shadow: none;
    page-break-inside: avoid;
  }
}

/* ============================================================================
   13. NOTES QUIZ - PROFESSIONAL REBUILD
   ============================================================================ */

/* Quiz header */
.notes-quiz .quiz-header {
  display: flex;
  justify-content: center;
  margin-bottom: var(--ear-space-lg);
}

.btn-large {
  font-size: 1.1rem;
  padding: 1rem 2rem;
  min-width: 200px;
}

.btn-icon {
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 1.3em;
}

.btn-text {
  display: inline-block;
}

/* Instrument & Context Selectors */
.instrument-selector,
.context-selector {
  margin-bottom: var(--ear-space-lg);
}

.setting-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ear-text-secondary);
  margin-bottom: var(--ear-space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-group {
  display: flex;
  gap: var(--ear-space-sm);
  flex-wrap: wrap;
}

.btn-icon-text {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  transition: all var(--ear-transition);
}

.btn-icon-text .btn-icon {
  margin: 0;
  font-size: 1.2em;
}

.btn-group button.active {
  background: linear-gradient(135deg, var(--ear-accent), #d946ef);
  color: white;
  box-shadow: var(--ear-accent-glow), var(--ear-shadow-sm);
  transform: translateY(-1px);
}

.btn-group button:not(.active):hover {
  background: var(--ear-surface-alt);
  transform: translateY(-1px);
}

/* Answer buttons */
.answers-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: var(--ear-space-md);
  margin: var(--ear-space-lg) 0;
}

.btn-answer {
  background: var(--ear-surface);
  border: 2px solid var(--ear-border);
  border-radius: var(--ear-radius);
  color: var(--ear-text);
  font-size: 1.5rem;
  font-weight: 700;
  padding: 1.2rem 0.8rem;
  cursor: pointer;
  transition: all var(--ear-transition);
  font-family: var(--ear-font-stack);
  box-shadow: var(--ear-shadow-sm);
  white-space: pre-line; /* Allow line breaks for sharp/flat notation */
  line-height: 1.3;
}

.btn-answer:hover {
  background: var(--ear-surface-alt);
  border-color: var(--ear-accent);
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--ear-accent-glow), var(--ear-shadow);
}

.btn-answer:active {
  transform: translateY(0) scale(0.98);
}

.btn-answer:focus {
  outline: 2px solid var(--ear-focus);
  outline-offset: 2px;
}

/* Quiz Action Area - groups play button and answers together */
.quiz-action-area {
  background: var(--ear-surface);
  border: 2px solid var(--ear-accent);
  border-radius: var(--ear-radius-lg);
  padding: var(--ear-space-lg);
  margin: var(--ear-space-lg) 0;
  box-shadow: 0 0 30px -5px rgba(255, 110, 199, 0.3);
}

/* Answer animations */
.btn-answer.answer-correct {
  animation: answer-success 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%) !important;
  border-color: #16a34a !important;
  color: #fff !important;
}

@keyframes answer-success {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2) rotate(5deg);
    box-shadow: 0 0 40px 10px rgba(74, 222, 128, 0.8);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

.btn-answer.answer-wrong {
  animation: answer-error 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
  border-color: #b91c1c !important;
  color: #fff !important;
}

@keyframes answer-error {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-8px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(8px);
  }
}

.btn-answer.answer-reveal {
  animation: answer-reveal 1.5s ease-out;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important;
  border-color: #d97706 !important;
  color: #000 !important;
}

@keyframes answer-reveal {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.3);
  }
  20%, 40%, 60%, 80% {
    transform: scale(1.08);
    box-shadow: 0 0 40px 10px rgba(251, 191, 36, 0.8);
  }
  30%, 50%, 70%, 90% {
    transform: scale(1);
  }
}

/* Container shake animations */
.answers-container.success-shake {
  animation: success-bounce 0.6s ease-out;
}

@keyframes success-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  20% {
    transform: translateY(-10px);
  }
  40% {
    transform: translateY(-5px);
  }
  60% {
    transform: translateY(-2px);
  }
}

.answers-container.error-shake {
  animation: error-vibrate 0.5s ease-out;
}

@keyframes error-vibrate {
  0%, 100% {
    transform: translateX(0) rotate(0deg);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px) rotate(-1deg);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px) rotate(1deg);
  }
}

/* Stats container */
.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--ear-space-md);
  margin: var(--ear-space-lg) 0;
}

.stat-item {
  background: var(--ear-surface);
  border: 1px solid var(--ear-border);
  border-radius: var(--ear-radius);
  padding: var(--ear-space-md);
  display: flex;
  align-items: center;
  gap: var(--ear-space-md);
  box-shadow: var(--ear-shadow-sm);
  transition: all var(--ear-transition);
}

.stat-item:hover {
  background: var(--ear-surface-alt);
  transform: translateY(-2px);
}

.stat-item .stat-icon {
  font-size: 2rem;
  line-height: 1;
}

.stat-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--ear-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ear-accent);
  line-height: 1;
}

/* Note Management Panel */
.note-management-panel {
  background: var(--ear-surface);
  border: 1px solid var(--ear-border);
  border-radius: var(--ear-radius);
  padding: 1rem;
  margin: var(--ear-space-lg) 0;
}

.note-management-panel h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 1rem 0;
  font-size: 1rem;
  cursor: pointer;
  user-select: none;
}

.toggle-management-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem 0.5rem;
  color: var(--ear-text);
  transition: transform 0.2s;
}

.toggle-management-btn:hover {
  transform: scale(1.1);
}

.note-management-info {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--ear-surface-alt);
  border-radius: var(--ear-radius-sm);
  font-size: 0.9rem;
  opacity: 0.9;
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 0.5rem;
}

.note-manage-btn {
  padding: 0.75rem 0.5rem;
  border: 2px solid var(--ear-border);
  border-radius: var(--ear-radius-sm);
  background: var(--ear-surface-alt);
  color: var(--ear-text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: pre-line;
  line-height: 1.3;
}

.note-manage-btn:hover {
  border-color: var(--ear-accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.note-manage-btn.active {
  background: var(--ear-primary);
  border-color: var(--ear-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.4);
}

.note-manage-btn.active:hover {
  background: var(--ear-primary-dark);
  border-color: var(--ear-primary-dark);
}

/* Quiz actions */
.quiz-actions {
  display: flex;
  gap: var(--ear-space-md);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: var(--ear-space-lg);
}

.quiz-actions button {
  flex: 1 1 auto;
  min-width: 150px;
}

/* Loading state for play button */
button.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

button.loading::after {
  content: '';
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .btn-large {
    font-size: 1rem;
    padding: 0.9rem 1.5rem;
    min-width: 160px;
  }
  
  .answers-container {
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: var(--ear-space-sm);
  }
  
  .btn-answer {
    font-size: 1.3rem;
    padding: 1rem 0.6rem;
  }
  
  .stats-container {
    grid-template-columns: 1fr;
  }
  
  .quiz-actions {
    flex-direction: column;
  }
  
  .quiz-actions button {
    width: 100%;
  }
}

/* ============================================================================
   INSTRUMENT CHANGE ANIMATION
   ============================================================================ */
.instrument-change-animation {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.instrument-change-animation.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.instrument-icon-large {
  font-size: 8rem;
  line-height: 1;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.4));
  animation: instrument-bounce 0.6s ease-out;
}

.instrument-name {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ear-text);
  text-shadow: 
    0 2px 12px rgba(0,0,0,0.6),
    0 0 30px var(--ear-accent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  animation: instrument-glow 0.6s ease-out;
}

@keyframes instrument-bounce {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotate(10deg);
  }
  70% {
    transform: scale(0.9) rotate(-5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes instrument-glow {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Enhanced instrument selector styling */
.instrument-selector {
  background: linear-gradient(135deg, 
    rgba(255, 110, 199, 0.05) 0%, 
    rgba(123, 177, 255, 0.05) 100%);
  padding: 1.5rem;
  border-radius: var(--ear-radius);
  border: 1px solid rgba(255, 110, 199, 0.15);
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  margin-bottom: 1rem;
}

.instrument-selector .setting-label {
  margin-bottom: 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ear-accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.instrument-selector .setting-label::before {
  content: '🎼';
  font-size: 1.2rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.instrument-selector .btn-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.instrument-selector .btn-secondary {
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.instrument-selector .btn-secondary::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: radial-gradient(circle, 
    rgba(255, 110, 199, 0.3) 0%, 
    transparent 70%);
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease;
}

.instrument-selector .btn-secondary:hover::before {
  width: 200%;
  height: 200%;
}

.instrument-selector .btn-secondary.active {
  background: linear-gradient(135deg, 
    rgba(255, 110, 199, 0.25) 0%, 
    rgba(123, 177, 255, 0.15) 100%);
  border-color: var(--ear-accent);
  transform: translateY(-2px);
  box-shadow: 
    0 6px 20px rgba(255, 110, 199, 0.3),
    0 0 20px rgba(255, 110, 199, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.instrument-selector .btn-secondary.active .btn-icon {
  animation: instrument-pulse 0.6s ease;
  filter: drop-shadow(0 0 8px rgba(255, 110, 199, 0.8));
}

@keyframes instrument-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
}

/* Context selector - more compact styling */
.context-selector {
  background: rgba(255, 255, 255, 0.03);
  padding: 1rem;
  border-radius: var(--ear-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 1rem;
}

.context-selector .setting-label {
  margin-bottom: 0.75rem;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--ear-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.context-selector .btn-group {
  gap: 0.5rem;
}

.context-selector .btn-secondary {
  font-size: 0.9rem;
  padding: 0.6rem 1rem;
}

/* ============================================================================
   NOTES QUIZ ENTRANCE ANIMATIONS
   ============================================================================ */

/* Initial state - elements hidden before animation */
.notes-quiz-entrance > * {
  opacity: 0;
  transform: translateY(30px) scale(0.95);
}

/* Animated state - elements slide in and scale up */
.notes-quiz-entrance > .animate-in {
  animation: notes-section-slide-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes notes-section-slide-in {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.95) rotateX(10deg);
    filter: blur(4px);
  }
  60% {
    transform: translateY(-5px) scale(1.02) rotateX(-2deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotateX(0deg);
    filter: blur(0);
  }
}

/* Special animation for play button */
.notes-quiz-entrance .btn-large {
  animation: notes-play-button-entrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes notes-play-button-entrance {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-10deg);
    box-shadow: 0 0 0 0 rgba(255, 110, 199, 0);
  }
  50% {
    transform: scale(1.1) rotate(2deg);
    box-shadow: 0 0 40px 10px rgba(255, 110, 199, 0.6);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    box-shadow: 0 4px 18px -4px rgba(0, 0, 0, 0.5);
  }
}

/* Piano entrance with musical wave effect */
.notes-quiz-entrance .piano {
  animation: notes-piano-entrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes notes-piano-entrance {
  0% {
    opacity: 0;
    transform: translateY(40px) perspective(600px) rotateX(-15deg);
    filter: blur(6px);
  }
  60% {
    transform: translateY(-8px) perspective(600px) rotateX(3deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) perspective(600px) rotateX(0deg);
    filter: blur(0);
  }
}

/* Piano keys cascade animation */
.notes-quiz-entrance .piano .key {
  animation: piano-key-cascade 0.4s ease-out forwards;
  animation-delay: calc(var(--key-index, 0) * 0.02s);
  opacity: 0;
}

@keyframes piano-key-cascade {
  0% {
    opacity: 0;
    transform: translateY(-20px) scale(0.8);
  }
  50% {
    transform: translateY(5px) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Instrument selector special entrance */
.notes-quiz-entrance .instrument-selector {
  animation: notes-instrument-entrance 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes notes-instrument-entrance {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    filter: blur(8px) brightness(0.5);
  }
  50% {
    filter: blur(2px) brightness(1.2);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0) brightness(1);
  }
}

/* Answer buttons entrance with bounce */
.notes-quiz-entrance .answers-container {
  animation: notes-answers-entrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes notes-answers-entrance {
  0% {
    opacity: 0;
    transform: scale(0.7) translateY(30px);
  }
  60% {
    transform: scale(1.05) translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Stats container fade and slide */
.notes-quiz-entrance .stats-container {
  animation: notes-stats-entrance 0.5s ease-out forwards;
}

@keyframes notes-stats-entrance {
  0% {
    opacity: 0;
    transform: translateX(-30px);
    filter: blur(4px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
    filter: blur(0);
  }
}

/* Add subtle glow pulse to the entire card on entrance */
.notes-quiz-entrance {
  animation: notes-card-glow 1.5s ease-in-out;
}

@keyframes notes-card-glow {
  0%, 100% {
    box-shadow: 0 4px 18px -4px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.18);
  }
  50% {
    box-shadow: 
      0 8px 32px -4px rgba(255, 110, 199, 0.3),
      0 0 60px rgba(255, 110, 199, 0.2),
      0 0 0 1px rgba(255, 110, 199, 0.4);
  }
}

/* ============================================================================
   DICTATION ENTRANCE ANIMATIONS
   ============================================================================ */

/* Initial state - elements hidden before animation */
.dictation-entrance > * {
  opacity: 0;
  transform: translateY(30px) scale(0.95);
}

/* Animated state - elements slide in and scale up */
.dictation-entrance > .animate-in {
  animation: dictation-section-slide-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes dictation-section-slide-in {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.95) rotateX(10deg);
    filter: blur(4px);
  }
  60% {
    transform: translateY(-5px) scale(1.02) rotateX(-2deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotateX(0deg);
    filter: blur(0);
  }
}

/* Intro section with dramatic entrance */
.dictation-entrance .dictation-intro {
  animation: dictation-intro-entrance 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes dictation-intro-entrance {
  0% {
    opacity: 0;
    transform: translateY(40px) scale(0.9);
    filter: blur(8px) brightness(0.5);
  }
  50% {
    filter: blur(2px) brightness(1.2);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0) brightness(1);
  }
}

/* Controls bar slide in from top */
.dictation-entrance .dictation-controls {
  animation: dictation-controls-entrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes dictation-controls-entrance {
  0% {
    opacity: 0;
    transform: translateY(-30px) scaleY(0.8);
    filter: blur(4px);
  }
  60% {
    transform: translateY(5px) scaleY(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scaleY(1);
    filter: blur(0);
  }
}

/* Dictation cards grid cascade */
.dictation-entrance .dictation-list {
  animation: dictation-list-entrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes dictation-list-entrance {
  0% {
    opacity: 0;
    transform: translateY(40px) perspective(800px) rotateX(-10deg);
    filter: blur(6px);
  }
  60% {
    transform: translateY(-8px) perspective(800px) rotateX(2deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) perspective(800px) rotateX(0deg);
    filter: blur(0);
  }
}

/* Individual dictation cards cascade */
.dictation-entrance .dictation-card {
  animation: dictation-card-cascade 0.5s ease-out forwards;
  animation-delay: calc(var(--card-index, 0) * 0.08s);
  opacity: 0;
}

@keyframes dictation-card-cascade {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.85) rotateY(-10deg);
    filter: blur(3px);
  }
  50% {
    transform: translateY(-5px) scale(1.03) rotateY(2deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotateY(0deg);
    filter: blur(0);
  }
}

/* Detail view entrance */
.dictation-detail-wrapper {
  animation: dictation-detail-entrance 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes dictation-detail-entrance {
  0% {
    opacity: 0;
    transform: translateY(50px) scale(0.95);
    filter: blur(8px);
  }
  60% {
    transform: translateY(-10px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* Back button special entrance */
.dictation-detail-wrapper .btn-secondary {
  animation: dictation-back-button 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: 0.1s;
  opacity: 0;
}

@keyframes dictation-back-button {
  0% {
    opacity: 0;
    transform: translateX(-30px) scale(0.8);
  }
  60% {
    transform: translateX(5px) scale(1.1);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* ============================================================================
   TUTORIAL PANEL STYLES
   ============================================================================ */
.tutorial-panel {
  background: linear-gradient(135deg, var(--ear-surface-alt), var(--ear-surface));
  border: 2px solid var(--ear-border);
  border-radius: var(--ear-radius-lg);
  margin-bottom: var(--ear-space-lg);
  overflow: hidden;
  box-shadow: var(--ear-shadow);
  animation: tutorial-entrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes tutorial-entrance {
  0% {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tutorial-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ear-space-lg);
  background: linear-gradient(135deg, var(--ear-accent), #ffd86b);
  border-bottom: 1px solid var(--ear-border);
}

.tutorial-header h3 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: #000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tutorial-icon {
  font-size: 1.6rem;
}

.tutorial-close {
  background: rgba(0, 0, 0, 0.15);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1.5rem;
  color: #000;
  cursor: pointer;
  transition: all var(--ear-transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.tutorial-close:hover {
  background: rgba(0, 0, 0, 0.25);
  transform: rotate(90deg);
}

.tutorial-content {
  padding: var(--ear-space-lg);
}

.tutorial-section {
  display: flex;
  flex-direction: column;
  gap: var(--ear-space-lg);
}

.tutorial-step {
  display: flex;
  gap: var(--ear-space-md);
  align-items: flex-start;
  animation: step-entrance 0.4s ease-out forwards;
  animation-delay: calc(var(--step-index, 0) * 0.1s);
  opacity: 0;
}

.tutorial-step:nth-child(1) { --step-index: 1; }
.tutorial-step:nth-child(2) { --step-index: 2; }
.tutorial-step:nth-child(3) { --step-index: 3; }
.tutorial-step:nth-child(4) { --step-index: 4; }

@keyframes step-entrance {
  0% {
    opacity: 0;
    transform: translateX(-20px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.step-number {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ear-accent), #ffd86b);
  color: #000;
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(255, 110, 199, 0.3);
}

.step-content {
  flex: 1;
}

.step-content h4 {
  margin: 0 0 0.4rem 0;
  font-size: 1.1rem;
  color: var(--ear-text);
  font-weight: 600;
}

.step-content p {
  margin: 0;
  color: var(--ear-text-secondary);
  line-height: 1.6;
  font-size: 0.95rem;
}

.tutorial-tip {
  background: linear-gradient(135deg, rgba(255, 183, 71, 0.15), rgba(255, 110, 199, 0.15));
  border: 1px solid rgba(255, 183, 71, 0.3);
  border-radius: var(--ear-radius);
  padding: var(--ear-space-md);
  display: flex;
  gap: var(--ear-space-md);
  align-items: flex-start;
  animation: tip-pulse 2s ease-in-out infinite;
}

@keyframes tip-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 183, 71, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 183, 71, 0);
  }
}

.tip-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.tip-content {
  color: var(--ear-text);
  line-height: 1.6;
  font-size: 0.95rem;
}

.tip-content strong {
  color: var(--ear-accent);
  font-weight: 600;
}

.tutorial-footer {
  padding: var(--ear-space-lg);
  background: var(--ear-surface);
  border-top: 1px solid var(--ear-border);
  display: flex;
  flex-direction: column;
  gap: var(--ear-space-md);
  align-items: center;
}

.tutorial-start-btn {
  width: 100%;
  max-width: 300px;
  justify-content: center;
}

.tutorial-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--ear-text-secondary);
  cursor: pointer;
  user-select: none;
}

.tutorial-checkbox input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
  accent-color: var(--ear-accent);
}

/* Light theme adjustments for tutorial */
[data-theme="light"] .tutorial-header h3,
[data-theme="light"] .tutorial-close {
  color: #000;
}

[data-theme="light"] .step-number {
  color: #000;
}

/* Responsive tutorial */
@media (max-width: 768px) {
  .tutorial-step {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .step-number {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }
  
  .tutorial-header h3 {
    font-size: 1.2rem;
  }
  
  .step-content h4 {
    font-size: 1rem;
  }
}

/* Video thumbnail hover enhancement */
.dictation-card:hover .thumb {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(255, 110, 199, 0.3);
}

/* Add subtle glow pulse to the dictation shell on entrance */
.dictation-entrance {
  animation: dictation-shell-glow 1.5s ease-in-out;
}

@keyframes dictation-shell-glow {
  0%, 100% {
    filter: drop-shadow(0 0 0 transparent);
  }
  50% {
    filter: drop-shadow(0 0 40px rgba(255, 110, 199, 0.2));
  }
}

/* ============================================================================
   PROGRESSIVE NOTES QUIZ - NEW COMPONENTS
   ============================================================================ */

/* Toggle Switch for Melody On/Off */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: var(--ear-space-md);
  cursor: pointer;
  user-select: none;
  margin: var(--ear-space-md) 0;
}

.toggle-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  width: 52px;
  height: 28px;
  background: var(--ear-surface-alt);
  border: 1px solid var(--ear-border);
  border-radius: 100px;
  transition: all var(--ear-transition);
  flex-shrink: 0;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ear-text-secondary);
  top: 3px;
  left: 3px;
  transition: all var(--ear-transition);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, var(--ear-accent) 0%, #ff85d4 100%);
  border-color: var(--ear-accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(24px);
  background: white;
}

.toggle-switch:hover .toggle-slider {
  border-color: var(--ear-accent);
}

.toggle-label {
  font-size: 0.95rem;
  color: var(--ear-text);
  flex: 1;
}

/* Melody Pattern Grid */
.melody-pattern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--ear-space-sm);
}

/* Melody pattern buttons - allow text wrapping */
.melody-pattern-grid .btn-secondary {
  overflow: visible;
  white-space: normal;
  text-align: center;
  min-height: 2.8rem;
  height: auto;
  padding: 0.6rem 0.8rem;
}

.melody-pattern-grid .btn-icon-text {
  flex-wrap: wrap;
  justify-content: center;
}

/* Category Headers in Melody Pattern Grid */
.melody-category-header {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ear-accent);
  padding: var(--ear-space-md) var(--ear-space-sm) var(--ear-space-xs);
  margin-top: var(--ear-space-md);
  border-bottom: 2px solid var(--ear-border);
  opacity: 0.9;
}

.melody-category-header:first-child {
  margin-top: 0;
}

.melody-selector {
  margin: var(--ear-space-lg) 0;
}

/* Key Selector */
.key-selector {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.key-selector label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.melody-key-select {
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--ear-border);
  border-radius: var(--ear-radius-sm);
  background: var(--ear-surface);
  color: var(--ear-text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.melody-key-select:hover {
  border-color: var(--ear-accent);
}

.melody-key-select:focus {
  outline: none;
  border-color: var(--ear-primary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
}

/* Progress Bar Container */
.progress-container {
  background: var(--ear-surface);
  border: 1px solid var(--ear-border);
  border-radius: var(--ear-radius);
  padding: var(--ear-space-lg);
  margin: var(--ear-space-lg) 0;
  box-shadow: var(--ear-shadow-sm);
}

.progress-label {
  display: flex;
  align-items: center;
  gap: var(--ear-space-sm);
  margin-bottom: var(--ear-space-md);
  font-weight: 600;
  color: var(--ear-text);
}

.progress-icon {
  font-size: 1.5rem;
}

.progress-text {
  font-size: 1rem;
}

.progress-bar-container {
  position: relative;
}

.progress-bar {
  width: 100%;
  height: 32px;
  background: var(--ear-surface-alt);
  border: 1px solid var(--ear-border);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.2);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, 
    var(--ear-accent) 0%, 
    #ff85d4 50%,
    #ffa3e0 100%
  );
  border-radius: 100px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.progress-fill::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(255,255,255,0.3) 50%, 
    transparent 100%
  );
  animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
  0% {
    left: -100%;
  }
  100% {
    left: 200%;
  }
}

.progress-bar.complete .progress-fill {
  animation: progress-pulse 0.6s ease-in-out;
  box-shadow: 0 0 20px var(--ear-accent);
}

@keyframes progress-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

.progress-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--ear-space-xs);
  margin-top: var(--ear-space-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ear-text-secondary);
}

.progress-current {
  color: var(--ear-accent);
  font-size: 1.1rem;
}

.progress-percentage {
  color: var(--ear-text-secondary);
  font-weight: normal;
}

/* Note Selection Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--ear-transition-slow);
}

.modal.show {
  opacity: 1;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.modal-content {
  position: relative;
  z-index: 2;
  background: var(--ear-surface);
  border: 1px solid var(--ear-border);
  border-radius: var(--ear-radius-lg);
  padding: var(--ear-space-xl);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--ear-shadow), 0 20px 60px rgba(0,0,0,0.5);
  transform: translateY(-20px);
  transition: transform var(--ear-transition-slow);
}

.modal.show .modal-content {
  transform: translateY(0);
}

.modal-header {
  margin-bottom: var(--ear-space-lg);
  text-align: center;
}

.modal-header h3 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--ear-space-sm);
  font-size: 1.8rem;
  color: var(--ear-text);
  margin: 0;
}

.modal-icon {
  font-size: 2rem;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--ear-space-xl);
  min-height: 200px;
}

.note-choices {
  display: flex;
  flex-direction: column;
  gap: var(--ear-space-md);
}

.note-choices h4 {
  font-size: 1.2rem;
  color: var(--ear-text);
  margin: 0 0 var(--ear-space-sm) 0;
  text-align: center;
  font-weight: 600;
}

.note-choices > .btn-note-choice {
  display: inline-block;
}

/* Grid layout for note buttons */
.note-choices {
  display: block;
}

.note-choices h4 + .btn-note-choice,
.note-choices .btn-note-choice ~ .btn-note-choice {
  margin-right: var(--ear-space-md);
  margin-bottom: var(--ear-space-md);
  display: inline-block;
  min-width: 120px;
}

.btn-note-choice {
  padding: var(--ear-space-lg);
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--ear-surface-alt) 0%, var(--ear-surface) 100%);
  border: 2px solid var(--ear-border);
  border-radius: var(--ear-radius);
  color: var(--ear-text);
  cursor: pointer;
  transition: all var(--ear-transition);
  font-family: var(--ear-font-stack);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: var(--ear-shadow-sm);
  white-space: pre-line;
  line-height: 1.3;
}

.btn-note-choice:hover {
  transform: translateY(-2px) scale(1.02);
  border-color: var(--ear-accent);
  box-shadow: var(--ear-accent-glow), var(--ear-shadow);
  background: linear-gradient(135deg, var(--ear-accent) 0%, #ff85d4 100%);
  color: white;
}

.btn-note-choice:active {
  transform: translateY(0) scale(0.98);
}

.btn-note-choice.sharp {
  background: linear-gradient(135deg, rgba(123,177,255,0.15) 0%, var(--ear-surface) 100%);
}

.btn-note-choice.sharp:hover {
  background: linear-gradient(135deg, var(--ear-info) 0%, #5a9fff 100%);
}

.lock-message {
  text-align: center;
  padding: var(--ear-space-xl);
  background: var(--ear-surface-alt);
  border: 1px dashed var(--ear-border);
  border-radius: var(--ear-radius);
  color: var(--ear-text-secondary);
}

.lock-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: var(--ear-space-md);
  opacity: 0.5;
}

.lock-message p {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

/* Responsive Modal */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    padding: var(--ear-space-lg);
  }
  
  .modal-header h3 {
    font-size: 1.4rem;
  }
  
  .note-choices h4 + .btn-note-choice,
  .note-choices .btn-note-choice ~ .btn-note-choice {
    margin-right: var(--ear-space-sm);
    margin-bottom: var(--ear-space-sm);
    min-width: 100px;
  }
  
  .btn-note-choice {
    padding: var(--ear-space-md);
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .note-choices h4 + .btn-note-choice,
  .note-choices .btn-note-choice ~ .btn-note-choice {
    display: block;
    width: 100%;
    margin-right: 0;
    margin-bottom: var(--ear-space-sm);
  }
}

/* ----------------------------------------------------------------------------
   COMING SOON SECTION
   ---------------------------------------------------------------------------- */

.coming-soon-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 2rem;
  animation: fadeIn 0.6s ease-out;
}

.coming-soon-card {
  background: var(--ear-surface);
  border: 2px solid var(--ear-border);
  border-radius: var(--ear-radius);
  padding: 3rem 2.5rem;
  max-width: 600px;
  width: 100%;
  text-align: center;
  box-shadow: var(--ear-shadow);
  position: relative;
  overflow: hidden;
}

.coming-soon-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, var(--ear-accent) 0%, transparent 70%);
  opacity: 0.03;
  animation: pulse 4s ease-in-out infinite;
}

.coming-soon-icon-wrapper {
  position: relative;
  display: inline-block;
  margin-bottom: 2rem;
}

.coming-soon-icon-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 140px;
  height: 140px;
  background: linear-gradient(135deg, var(--ear-accent), #d946ef);
  opacity: 0.1;
  border-radius: 50%;
  animation: pulse 3s ease-in-out infinite;
}

.coming-soon-icon {
  position: relative;
  font-size: 5rem;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(255,110,199,0.3));
  animation: float 3s ease-in-out infinite;
}

.coming-soon-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 1rem;
  background: linear-gradient(135deg, var(--ear-accent), #d946ef);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.coming-soon-description {
  font-size: 1.1rem;
  color: var(--ear-text-secondary);
  margin: 0 0 2.5rem;
  line-height: 1.6;
}

.coming-soon-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2.5rem;
  padding: 1.5rem;
  background: var(--ear-surface-alt);
  border-radius: var(--ear-radius-sm);
  border: 1px solid var(--ear-border);
}

.coming-soon-spinner {
  display: flex;
  gap: 0.5rem;
}

.spinner-dot {
  width: 12px;
  height: 12px;
  background: var(--ear-accent);
  border-radius: 50%;
  animation: spinnerBounce 1.4s ease-in-out infinite both;
}

.spinner-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.spinner-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes spinnerBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.coming-soon-text {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ear-text);
}

.coming-soon-features {
  display: grid;
  gap: 1rem;
  margin-bottom: 2rem;
  text-align: left;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--ear-surface-alt);
  border-radius: var(--ear-radius-sm);
  border: 1px solid var(--ear-border);
  transition: all 0.3s ease;
}

.feature-item:hover {
  transform: translateX(8px);
  border-color: var(--ear-accent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.feature-item i {
  color: var(--ear-accent);
  font-size: 1.5rem;
  flex-shrink: 0;
}

.feature-item span {
  font-size: 1rem;
  color: var(--ear-text);
  font-weight: 500;
}

.coming-soon-notify {
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(255,110,199,0.1), rgba(217,70,239,0.1));
  border-radius: var(--ear-radius-sm);
  border: 1px dashed var(--ear-accent);
}

.notify-text {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ear-text-secondary);
  line-height: 1.5;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-15px);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.15;
  }
}

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

/* Mobile responsive for coming soon */
@media (max-width: 768px) {
  .coming-soon-container {
    padding: 1rem;
    min-height: 50vh;
  }
  
  .coming-soon-card {
    padding: 2rem 1.5rem;
  }
  
  .coming-soon-icon {
    font-size: 3.5rem;
  }
  
  .coming-soon-title {
    font-size: 2rem;
  }
  
  .coming-soon-description {
    font-size: 1rem;
  }
  
  .coming-soon-status {
    flex-direction: column;
    gap: 0.8rem;
  }
  
  .coming-soon-text {
    font-size: 1rem;
  }
}

