/* ==========================================================================
   MAJESTICTAB — MODERN THEME ENGINE & UI STYLES
   Guitar Finish Themes (Mystic Dream default) ported from concerts
   ========================================================================== */

/* --------------------------------------------------------------------------
   Guitar Finish Palettes
   -------------------------------------------------------------------------- */
:root, [data-theme="Mystic Dream"] {
  --bg-body: #06050a;
  --bg-ambient-1: rgba(147, 51, 234, 0.25);
  --bg-ambient-2: rgba(16, 185, 129, 0.22);
  --bg-card: rgba(18, 14, 28, 0.88);
  --bg-card-solid: #151022;
  --bg-card-hover: #231838;
  --bg-elevated: #0f0b1a;
  --bg-modal: #0a0714;
  --border-subtle: rgba(147, 51, 234, 0.28);
  --border-prominent: rgba(16, 185, 129, 0.45);
  --text-primary: #f8fafc;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;
  --accent-primary: #a855f7;
  --accent-secondary: #10b981;
  --accent-gradient: linear-gradient(135deg, #9333ea 0%, #06b6d4 50%, #10b981 100%);
  --accent-gradient-hover: linear-gradient(135deg, #a855f7 0%, #0891b2 50%, #059669 100%);
  --accent-glow: rgba(16, 185, 129, 0.28);
  --accent-primary-alpha: rgba(147, 51, 234, 0.16);
  --accent-border-alpha: rgba(16, 185, 129, 0.45);
  --accent-text: #a7f3d0;
  
  /* Sheet Music Specific Tokens (Default: Clean & Crisp) */
  --sheet-bg: #ffffff;
  --sheet-text: #111827;
  --sheet-border: #e2e8f0;
  --sheet-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

[data-theme="Blue Pearl"] {
  --bg-body: #060d1f;
  --bg-ambient-1: rgba(37, 99, 235, 0.16);
  --bg-ambient-2: rgba(56, 189, 248, 0.1);
  --bg-card: rgba(12, 25, 54, 0.85);
  --bg-card-solid: #0d1e40;
  --bg-card-hover: #173264;
  --bg-elevated: #081229;
  --bg-modal: #071026;
  --border-subtle: rgba(56, 189, 248, 0.2);
  --border-prominent: rgba(59, 130, 246, 0.45);
  --text-primary: #f0f7ff;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;
  --accent-primary: #2563eb;
  --accent-secondary: #38bdf8;
  --accent-gradient: linear-gradient(135deg, #1d4ed8, #38bdf8);
  --accent-gradient-hover: linear-gradient(135deg, #1e40af, #0284c7);
  --accent-glow: rgba(56, 189, 248, 0.32);
  --accent-primary-alpha: rgba(37, 99, 235, 0.16);
  --accent-border-alpha: rgba(56, 189, 248, 0.45);
  --accent-text: #93c5fd;
  --sheet-bg: #ffffff;
  --sheet-text: #111827;
  --sheet-border: #e2e8f0;
  --sheet-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

[data-theme="Cerulean Paradise"] {
  --bg-body: #03141a;
  --bg-ambient-1: rgba(6, 182, 212, 0.16);
  --bg-ambient-2: rgba(2, 132, 199, 0.11);
  --bg-card: rgba(8, 38, 51, 0.85);
  --bg-card-solid: #0b3142;
  --bg-card-hover: #134e66;
  --bg-elevated: #051c24;
  --bg-modal: #04171f;
  --border-subtle: rgba(6, 182, 212, 0.2);
  --border-prominent: rgba(34, 211, 238, 0.45);
  --text-primary: #ecfeff;
  --text-muted: #cffafe;
  --text-dim: #94a3b8;
  --accent-primary: #06b6d4;
  --accent-secondary: #0284c7;
  --accent-gradient: linear-gradient(135deg, #06b6d4, #0284c7);
  --accent-gradient-hover: linear-gradient(135deg, #0891b2, #0369a1);
  --accent-glow: rgba(6, 182, 212, 0.32);
  --accent-primary-alpha: rgba(6, 182, 212, 0.15);
  --accent-border-alpha: rgba(34, 211, 238, 0.45);
  --accent-text: #67e8f9;
  --sheet-bg: #ffffff;
  --sheet-text: #111827;
  --sheet-border: #e2e8f0;
  --sheet-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

[data-theme="Dark Side"] {
  --bg-body: #000000;
  --bg-ambient-1: rgba(212, 212, 216, 0.05);
  --bg-ambient-2: rgba(39, 39, 42, 0.35);
  --bg-card: rgba(18, 18, 18, 0.92);
  --bg-card-solid: #141414;
  --bg-card-hover: #242424;
  --bg-elevated: #0a0a0a;
  --bg-modal: #050505;
  --border-subtle: rgba(212, 212, 216, 0.15);
  --border-prominent: rgba(161, 161, 170, 0.4);
  --text-primary: #f4f4f5;
  --text-muted: #e4e4e7;
  --text-dim: #a1a1aa;
  --accent-primary: #a1a1aa;
  --accent-secondary: #71717a;
  --accent-gradient: linear-gradient(135deg, #a1a1aa, #52525b);
  --accent-gradient-hover: linear-gradient(135deg, #8e8e93, #3f3f46);
  --accent-glow: rgba(161, 161, 170, 0.22);
  --accent-primary-alpha: rgba(161, 161, 170, 0.14);
  --accent-border-alpha: rgba(161, 161, 170, 0.4);
  --accent-text: #e4e4e7;
  --sheet-bg: #ffffff;
  --sheet-text: #111827;
  --sheet-border: #e2e8f0;
  --sheet-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

[data-theme="Ember Glow"] {
  --bg-body: #120804;
  --bg-ambient-1: rgba(249, 115, 22, 0.18);
  --bg-ambient-2: rgba(239, 68, 68, 0.12);
  --bg-card: rgba(36, 17, 10, 0.88);
  --bg-card-solid: #26120b;
  --bg-card-hover: #421e12;
  --bg-elevated: #1a0b06;
  --bg-modal: #150804;
  --border-subtle: rgba(249, 115, 22, 0.2);
  --border-prominent: rgba(251, 146, 60, 0.45);
  --text-primary: #fff7ed;
  --text-muted: #fed7aa;
  --text-dim: #cbd5e1;
  --accent-primary: #f97316;
  --accent-secondary: #ef4444;
  --accent-gradient: linear-gradient(135deg, #f97316, #ef4444);
  --accent-gradient-hover: linear-gradient(135deg, #ea580c, #dc2626);
  --accent-glow: rgba(249, 115, 22, 0.32);
  --accent-primary-alpha: rgba(249, 115, 22, 0.16);
  --accent-border-alpha: rgba(251, 146, 60, 0.45);
  --accent-text: #fdba74;
  --sheet-bg: #ffffff;
  --sheet-text: #111827;
  --sheet-border: #e2e8f0;
  --sheet-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

[data-theme="Purple Nebula"] {
  --bg-body: #0e0616;
  --bg-ambient-1: rgba(192, 38, 211, 0.18);
  --bg-ambient-2: rgba(124, 58, 237, 0.14);
  --bg-card: rgba(30, 13, 44, 0.88);
  --bg-card-solid: #210d32;
  --bg-card-hover: #3a1656;
  --bg-elevated: #150821;
  --bg-modal: #11061b;
  --border-subtle: rgba(192, 38, 211, 0.2);
  --border-prominent: rgba(217, 70, 239, 0.45);
  --text-primary: #fdf4ff;
  --text-muted: #f5d0fe;
  --text-dim: #cbd5e1;
  --accent-primary: #c026d3;
  --accent-secondary: #7c3aed;
  --accent-gradient: linear-gradient(135deg, #c026d3, #7c3aed);
  --accent-gradient-hover: linear-gradient(135deg, #a21caf, #6d28d9);
  --accent-glow: rgba(192, 38, 211, 0.32);
  --accent-primary-alpha: rgba(192, 38, 211, 0.16);
  --accent-border-alpha: rgba(217, 70, 239, 0.45);
  --accent-text: #f0abfc;
  --sheet-bg: #ffffff;
  --sheet-text: #111827;
  --sheet-border: #e2e8f0;
  --sheet-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

[data-theme="Red Nebula"] {
  --bg-body: #100508;
  --bg-ambient-1: rgba(225, 29, 72, 0.16);
  --bg-ambient-2: rgba(71, 85, 105, 0.28);
  --bg-card: rgba(28, 12, 17, 0.88);
  --bg-card-solid: #1e0d13;
  --bg-card-hover: #321620;
  --bg-elevated: #16070b;
  --bg-modal: #110407;
  --border-subtle: rgba(225, 29, 72, 0.2);
  --border-prominent: rgba(225, 29, 72, 0.45);
  --text-primary: #fdf2f4;
  --text-muted: #fecdd3;
  --text-dim: #cbd5e1;
  --accent-primary: #e11d48;
  --accent-secondary: #475569;
  --accent-gradient: linear-gradient(135deg, #e11d48, #475569);
  --accent-gradient-hover: linear-gradient(135deg, #be123c, #334155);
  --accent-glow: rgba(225, 29, 72, 0.32);
  --accent-primary-alpha: rgba(225, 29, 72, 0.16);
  --accent-border-alpha: rgba(225, 29, 72, 0.45);
  --accent-text: #fda4af;
  --sheet-bg: #ffffff;
  --sheet-text: #111827;
  --sheet-border: #e2e8f0;
  --sheet-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

[data-theme="Red Pearl Burst"] {
  --bg-body: #130507;
  --bg-ambient-1: rgba(225, 29, 72, 0.18);
  --bg-ambient-2: rgba(153, 27, 27, 0.14);
  --bg-card: rgba(38, 12, 18, 0.88);
  --bg-card-solid: #280b12;
  --bg-card-hover: #481421;
  --bg-elevated: #1a060c;
  --bg-modal: #150509;
  --border-subtle: rgba(244, 63, 94, 0.2);
  --border-prominent: rgba(251, 113, 133, 0.45);
  --text-primary: #fff1f2;
  --text-muted: #ffe4e6;
  --text-dim: #cbd5e1;
  --accent-primary: #e11d48;
  --accent-secondary: #991b1b;
  --accent-gradient: linear-gradient(135deg, #e11d48, #991b1b);
  --accent-gradient-hover: linear-gradient(135deg, #be123c, #7f1d1d);
  --accent-glow: rgba(225, 29, 72, 0.32);
  --accent-primary-alpha: rgba(225, 29, 72, 0.16);
  --accent-border-alpha: rgba(251, 113, 133, 0.45);
  --accent-text: #fda4af;
  --sheet-bg: #ffffff;
  --sheet-text: #111827;
  --sheet-border: #e2e8f0;
  --sheet-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

/* Global Text Contrast Overrides */
.text-muted,
.text-white-50 {
  color: var(--text-muted) !important;
}

/* --------------------------------------------------------------------------
   Document & Base Layout
   -------------------------------------------------------------------------- */
html {
  min-height: 100%;
  background-color: var(--bg-body);
}

body {
  -webkit-user-select: none;
  user-select: none;
}

/* Keep selection working in editable fields and the extension code editor. */
input,
textarea,
[contenteditable="true"],
.CodeMirror,
.CodeMirror * {
  -webkit-user-select: text;
  user-select: text;
}

body {
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-body) !important;
  background-image: 
    radial-gradient(circle at 15% 10%, var(--bg-ambient-1) 0%, transparent 45%),
    radial-gradient(circle at 85% 15%, var(--bg-ambient-2) 0%, transparent 45%),
    radial-gradient(circle at 50% 85%, var(--bg-ambient-1) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, var(--bg-body) 0%, #030205 100%);
  background-attachment: fixed;
  color: var(--text-primary) !important;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* --------------------------------------------------------------------------
   Minimalist Glass Top Bar (Floating HUD)
   -------------------------------------------------------------------------- */
#topBar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-card) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.5), inset 0 1px 0 0 rgba(255, 255, 255, 0.06);
  flex-wrap: nowrap;
  gap: 0.75rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  cursor: grab;
}

.tauri-macos #topBar {
  padding-left: 84px;
  min-height: 50px;
}

/* Themed scrollbars; scrollbar-color inherits to all scroll containers. */
:root {
  scrollbar-color: color-mix(in srgb, var(--accent-primary) 55%, transparent) transparent;
  scrollbar-width: thin;
}

#winControls {
  display: none;
}

.tauri-windows #winControls {
  display: flex;
  position: fixed;
  top: 0;
  right: 0;
  height: 50px;
  z-index: 1001;
}

.tauri-windows #topBar {
  padding-right: 148px;
  min-height: 50px;
}

.win-ctrl-btn {
  width: 46px;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.win-ctrl-btn:hover {
  color: var(--accent-text);
  background: var(--bg-card-hover);
}

.win-ctrl-btn.win-ctrl-close:hover {
  color: #fff;
  background: #e81123;
}

.tauri-windows .offcanvas {
  top: 50px;
}

#topBar::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

#topBar.is-dragging {
  cursor: grabbing;
  user-select: none;
}

#brandSection {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 0 0 auto;
  min-width: max-content;
  overflow: visible;
  justify-content: flex-start;
}

.brand-btn {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 0.75rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
  flex-shrink: 0;
}

.brand-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 0 12px -2px var(--accent-glow);
}

.menu-toggle-btn {
  border-radius: 9999px;
  width: 35px;
  height: 35px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.menu-toggle-btn i {
  font-size: 1.15rem;
  line-height: 1;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff !important;
  display: inline-flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-title .brand-title-accent {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}


#centerSection {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex: 0 0 auto;
  justify-self: center;
}

/* Glass Pill Button Groups */
.hud-pill-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 2px;
  gap: 2px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}

.hud-pill-group .btn-check + .btn {
  border-radius: 9999px !important;
  border: none !important;
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hud-pill-group .btn-check:checked + .btn {
  background: var(--accent-gradient) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.hud-pill-group .btn:hover:not(:disabled) {
  color: #ffffff;
}

/* Keep top bar controls from showing lingering focus rings while using the score */
#topBar .btn:focus,
#topBar .btn:focus-visible,
#topBar .brand-btn:focus,
#topBar .brand-btn:focus-visible,
#topBar .btn-check:focus + .btn,
#topBar .btn-check:focus-visible + .btn {
  outline: none;
  box-shadow: none;
}

#topBar .hud-pill-group .btn-check:checked:focus + .btn,
#topBar .hud-pill-group .btn-check:checked:focus-visible + .btn {
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* Right Section Controls */
#rightSection {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex: 0 0 auto;
  min-width: max-content;
}

/* Consolidated Playback Controls & Audio Source Selector Pill */
#globalAudioControls,
#audioSourcePill,
#synthMiniPill,
#ytMiniPill {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 2px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}

#globalAudioControls .btn,
#audioSourcePill .btn,
#fullscreenPill .btn,
#synthMiniPill .btn,
#ytMiniPill .btn {
  border: none !important;
  background: transparent;
  color: var(--text-muted);
  border-radius: 9999px;
  padding: 0.3rem 0.55rem;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

#globalAudioControls .btn:hover:not(:disabled),
#fullscreenPill .btn:hover:not(:disabled) {
  color: var(--accent-text);
  background: var(--bg-card-hover);
}

#synthToggleBtn:hover:not(:disabled) {
  color: #10b981;
  background: rgba(16, 185, 129, 0.15);
}

#ytToggleBtn:hover:not(:disabled) {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

#globalAudioControls .btn:disabled,
#audioSourcePill .btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#synthToggleBtn.active,
#synthToggleBtn.active-audio-mode {
  color: #10b981 !important;
  background: rgba(16, 185, 129, 0.22) !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.45) !important;
}

#ytToggleBtn.active,
#ytToggleBtn.active-audio-mode {
  color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.22) !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.45) !important;
}

/* Theme Swatch Button in Top Bar */
.theme-swatch-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 9999px;
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.theme-swatch-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px -2px var(--accent-glow);
  transform: translateY(-1px);
}

.theme-swatch-icon {
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
  flex-shrink: 0;
}

/* Navigation Buttons & Page Indicator */
#navButtons {
  display: none;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 2px 6px;
  min-height: 35px;
  box-sizing: border-box;
}

#navButtons .btn {
  border: none !important;
  background: transparent;
  color: var(--text-primary);
  border-radius: 9999px;
  padding: 0.25rem 0.45rem;
  font-size: 0.8rem;
}

#navButtons .btn:hover:not(:disabled) {
  background: var(--accent-primary-alpha);
  color: #ffffff;
}

#pageIndicator {
  font-size: 0.75rem;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-muted);
  padding: 0 0.4rem;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Floating Dropdown Panels (Synth & YouTube)
   -------------------------------------------------------------------------- */
.synth-panel, .yt-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 1.5rem;
  width: 370px;
  max-width: calc(100vw - 2rem);
  background: var(--bg-card) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.7), 0 0 16px -2px var(--accent-glow);
  z-index: 1050;
  overflow: hidden;
  animation: panelSlideDown 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-primary);
}

@keyframes panelSlideDown {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.yt-panel {
  animation-name: ytPanelSlideDown;
}

@keyframes ytPanelSlideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.synth-panel-header, .yt-panel-header {
  background: var(--bg-card-solid);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.synth-panel-title, .yt-panel-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.synth-panel-body, .yt-panel-body {
  padding: 1rem;
}

.synth-panel .form-control {
  background: var(--bg-card);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.synth-panel .form-control:focus {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  color: var(--text-primary);
  box-shadow: 0 0 0 0.2rem var(--accent-primary-alpha);
}

/* Range Inputs / Sliders */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  outline: none;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform 0.15s ease;
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* Speed Button Group */
#synthSpeedButtons .btn {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

#synthSpeedButtons .btn:hover {
  background: var(--bg-card-hover);
  color: #ffffff;
}

#synthSpeedButtons .btn.active {
  background: var(--accent-gradient) !important;
  border-color: transparent !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px var(--accent-glow);
}

/* YouTube Wrapper and Themed Elements */
.yt-header-badge {
  width: 26px;
  height: 26px;
  border-radius: 0.5rem;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #ef4444;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.yt-mode-selector {
  display: flex;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 0.65rem;
  padding: 3px;
  gap: 3px;
}

.yt-mode-btn {
  flex: 1;
  text-align: center;
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.yt-mode-btn:hover {
  color: #ffffff;
  background: var(--bg-card-hover);
}

.btn-check:checked + .yt-mode-btn {
  background: var(--accent-gradient) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px var(--accent-glow);
  font-weight: 700;
}

.yt-iframe-wrapper {
  background: #000000;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  position: relative;
}

.yt-state-card {
  position: absolute;
  inset: 0;
  background: var(--bg-card-solid);
  z-index: 2;
}

.yt-prompt-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

.yt-search-group .form-control {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.78rem;
}

.yt-search-group .form-control:focus {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 0 0 0.15rem var(--accent-primary-alpha);
}

.yt-search-group .form-control::placeholder {
  color: var(--text-dim);
  opacity: 0.75;
}

.yt-search-group .yt-play-btn {
  background: var(--accent-gradient);
  border: 1px solid transparent;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
  transition: all 0.2s ease;
}

.yt-search-group .yt-play-btn:hover {
  background: var(--accent-gradient-hover);
  box-shadow: 0 0 10px var(--accent-glow);
  color: #ffffff;
}

.yt-search-group .yt-ext-btn {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 0.35rem 0.65rem;
  transition: all 0.2s ease;
}

.yt-search-group .yt-ext-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Theme Chooser Modal & Interactive Finish Cards
   -------------------------------------------------------------------------- */
.theme-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.theme-modal-card {
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  background: var(--bg-modal) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 1.25rem;
  box-shadow: 0 24px 48px -8px rgba(0, 0, 0, 0.8), 0 0 24px -4px var(--accent-glow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleUp {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.theme-modal-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg-card-solid);
  min-width: 0;
}

.theme-modal-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}

.theme-modal-icon {
  flex-shrink: 0;
}

.theme-modal-titles {
  min-width: 0;
  flex: 1;
}

.theme-modal-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.theme-modal-close-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.theme-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.85rem;
}

.theme-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 0.85rem;
  padding: 0.85rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  transition: all 0.2s ease;
  position: relative;
}

.theme-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.5), 0 0 12px -2px var(--accent-glow);
}

.theme-card.active {
  border-color: var(--accent-primary) !important;
  background: var(--accent-primary-alpha) !important;
  box-shadow: 0 0 18px -2px var(--accent-glow), inset 0 0 0 1px var(--accent-primary);
}

.theme-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.theme-card-identity {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.theme-card-swatch {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.theme-card-text {
  min-width: 0;
}

.theme-card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-card-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-active-pill {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent-primary-alpha);
  border: 1px solid var(--accent-border-alpha);
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  flex-shrink: 0;
}

.theme-select-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.2s ease;
  font-weight: 600;
}

.theme-card:hover .theme-select-hint {
  opacity: 1;
  color: var(--accent-primary);
}

.theme-card-gradient-bar {
  height: 6px;
  width: 100%;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.theme-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.5rem;
}

.theme-palette-label {
  font-size: 0.65rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.theme-palette-chips {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.theme-colorway-chip {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Google Drive In-App File Browser
   -------------------------------------------------------------------------- */
.drive-modal-card {
  max-width: 640px;
}

.drive-modal-toolbar {
  background: var(--bg-card-solid);
  border-bottom: 1px solid var(--border-subtle);
}

.drive-breadcrumbs {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.drive-breadcrumb-item {
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  transition: background 0.15s ease, color 0.15s ease;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
}

.drive-breadcrumb-item:hover {
  color: #ffffff;
  background: var(--bg-card-hover);
}

.drive-breadcrumb-item.active {
  color: var(--accent-text);
  font-weight: 600;
  cursor: default;
}

.drive-breadcrumb-item.active:hover {
  background: transparent;
}

.drive-file-list-container {
  overflow-y: auto;
  max-height: 55vh;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.drive-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-radius: 0.65rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.15s ease;
  color: #ffffff;
  text-decoration: none;
}

.drive-file-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

.drive-file-item-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}

.drive-file-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-card-solid);
}

.drive-file-name {
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drive-file-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
  text-align: right;
  margin-left: 0.5rem;
}

/* --------------------------------------------------------------------------
   Modernized Offcanvas Settings Drawer
   -------------------------------------------------------------------------- */
.offcanvas {
  background: var(--bg-modal) !important;
  color: var(--text-primary) !important;
  border-right: 1px solid var(--border-subtle) !important;
  box-shadow: 12px 0 36px rgba(0, 0, 0, 0.85);
  width: 380px !important;
  max-width: 90vw !important;
}

.tauri-macos .offcanvas {
  top: 50px;
}

/* Clip the shadow's upward bleed onto the top bar */
.tauri-macos .offcanvas,
.tauri-windows .offcanvas {
  clip-path: inset(0 -60px 0 0);
}

.tauri-macos .offcanvas-backdrop,
.tauri-windows .offcanvas-backdrop {
  top: 50px;
  height: calc(100% - 50px);
}

.offcanvas-header {
  border-bottom: 1px solid var(--border-subtle);
  padding: 1rem 1.25rem;
  background: var(--bg-card-solid);
}

.offcanvas-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: #ffffff !important;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.offcanvas-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.settings-card {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.settings-header-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

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

.theme-control-btn {
  background: var(--bg-card-hover);
  border: 1px solid var(--accent-border-alpha);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-weight: 600;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.theme-control-btn:hover:not(:disabled) {
  background: var(--accent-gradient);
  border-color: var(--accent-border-alpha);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.theme-control-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 0.2rem var(--accent-primary-alpha);
}

.theme-control-btn:disabled {
  opacity: 0.5;
}

.theme-value-badge,
.settings-beta-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--accent-text);
  font-weight: 700;
  white-space: nowrap;
}

.theme-value-badge {
  min-width: 44px;
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
  text-align: center;
}

.settings-beta-badge {
  margin-left: 0.25rem;
  padding: 0.1rem 0.35rem;
  font-size: 0.65rem;
}

.settings-progress {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.settings-progress-bar {
  background: var(--accent-gradient);
}

.offcanvas .form-control {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: #ffffff;
  border-radius: 0.5rem;
  font-size: 0.82rem;
  padding: 0.4rem 0.65rem;
}

.offcanvas .form-control:focus {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 0 0 0.2rem var(--accent-primary-alpha);
}

.extension-modal-card {
  max-width: 900px;
}

.extension-modal-body {
  height: min(72vh, 680px);
  min-height: 0;
}

.extension-modal-body .form-control {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: #ffffff;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  padding: 0.75rem;
}

.extension-modal-body .form-control:focus {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 0 0 0.2rem var(--accent-primary-alpha);
}

.extension-list-view {
  gap: 0.75rem;
}

.extension-list-toolbar,
.extension-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.extension-list-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.extension-list {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 0.55rem;
  overflow-y: auto;
  padding: 0.15rem;
}

.extension-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  background: var(--bg-card-solid);
}

.extension-item-details {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.2rem;
}

.extension-item-name {
  overflow: hidden;
  color: var(--text-primary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.extension-item-state {
  color: var(--text-muted);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

.extension-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.extension-toggle {
  margin: 0;
}

.extension-delete-button:hover {
  border-color: #ef4444;
  color: #fca5a5;
}

.extension-empty-state {
  display: grid;
  flex: 1;
  min-height: 10rem;
  place-items: center;
  border: 1px dashed var(--border-subtle);
  border-radius: 0.5rem;
  color: var(--text-muted);
}

.extension-editor-view {
  gap: 0.7rem;
}

.extension-name {
  width: 100%;
}

.extension-code-field {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.CodeMirror {
  min-height: 16rem;
  height: 100%;
  flex: 1;
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  background: var(--bg-card) !important;
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.55;
}

.CodeMirror-focused {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 0.2rem var(--accent-primary-alpha);
}

.CodeMirror-gutters {
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-card-solid);
}

.CodeMirror-linenumber {
  color: var(--text-dim);
}

.CodeMirror-cursor {
  border-left-color: var(--text-primary);
}

.CodeMirror-selected {
  background: var(--accent-primary-alpha) !important;
}

.cm-keyword,
.cm-operator {
  color: var(--accent-text) !important;
}

.cm-def,
.cm-variable-2,
.cm-builtin {
  color: #7dd3fc !important;
}

.cm-string,
.cm-string-2 {
  color: #86efac !important;
}

.cm-number,
.cm-atom {
  color: #fdba74 !important;
}

.cm-comment {
  color: var(--text-dim) !important;
}

.cm-property {
  color: #f0abfc !important;
}

.CodeMirror-placeholder {
  color: var(--text-muted) !important;
  opacity: 0.8;
}

.extension-source {
  flex: 1;
  min-height: 16rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important;
  white-space: pre;
  tab-size: 2;
}

.extension-source::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

@media (max-width: 575.98px) {
  .extension-modal-body {
    height: min(76vh, 680px);
    padding: 1rem;
  }

  .extension-item {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.65rem;
  }

  .extension-item-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .extension-list-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .extension-list-actions {
    width: 100%;
  }

  .extension-list-actions button {
    flex: 1;
  }

  .extension-code-field .CodeMirror {
    min-height: 12rem;
  }
}

.offcanvas input[type="file"]::file-selector-button,
.offcanvas input[type="file"]::-webkit-file-upload-button {
  margin: -0.4rem 0.65rem -0.4rem -0.65rem;
  padding: 0.4rem 0.65rem;
  background: var(--bg-card-hover);
  border: 1px solid var(--accent-border-alpha);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-weight: 600;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.offcanvas input[type="file"]:hover::file-selector-button,
.offcanvas input[type="file"]:hover::-webkit-file-upload-button {
  background: var(--accent-gradient);
  border-color: var(--accent-border-alpha);
  border-radius: 0.5rem;
  color: #ffffff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.offcanvas .btn-outline-primary {
  border-color: var(--accent-border-alpha);
  color: #ffffff;
  background: var(--bg-card-hover);
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.45rem 0.75rem;
  transition: all 0.2s ease;
}

.offcanvas .btn-outline-primary:hover {
  background: var(--accent-gradient);
  border-color: var(--accent-border-alpha);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.offcanvas .form-check-input {
  background-color: var(--bg-card);
  border-color: var(--border-subtle);
}

.offcanvas .form-check-input:checked {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-glow);
}

.synth-panel .theme-switch {
  background-color: var(--bg-elevated);
  border-color: var(--border-subtle);
  cursor: pointer;
}

.form-switch .form-check-input:not(:checked) {
  background-image: radial-gradient(circle, var(--text-muted) 60%, transparent 62%);
  background-size: 1em 1em;
}

.synth-panel .theme-switch:checked {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-glow);
}

.synth-panel .theme-switch:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 0.2rem var(--accent-primary-alpha);
}

.offcanvas .form-range {
  accent-color: var(--accent-primary);
  background: transparent;
  cursor: pointer;
}

.offcanvas .form-range::-webkit-slider-runnable-track {
  height: 0.38rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.offcanvas .form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 2px var(--accent-primary-alpha);
  margin-top: -0.32rem;
}

.offcanvas .form-range::-moz-range-track {
  height: 0.38rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.offcanvas .form-range::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 2px var(--accent-primary-alpha);
}

.gp-scale-slider {
  min-width: 0;
}

.offcanvas .gp-scale-slider .form-range::-webkit-slider-runnable-track {
  background-image:
    linear-gradient(var(--text-muted), var(--text-muted)),
    linear-gradient(var(--text-muted), var(--text-muted)),
    linear-gradient(var(--text-muted), var(--text-muted)),
    linear-gradient(var(--text-muted), var(--text-muted)),
    linear-gradient(var(--text-muted), var(--text-muted));
  background-position:
    calc(0% + 0.5rem) 50%,
    calc(25% + 0.25rem) 50%,
    50% 50%,
    calc(75% - 0.25rem) 50%,
    calc(100% - 0.5rem) 50%;
  background-repeat: no-repeat;
  background-size: 1px 60%;
}

.offcanvas .gp-scale-slider .form-range::-moz-range-track {
  background-image:
    linear-gradient(var(--text-muted), var(--text-muted)),
    linear-gradient(var(--text-muted), var(--text-muted)),
    linear-gradient(var(--text-muted), var(--text-muted)),
    linear-gradient(var(--text-muted), var(--text-muted)),
    linear-gradient(var(--text-muted), var(--text-muted));
  background-position:
    calc(0% + 0.5rem) 50%,
    calc(25% + 0.25rem) 50%,
    50% 50%,
    calc(75% - 0.25rem) 50%,
    calc(100% - 0.5rem) 50%;
  background-repeat: no-repeat;
  background-size: 1px 60%;
}

/* --------------------------------------------------------------------------
   Sheet Music Canvas & Page Layout
   Default: Clean & Crisp Standard Notation
   Opt-In: .theme-sheet-active
   -------------------------------------------------------------------------- */
#mainContent {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  min-height: 0;
  isolation: isolate;
  width: 100%;
}

#output {
  transform-origin: 0 0;
  will-change: transform;
  position: relative;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}

#output.continuous-mode {
  overflow-y: auto;
  align-items: center;
  scroll-behavior: auto !important;
}

