/* ═══════════════════════════════════════════════════════════════
   JAZZMIND — Design System & Component Styles
   Neural Expressive + Material 3 Expressive foundations.
   Dark jazz-club aesthetic · warm amber · neon cyan · glassmorphism
   ═══════════════════════════════════════════════════════════════ */

/* ─── TIER 1: Literal Tokens ───
   Direct value definitions from DESIGN.md.
   Never reference these directly in component CSS —
   use the Tier 2 semantic aliases instead.                     */
:root {
  /* Charcoal palette (backgrounds) */
  --charcoal-950: #000000;
  --charcoal-900: #000000;
  --charcoal-800: #121212;
  --charcoal-700: #1a1a1a;
  --charcoal-600: #242424;
  --charcoal-500: #333333;

  /* Amber / Gold (accent) */
  --amber-400: #f0a030;
  --amber-300: #f4b860;
  --amber-200: #f8d090;
  --amber-100: #fce8c0;
  --amber-glow: rgba(240, 160, 48, 0.25);

  /* Cool Cyan (cool accent) */
  --cyan-400: #20b8c8;
  --cyan-glow: rgba(32, 184, 200, 0.25);

  /* Neutral Active (active state) */
  --active-400: #e2e2e9;
  --active-300: #a5a5b5;
  --active-200: #ffffff;
  --active-glow: rgba(226, 226, 233, 0.05);

  /* Signal: Error */
  --red-400: #e74040;
  --red-glow: rgba(231, 64, 64, 0.3);

  /* Signal: Success */
  --green-400: #00e676;
  --green-glow: rgba(0, 230, 118, 0.25);

  /* Neutrals */
  --neutral-100: #f0f0f5;
  --neutral-200: #c8c8d5;
  --neutral-300: #9898aa;
  --neutral-400: #686880;
  --neutral-500: #48485a;

  /* Typography */
  --font-display: 'Outfit', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  /* Spacing (8px base grid) */
  --space-xs: 0.25rem;   /* 4px  */
  --space-sm: 0.5rem;    /* 8px  */
  --space-md: 1rem;      /* 16px */
  --space-lg: 1.5rem;    /* 24px */
  --space-xl: 2rem;      /* 32px */
  --space-2xl: 3rem;     /* 48px */

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Motion — Neural Expressive spring physics */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);            /* Deceleration (primary) */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);     /* Overshoot / bounce */
  --ease-gentle: cubic-bezier(0.4, 0, 0.2, 1);          /* Subtle / micro */
  --duration-fast: 120ms;     /* Hover, toggle, color change */
  --duration-normal: 250ms;   /* Panel expand, chip state */
  --duration-slow: 500ms;     /* Page transition, dialog open */
  --duration-spring: 600ms;   /* Spring-physics animations */

  /* Elevation */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.7);
  --glass-border: rgba(240, 240, 245, 0.06);
  --backdrop-blur: blur(24px) saturate(1.6);
}

/* ─── TIER 2: Semantic Tokens ───
   Map literal tokens → purpose.
   Components reference ONLY these.                            */
:root {
  /* Backgrounds — elevation hierarchy */
  --color-bg-primary: var(--charcoal-900);       /* Level 0: Canvas */
  --color-bg-subtle: var(--charcoal-800);         /* Level 1: Recessed */
  --color-bg-elevated: var(--charcoal-700);       /* Level 2: Standard surfaces */
  --color-bg-floating: var(--charcoal-500);       /* Level 4: Tooltips, toasts */
  --color-surface: rgba(30, 30, 33, 0.75);        /* Semi-opaque surface */
  --color-surface-glass: rgba(30, 30, 33, 0.55);  /* Level 3: Glass */

  /* Key Colors (Customizable via settings) */
  --white-key-value: 100%;
  --black-key-value: 0%;
  --white-key-color: hsl(0 0% var(--white-key-value));
  --black-key-color: hsl(0 0% var(--black-key-value));
  --white-key-active-value: calc(var(--white-key-value) + (50% - var(--white-key-value)) * 0.3);
  --black-key-active-value: calc(var(--black-key-value) + (50% - var(--black-key-value)) * 0.3);
  --white-key-radius: 12px;
  --black-key-radius: 12px;
  --key-outline-width: 4px;
  --key-outline-value: 50%;
  --key-outline-color: hsl(0 0% var(--key-outline-value));

  /* Text */
  --color-text-primary: var(--neutral-100);
  --color-text-secondary: var(--neutral-300);
  --color-text-muted: var(--neutral-400);

  /* Semantics */
  --color-accent: var(--amber-400);
  --color-accent-soft: var(--amber-200);
  --color-active: var(--active-400);
  --color-success: var(--green-400);
  --color-error: var(--red-400);

  /* Borders */
  --color-border: var(--glass-border);
  --color-border-active: rgba(240, 240, 245, 0.15);
}


/* ═══════════════════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════════════════ */

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  background-color: var(--color-bg-primary);
}

body {
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* ═══════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════ */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-surface-glass);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--color-border);
  z-index: 10;
  flex-shrink: 0;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.logo-icon {
  font-size: 1.5rem;
  color: var(--color-accent);
  text-shadow: 0 0 12px var(--amber-glow);
  animation: note-sway 3s ease-in-out infinite;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--color-accent), var(--amber-300));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Phase indicator pill */
.phase-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  color: var(--color-text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    border-color var(--duration-normal) var(--ease-out),
    color var(--duration-normal) var(--ease-out),
    background-color var(--duration-normal) var(--ease-out);
}

.phase-indicator:hover {
  border-color: var(--color-border-active);
  color: var(--color-text-primary);
  background: var(--color-bg-elevated);
}

.phase-icon { font-size: 1.1rem; }

.phase-chevron {
  font-size: 0.7rem;
  opacity: 0.5;
  transition: transform var(--duration-fast) var(--ease-out);
}

.phase-indicator:hover .phase-chevron {
  transform: translateY(1px);
}

.phase-name { /* no special styling needed — inherits from phase-indicator */ }

