/* ==========================================================================
   Virtuoso - Premium Virtual Piano Stylesheet
   ========================================================================== */

:root {
  --bg-primary: #0b0d14;
  --bg-secondary: #121622;
  --bg-tertiary: #1b2030;
  --bg-glass: rgba(18, 22, 34, 0.75);
  --bg-glass-card: rgba(27, 32, 48, 0.65);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  --accent-gold: #f59e0b;
  --accent-gold-glow: rgba(245, 158, 11, 0.35);
  --accent-cyan: #38bdf8;
  --accent-cyan-glow: rgba(56, 189, 248, 0.35);
  --accent-indigo: #6366f1;
  --accent-indigo-glow: rgba(99, 102, 241, 0.4);
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --white-key-width: 26px;
  --white-key-height: 220px;
  --black-key-width: 17px;
  --black-key-height: 140px;

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

  --shadow-key-white: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3), inset 0 -3px 0 rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --shadow-key-white-active: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 -1px 0 rgba(0, 0, 0, 0.1), inset 0 0 16px rgba(56, 189, 248, 0.4);
  --shadow-key-black: 0 6px 10px rgba(0, 0, 0, 0.7), inset 0 1px 1px rgba(255, 255, 255, 0.35), inset 0 -2px 4px rgba(0, 0, 0, 0.8);
  --shadow-key-black-active: 0 2px 4px rgba(0, 0, 0, 0.8), inset 0 0 14px rgba(245, 158, 11, 0.6);

  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* Reset & Base Setup */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html,
body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-main);
  line-height: 1.5;
}

/* Homepage SEO content section (below the app, crawlable copy) */
.seo-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.seo-content h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 16px;
}

.seo-content h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 30px 0 12px;
  color: #ffffff;
}

.seo-content h3 {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 18px 0 6px;
  color: var(--accent-cyan);
}

.seo-content p {
  color: #cbd5e1;
  font-size: 0.98rem;
  line-height: 1.75;
  margin-bottom: 14px;
}

.seo-content a {
  color: var(--accent-cyan);
}

.seo-content .seo-cta {
  text-align: center;
  margin-top: 34px;
}

.seo-content .seo-cta a {
  color: #ffffff;
  text-decoration: none;
}

/* App Container Layout */
.app-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: radial-gradient(circle at 50% -20%, rgba(99, 102, 241, 0.15), transparent 70%),
    radial-gradient(circle at 20% 80%, rgba(56, 189, 248, 0.08), transparent 50%),
    var(--bg-primary);
}

/* Header Bar */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  transition: opacity 0.35s ease, max-height 0.35s ease, padding 0.35s ease;
  flex-shrink: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 20;
  gap: 16px;
  flex-wrap: nowrap;
  box-sizing: border-box;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-cyan));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 0 18px var(--accent-indigo-glow);
}

.logo-icon svg {
  width: 22px;
  height: 22px;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #ffffff 30%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: block;
}

/* Status Pill (Chord & Scale) */
.realtime-status-pill {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0 16px;
  height: 32px;
  max-height: 32px;
  gap: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-group {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
  line-height: 1;
}

.status-value {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent-cyan);
  min-width: 44px;
  max-width: 220px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
  transition: color 0.15s ease;
}