/* Outer & Page Containers */
.outer-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.pageContainer {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  padding: 20px;
  min-height: 100%;
  box-sizing: border-box;
  overflow: hidden;
  width: 100%;
  height: 100%;
}

.gp-page-container {
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 10px;
  padding: 10px;
  box-sizing: border-box;
  overflow: hidden;
}

/* Default Standard Sheet Page (Clean Crisp Paper) */
.pageWrapper, .gp-page-wrapper, .alphaTabContainer {
  background-color: var(--sheet-bg);
  color: var(--sheet-text);
  border: 1px solid var(--sheet-border);
  box-shadow: var(--sheet-shadow);
  border-radius: 6px;
  position: relative;
  box-sizing: border-box;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.pageWrapper {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  max-width: 95%;
  overflow: hidden;
}

.pageWrapper > div {
  margin: 0;
  padding: 20px;
  width: 100%;
  flex: 1;
  box-sizing: border-box;
  font-size: calc(14px * var(--text-scale, 1));
  font-family: monospace;
  line-height: 1.5;
}

.gp-page-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  margin-left: auto;
  margin-right: auto;
  user-select: none;
  font-family: alphaTab, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.alphaTabContainer {
  width: 100%;
  min-height: 100%;
  margin: 0 auto;
  overflow: visible;
  flex-shrink: 0;
}

.alphaTab-gp-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex: 1;
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  font-family: alphaTab, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

canvas {
  display: block;
  margin: 0 auto;
  background: white;
  max-width: 100%;
  height: auto;
}

.pageNumber {
  position: absolute;
  bottom: 5px;
  right: 5px;
  background: rgba(255, 255, 255, 0.85);
  padding: 2px 6px;
  font-size: 11px;
  font-family: system-ui, sans-serif;
  color: #4b5563;
  border-radius: 4px;
}

/* Text / Chord Tabs */
.text-content {
  width: 100%;
  max-width: 1200px;
  margin: 20px auto;
  padding: 24px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.5;
  background-color: var(--sheet-bg);
  color: var(--sheet-text);
  box-shadow: var(--sheet-shadow);
  border: 1px solid var(--sheet-border);
  border-radius: 6px;
  font-size: calc(14px * var(--text-scale, 1));
  user-select: none;
}

.measure-div {
  font-family: monospace;
  font-size: calc(14px * var(--text-scale, 1));
  line-height: 1.5;
}

.chord-lyric-chord {
  min-height: 1.5em;
  color: #1d4ed8;
  font-weight: bold;
}

/* --------------------------------------------------------------------------
   Sheet Mode: Dark Mode (.sheet-mode-dark)
   Standard neutral dark sheet music (when extended guitar theme is not active)
   -------------------------------------------------------------------------- */
body.sheet-mode-dark:not(.theme-sheet-active) .pageWrapper,
body.sheet-mode-dark:not(.theme-sheet-active) .gp-page-wrapper,
body.sheet-mode-dark:not(.theme-sheet-active) .alphaTabContainer,
body.sheet-mode-dark:not(.theme-sheet-active) .text-content {
  background-color: #242424 !important;
  color: #e0e0e0 !important;
  border-color: #404040 !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.7);
}

body.sheet-mode-dark:not(.theme-sheet-active) .pageNumber {
  background: #1f1f1f;
  color: #a0a0a0;
}

body.sheet-mode-dark:not(.theme-sheet-active) canvas {
  filter: invert(1) hue-rotate(180deg);
}

body.sheet-mode-dark:not(.theme-sheet-active) #output svg text {
  fill: #e0e0e0 !important;
}