/* Header action buttons — 44px touch targets per DESIGN.md */
.header-actions {
  display: flex;
  gap: var(--space-xs);
  position: relative;
}

#actions-group {
  display: contents;
}

#more-actions-btn {
  display: none;
}

.btn-label {
  display: none;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition:
    color var(--duration-fast) var(--ease-gentle),
    background-color var(--duration-fast) var(--ease-gentle),
    border-color var(--duration-fast) var(--ease-gentle);
}

.btn-icon:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-subtle);
  border-color: var(--color-border);
}

.btn-icon.active {
  color: var(--color-active);
  background: var(--active-glow);
  border-color: var(--color-border-active);
}

.auth-avatar-img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--color-border);
  transition: border-color var(--duration-fast) var(--ease-gentle);
}

.btn-icon:hover .auth-avatar-img {
  border-color: var(--color-text-primary);
}


/* ═══════════════════════════════════════════════════════════════
   STATS BAR
   Level 1 surface (recessed). Glance-only metrics.
   ═══════════════════════════════════════════════════════════════ */

.stats-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-xl);
  padding: var(--space-sm) var(--space-xl);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 880px;
  box-sizing: border-box;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 60px;
}

.stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  transition: color var(--duration-fast) var(--ease-gentle);
}

.stat-label {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}


/* ═══════════════════════════════════════════════════════════════
   PROMPT AREA
   The hero element — the chord the user must play.
   Maximum negative space around the focal point.
   ═══════════════════════════════════════════════════════════════ */

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) var(--space-lg);
  gap: var(--space-lg);
  position: relative;
  min-height: 0;
}

.prompt-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: min(280px, 70vw);
  height: min(280px, 70vw);
  aspect-ratio: 1 / 1;
  margin: var(--space-sm) auto var(--space-md) auto;
  padding: 0;
  min-height: min(280px, 70vw);
}

/* Play Container (stopped state) */
.prompt-play-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  z-index: 5;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.prompt-play-container[hidden] {
  display: none !important;
}

.btn-play-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface-glass);
  color: var(--color-accent);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition:
    transform var(--duration-fast) var(--ease-spring),
    border-color var(--duration-fast) var(--ease-gentle),
    box-shadow var(--duration-fast) var(--ease-gentle),
    background-color var(--duration-fast) var(--ease-gentle);
}

.btn-play-trigger svg {
  padding-left: 2px;
  transition: transform var(--duration-fast) var(--ease-gentle);
}

.btn-play-trigger:hover {
  border-color: var(--color-border-active);
  box-shadow: 0 0 24px var(--amber-glow);
  background: var(--color-bg-elevated);
  transform: scale(1.08);
}

.btn-play-trigger:hover svg {
  transform: scale(1.1);
}

.btn-play-trigger:active {
  transform: scale(0.95);
}



/* Stop Trigger (running state) */
.btn-stop-trigger {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface-glass);
  color: var(--color-text-muted);
  cursor: pointer;
  z-index: 10;
  transition:
    transform var(--duration-fast) var(--ease-spring),
    color var(--duration-fast) var(--ease-gentle),
    border-color var(--duration-fast) var(--ease-gentle),
    box-shadow var(--duration-fast) var(--ease-gentle),
    background-color var(--duration-fast) var(--ease-gentle);
}

.btn-stop-trigger[hidden] {
  display: none !important;
}

.btn-stop-trigger:hover {
  color: var(--color-error);
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.25);
  background: var(--color-bg-elevated);
  transform: scale(1.05);
}

.btn-stop-trigger:active {
  transform: scale(0.92);
}

/* Chord prompt — entrance: Decelerate scale(0.95→1) + fade */
.prompt-chord {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  z-index: 2;
  transition:
    opacity var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
}

.prompt-chord.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Success: Spring 600ms scale(1→1.08→1) */
.prompt-chord.success {
  animation: chord-success var(--duration-spring) var(--ease-spring);
}

.prompt-chord.timeout {
  animation: chord-timeout 400ms var(--ease-out);
}

.chord-name {
  display: flex;
  align-items: baseline;
}

/* Chord root — display font, Boomwhackers color (set via JS) */
.chord-root {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3rem, 8vw, 5rem);
  color: var(--color-accent);
  text-shadow: 0 0 30px var(--amber-glow);
  line-height: 1;
}

/* Quality superscript */
.chord-symbol {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  color: var(--color-text-secondary);
  line-height: 1;
  position: relative;
  top: -0.5em;
}

/* Interval instruction */
.chord-hint {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: clamp(0.95rem, 2.5vw, 1.2rem);
  letter-spacing: 0.04em;
  text-transform: lowercase;
  opacity: 0.85;
  margin-top: 4px;
  min-height: 1.5em;
  transition:
    color var(--duration-fast) var(--ease-gentle),
    opacity var(--duration-fast) var(--ease-gentle);
}

.chord-hint:empty { display: none; }

/* Interval-specific colors: warm → neutral → cool */
.chord-hint.hint-3rd {
  color: var(--amber-400);
  text-shadow: 0 0 16px var(--amber-glow);
}

.chord-hint.hint-5th {
  color: var(--color-text-secondary);
}

.chord-hint.hint-7th {
  color: var(--cyan-400);
  text-shadow: 0 0 16px var(--cyan-glow);
}

/* Timer */
.prompt-timer {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--color-text-muted);
  z-index: 2;
  transition: color var(--duration-fast) var(--ease-gentle);
  min-height: 2rem;
}

.prompt-timer.fast   { color: var(--color-success); text-shadow: 0 0 12px var(--green-glow); }
.prompt-timer.medium { color: var(--color-accent);  text-shadow: 0 0 12px var(--amber-glow); }
.prompt-timer.slow   { color: var(--color-error);   text-shadow: 0 0 12px var(--red-glow); }