.status-divider {
  width: 1px;
  height: 16px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

/* Waterfall Chord & Scale Pill (Top-Left of Waterfall, under Song Banner) */
.waterfall-status-pill {
  position: absolute;
  top: 10px;
  left: 16px;
  display: flex;
  align-items: center;
  background: rgba(11, 13, 20, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0 16px;
  height: 32px;
  max-height: 32px;
  gap: 12px;
  white-space: nowrap;
  flex-shrink: 0;
  z-index: 5;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.waterfall-status-pill .status-value {
  font-size: 0.95rem;
}

.waterfall-status-pill .status-value#chord-display {
  color: #ffffff;
  font-weight: 700;
  min-width: 60px;
}

/* Header Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.86rem;
  font-weight: 600;
  font-family: var(--font-main);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  white-space: nowrap;
}

.btn svg {
  width: 17px;
  height: 17px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-indigo), #4f46e5);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--accent-indigo-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-indigo-glow);
  filter: brightness(1.1);
}

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

.btn-glass {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.btn-glass:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-glass.active-fullscreen {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.record-btn {
  position: relative;
}

.record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-rose);
  box-shadow: 0 0 8px rgba(244, 63, 94, 0.6);
  transition: all 0.2s ease;
}

.record-btn.recording .record-dot {
  animation: pulse-red 1s infinite alternate;
}

@keyframes pulse-red {
  0% {
    transform: scale(0.9);
    opacity: 0.6;
  }

  100% {
    transform: scale(1.3);
    opacity: 1;
    box-shadow: 0 0 16px rgba(244, 63, 94, 0.9);
  }
}

/* Studio Toolbar / Control Strip */
.control-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px;
  max-height: 120px;
  transition: opacity 0.35s ease, max-height 0.35s ease, padding 0.35s ease;
  background: rgba(14, 17, 26, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  gap: 20px;
  z-index: 15;
  overflow-x: auto;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.control-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.8px;
}

/* Custom Select Dropdown */
.select-wrapper {
  position: relative;
}

.custom-select {
  appearance: none;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 6px 32px 6px 12px;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}

.custom-select:hover,
.custom-select:focus {
  border-color: var(--border-focus);
}

.select-wrapper::after {
  content: "▾";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
  font-size: 0.8rem;
}

/* Key Labels Segmented Control */

/* Segmented Control */
.segmented-control {
  display: flex;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.seg-btn:hover {
  color: var(--text-primary);
}

.seg-btn.active {
  background: var(--accent-indigo);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--accent-indigo-glow);
}

.keys-range-readout {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Short (landscape-phone) screens: smaller key labels, non-wrapping footer */
@media (max-height: 500px) {
  .white-key .key-label {
    font-size: 0.62rem;
  }

  .black-key .key-label {
    font-size: 0.55rem;
  }
}

.app-footer {
  overflow-x: auto;
  scrollbar-width: none;
}

.app-footer::-webkit-scrollbar {
  display: none;
}

.app-footer > div {
  flex-shrink: 0;
}

/* Sustain Pedal Button */
.btn-sustain {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pedal-icon {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--text-muted);
  transition: all 0.2s ease;
}

.btn-sustain.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  box-shadow: 0 0 14px var(--accent-gold-glow);
}

.btn-sustain.active .pedal-icon {
  background: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
}

/* Knobs & Sliders */
.audio-knobs {
  display: flex;
  gap: 16px;
}

.knob-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.knob-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
}

.knob-val {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  min-width: 32px;
}

.custom-range {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  width: 80px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  outline: none;
  border: 1px solid var(--border-subtle);
}

.custom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-cyan-glow);
  transition: transform 0.1s;
}

.custom-range::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

/* Active Song Banner */
.song-player-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 8px;
  padding: 10px 24px;
  max-height: 300px;
  transition: opacity 0.35s ease, max-height 0.35s ease, padding 0.35s ease;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.2), rgba(56, 189, 248, 0.15));
  border-bottom: 1px solid rgba(99, 102, 241, 0.3);
  position: relative;
  z-index: 14;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.song-player-banner.hidden {
  display: none;
}

.song-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.song-playing-icon {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 18px;
}

.song-playing-icon .bar {
  width: 3px;
  background: var(--accent-cyan);
  border-radius: 1px;
  animation: equalize 0.8s ease-in-out infinite alternate;
}

.song-playing-icon .bar:nth-child(1) {
  height: 60%;
  animation-delay: 0.1s;
}

.song-playing-icon .bar:nth-child(2) {
  height: 100%;
  animation-delay: 0.3s;
}

.song-playing-icon .bar:nth-child(3) {
  height: 40%;
  animation-delay: 0.2s;
}

@keyframes equalize {
  0% {
    height: 20%;
  }

  100% {
    height: 100%;
  }
}

.song-info h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-info span {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.song-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.song-mode-switch {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-md);
  padding: 2px;
  border: 1px solid var(--border-subtle);
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

.mode-btn.active {
  background: var(--accent-indigo);
  color: #fff;
}

.custom-select-mini {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 0.78rem;
  outline: none;
}

.song-time-display {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-cyan);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.song-progress-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: height 0.15s ease, background 0.15s ease;
  z-index: 5;
}

/* Enlarge hover/click area for effortless scrub targeting */
.song-progress-container::before {
  content: "";
  position: absolute;
  top: -8px;
  bottom: -4px;
  left: 0;
  right: 0;
}

.song-progress-container:hover,
.song-progress-container.dragging {
  height: 10px;
  background: rgba(255, 255, 255, 0.22);
}