body.sheet-mode-dark:not(.theme-sheet-active) #output svg path[style*="stroke: none"],
body.sheet-mode-dark:not(.theme-sheet-active) #output svg path:not([style*="fill: none"]):not([fill="none"]) {
  fill: #e0e0e0 !important;
}

body.sheet-mode-dark:not(.theme-sheet-active) #output svg path[style*="fill: none"] {
  fill: none !important;
  stroke: #e0e0e0 !important;
}

body.sheet-mode-dark:not(.theme-sheet-active) #output svg rect[fill="#000000"],
body.sheet-mode-dark:not(.theme-sheet-active) #output svg rect[fill="#222211"],
body.sheet-mode-dark:not(.theme-sheet-active) #output svg rect:not([fill="#A5A5A5"]) {
  fill: #e0e0e0 !important;
}

body.sheet-mode-dark:not(.theme-sheet-active) #output svg rect[fill="#A5A5A5"] {
  fill: #777777 !important;
}

body.sheet-mode-dark:not(.theme-sheet-active) #output svg polygon,
body.sheet-mode-dark:not(.theme-sheet-active) #output svg polyline,
body.sheet-mode-dark:not(.theme-sheet-active) #output svg line,
body.sheet-mode-dark:not(.theme-sheet-active) #output svg circle,
body.sheet-mode-dark:not(.theme-sheet-active) #output svg ellipse {
  fill: #e0e0e0 !important;
  stroke: #e0e0e0 !important;
}