.timer-value {
  min-width: 4ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.timer-unit {
  font-size: 0.75em;
  opacity: 0.5;
}


/* ═══════════════════════════════════════════════════════════════
   PITCH CIRCLE HINT
   ═══════════════════════════════════════════════════════════════ */

.hint-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.hint-container[hidden] { display: none; }
.hint-container.visible { display: block; }

.hint-clock { display: block; }

.pitch-circle {
  width: 100%;
  height: 100%;
  display: block;
}

.pitch-dot {
  fill: var(--charcoal-500);
  transition:
    fill var(--duration-fast) var(--ease-gentle),
    r var(--duration-fast) var(--ease-gentle);
}

.pitch-dot.target {
  fill: var(--color-active);
  filter: drop-shadow(0 0 4px var(--active-glow));
}

.pitch-dot.root-marker {
  fill: var(--color-accent);
  filter: drop-shadow(0 0 4px var(--amber-glow));
}

.pitch-label {
  fill: var(--neutral-400);
  font-size: 6px;
  font-family: var(--font-mono);
  text-anchor: middle;
  dominant-baseline: central;
}


/* ═══════════════════════════════════════════════════════════════
   START SCREEN
   ═══════════════════════════════════════════════════════════════ */

.start-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  background: rgba(11, 11, 13, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity var(--duration-slow) var(--ease-out);
  cursor: pointer;
}

.start-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.start-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.start-subtitle {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--color-text-secondary);
  letter-spacing: 0.04em;
}

.start-instructions {
  font-size: 1rem;
  color: var(--color-text-muted);
}

.start-instructions kbd {
  display: inline-block;
  padding: 2px 8px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--color-active);
}

.start-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  opacity: 0.6;
  max-width: 320px;
  margin: 0 auto;
}


/* ═══════════════════════════════════════════════════════════════
   PIANO
   Tactile, physical feel. Minimal radii. NO glow on keys.
   ═══════════════════════════════════════════════════════════════ */

.piano-container {
  width: 100%;
  max-width: 880px;
  flex-shrink: 0;
}

.piano {
  position: relative;
  display: flex;
  height: clamp(140px, 22vh, 220px);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.piano-key {
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition:
    background-color var(--duration-fast) var(--ease-gentle),
    border-color var(--duration-fast) var(--ease-gentle),
    transform var(--duration-fast) var(--ease-gentle);
}

/* White keys — minimal bottom radius (2-3px per DESIGN.md) */
.piano-key.white {
  flex: 1;
  background: var(--white-key-color);
  border-radius: 0 0 var(--white-key-radius) var(--white-key-radius);
  z-index: 1;
  border-bottom: var(--key-outline-width) solid var(--key-outline-color);
  border-left: var(--key-outline-width) solid var(--key-outline-color);
  border-right: var(--key-outline-width) solid var(--key-outline-color);
  border-top: none;
  margin-left: calc(-1 * var(--key-outline-width));
}

.piano-key.white:first-child {
  margin-left: 0;
}

.piano-key.white:active,
.piano-key.white.active {
  background: hsl(0 0% var(--white-key-active-value));
  transform: translateY(2px);
}

.piano-key.white.active {
  background: color-mix(in oklch, var(--color-active), var(--white-key-color) 70%);
}

/* Black keys — no radius per DESIGN.md */
.piano-key.black {
  position: absolute;
  width: clamp(24px, 4.2%, 38px);
  height: 60%;
  background: var(--black-key-color);
  border-radius: 0 0 var(--black-key-radius) var(--black-key-radius);
  z-index: 2;
  border-bottom: var(--key-outline-width) solid var(--key-outline-color);
  border-left: var(--key-outline-width) solid var(--key-outline-color);
  border-right: var(--key-outline-width) solid var(--key-outline-color);
  border-top: none;
}

.piano-key.black:active,
.piano-key.black.active {
  background: hsl(0 0% var(--black-key-active-value));
  height: 58%;
}

.piano-key.black.active {
  background: color-mix(in oklch, var(--color-active), var(--black-key-color) 65%);
}

/* Root anchor — subtle amber highlight (no glow per DESIGN.md) */
.piano-key.root-highlight {
  animation: root-pulse 2s ease-in-out infinite;
}

.piano-key.white.root-highlight {
  box-shadow:
    inset 0 -3px 6px rgba(0, 0, 0, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.3),
    inset 0 0 20px rgba(240, 160, 48, 0.06);
}

.piano-key.black.root-highlight {
  box-shadow:
    inset 0 -2px 4px rgba(0, 0, 0, 0.4),
    0 3px 8px rgba(0, 0, 0, 0.5),
    inset 0 0 12px rgba(240, 160, 48, 0.08);
}

/* Success flash on keys */
.piano-key.flash-success {
  animation: key-success 500ms var(--ease-out);
}

.piano-key.white.flash-success {
  background: color-mix(in oklch, var(--color-success), var(--white-key-color) 50%);
}

.piano-key.black.flash-success {
  background: color-mix(in oklch, var(--color-success), var(--black-key-color) 40%);
}

/* Error flash on keys */
.piano-key.flash-error {
  animation: key-error 350ms var(--ease-out);
}

.piano-key.white.flash-error {
  background: color-mix(in oklch, var(--color-error), var(--white-key-color) 60%);
}

.piano-key.black.flash-error {
  background: color-mix(in oklch, var(--color-error), var(--black-key-color) 50%);
}

/* Answer reveal (timeout shows correct answer)
   No z-index change — black keys must always stay above white keys. */

.piano-key.answer-reveal.white {
  background: hsl(175 70% 45%);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.3);
}

.piano-key.answer-reveal.black {
  background: hsl(175 60% 36%);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.3);
}

/* Key labels */
.piano-key-label {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  pointer-events: none;
  opacity: 0.35;
  transition: opacity var(--duration-fast) var(--ease-gentle);
}

.piano-key.white .piano-key-label {
  color: hsl(0 0% calc(100% - var(--white-key-value)));
}

.piano-key.black .piano-key-label {
  color: hsl(0 0% calc(100% - var(--black-key-value)));
  bottom: 4px;
  font-size: 0.5rem;
}

.piano-key:hover .piano-key-label { opacity: 0.7; }