.song-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-indigo), var(--accent-cyan));
  position: relative;
  border-radius: 0 3px 3px 0;
}

.progress-scrub-handle {
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 8px var(--accent-cyan), 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease;
  pointer-events: none;
}

.song-progress-container:hover .progress-scrub-handle,
.song-progress-container.dragging .progress-scrub-handle {
  transform: translateY(-50%) scale(1);
}

/* Visualizer Container & Falling Notes */
.visualizer-container {
  position: relative;
  flex: 1;
  min-height: 140px;
  width: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #07090e 0%, #0c0f17 100%);
}

#falling-notes-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

#audio-wave-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  opacity: 0.45;
}

.hit-target-line {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), var(--accent-indigo), var(--accent-gold), transparent);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
  z-index: 3;
}

.visualizer-overlay-tools {
  position: absolute;
  top: 10px;
  right: 16px;
  display: flex;
  gap: 6px;
  z-index: 5;
  transition: opacity 0.35s ease;
}

/* Performance mode: UI melts away while playing (song banner stays for transport) */
body.performing .app-header,
body.performing .control-strip,
body.performing .app-footer,
body.performing .landscape-nudge {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
  margin-bottom: 0;
  border-color: transparent;
  pointer-events: none;
  overflow: hidden;
}

body.performing .visualizer-overlay-tools .btn-tool:not(#btn-ui-toggle),
body.performing .waterfall-status-pill,
body.performing .piano-touch-hint {
  opacity: 0;
  pointer-events: none;
}

.visualizer-overlay-tools,
.waterfall-status-pill,
.piano-touch-hint {
  transition: opacity 0.35s ease;
}

.btn-tool {
  background: rgba(18, 22, 34, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn-tool:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.tool-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.tool-dot.active {
  background: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
}

.practice-feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  background: rgba(16, 185, 129, 0.25);
  border: 1px solid var(--accent-emerald);
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.5);
  color: #ffffff;
  padding: 8px 24px;
  border-radius: var(--radius-full);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 1px;
  z-index: 10;
  pointer-events: none;
  animation: popFeedback 0.4s ease-out;
}

@keyframes popFeedback {
  0% {
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 0;
  }

  60% {
    transform: translate(-50%, -50%) scale(1.15);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.practice-feedback.hidden {
  display: none;
}

.piano-touch-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 13, 20, 0.9);
  border: 1px solid var(--accent-cyan);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  z-index: 6;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.piano-touch-hint.hidden {
  display: none;
}

/* Landscape-required piano cover (small touch portrait only, page safe) */
.piano-rotate-cover {
  display: none;
}

@media (pointer: coarse) and (max-width: 480px) and (orientation: portrait) {
  .piano-rotate-cover {
    display: flex;
    position: absolute;
    inset: 0;
    background: rgba(4, 6, 10, 0.93);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    z-index: 40;
    padding: 20px;
  }

  body.allow-portrait .piano-rotate-cover {
    display: none;
  }
}

.rotate-cover-card {
  text-align: center;
}

.rotate-phone {
  font-size: 2.6rem;
  animation: rotateHint 1.8s ease-in-out infinite;
}

@keyframes rotateHint {
  0%, 100% {
    transform: rotate(0deg);
  }

  50% {
    transform: rotate(90deg);
  }
}

.rotate-cover-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 8px 0 12px;
  color: var(--text-primary);
}

.cover-anyway {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px;
  font-family: var(--font-main);
}

/* Slim landscape nudge (portrait phones only, never covers content) */
.landscape-nudge {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(99, 102, 241, 0.14);
  border-bottom: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  max-height: 60px;
  text-align: center;
  transition: opacity 0.35s ease, max-height 0.35s ease, padding 0.35s ease;
  overflow: hidden;
}

.landscape-nudge.hidden {
  display: none;
}

@media (max-width: 700px) and (orientation: portrait) {
  .landscape-nudge.visible {
    display: flex;
  }
}

.nudge-dismiss {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 6px;
  flex-shrink: 0;
}

.consent-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(560px, calc(100vw - 32px));
  background: rgba(11, 13, 20, 0.96);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  padding: 12px 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  z-index: 250;
}

.consent-bar.hidden {
  display: none;
}

.consent-bar a {
  color: var(--accent-cyan);
}