body.sheet-mode-dark:not(.theme-sheet-active) .chord-lyric-chord {
  color: #7eb6ff !important;
}

/* --------------------------------------------------------------------------
   OPT-IN: Extended Guitar Finish Theming (.theme-sheet-active)
   Overrides sheet styling with active guitar finish palette and glowing ambient accents
   -------------------------------------------------------------------------- */
body.theme-sheet-active .pageWrapper,
body.theme-sheet-active .gp-page-wrapper,
body.theme-sheet-active .alphaTabContainer,
body.theme-sheet-active .text-content {
  background-color: var(--bg-card-solid) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7), 0 0 12px -2px var(--accent-glow);
}

body.theme-sheet-active .pageNumber {
  background: var(--bg-card);
  color: var(--text-muted);
}

body.theme-sheet-active canvas {
  filter: invert(1) hue-rotate(180deg);
}

body.theme-sheet-active #output svg text {
  fill: var(--text-primary) !important;
}

body.theme-sheet-active #output svg path[style*="stroke: none"],
body.theme-sheet-active #output svg path:not([style*="fill: none"]):not([fill="none"]) {
  fill: var(--text-primary) !important;
}

body.theme-sheet-active #output svg path[style*="fill: none"] {
  fill: none !important;
  stroke: var(--text-primary) !important;
}