/* ═══════════════════════════════════════════════════════════════
   KEYBOARD LEGEND
   Level 1 surface (recessed). Fades contextually.
   ═══════════════════════════════════════════════════════════════ */

.keyboard-legend {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  opacity: 0.35;
  transition: opacity var(--duration-normal) var(--ease-gentle);
}

.keyboard-legend:hover { opacity: 0.7; }

.legend-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-subtle);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.legend-label {
  font-weight: 500;
  margin-right: var(--space-xs);
  min-width: 70px;
}

.legend-row kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 20px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--color-text-secondary);
}

.legend-gap { width: 8px; }


/* ═══════════════════════════════════════════════════════════════
   PROGRESS INDICATOR & POOL PANEL
   ═══════════════════════════════════════════════════════════════ */

/* Toast notifications — Spring entrance, Gentle exit */
.unlock-toast {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  padding: var(--space-sm) var(--space-xl);
  background: var(--color-bg-floating);
  border: 1px solid rgba(240, 160, 48, 0.4);
  border-radius: var(--radius-md);
  color: var(--color-accent);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  z-index: 100;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition:
    transform var(--duration-spring) var(--ease-spring),
    opacity var(--duration-normal) var(--ease-gentle);
}

.unlock-toast.visible {
  transform: translateX(-50%) translateY(calc(var(--space-xl) + 48px));
  opacity: 1;
}

/* Progress bar */
.progress-indicator {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  max-width: 520px;
  position: relative;
  z-index: 50;
}

.progress-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  padding: var(--space-xs) 0;
  min-height: 40px;
  transition: opacity var(--duration-fast) var(--ease-gentle);
}

.progress-header > * {
  pointer-events: none;
}

.progress-header:hover { opacity: 0.85; }

.progress-bar-track {
  flex: 1;
  height: 4px;
  background: var(--color-bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--amber-400);
  border-radius: 2px;
  transition: width var(--duration-spring) var(--ease-out);
  min-width: 2px;
}

.progress-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.progress-chevron {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  opacity: 0.5;
  transition: transform var(--duration-fast) var(--ease-out);
}

/* Expandable pool panel — Level 2 surface */
.pool-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md);
  margin-top: var(--space-xs);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.pool-panel.visible {
  display: flex;
  animation: pool-panel-in var(--duration-normal) var(--ease-out);
}

.pool-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* Section labels — DESIGN.md section-label spec */
.pool-section-label {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  padding-left: 2px;
}

.pool-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* Pool chips — DESIGN.md chip component spec */
.pool-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0.4em 0.9em;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  min-height: 44px;
  opacity: 0.45;
  transition:
    border-color var(--duration-fast) var(--ease-gentle),
    color var(--duration-fast) var(--ease-gentle),
    background-color var(--duration-fast) var(--ease-gentle),
    opacity var(--duration-fast) var(--ease-gentle);
}

.pool-chip:hover {
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--color-text-secondary);
  opacity: 0.7;
}

.pool-chip.locked {
  opacity: 0.2;
  pointer-events: none;
  cursor: default;
}

/* Confidence-colored active chips — hue set via --chip-hue (0=red → 140=green) */
.pool-chip.active {
  opacity: 1;
  border-color: hsl(var(--chip-hue, 45) 80% 50%);
  color: hsl(var(--chip-hue, 45) 80% 70%);
  background: hsla(var(--chip-hue, 45) 80% 50% / 0.1);
}

.pool-chip.active:hover {
  background: hsla(var(--chip-hue, 45) 80% 50% / 0.18);
  opacity: 1;
}

/* Focus chord indicator — pulsing glow */
.pool-chip.focus {
  animation: focus-pulse 1.5s ease-in-out infinite;
}

/* Pool chip tooltips — Level 4 floating surface */
.pool-chip[data-tooltip]:not(.locked):not([data-tooltip=""])::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 5px 10px;
  background: var(--color-bg-floating);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 20;
  box-shadow: var(--shadow-sm);
  transition:
    opacity var(--duration-fast) var(--ease-gentle),
    transform var(--duration-fast) var(--ease-gentle);
}

.pool-chip[data-tooltip]:not(.locked):not([data-tooltip=""])::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--color-bg-floating);
  pointer-events: none;
  opacity: 0;
  z-index: 20;
  transition: opacity var(--duration-fast) var(--ease-gentle);
}

.pool-chip[data-tooltip]:not(.locked):not([data-tooltip=""]):hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.pool-chip[data-tooltip]:not(.locked):not([data-tooltip=""]):hover::before {
  opacity: 1;
}


/* ═══════════════════════════════════════════════════════════════
   PHASE DIALOG
   Level 3: Glass surface. Open: Decelerate translateY only.
   ═══════════════════════════════════════════════════════════════ */

.phase-dialog {
  background: var(--color-surface-glass);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  color: var(--color-text-primary);
  max-width: 560px;
  width: 90vw;
  padding: 0;
  overflow: hidden;

  /* Open animation: Decelerate translateY(16px→0) — NO scale per DESIGN.md */
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out),
    overlay var(--duration-normal) var(--ease-out) allow-discrete,
    display var(--duration-normal) var(--ease-out) allow-discrete;
}

.phase-dialog[open] {
  opacity: 1;
  transform: translateY(0);
}

@starting-style {
  .phase-dialog[open] {
    opacity: 0;
    transform: translateY(16px);
  }
}

.phase-dialog::backdrop {
  background: rgba(5, 8, 16, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition:
    opacity var(--duration-normal) var(--ease-out),
    overlay var(--duration-normal) var(--ease-out) allow-discrete,
    display var(--duration-normal) var(--ease-out) allow-discrete;
}

.phase-dialog[open]::backdrop { opacity: 1; }

@starting-style {
  .phase-dialog[open]::backdrop { opacity: 0; }
}

/* Dialog animation states (used by phases.js) */
.phase-dialog.opening {
  opacity: 0;
  transform: translateY(16px);
}

.phase-dialog.open {
  opacity: 1;
  transform: translateY(0);
}

.phase-dialog.closing {
  animation: dialog-close-anim var(--duration-fast) var(--ease-gentle) forwards;
}

/* Shared dialog header */
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--color-border);
}