.consent-btns {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .app-header {
    overflow-x: auto;
    gap: 8px;
    padding: 0 12px;
    scrollbar-width: none;
  }

  .app-header::-webkit-scrollbar {
    display: none;
  }

  .header-actions {
    flex-shrink: 0;
  }

  .song-player-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 14px 16px;
  }

  .song-controls {
    flex-wrap: wrap;
    gap: 8px;
  }

  .visualizer-overlay-tools {
    top: auto;
    bottom: 8px;
    right: 10px;
  }

  .control-strip {
    gap: 12px;
    padding: 6px 12px;
  }

  /* Icon-only transport buttons: hide text labels */
  .seek-txt,
  #song-play-txt {
    display: none;
  }

  /* Song banner joins performance-fade on mobile (tap outside keys to reveal) */
  body.performing .song-player-banner {
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    border-color: transparent;
    pointer-events: none;
    overflow: hidden;
  }
}

/* PC-only controls hidden on touch devices */
@media (pointer: coarse) {
  #btn-keybinds {
    display: none;
  }
}

/* Interactive Piano Keybed Stage */
.piano-stage-wrapper {
  position: relative;
  background: #080a0f;
  box-shadow: inset 0 10px 20px rgba(0, 0, 0, 0.8), 0 -5px 15px rgba(0, 0, 0, 0.5);
  z-index: 10;
  padding: 0 0 4px 0;
}

.piano-casing {
  position: relative;
  width: 100%;
}

.piano-wood-felt {
  width: 100%;
  height: 8px;
  background: linear-gradient(180deg, #991b1b 0%, #7f1d1d 100%);
  border-bottom: 1px solid #450a0a;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Mobile & Tablet Octave Navigator — positioned absolutely over the top of the piano
   so it doesn't create a gap between the waterfall canvas and the keyboard */
.mobile-octave-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 20;
  background: rgba(11, 13, 20, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 3px 6px;
  transition: opacity 0.2s ease;
}

.mobile-octave-bar:hover {
  background: rgba(11, 13, 20, 0.92);
}

.octave-nav-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.octave-nav-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.octave-pills-row {
  display: flex;
  gap: 2px;
}

.oct-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.oct-pill:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.1);
}

.oct-pill.active {
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.3);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.15);
}

.piano-keys-scroll-area {
  width: 100%;
  overflow: hidden;
  display: flex;
  justify-content: stretch;
}

/* No scrollbar — all 88 keys visible at once, filling 100% width */

.piano-keyboard {
  display: flex;
  position: relative;
  width: 100%;
  margin: 0;
  padding: 0;
  height: var(--white-key-height);
  touch-action: none;
}

/* White & Black Key Styles */
.piano-key {
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 12px;
  will-change: transform;
  transform: translateZ(0);
  transition: transform 0.03s ease;
  user-select: none;
}

.piano-key.white-key {
  flex: 1 1 0;
  /* Never shrink below computed width — the strip scrolls instead of squishing */
  min-width: var(--white-key-width);
  width: auto;
  height: var(--white-key-height);
  background: linear-gradient(180deg, #fdfdfd 0%, #f1f5f9 85%, #e2e8f0 100%);
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  border-top: none;
  border-left: none;
  border-radius: 0 0 5px 5px;
  box-shadow: var(--shadow-key-white);
  z-index: 1;
}

.piano-key.white-key:first-child {
  border-left: 1px solid #cbd5e1;
}

.piano-key.white-key:hover {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 85%, #e2e8f0 100%);
}

.piano-key.white-key.active,
.piano-key.white-key:active {
  transform: translateY(3px) scaleY(0.985) translateZ(0);
  background: linear-gradient(180deg, #e0f2fe 0%, #bae6fd 85%, #7dd3fc 100%);
  box-shadow: var(--shadow-key-white-active);
  border-color: #38bdf8;
}

.piano-key.black-key {
  position: relative;
  flex: 0 0 var(--black-key-width);
  width: var(--black-key-width);
  height: var(--black-key-height);
  background: linear-gradient(180deg, #27272a 0%, #18181b 60%, #09090b 100%);
  border: 1px solid #000000;
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow: var(--shadow-key-black);
  z-index: 2;
  margin-left: calc(var(--black-key-width) / -2);
  margin-right: calc(var(--black-key-width) / -2);
}

.piano-key.black-key::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  height: 70%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, transparent 100%);
  border-radius: 2px;
  pointer-events: none;
}

.piano-key.black-key:hover {
  background: linear-gradient(180deg, #3f3f46 0%, #27272a 60%, #18181b 100%);
}

.piano-key.black-key.active,
.piano-key.black-key:active {
  transform: translateY(2px) scaleY(0.99);
  background: linear-gradient(180deg, #78350f 0%, #451a03 60%, #1c0a00 100%);
  box-shadow: var(--shadow-key-black-active);
  border-color: var(--accent-gold);
}

/* Key Labels */
.key-label {
  font-size: 0.72rem;
  font-weight: 700;
  pointer-events: none;
  transition: opacity 0.15s ease;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
}

.white-key .key-label {
  color: #64748b;
}

.white-key.active .key-label {
  color: #0369a1;
}

.black-key .key-label {
  color: #a1a1aa;
  font-size: 0.65rem;
}

.black-key.active .key-label {
  color: var(--accent-gold);
}

.key-label-sub {
  font-size: 0.6rem;
  color: #94a3b8;
  display: block;
}

/* Scale Highlight Classes */
.piano-key.scale-highlight-root {
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.8), inset 0 0 8px rgba(245, 158, 11, 0.4) !important;
  border-color: var(--accent-gold) !important;
}

.piano-key.scale-highlight-note {
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6), inset 0 0 6px rgba(56, 189, 248, 0.3) !important;
}

.piano-key.practice-target {
  animation: keyTargetPulse 0.8s infinite alternate !important;
}

@keyframes keyTargetPulse {
  0% {
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5), inset 0 0 10px rgba(16, 185, 129, 0.3);
  }

  100% {
    box-shadow: 0 0 22px rgba(16, 185, 129, 0.9), inset 0 0 16px rgba(16, 185, 129, 0.6);
  }
}