body.theme-sheet-active #output svg rect[fill="#000000"],
body.theme-sheet-active #output svg rect[fill="#222211"],
body.theme-sheet-active #output svg rect:not([fill="#A5A5A5"]) {
  fill: var(--text-primary) !important;
}

body.theme-sheet-active #output svg rect[fill="#A5A5A5"] {
  fill: var(--text-dim) !important;
}

body.theme-sheet-active #output svg polygon,
body.theme-sheet-active #output svg polyline,
body.theme-sheet-active #output svg line,
body.theme-sheet-active #output svg circle,
body.theme-sheet-active #output svg ellipse {
  fill: var(--text-primary) !important;
  stroke: var(--text-primary) !important;
}

body.theme-sheet-active .chord-lyric-chord {
  color: var(--accent-text) !important;
}

/* --------------------------------------------------------------------------
   AlphaTab Playback Cursors & Overlays (Continuous & Page Mode)
   -------------------------------------------------------------------------- */
/* Hide continuous mode cursors/selection until playback has started */
body:not(.synth-playback-started) .at-cursors,
body:not(.synth-playback-started) .at-selection,
body:not(.synth-playback-started) .at-cursor-bar,
body:not(.synth-playback-started) .at-cursor-beat,
body:not(.synth-playback-started) .at-highlight {
  display: none !important;
}