.dialog-header h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
}

.dialog-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition:
    background-color var(--duration-fast) var(--ease-gentle),
    color var(--duration-fast) var(--ease-gentle);
}

.dialog-close:hover {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
}

/* Phase cards list */
.phase-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-lg);
}

/* Phase card — from both original dialog and phases.js */
.phase-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    border-color var(--duration-normal) var(--ease-out),
    background-color var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
}

.phase-card:hover {
  border-color: var(--color-border-active);
  background: var(--charcoal-600);
  transform: translateX(4px);
}

.phase-card.current {
  border-color: var(--color-accent);
  box-shadow: 0 0 16px var(--amber-glow);
}

.phase-card-icon-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.phase-card-icon {
  font-size: 1.6rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border-radius: var(--radius-md);
}

.phase-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.phase-card-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}

.phase-card-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.phase-card-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 2px 8px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--color-text-secondary);
}

.phase-card-meta {
  display: flex;
  gap: var(--space-sm);
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
}

.phase-card-meta span {
  padding: 2px 6px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
}

.phase-card-stats {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  padding-top: var(--space-sm);
}

.phase-card-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 52px;
  height: 52px;
}

.phase-card-acc-label,
.phase-card-latency-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.phase-card-latency {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.phase-card-latency-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text-primary);
}

.phase-card-attempts {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.phase-card-select {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-accent);
  color: var(--charcoal-900);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 44px;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
  align-self: flex-end;
}

.phase-card-select:hover {
  background: var(--amber-300);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--amber-glow);
}

/* Progress ring (SVG in phase card) */
.ring-bg {
  fill: none;
  stroke: var(--charcoal-500);
  stroke-width: 3;
}

.ring-progress {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 3;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset var(--duration-slow) var(--ease-out);
}

.ring-text {
  fill: var(--color-text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

.progress-ring { display: block; }

.progress-ring-circle {
  transition: stroke-dashoffset var(--duration-slow) var(--ease-out);
}

/* Phase modal content (dynamically created by phases.js) */
.phase-modal-content {
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.phase-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.phase-modal-header h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
}

.phase-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition:
    background-color var(--duration-fast) var(--ease-gentle),
    color var(--duration-fast) var(--ease-gentle);
}

.phase-modal-close:hover {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
}

.phase-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg);
  overflow-y: auto;
}


/* ═══════════════════════════════════════════════════════════════
   TUTORIAL DIALOG
   ═══════════════════════════════════════════════════════════════ */

.tutorial-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  margin: auto;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: tutorial-enter 350ms var(--ease-out);
}

.tutorial-dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.tutorial-header {
  text-align: center;
  padding: var(--space-xl) var(--space-xl) var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.tutorial-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: var(--space-sm);
}

.tutorial-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-accent);
  margin: 0 0 var(--space-xs);
}

.tutorial-subtitle {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin: 0;
  line-height: 1.5;
}

.tutorial-body {
  padding: var(--space-lg) var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.tutorial-section-heading {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 var(--space-xs);
}

.tutorial-section-body {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-sm);
}

/* Interval table */
.tutorial-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.tutorial-table-row {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-bg-elevated);
  font-size: 0.8rem;
}

.tutorial-table-row:nth-child(odd) { background: var(--color-bg-subtle); }

.tutorial-table-label {
  flex: 0 0 40%;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--color-text-primary);
}

.tutorial-table-value {
  flex: 1;
  color: var(--color-text-secondary);
}

.tutorial-note {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-style: italic;
  margin: var(--space-xs) 0 0;
  padding-left: var(--space-sm);
  border-left: 2px solid var(--color-border);
  line-height: 1.5;
}

.tutorial-footer {
  padding: var(--space-md) var(--space-xl) var(--space-xl);
  text-align: center;
}

.tutorial-start-btn {
  padding: var(--space-sm) var(--space-2xl);
  background: linear-gradient(135deg, var(--amber-400), hsl(35 90% 55%));
  color: var(--color-bg-primary);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  min-height: 44px;
  transition:
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.tutorial-start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(240, 160, 48, 0.35);
}

.tutorial-start-btn:active { transform: translateY(0); }

/* App Views and Navigation Page Layouts */
.app-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 0;
  animation: fade-in var(--duration-normal) var(--ease-out);
}

.app-view[hidden] {
  display: none !important;
}

#view-practice {
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
}

#view-stats,
#view-settings {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: var(--space-xl);
}

/* Scrollbar styling for pages */
#view-stats::-webkit-scrollbar,
#view-settings::-webkit-scrollbar {
  width: 6px;
}
#view-stats::-webkit-scrollbar-track,
#view-settings::-webkit-scrollbar-track {
  background: transparent;
}
#view-stats::-webkit-scrollbar-thumb,
#view-settings::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-sm);
}
#view-stats::-webkit-scrollbar-thumb:hover,
#view-settings::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-active);
}

/* Page Headers */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-xs) 0 var(--space-md) 0;
  margin-bottom: var(--space-lg);
  width: 100%;
  flex-shrink: 0;
}

.view-header h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  margin: 0;
  background: linear-gradient(135deg, var(--color-text-primary), var(--neutral-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.view-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition:
    color var(--duration-fast) var(--ease-gentle),
    background-color var(--duration-fast) var(--ease-gentle);
}

.view-close-btn:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-subtle);
}

/* Stats Bar Action Buttons (Mute and New Session) */
.btn-stat-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-gentle);
  flex-shrink: 0;
}

.btn-stat-action:hover {
  background: var(--color-bg-elevated);
  border-color: var(--color-border-active);
  color: var(--color-accent);
  box-shadow: 0 0 12px var(--amber-glow);
}

.btn-stat-action:active {
  transform: scale(0.92);
}

.btn-stat-action.active {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: rgba(240, 160, 48, 0.08);
}