/* Bottom Status Footer */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  transition: opacity 0.35s ease, max-height 0.35s ease, padding 0.35s ease;
  flex-shrink: 0;
  background: var(--bg-glass);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-secondary);
  z-index: 20;
  white-space: nowrap;
  box-sizing: border-box;
}

.footer-left,
.footer-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.midi-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.midi-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.midi-led.connected {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.midi-led.disconnected {
  background: var(--text-muted);
}

.keyboard-tip {
  color: var(--text-muted);
}

/* ================= MODALS & OVERLAYS ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.82);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.2s ease;
  padding: 20px;
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-window {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(99, 102, 241, 0.15);
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-compact {
  max-width: 420px;
}

.modal-lg {
  max-width: 860px;
}

@keyframes modalScaleUp {
  from {
    transform: scale(0.94);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.modal-header-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-subtitle {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.btn-modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}

/* Song Library Tab Layout */
.song-library-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--bg-tertiary);
  color: #fff;
  box-shadow: inset 0 0 0 1px var(--border-subtle);
}

.song-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.song-card {
  background: var(--bg-glass-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  transition: all 0.2s ease;
}

.song-card:hover {
  border-color: var(--accent-indigo);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.2);
}

.song-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
}

.song-card-artist {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.song-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.difficulty-tag {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.65rem;
  text-transform: uppercase;
}

.difficulty-tag.easy {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.difficulty-tag.medium {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.difficulty-tag.hard {
  background: rgba(244, 63, 94, 0.2);
  color: #f43f5e;
}

/* Retention: streak, best scores, recent, learn path, practice score */
.streak-gold {
  color: var(--accent-gold) !important;
}

.song-score-display {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-emerald);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.song-score-display.hidden {
  display: none;
}

.vote-btn {
  font-size: 0.85rem;
  padding: 4px 8px;
  line-height: 1;
}

.vote-btn.voted {
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.15);
  box-shadow: 0 0 10px var(--accent-gold-glow);
}

.feedback-footer {
  text-align: center;
  margin-top: 14px;
}

.feedback-footer a {
  font-size: 0.8rem;
  color: var(--accent-cyan);
  text-decoration: none;
}

.feedback-footer a:hover {
  text-decoration: underline;
}

.song-card-best {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
}

.song-card-best .best-done {
  color: var(--accent-emerald);
  font-weight: 700;
}

.recent-row {
  margin-bottom: 14px;
  padding: 12px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-md);
}

.recent-row.hidden {
  display: none;
}

.recent-row-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.recent-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.recent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-chip {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
}

.recent-chip:hover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.15);
}

.learn-step {
  display: flex;
  align-items: center;
  gap: 12px;
}

.learn-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-secondary);
}

.learn-num.done {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}