.at-cursor-bar,
.gp-page-cursor-bar {
  background-color: var(--accent-primary-alpha) !important;
  border-radius: 4px;
}

.at-cursor-beat,
.gp-page-cursor-beat {
  background-color: var(--accent-glow) !important;
  border-radius: 3px;
}

.at-selection {
  background-color: var(--accent-primary-alpha) !important;
}

.gp-page-cursor-bar {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  box-sizing: border-box;
  display: none;
  transition: left 0.12s linear, width 0.12s linear;
}

.gp-page-cursor-beat {
  position: absolute;
  pointer-events: none;
  z-index: 6;
  box-sizing: border-box;
  display: none;
  transition: left 0.12s linear;
}

/* Progress Bar */
#progressContainer {
  width: 100%;
  height: 4px;
  background: var(--bg-card-solid);
  position: relative;
  display: none;
}

#progressBar {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  transition: width 0.2s;
}

/* --------------------------------------------------------------------------
   Responsive & Mobile Adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  #topBar {
    padding: 0.35rem 0.5rem;
    gap: 0.3rem;
  }
  
  #centerSection {
    gap: 0.25rem;
  }

  #rightSection {
    gap: 0.25rem;
  }

  .brand-title {
    display: none;
  }
  
  #modeButtons .mode-btn-text {
    display: none;
  }

  #modeButtons label i {
    margin-right: 0 !important;
  }

  .hud-pill-group {
    padding: 1px;
    gap: 1px;
  }

  .menu-toggle-btn {
    width: 30px;
    height: 30px;
    padding: 0;
  }

  .menu-toggle-btn i {
    font-size: 1rem;
  }

  .hud-pill-group .btn-check + .btn,
  #globalAudioControls .btn,
  #audioSourcePill .btn,
  #fullscreenPill .btn,
  .brand-btn {
    padding: 0.25rem 0.4rem;
    font-size: 0.78rem;
  }

  #navButtons {
    padding: 1px 4px;
    gap: 0.15rem;
    min-height: 30px;
  }

  #navButtons .btn {
    padding: 0.2rem 0.35rem;
    font-size: 0.75rem;
  }

  #pageIndicator {
    padding: 0 0.25rem;
    font-size: 0.7rem;
  }
  
  #topBarThemeLabel {
    display: none;
  }
  
  .theme-swatch-btn {
    padding: 0.3rem 0.45rem;
  }

  .synth-panel, .yt-panel {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    max-width: calc(100vw - 1rem);
  }

  .pageContainer, .gp-page-container {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px;
  }

  .pageWrapper {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Update notification */
.update-banner {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-prominent);
  border-radius: 8px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}
.update-banner[hidden] { display: none; }
.hud-pill-group .w-33 { width: 33.333%; }