/* ═══════════════════════════════════════════════════════════════
   PROFILE DASHBOARD
   Level 3 surface (glass). Data-dense — can use midnight-600.
   ═══════════════════════════════════════════════════════════════ */

.profile-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 780px;
  max-height: 92vh;
  margin: auto;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--charcoal-900);
  color: var(--color-text-primary);
  overflow: hidden;
  display: flex;
  flex-direction: column;

  /* Open: Decelerate translateY only — NO scale per DESIGN.md */
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out),
    overlay var(--duration-normal) var(--ease-out) allow-discrete,
    display var(--duration-normal) var(--ease-out) allow-discrete;
}

.profile-dialog[open] {
  opacity: 1;
  transform: translateY(0);
}

@starting-style {
  .profile-dialog[open] {
    opacity: 0;
    transform: translateY(16px);
  }
}

.profile-dialog::backdrop {
  background: rgba(5, 8, 16, 0.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition:
    opacity var(--duration-normal) var(--ease-out),
    overlay var(--duration-normal) var(--ease-out) allow-discrete,
    display var(--duration-normal) var(--ease-out) allow-discrete;
}

.profile-dialog[open]::backdrop { opacity: 1; }

@starting-style {
  .profile-dialog[open]::backdrop { opacity: 0; }
}

.profile-dialog .dialog-header { flex-shrink: 0; }

.profile-content {
  flex-shrink: 0;
  overflow-x: hidden;
  padding: 0 var(--space-lg) var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* Phase tabs */
.profile-phase-tabs {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-md) 0 0;
  flex-shrink: 0;
}

.profile-tab {
  flex: 1;
  padding: var(--space-sm) var(--space-xs);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  min-height: 44px;
  transition:
    color var(--duration-fast) var(--ease-gentle),
    border-color var(--duration-fast) var(--ease-gentle),
    background-color var(--duration-fast) var(--ease-gentle);
}

.profile-tab:hover {
  color: var(--color-text-secondary);
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--color-bg-subtle);
}

.profile-tab.active {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: rgba(240, 160, 48, 0.08);
  font-weight: 600;
}

/* Profile summary stats */
.profile-summary {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
  justify-content: center;
}

.profile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 60px;
}

.profile-stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.profile-stat-label {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

/* Chart sections */
.chart-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.chart-section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--color-border);
}

.chart-container {
  width: 100%;
  min-height: 60px;
  position: relative;
}

/* SVG chart elements */
.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid-line {
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-axis-label {
  fill: var(--neutral-400);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
}

.chart-axis-label--y { text-anchor: end; }

.chart-target-line {
  stroke: rgba(240, 160, 48, 0.4);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  vector-effect: non-scaling-stroke;
}

.chart-target-label {
  fill: var(--amber-400);
  font-size: 9px;
  opacity: 0.7;
}

.chart-session-line {
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
}

.chart-trend-line {
  fill: none;
  stroke: var(--active-400);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
  vector-effect: non-scaling-stroke;
}

.chart-regression-line {
  stroke: var(--active-300);
  stroke-width: 1.5;
  stroke-dasharray: 8 4;
  opacity: 0.5;
  vector-effect: non-scaling-stroke;
}

.chart-dot {
  transition: r 100ms var(--ease-gentle);
  cursor: default;
}

.chart-dot:hover { r: 6; }

.chart-dot--correct {
  fill: var(--color-success);
  opacity: 0.85;
}

.chart-dot--wrong {
  fill: var(--color-error);
  opacity: 0.5;
}

/* Heatmap */
.heatmap-svg {
  max-width: 100%;
  overflow: visible;
}

.heatmap-header {
  font-size: 11px;
  font-weight: 700;
}

.heatmap-row-label { font-size: 10px; }

.heatmap-cell {
  transition: opacity 150ms var(--ease-gentle);
  cursor: default;
}

.heatmap-cell:hover {
  opacity: 0.85;
  filter: brightness(1.2);
}

.heatmap-cell-text {
  fill: rgba(255, 255, 255, 0.85);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  pointer-events: none;
}

/* Calendar (GitHub-style contribution grid) */
.calendar-svg { max-width: 100%; }

.calendar-cell {
  cursor: default;
  transition: filter 100ms var(--ease-gentle);
}

.calendar-cell:hover { filter: brightness(1.3); }

.calendar-day-label { font-size: 9px; }

.calendar-month-label {
  font-size: 9px;
  fill: var(--neutral-300);
}

.calendar-streak {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  margin-top: var(--space-xs);
}

.streak-flame { font-size: 1.2rem; }

.streak-count {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--color-text-primary);
}

.streak-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Chord selector (per-chord speed chart) */
.chord-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: var(--space-xs) 0;
  max-height: 120px;
  overflow-y: auto;
}

.chord-chip {
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  min-height: 32px;
  transition:
    color var(--duration-fast) var(--ease-gentle),
    border-color var(--duration-fast) var(--ease-gentle),
    background-color var(--duration-fast) var(--ease-gentle);
}

.chord-chip:hover {
  color: var(--color-text-secondary);
  border-color: rgba(255, 255, 255, 0.15);
}

.chord-chip.active {
  color: var(--color-active);
  border-color: var(--color-active);
  background: var(--active-glow);
}

/* Chord speed stats text */
.chord-speed-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  flex-wrap: wrap;
}

.chord-stat strong {
  color: var(--color-text-primary);
  font-weight: 600;
}

.chord-stat-sep { opacity: 0.3; }

/* Empty state */
.profile-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  padding: var(--space-xl);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-style: italic;
  opacity: 0.6;
}


/* ═══════════════════════════════════════════════════════════════
   KEYFRAMES
   All animations in one consolidated section.
   ═══════════════════════════════════════════════════════════════ */

@keyframes note-sway {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

/* Chord prompt: success = Spring scale overshoot */
@keyframes chord-success {
  0%   { transform: scale(1); filter: brightness(1); }
  30%  { transform: scale(1.08); filter: brightness(1.5); }
  100% { transform: scale(1); filter: brightness(1); }
}

@keyframes chord-timeout {
  0%, 100% { opacity: 1; }
  25%, 75% { opacity: 0.3; }
}

/* Piano key feedback */
@keyframes root-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}