.learn-num.next {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--accent-indigo);
  color: #fff;
}

/* Drag & Drop MIDI Zone */
.midi-upload-zone {
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.midi-upload-zone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
}

.midi-external-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 2px;
}

.midi-upload-zone svg {
  color: var(--accent-cyan);
}

.hidden-input {
  display: none;
}

/* Comprehensive MIDI Guide Styles */
.midi-guide-container {
  margin-top: 24px;
  padding: 22px;
  background: rgba(18, 22, 34, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.midi-guide-header {
  text-align: left;
}

.guide-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(56, 189, 248, 0.25));
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
  margin-bottom: 8px;
}

.midi-guide-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.midi-guide-header p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.midi-guide-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.midi-step-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-glass-card);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.midi-step-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.3);
}

.step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-cyan));
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(56, 189, 248, 0.3);
}

.step-content h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.step-content p {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.step-content code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.4);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent-cyan);
  font-size: 0.74rem;
}

/* Recommended Free MIDI Sources */
.midi-sources-section {
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
}

.midi-sources-section h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.midi-sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.midi-source-link {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.midi-source-link:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
}

.source-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.midi-source-link div {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.midi-source-link strong {
  font-size: 0.85rem;
  color: var(--text-primary);
}

.midi-source-link span {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.source-arrow {
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: transform 0.15s ease, color 0.15s ease;
}

.midi-source-link:hover .source-arrow {
  transform: translate(2px, -2px);
  color: var(--accent-cyan);
}

/* Developer / Code Guide Collapsible */
.midi-code-guide {
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
}

.midi-code-guide summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-cyan);
  outline: none;
  user-select: none;
  transition: color 0.15s ease;
}

.midi-code-guide summary:hover {
  color: #7dd3fc;
}

.code-guide-body {
  margin-top: 12px;
  padding: 14px;
  background: #080a0f;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.code-guide-body p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.code-guide-body pre {
  background: #040508;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #a5f3fc;
  line-height: 1.45;
  margin-bottom: 8px;
}

.code-guide-tip {
  font-size: 0.74rem !important;
  color: var(--accent-gold) !important;
}

/* Metronome Modal Layout */
.metronome-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.metronome-visual {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.metronome-pendulum {
  width: 60px;
  height: 4px;
  background: var(--accent-indigo);
  border-radius: var(--radius-full);
  transform-origin: center;
  transition: transform 0.1s linear;
}

.beat-indicators {
  display: flex;
  gap: 10px;
}

.beat-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  transition: all 0.1s ease;
}

.beat-dot.active {
  background: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan);
}

.beat-dot.downbeat {
  background: var(--accent-gold);
  box-shadow: 0 0 14px var(--accent-gold);
}

.metronome-bpm-display {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

#metro-bpm-val {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 800;
  color: #ffffff;
}

.metro-sub {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.metronome-slider-box {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.metronome-slider-box .custom-range {
  flex: 1;
}

.metronome-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
}

.btn-block {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
}

.text-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 7px 10px;
  font-family: var(--font-main);
  font-size: 0.85rem;
  outline: none;
  width: 100%;
  max-width: 280px;
  user-select: text;
  -webkit-user-select: text;
}

.text-input:focus {
  border-color: var(--border-focus);
}

/* Settings Modal */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-card {
  background: var(--bg-glass-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.settings-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.card-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.84rem;
}

.form-row:last-child {
  margin-bottom: 0;
}

.keyboard-guide {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
}

.guide-badge {
  background: var(--bg-tertiary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  min-width: 90px;
  text-align: center;
  color: var(--accent-cyan);
}

code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-gold);
}

/* Recording Studio Details */
.record-active-details {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.record-status-text {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.badge {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.badge.recording {
  background: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
}

#record-timer {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}

.record-actions-row {
  display: flex;
  gap: 10px;
}

.section-subheading {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.saved-tracks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.saved-track-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-glass-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.track-info {
  display: flex;
  flex-direction: column;
}

.track-title {
  font-size: 0.88rem;
  font-weight: 600;
}

.track-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.track-actions {
  display: flex;
  gap: 8px;
}

.empty-hint {
  font-size: 0.84rem;
  color: var(--text-muted);
  text-align: center;
  padding: 24px 0;
}

/* ================= KEYBIND STUDIO & PROFILES STYLES ================= */
.keybind-profile-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-tertiary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 12px;
}

.profile-select-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: rgba(245, 158, 11, 0.07);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin: 0 0 12px;
  line-height: 1.5;
}

.profile-desc:empty {
  display: none;
}

.profile-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.profile-select {
  min-width: 220px;
}

.badge-preset {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-indigo);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-custom {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.profile-actions-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 4px;
}

.btn-danger-hover:hover {
  background: rgba(244, 63, 94, 0.25) !important;
  color: var(--accent-rose) !important;
  border-color: rgba(244, 63, 94, 0.4) !important;
}

.keybind-sub-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.octave-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.keybind-helper-hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.keybind-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
}

.keybind-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: all 0.2s ease;
}

.keybind-card:hover {
  border-color: var(--border-focus);
}

.keybind-card.white-card {
  border-left: 4px solid #cbd5e1;
}

.keybind-card.black-card {
  border-left: 4px solid #38bdf8;
  background: rgba(18, 22, 34, 0.95);
}

.keybind-card.listening {
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 16px var(--accent-cyan-glow);
  animation: listenPulse 1s infinite alternate;
}

@keyframes listenPulse {
  0% {
    transform: scale(0.98);
    border-color: var(--accent-cyan);
  }

  100% {
    transform: scale(1.02);
    border-color: #ffffff;
  }
}

.keybind-note-info {
  display: flex;
  flex-direction: column;
}

.keybind-note-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  font-family: var(--font-mono);
}

.keybind-note-type {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.keybind-action-zone {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-audition-key {
  padding: 3px 6px;
  font-size: 0.72rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 1;
}

.keybind-badge {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  min-width: 44px;
  text-align: center;
}

.keybind-badge.assigned {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.keybind-badge.unassigned {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.listening-pulse {
  color: var(--accent-gold);
  font-size: 0.72rem;
  animation: pulseGold 0.8s infinite alternate;
}

@keyframes pulseGold {
  0% {
    opacity: 0.6;
  }

  100% {
    opacity: 1;
  }
}

.btn-clear-bind {
  padding: 4px 6px;
  font-size: 0.75rem;
}

/* Piano Click-to-Bind Capture Mode */
.piano-bind-toast {
  position: fixed;
  bottom: 260px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(11, 13, 20, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--accent-cyan);
  box-shadow: 0 0 24px var(--accent-cyan-glow), 0 8px 24px rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-full);
  padding: 8px 10px 8px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  z-index: 200;
  white-space: nowrap;
  animation: modalScaleUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.piano-bind-toast.hidden {
  display: none;
}

.piano-key.bind-capture-target {
  animation: bindTargetPulse 0.7s infinite alternate !important;
  border-color: var(--accent-cyan) !important;
}

@keyframes bindTargetPulse {
  0% {
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.5), inset 0 0 8px rgba(56, 189, 248, 0.3);
  }

  100% {
    box-shadow: 0 0 22px rgba(56, 189, 248, 0.95), inset 0 0 14px rgba(56, 189, 248, 0.6);
  }
}

/* ================= RESPONSIVE DESIGN ================= */
@media (max-width: 900px) {
  :root {
    --white-key-width: 40px;
    --white-key-height: 180px;
    --black-key-width: 24px;
    --black-key-height: 115px;
  }

  .app-header {
    padding: 8px 14px;
  }

  .brand-text h1 {
    font-size: 1.1rem;
  }

  .control-strip {
    padding: 6px 14px;
  }

  .audio-knobs {
    display: none;
  }

  .keyboard-tip {
    display: none;
  }
}

@media (max-width: 640px) {
  :root {
    --white-key-width: 34px;
    --white-key-height: 160px;
    --black-key-width: 20px;
    --black-key-height: 100px;
  }

  .brand-subtitle {
    display: none;
  }

  .realtime-status-pill {
    display: none;
  }

  .waterfall-status-pill {
    top: 8px;
    left: 10px;
    padding: 0 10px;
    height: 28px;
    max-height: 28px;
    gap: 8px;
  }

  .waterfall-status-pill .status-value {
    font-size: 0.8rem;
    max-width: 110px;
    min-width: 30px;
  }

  .waterfall-status-pill .status-value#chord-display {
    min-width: 40px;
  }

  .visualizer-overlay-tools .btn-tool {
    padding: 3px 6px;
    font-size: 0.68rem;
  }

  .btn span {
    display: none;
  }

  .btn-primary span,
  .btn-sustain span {
    display: inline;
  }
}