@keyframes key-success {
  0%   { filter: brightness(1); }
  30%  { filter: brightness(1.5); }
  100% { filter: brightness(1); }
}

@keyframes key-error {
  0%   { opacity: 1; }
  50%  { opacity: 0.6; }
  100% { opacity: 1; }
}

/* Focus chord pulsing glow */
@keyframes focus-pulse {
  0%, 100% { box-shadow: 0 0 0 0 hsla(var(--chip-hue, 45) 80% 50% / 0.4); }
  50%      { box-shadow: 0 0 8px 2px hsla(var(--chip-hue, 45) 80% 50% / 0.15); }
}

/* Pool panel entrance */
@keyframes pool-panel-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Utility */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px var(--amber-glow); }
  50%      { box-shadow: 0 0 24px var(--amber-glow); }
}

/* Tutorial entrance */
@keyframes tutorial-enter {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Dialog close */
@keyframes dialog-close-anim {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}


/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   All media queries consolidated at the end.
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  /* Header */
  .app-header {
    padding: var(--space-xs) var(--space-md);
  }

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

  .btn-icon {
    width: 40px;
    height: 40px;
  }

  /* Stats */
  .stats-bar {
    gap: var(--space-md);
    padding: var(--space-xs) var(--space-md);
  }

  .stat-value { font-size: 1.3rem; }

  /* Prompt */
  .prompt-area {
    padding: var(--space-md);
    min-height: 140px;
  }

  /* Keyboard legend — hidden on mobile (tap, not type) */
  .keyboard-legend { display: none; }

  /* Piano — naturally wider & scrollable to avoid squash distortions */
  .piano-container {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .piano-container::-webkit-scrollbar {
    display: none;
  }

  .piano {
    height: clamp(130px, 18vh, 170px);
    width: 180%;
    transform: none;
  }

  .piano-key-label { display: none; }

  /* Profile dashboard */
  .profile-dialog {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
    inset: 0;
  }

  .profile-content {
    padding: 0 var(--space-md) var(--space-lg);
  }

  .profile-summary {
    gap: var(--space-sm);
    padding: var(--space-sm);
  }

  .profile-stat-value { font-size: 1.3rem; }

  .profile-phase-tabs { gap: 2px; }

  .profile-tab {
    font-size: 0.7rem;
    padding: var(--space-xs);
    min-height: 36px;
  }

  .chord-selector { max-height: 80px; }
}

@media (max-width: 420px) {
  .stats-bar { gap: var(--space-sm); }
  .stat-item { min-width: 45px; }
  .stat-value { font-size: 1.1rem; }
}


/* ═══════════════════════════════════════════════════════════════
   SETTINGS DIALOG & SLIDERS
   ═══════════════════════════════════════════════════════════════ */

.settings-dialog {
  background: var(--color-surface-glass);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  color: var(--color-text-primary);
  max-width: 420px;
  width: 90vw;
  padding: 0;
  overflow: hidden;

  /* Open animation */
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out),
    overlay var(--duration-normal) var(--ease-out) allow-discrete,
    display var(--duration-normal) var(--ease-out) allow-discrete;
}

.settings-dialog[open] {
  opacity: 1;
  transform: translateY(0);
}

.settings-dialog.closing {
  animation: dialog-close-anim var(--duration-fast) var(--ease-gentle) forwards;
}

@starting-style {
  .settings-dialog[open] {
    opacity: 0;
    transform: translateY(16px);
  }
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition:
    opacity var(--duration-normal) var(--ease-out),
    overlay var(--duration-normal) var(--ease-out) allow-discrete,
    display var(--duration-normal) var(--ease-out) allow-discrete;
}

.settings-dialog[open]::backdrop { opacity: 1; }

@starting-style {
  .settings-dialog[open]::backdrop { opacity: 0; }
}

.settings-content {
  flex-shrink: 0;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.setting-group label {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  display: flex;
  justify-content: space-between;
}

.setting-group label span {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--color-accent);
}

/* Settings Sections & Groups */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.settings-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-section-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.85;
}

.settings-section-title.text-danger {
  color: var(--color-error);
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
}

.settings-section-desc {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-xs) 0;
  line-height: 1.4;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-xs) 0;
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.setting-label-text {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.setting-desc {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.3;
}

/* Action Buttons inside Settings Dialog */
.settings-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  min-height: 38px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-glass);
  color: var(--color-text-primary);
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform var(--duration-fast) var(--ease-spring),
    border-color var(--duration-fast) var(--ease-gentle),
    background-color var(--duration-fast) var(--ease-gentle),
    box-shadow var(--duration-fast) var(--ease-gentle),
    color var(--duration-fast) var(--ease-gentle);
}

.settings-action-btn:hover {
  background: var(--color-bg-elevated);
  border-color: var(--color-border-active);
  transform: translateY(-1px);
}

.settings-action-btn:active {
  transform: translateY(1px);
}

#auth-btn.settings-action-btn {
  width: 100%;
  justify-content: center;
  border-color: var(--color-border);
}

#auth-btn.settings-action-btn:hover {
  box-shadow: 0 0 16px var(--amber-glow);
  border-color: var(--color-border-active);
  color: var(--color-accent);
}

.settings-action-btn.btn-secondary {
  border-color: var(--color-border);
  color: var(--color-text-secondary);
}

.settings-action-btn.btn-secondary:hover {
  border-color: var(--color-border-active);
  color: var(--color-text-primary);
}

.settings-action-btn.btn-secondary.active {
  color: var(--color-active);
  background: var(--active-glow);
  border-color: var(--color-border-active);
}

.settings-action-btn.btn-danger {
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--color-error);
}

.settings-action-btn.btn-danger:hover {
  border-color: var(--color-error);
  background: rgba(239, 68, 68, 0.08);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.2);
}

.btn-label-inline {
  /* shown inline with settings buttons */
}

.settings-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-subtle);
  outline: none;
  transition: background var(--duration-fast) var(--ease-gentle);
}

.settings-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: var(--charcoal-600);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 8px var(--amber-glow);
  cursor: pointer;
  margin-top: -6px; /* offset to center track */
  transition: transform var(--duration-fast) var(--ease-spring), background var(--duration-fast) var(--ease-gentle);
}

.settings-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.settings-slider::-webkit-slider-thumb:active {
  transform: scale(0.95);
  background: var(--color-accent-soft);
}

/* Firefox */
.settings-slider::-moz-range-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: var(--charcoal-600);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.settings-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  border: none;
  box-shadow: 0 0 8px var(--amber-glow);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-spring), background var(--duration-fast) var(--ease-gentle);
}

.settings-slider::-moz-range-thumb:hover {
  transform: scale(1.15);
}

.settings-slider::-moz-range-thumb:active {
  transform: scale(0.95);
  background: var(--color-accent-soft);
}

.setting-toggle-group {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-md);
}

.setting-label {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-primary);
}

.btn-toggle {
  padding: var(--space-xs) var(--space-md);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-gentle);
}

.btn-toggle:hover {
  background: var(--color-bg-elevated);
  border-color: var(--color-border-active);
  color: var(--color-text-primary);
}

.btn-toggle:active {
  transform: scale(0.98);
}

/* ═══════════════════════════════════════════════════════════════
   PORTRAIT LAYOUT OPTIMIZATION
   Enhances spacing, enlarges chord labels, and expands keys 
   in portrait viewports to prevent wasted vertical space and 
   improve playability.
   ═══════════════════════════════════════════════════════════════ */

@media (orientation: portrait) {
  .app-main {
    justify-content: space-between;
    padding: var(--space-md) var(--space-md) var(--space-lg) var(--space-md);
    gap: var(--space-md);
  }

  #view-practice {
    justify-content: space-between;
    gap: var(--space-md);
  }

  .stats-bar {
    margin-bottom: 0;
  }

  .prompt-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: auto;
    min-height: 240px;
    aspect-ratio: auto;
    margin: 0;
  }

  .chord-root {
    font-size: clamp(5rem, 15vh, 8.5rem);
  }

  .chord-symbol {
    font-size: clamp(2.5rem, 7.5vh, 4rem);
  }

  .chord-hint {
    font-size: clamp(1.2rem, 3.5vh, 1.8rem);
    margin-top: var(--space-sm);
  }

  .prompt-timer {
    font-size: clamp(1.6rem, 4vh, 2.2rem);
    margin-top: var(--space-md);
  }

  .hint-container {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .pitch-circle {
    width: min(280px, 80vw, 35vh);
    height: min(280px, 80vw, 35vh);
  }

  .piano-container {
    overflow-x: auto;
    width: calc(100% + var(--space-md) * 2);
    margin-left: calc(-1 * var(--space-md));
    margin-right: calc(-1 * var(--space-md));
    max-width: none;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .piano-container::-webkit-scrollbar {
    display: none;
  }

  .piano {
    height: clamp(180px, 26vh, 250px);
    width: 180%; /* 1.8x keyboard width so keys are wider and play-friendly */
    transform: none !important;
  }
}

/* Vertical Sidebar layout on Desktop/Landscape viewports */
@media (min-width: 769px) {
  .app-header {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 200px;
    height: 100dvh;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-lg) 0;
    border-right: 1px solid var(--color-border);
    border-bottom: none;
    z-index: 100;
  }

  .logo {
    flex-direction: row;
    gap: var(--space-sm);
    padding: 0 var(--space-md);
    width: 100%;
    align-items: center;
  }

  .logo-text {
    display: inline-block;
    font-size: 1.3rem;
  }

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

  .phase-indicator {
    width: calc(100% - var(--space-md) * 2);
    height: auto;
    border-radius: var(--radius-xl);
    padding: var(--space-xs) var(--space-md);
    margin: 0 var(--space-md);
    justify-content: space-between;
  }

  .phase-name,
  .phase-chevron {
    display: inline;
  }

  .header-actions {
    flex-direction: column;
    gap: var(--space-xs);
    align-items: flex-start;
    width: 100%;
    padding: 0 var(--space-md);
    margin-top: var(--space-sm);
  }

  /* Style all actions inside sidebar as navigation rows */
  .header-actions .btn-icon {
    width: 100%;
    height: 40px;
    justify-content: flex-start;
    gap: var(--space-sm);
    padding: 0 var(--space-md);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    border: 1px solid transparent;
  }

  .header-actions .btn-icon:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-subtle);
    border-color: var(--color-border);
  }

  .header-actions .btn-icon.active {
    color: var(--color-active);
    background: var(--active-glow);
    border-color: var(--color-border-active);
  }

  .header-actions .btn-label {
    display: inline;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
  }

  #more-actions-btn {
    display: none !important;
  }

  #actions-group {
    display: contents;
  }

  #practice-btn {
    order: 1;
  }

  #profile-btn {
    order: 2;
  }

  #help-btn {
    order: 3;
  }

  #settings-btn {
    order: 4;
  }

  .app-main {
    margin-left: 200px;
  }
}

/* Collapsible Dropdown Actions on Mobile/Tablet viewports */
@media (max-width: 768px) {
  #more-actions-btn {
    display: flex;
  }

  .btn-label {
    display: none;
  }

  #actions-group {
    display: none;
    position: absolute;
    top: 56px;
    right: 0;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    flex-direction: column;
    gap: var(--space-xs);
    z-index: 150;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
  }

  #actions-group.visible {
    display: flex;
    animation: menu-slide-in 200ms var(--ease-out);
  }

  /* Make actions inside dropdown act as menu row list items */
  #actions-group .btn-icon {
    width: 100%;
    height: 40px;
    justify-content: flex-start;
    gap: var(--space-sm);
    padding: 0 var(--space-md);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--color-text-secondary);
  }

  #actions-group .btn-icon:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-subtle);
  }

  #actions-group .btn-label {
    display: inline;
  }
}

@keyframes menu-slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
