/* GigaCharts - Modern Stage CSS */
:root {
  --bg-primary: #0a0b10;
  --bg-surface: #12141e;
  --bg-surface-elevated: #1a1e2d;
  --border-color: rgba(255, 255, 255, 0.09);
  --border-focus: #6366f1;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --chord-color: #fbbf24;
  --section-badge: #6366f1;
  --accent-pink: #ec4899;
  --accent-green: #10b981;
  --accent-blue: #3b82f6;
  --accent-amber: #f59e0b;
  
  --sheet-bg: #151824;
  --sheet-text: #f1f5f9;
  --sheet-chord: #fbbf24;
  --sheet-border: rgba(255, 255, 255, 0.12);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* Light Mode / Outdoor Daylight Gig Theme */
body.theme-light, html.theme-light body, [data-theme="light"], [data-theme="light"] body {
  --bg-primary: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #4f46e5;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --sheet-bg: #ffffff;
  --sheet-text: #0f172a;
  --sheet-chord: #b45309;
  --sheet-border: #cbd5e1;
}

/* OLED Pitch Black Theme */
[data-theme="oled"], [data-theme="oled"] body {
  --bg-primary: #000000;
  --bg-surface: #0a0a0c;
  --bg-surface-elevated: #141416;
  --border-color: rgba(255, 255, 255, 0.12);
  --border-focus: #818cf8;
  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --chord-color: #facc15;
  --section-badge: #818cf8;
  --sheet-bg: #000000;
  --sheet-text: #ffffff;
  --sheet-chord: #facc15;
  --sheet-border: #27272a;
}
[data-theme="oled"] .stage-header {
  background: rgba(0, 0, 0, 0.96);
  border-bottom-color: #27272a;
}
[data-theme="oled"] .stage-subbar {
  background: #09090b;
  border-bottom-color: #27272a;
}

/* Warm Amber Studio Console Theme */
[data-theme="amber"], [data-theme="amber"] body {
  --bg-primary: #120e08;
  --bg-surface: #1a140d;
  --bg-surface-elevated: #281e13;
  --border-color: rgba(245, 158, 11, 0.18);
  --border-focus: #f59e0b;
  --text-primary: #fef3c7;
  --text-secondary: #d97706;
  --text-muted: #92400e;
  --chord-color: #fbbf24;
  --section-badge: #d97706;
  --sheet-bg: #18120b;
  --sheet-text: #fffbeb;
  --sheet-chord: #f59e0b;
  --sheet-border: rgba(245, 158, 11, 0.22);
}
[data-theme="amber"] .stage-header {
  background: rgba(24, 18, 11, 0.96);
  border-bottom-color: rgba(245, 158, 11, 0.2);
}
[data-theme="amber"] .stage-subbar {
  background: #1a140d;
  border-bottom-color: rgba(245, 158, 11, 0.2);
}

/* Nordic Slate / Cyan Theme */
[data-theme="nordic"], [data-theme="nordic"] body {
  --bg-primary: #060b13;
  --bg-surface: #0b1322;
  --bg-surface-elevated: #132238;
  --border-color: rgba(56, 189, 248, 0.16);
  --border-focus: #06b6d4;
  --text-primary: #f0f9ff;
  --text-secondary: #7dd3fc;
  --text-muted: #0284c7;
  --chord-color: #38bdf8;
  --section-badge: #0891b2;
  --sheet-bg: #0b1424;
  --sheet-text: #f0f9ff;
  --sheet-chord: #38bdf8;
  --sheet-border: rgba(56, 189, 248, 0.22);
}
[data-theme="nordic"] .stage-header {
  background: rgba(11, 20, 36, 0.96);
  border-bottom-color: rgba(56, 189, 248, 0.2);
}
[data-theme="nordic"] .stage-subbar {
  background: #0b1322;
  border-bottom-color: rgba(56, 189, 248, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  overflow: hidden;
  height: 100%;
  width: 100%;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden; /* Avoid page scroll in stage mode */
  height: 100%;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important; /* Prevent accidental text selection on stage */
  -webkit-tap-highlight-color: transparent !important;
}

*, *::before, *::after {
  -webkit-tap-highlight-color: transparent !important;
}

/* Top App Header */
.stage-header {
  height: 64px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 50;
  position: relative;
  flex-wrap: nowrap !important;
  overflow: visible !important;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.band-logo {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.band-logo .band-logo-icon {
  font-size: 1.25rem;
  display: inline-block;
  -webkit-text-fill-color: initial;
}

.band-title-text {
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Sync Status Bubble (Green for Synced, Orange for Connecting/Peeking, Red for Offline) */
.sync-status-bubble {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  cursor: default;
  transition: all 0.25s ease;
  margin-left: 0.4rem;
  flex-shrink: 0;
}

.sync-status-bubble .sync-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  transition: all 0.25s ease;
}

/* Synced / Connected: Green */
.sync-status-bubble.synced {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
}
.sync-status-bubble.synced .sync-dot {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

/* Connecting / Peeking: Orange */
.sync-status-bubble.connecting,
.sync-status-bubble.peeking {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
}
.sync-status-bubble.connecting .sync-dot,
.sync-status-bubble.peeking .sync-dot {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulse-dot 1.2s infinite ease-in-out;
}

/* Offline / Disconnected: Red */
.sync-status-bubble.offline {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
}
.sync-status-bubble.offline .sync-dot {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.6; }
}

.role-badge.master {
  background: rgba(236, 72, 153, 0.15);
  color: var(--accent-pink);
  border: 1px solid rgba(236, 72, 153, 0.3);
}

.role-badge.slave {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.role-badge.peeking {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.4);
  animation: pulse-amber 1.5s infinite;
}

@keyframes pulse-amber {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* Header Transposition Controls (Center, available for all members, device-local) */
.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
  flex: 1 1 auto;
}

.header-transpose-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(20, 24, 40, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 30px;
  padding: 0.25rem 0.5rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  user-select: none;
}

.btn-transpose {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(30, 36, 60, 0.5);
  color: var(--text-primary);
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
  flex-shrink: 0;
}

.btn-transpose:hover {
  background: rgba(99, 102, 241, 0.4);
  border-color: #818cf8;
  transform: scale(1.08);
}

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

.transpose-display {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-width: 84px; /* Fixed generous space so button never moves if going from Fm to F#m */
  padding: 0 0.4rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  user-select: none;
  border-radius: 6px;
  transition: background 0.15s ease;
  text-align: center;
  flex-shrink: 0;
}

.transpose-display:hover {
  background: rgba(255, 255, 255, 0.08);
}

.transpose-key {
  color: var(--sheet-chord, #a5b4fc);
  font-family: var(--font-mono);
  font-size: 0.98rem;
  font-weight: 800;
  min-width: 2.8rem;
  text-align: center;
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

.transpose-offset {
  background: #10b981;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.1rem 0.35rem;
  border-radius: 10px;
  line-height: 1.1;
  min-width: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.btn-transpose-reset {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
  visibility: hidden; /* Reserves space so ♭ and ♯ buttons stay completely stationary */
}

.btn-transpose-reset:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #ef4444;
  transform: scale(1.1);
}

/* Light Mode Overrides */
[data-theme="light"] .header-transpose-controls {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .btn-transpose {
  background: rgba(240, 243, 250, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.15);
  color: #1e293b;
}

[data-theme="light"] .btn-transpose:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: #6366f1;
}

/* Header Controls (Right) */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  flex-wrap: nowrap !important;
}

/* Logout Button */
.btn-logout {
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.45) !important;
  background: rgba(239, 68, 68, 0.08) !important;
  width: auto !important;
  padding: 0 0.75rem !important;
  font-weight: 700;
  gap: 0.35rem;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0 !important;
  transition: all 0.15s ease;
}

.btn-logout:hover,
.btn-logout:active {
  background: rgba(239, 68, 68, 0.22) !important;
  border-color: #ef4444 !important;
  color: #fca5a5 !important;
}

/* Tablet & Mobile Tools Dropdown */
.header-tools-dropdown-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.header-tools-trigger {
  border-color: #6366f1 !important;
  color: #a5b4fc !important;
  width: auto !important;
  padding: 0 0.75rem !important;
  font-weight: 700;
  gap: 0.35rem;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.1) !important;
  transition: all 0.15s ease;
}

.header-tools-trigger:hover,
.header-tools-trigger:active {
  background: rgba(99, 102, 241, 0.25) !important;
  border-color: #818cf8 !important;
  color: #fff !important;
}

.header-tools-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: #181c2e;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75), 0 2px 6px rgba(0, 0, 0, 0.4);
  padding: 0.4rem;
  z-index: 1500;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  flex-direction: column;
  gap: 0.25rem;
}

.header-tools-menu.active {
  display: flex !important;
  animation: fadeInToolsMenu 0.15s ease-out;
}

@keyframes fadeInToolsMenu {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header-tools-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: all 0.12s ease;
}

.header-tools-item:hover,
.header-tools-item:active {
  background: rgba(99, 102, 241, 0.2);
  color: #fff;
}

.header-tools-item .tool-icon,
.header-tools-item .tool-icon-svg {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #a5b4fc;
}

.header-tools-item:hover .tool-icon,
.header-tools-item:hover .tool-icon-svg {
  color: #fff;
}

.btn-icon {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 1rem;
}

.btn-icon:hover {
  background: #23283c;
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-nav-song {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 1rem;
  height: 42px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--border-color);
}

.btn-nav-song.prev {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.btn-nav-song.next {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  border-color: #6366f1;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-nav-song:hover {
  filter: brightness(1.15);
}

.btn-nav-song:active {
  transform: scale(0.97);
}

/* Sub-Bar: Connected Roster & Up-Next Indicator */
.stage-subbar {
  height: 38px;
  background-color: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

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

.roster-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  font-size: 0.72rem;
  font-weight: 600;
}

.roster-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.roster-dot.offline {
  background: #64748b;
  box-shadow: none;
}

.roster-dot.peeking {
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
}

.up-next-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.up-next-pill {
  color: var(--text-primary);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.3);
}

/* Peeking Notification Banner */
.peek-alert-bar {
  display: none;
  background: linear-gradient(90deg, #b45309, #d97706);
  color: #fff;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 40;
}

.btn-snap-sync {
  background: #ffffff;
  color: #b45309;
  border: none;
  padding: 0.2rem 0.75rem;
  border-radius: 20px;
  font-weight: 800;
  font-size: 0.75rem;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Main Viewport Container */
.stage-main-viewport {
  position: relative;
  width: 100vw;
  height: calc(100vh - 102px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-primary);
}

.stage-main-viewport.fit-width-mode,
.stage-main-viewport.single-column-mode {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  align-items: flex-start !important;
  justify-content: center !important;
  touch-action: pan-y !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain;
  padding-top: 14px;
  padding-bottom: 70px;
}

.a4-frame-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stage-main-viewport.fit-width-mode .a4-frame-wrapper,
.stage-main-viewport.single-column-mode .a4-frame-wrapper {
  margin: 0 auto;
  height: auto !important;
}

/* A4 Page Container */
/* Standard A4 aspect ratio is 1 : 1.4142 (e.g. 800px x 1131px) */
.a4-page-frame {
  width: 800px;
  height: 1131px;
  background: var(--sheet-bg);
  color: var(--sheet-text);
  border: 1px solid var(--sheet-border);
  border-radius: 8px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform-origin: center center;
  transition: transform 0.15s ease-out;
  padding: 1.8rem 1.85rem 2.2rem 1.85rem;
}

.stage-main-viewport.fit-width-mode .a4-page-frame,
.stage-main-viewport.single-column-mode .a4-page-frame {
  transform-origin: top center !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  margin: 0 auto;
  height: auto !important;
  min-height: 1131px;
}

.stage-main-viewport.single-column-mode .sheet-content-cols {
  column-count: 1 !important;
  column-gap: 0 !important;
  height: auto !important;
}

/* Sheet Header */
.sheet-header {
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.6rem;
  margin-bottom: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.sheet-title {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.sheet-artist {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 0.25rem;
}

.sheet-meta-box {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.sheet-key-tag {
  font-size: 1.2rem;
  color: var(--sheet-chord);
  font-family: var(--font-mono);
}

.sheet-bpm-tag {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  transition: all 0.15s ease;
  user-select: none;
}

.sheet-bpm-tag:hover {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.45);
  color: #c7d2fe;
}

.sheet-bpm-tag.has-custom-bpm {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.45);
  color: #34d399;
}

.sheet-bpm-tag .orig-bpm-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-left: 0.15rem;
}

#bpmModalTapBtn.tap-active {
  background: rgba(236, 72, 153, 0.4) !important;
  transform: scale(0.97);
}

.ui-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  vertical-align: middle;
  pointer-events: none;
}

.sheet-notes-bar {
  background: rgba(99, 102, 241, 0.12);
  border-left: 3px solid #6366f1;
  padding: 0.45rem 0.85rem;
  border-radius: 0 6px 6px 0;
  font-size: 0.82rem;
  color: #c7d2fe;
  font-weight: 600;
  margin-bottom: 1.2rem;
}

/* Song Content Render Area */
.sheet-content {
  flex: 1;
  min-height: 0;
  overflow: hidden; /* Fits strictly on 1 single page! */
  column-count: 2;
  column-gap: 1.6rem;
  column-rule: 1px dashed rgba(255, 255, 255, 0.1);
  font-size: 1.07rem;
  line-height: 1.48;
  font-family: var(--font-mono);
}

.sheet-section {
  break-inside: avoid-column;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: 0.8rem;
}

.section-label-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
  break-after: avoid;
  -webkit-column-break-after: avoid;
  page-break-after: avoid;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
}

.section-label {
  display: inline-block;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 800;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
  font-family: var(--font-sans);
  break-after: avoid;
  -webkit-column-break-after: avoid;
  page-break-after: avoid;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
}

.chart-line {
  white-space: pre-wrap; /* Allows long lines to wrap within column while preserving indentation and chords */
  word-break: break-word;
  overflow-wrap: break-word;
  margin-bottom: 0.1rem;
  color: var(--sheet-text);
  font-family: var(--font-mono);
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.chart-line.chord-line {
  color: var(--sheet-chord);
  font-weight: 800;
  min-height: 1.25em;
  margin-top: 0.25rem;
  break-after: avoid;
  -webkit-column-break-after: avoid;
  page-break-after: avoid;
}

.chart-line.lyric-line {
  color: var(--sheet-text);
  margin-bottom: 0.25rem;
}

.chord-tag {
  color: var(--sheet-chord);
  font-weight: 800;
  display: inline-block;
  font-family: var(--font-mono);
}

/* Google Docs Iframe Container (A4 Fit) */
.gdoc-iframe-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

.gdoc-iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Stage Cue Notification Banner (Top of page, does NOT block chord charts) */
.stage-cue-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  pointer-events: none;
  display: flex;
  justify-content: center;
  animation: cue-slide-down 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 90vw;
}

.stage-cue-box {
  background: linear-gradient(135deg, #ec4899, #f43f5e);
  color: #fff;
  padding: 0.7rem 1.4rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  box-shadow: 0 8px 32px rgba(236, 72, 153, 0.65), 0 0 20px rgba(255, 255, 255, 0.3);
  pointer-events: auto;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.35);
}

.stage-cue-text {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.stage-cue-sender {
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.28);
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  white-space: nowrap;
  opacity: 0.95;
}

.stage-cue-dismiss {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 800;
  transition: background 0.15s ease;
}

.stage-cue-dismiss:hover {
  background: rgba(0, 0, 0, 0.4);
}

@keyframes cue-slide-down {
  0% { transform: translateY(-40px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Modal Windows (Importer, Setlist, QR Code) */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

body.modal-open .header-tools-menu {
  display: none !important;
}

body.modal-open .stage-menu-container,
body.modal-open .bottom-left-fs-btn {
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  width: 90%;
  max-width: 580px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.modal-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Tablet & Touch friendly Song Editor */
.chart-editor-modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  flex: 1;
}

.chart-editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.chart-editor-left {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
  overscroll-behavior: contain;
  min-height: 0;
  padding-right: 0.5rem;
}

.chart-editor-right {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  background: var(--sheet-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.25rem;
}

.chart-editor-preview {
  flex: 1;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
  overscroll-behavior: contain;
  min-height: 0;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.chart-editor-textarea {
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
  overscroll-behavior: contain;
}

@media (max-width: 820px) {
  .chart-editor-grid {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr 1fr !important;
    gap: 0.85rem !important;
  }
  .chart-editor-modal-body {
    padding: 0.85rem !important;
  }
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.form-textarea {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  resize: vertical;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

/* Setlist Drawer */
.setlist-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-radius: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s;
}

.setlist-item:hover {
  border-color: rgba(99, 102, 241, 0.5);
  background: #1f2436;
}

.setlist-item.active {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.18);
}

.setlist-item-num {
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--text-muted);
  width: 28px;
}

.setlist-item-title {
  font-weight: 700;
  font-size: 1rem;
  flex: 1;
}

.setlist-item-key {
  font-family: var(--font-mono);
  color: var(--chord-color);
  font-weight: 700;
  font-size: 0.85rem;
  margin-right: 0.5rem;
}

/* Stage Metronome Indicator & Visual Top Bar */
.stage-metronome-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: transparent;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.04s ease-out;
}

.stage-metronome-bar.flash {
  background: #ec4899;
  box-shadow: 0 0 16px #ec4899, 0 0 32px #ec4899;
  opacity: 1;
}

/* Enhanced visibility for drummer */
body.is-drummer .stage-metronome-bar {
  height: 8px;
}

body.is-drummer .stage-metronome-bar.flash {
  background: #f43f5e;
  box-shadow: 0 0 24px #f43f5e, 0 0 48px #f43f5e;
}

/* Metronome blinking borders (square in header, circle on stage) */
#metronomeBtn.metronome-active {
  border-color: rgba(236, 72, 153, 0.45);
  color: #f472b6;
  transition: all 0.08s ease;
}

#metronomeBtn.flash {
  border-color: #ec4899 !important;
  box-shadow: 0 0 16px rgba(236, 72, 153, 0.95), inset 0 0 8px rgba(236, 72, 153, 0.45) !important;
  color: #ffffff !important;
  transform: scale(1.06);
}

#stageMetronomeBtn.metronome-active,
#stageMenuToggleBtn.metronome-active {
  border-color: rgba(236, 72, 153, 0.45) !important;
  color: #f472b6 !important;
  transition: all 0.08s ease;
}

#stageMetronomeBtn.flash,
#stageMenuToggleBtn.flash {
  border-color: #ec4899 !important;
  box-shadow: 0 0 20px rgba(236, 72, 153, 0.95), inset 0 0 10px rgba(236, 72, 153, 0.5) !important;
  color: #ffffff !important;
  transform: scale(1.1) !important;
}

#badgeBpm.metronome-active {
  border-color: rgba(236, 72, 153, 0.6);
  color: #f472b6;
}

#badgeBpm.flash {
  background: rgba(236, 72, 153, 0.35);
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.6);
}

/* Setlist Editor & Master Pool Panes */
.split-panes {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.25rem;
  min-height: 480px;
}

.pane-sidebar {
  border-right: 1px solid var(--border-color);
  padding-right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pane-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  max-height: 65vh;
  padding-right: 0.5rem;
}

.setlist-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s ease;
}

.setlist-nav-item:hover {
  background: #202538;
  border-color: rgba(99, 102, 241, 0.4);
}

.setlist-nav-item.selected {
  background: rgba(99, 102, 241, 0.2);
  border-color: #6366f1;
}

.badge-live-tag {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.4);
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.4rem;
  border-radius: 12px;
}

.btn-tiny {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.15s;
}

.btn-tiny:hover {
  background: #2a314b;
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-tiny.danger {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-tiny.danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

.btn-tiny.success {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.1);
}

.btn-tiny.success:hover {
  background: rgba(16, 185, 129, 0.2);
}

.pool-song-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: background 0.15s;
}

.pool-song-row:hover {
  background: #1c2132;
}

/* Responsive adjustments for Desktop vs Tablet/iPad vs Mobile */
@media (min-width: 1101px) {
  .header-tools-dropdown-wrapper {
    display: none !important;
  }
}

@media (max-width: 1100px) {
  .desktop-only-tool {
    display: none !important;
  }
  .header-tools-dropdown-wrapper {
    display: inline-flex !important;
  }
  .song-quick-title {
    max-width: 200px;
    font-size: 1.05rem;
  }
  .header-center {
    gap: 0.5rem;
  }
  .band-title-text {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 768px) {
  .stage-header {
    padding: 0 0.5rem;
  }
  .song-quick-title {
    max-width: 140px;
    font-size: 0.95rem;
  }
  .btn-nav-song span {
    display: none;
  }
  .btn-nav-song {
    padding: 0 0.75rem;
  }
  .sheet-content {
    column-count: 1;
  }
  .band-title-text {
    display: none;
  }
  .role-badge {
    padding: 0.15rem 0.4rem;
    font-size: 0.68rem;
  }
  .pill-badge {
    padding: 0.15rem 0.35rem;
    font-size: 0.7rem;
  }
}

@media (max-width: 600px) {
  .logout-label,
  .tools-label {
    display: none;
  }
  .btn-logout,
  .header-tools-trigger {
    padding: 0 !important;
    width: 38px !important;
    height: 38px !important;
    justify-content: center !important;
  }
}

/* Top Stage Header Collapse Toggle Button */
.header-collapse-btn {
  position: fixed;
  top: 102px;
  right: 16px;
  width: 44px;
  height: 28px;
  border-radius: 0 0 8px 8px;
  background: rgba(18, 22, 38, 0.5); /* 50% transparent frosted glass */
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-top: none;
  color: #c7d2fe;
  font-size: 0.85rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  opacity: 0.75;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-collapse-btn:hover {
  background: rgba(30, 36, 60, 0.55);
  color: #fff;
  border-color: #818cf8;
  opacity: 0.95;
}

/* When header is hidden / collapsed */
body.header-hidden .stage-header,
body.header-hidden .stage-subbar {
  display: none !important;
}

body.header-hidden .stage-main-viewport {
  height: 100vh !important;
}

body.header-hidden .header-collapse-btn {
  top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}

/* Top-Right Floating Stage Controls (Positioned where header collapse arrow was) */
.stage-menu-container {
  position: fixed;
  top: 108px; /* Sits at top-right where header collapse arrow was (below 102px stage header/subbar) */
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.65rem;
  transition: top 0.2s cubic-bezier(0.16, 1, 0.3, 1), right 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

body.header-hidden .stage-menu-container,
body.fullscreen-mode .stage-menu-container {
  top: 10px; /* Sits at top-right where header collapse arrow was in fullscreen */
  right: 16px;
}

/* Always-Visible Stage Action Buttons Row (Stage Cue & Gear Toggle) */
.stage-action-buttons {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  justify-content: flex-end;
}

/* 50% Translucent Frosted-Glass Stage Floating Bubbles (All Times) */
.stage-floating-btn {
  position: relative !important;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(18, 22, 38, 0.5) !important; /* 50% transparent frosted glass at all times */
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  opacity: 0.8;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.2s ease,
              border-color 0.2s ease,
              opacity 0.2s ease;
  flex-shrink: 0;
  outline: none !important;
  user-select: none;
  -webkit-user-select: none;
}

.stage-floating-btn:hover {
  background: rgba(30, 36, 60, 0.55) !important; /* Translucent on hover/touch, never solid opaque */
  transform: scale(1.08);
  border-color: rgba(255, 255, 255, 0.35);
  opacity: 1;
}

/* Dedicated Bottom-Left Fullscreen & Zoom Button */
.bottom-left-fs-btn {
  position: fixed !important;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
  width: 48px !important;
  height: 48px !important;
  font-size: 1.35rem !important;
  border-color: rgba(99, 102, 241, 0.45) !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

.bottom-left-fs-btn:hover {
  border-color: #818cf8 !important;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.4) !important;
}

.bottom-left-fs-btn.fit-width-active,
.stage-menu-container #stageFitWidthBtn.fit-width-active,
.stage-menu-container #stageSingleColBtn.single-col-active {
  border-color: #10b981 !important;
  color: #34d399 !important;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.5) !important;
  background: rgba(6, 78, 59, 0.6) !important;
}

/* Primary Toggle Button (Thumb friendly) */
.stage-menu-toggle-btn {
  z-index: 10;
  border-color: rgba(99, 102, 241, 0.45) !important;
}

.stage-menu-toggle-icon {
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.stage-menu-toggle-btn:hover .stage-menu-toggle-icon {
  transform: rotate(35deg) scale(1.05);
}

.stage-menu-container.is-expanded .stage-menu-toggle-btn {
  background: rgba(49, 46, 129, 0.55) !important;
  border-color: #818cf8 !important;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.4) !important;
  opacity: 1;
}

.stage-menu-container.is-expanded .stage-menu-toggle-icon {
  transform: scale(1.05);
}

/* Vertical Dropdown of Controls (expands downwards under gear toggle) */
.stage-controls-dropdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: flex-end;
  width: 48px;
  gap: 0.65rem;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transform: translateY(-8px) scale(0.95);
  transform-origin: top center;
  transition: max-height 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.2s ease,
              transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.stage-menu-container.is-expanded .stage-controls-dropdown {
  max-height: 480px;
  opacity: 1;
  pointer-events: auto;
  overflow: visible; /* Allows #quickSetlistPopup to open towards the left freely */
  transform: translateY(0) scale(1);
}

.stage-menu-container #stageFullscreenBtn:hover,
.stage-menu-container #bottomLeftFullscreenBtn:hover {
  border-color: #6366f1;
}

/* Always-Visible Stage Cue Button (Pink Accent) */
.stage-menu-container #stageCueBtn {
  border-color: rgba(236, 72, 153, 0.5) !important;
  color: #f472b6 !important;
}

.stage-menu-container #stageCueBtn:hover,
.stage-menu-container #bottomLeftCueBtn:hover {
  background: rgba(236, 72, 153, 0.25) !important;
  border-color: #ec4899 !important;
  box-shadow: 0 0 16px rgba(236, 72, 153, 0.4) !important;
  color: #fbcfe8 !important;
}

.stage-menu-container #stageMetronomeBtn:hover,
.stage-menu-container #bottomLeftMetronomeBtn:hover {
  background: rgba(236, 72, 153, 0.25) !important;
  border-color: #ec4899;
  box-shadow: 0 0 16px rgba(236, 72, 153, 0.4);
}

.stage-menu-container .font-adj-btn {
  font-weight: 800;
  border-color: rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
}

.stage-menu-container .font-adj-btn:hover {
  background: rgba(49, 46, 129, 0.5) !important;
  border-color: #818cf8;
  color: #fff;
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.35);
}

/* Quick Setlist Container inside Vertical Dropdown */
.stage-menu-container .quick-setlist-container {
  position: relative !important;
  display: inline-flex;
  align-items: center;
}

.stage-menu-container .quick-setlist-fab {
  position: relative !important;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(18, 22, 38, 0.5) !important;
  border: 1px solid rgba(99, 102, 241, 0.45);
  color: #c7d2fe;
  font-size: 1.1rem;
}

.stage-menu-container .quick-setlist-fab:hover,
.stage-menu-container .quick-setlist-fab.is-active {
  background: rgba(49, 46, 129, 0.65) !important;
  color: #fff;
  border-color: #818cf8;
  transform: scale(1.08);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.4);
  opacity: 1;
}

/* Quick Setlist Expandable Popup (Opens to the Left of Top-Right Dropdown) */
.quick-setlist-popup {
  position: absolute;
  top: 0;
  right: calc(100% + 14px); /* Opens to the left */
  left: auto;
  bottom: auto;
  width: 320px;
  max-width: calc(100vw - 80px);
  max-height: min(520px, calc(100vh - 160px));
  background: rgba(15, 18, 30, 0.92);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7), 0 0 20px rgba(99, 102, 241, 0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1002;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: quickSetlistPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top right;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

@keyframes quickSetlistPop {
  0% {
    opacity: 0;
    transform: scale(0.9) translateX(10px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateX(0);
  }
}

.quick-setlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  background: rgba(30, 34, 54, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 0.5rem;
}

.quick-setlist-header-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  overflow: hidden;
}

.quick-setlist-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-setlist-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.quick-setlist-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.quick-setlist-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}

.quick-setlist-songs {
  padding: 0.4rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 380px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.quick-setlist-songs::-webkit-scrollbar {
  width: 6px;
}
.quick-setlist-songs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 3px;
}

.quick-setlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 0.6rem;
}

.quick-setlist-item:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.35);
  transform: translateX(2px);
}

.quick-setlist-item.is-current {
  background: rgba(99, 102, 241, 0.25);
  border-color: #6366f1;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

.qs-item-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  overflow: hidden;
  flex: 1;
}

.qs-item-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
  width: 20px;
  text-align: right;
  flex-shrink: 0;
}

.quick-setlist-item.is-current .qs-item-num {
  color: #818cf8;
}

.qs-item-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 0.15rem;
}

.qs-item-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qs-item-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.qs-meta-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.qs-meta-badge.key {
  font-family: var(--font-mono);
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.qs-meta-badge.bpm {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.qs-item-status {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.3);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Stage Floating Toast Alert */
.stage-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(18, 20, 32, 0.95);
  border: 1px solid rgba(236, 72, 153, 0.6);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 16px rgba(236, 72, 153, 0.3);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.55rem 1.3rem;
  border-radius: 9999px;
  z-index: 10001;
  pointer-events: none;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.stage-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}



.master-stage-dock {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  z-index: 100;
  background: rgba(18, 22, 38, 0.5); /* 50% transparent frosted glass */
  padding: 0.4rem 0.5rem;
  border-radius: 40px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.master-stage-dock:hover {
  opacity: 0.95;
}

.btn-dock {
  height: 50px;
  padding: 0 1.35rem;
  border-radius: 30px;
  font-size: 0.98rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border-color);
  transition: all 0.15s ease;
}

.btn-dock.prev {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.btn-dock.prev:hover {
  background: #283049;
}

.btn-dock.next {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  border-color: #6366f1;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-dock.next:hover {
  filter: brightness(1.15);
  transform: scale(1.04);
}

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

/* Light Theme Bubbles & Floating Controls (Frosted Glass) */
[data-theme="light"] .stage-floating-btn,
[data-theme="light"] .stage-menu-container .quick-setlist-fab,
[data-theme="light"] .master-stage-dock,
[data-theme="light"] .header-collapse-btn {
  background: rgba(255, 255, 255, 0.5) !important;
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: #1e293b;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  opacity: 0.85;
}

[data-theme="light"] .stage-floating-btn:hover {
  background: rgba(240, 243, 250, 0.75) !important;
  opacity: 1;
}

[data-theme="light"] .stage-menu-container.is-expanded .stage-menu-toggle-btn {
  background: rgba(99, 102, 241, 0.2) !important;
  border-color: #6366f1 !important;
  color: #4f46e5 !important;
}

/* ========================================================
   SETTINGS MODAL & THEME SELECTOR STYLES
   ======================================================== */
.settings-section {
  margin-bottom: 1.25rem;
}
.settings-section-title {
  display: block;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.settings-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}
.settings-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1.25rem 0;
}
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.65rem;
  margin-top: 0.5rem;
}
.theme-card {
  display: flex;
  flex-direction: column;
  padding: 0.6rem;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 2px solid var(--border-color);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-primary);
  font-family: inherit;
}
.theme-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.5);
}
.theme-card.active {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.14);
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.35);
}
.theme-preview-swatch {
  height: 44px;
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  font-weight: 700;
}
.theme-swatch-dark {
  background: #0a0b10;
  border: 1px solid #23283c;
}
.theme-swatch-dark .swatch-chord { color: #fbbf24; }
.theme-swatch-dark .swatch-lyric { color: #f8fafc; }

.theme-swatch-oled {
  background: #000000;
  border: 1px solid #27272a;
}
.theme-swatch-oled .swatch-chord { color: #facc15; }
.theme-swatch-oled .swatch-lyric { color: #ffffff; }

.theme-swatch-amber {
  background: #14100a;
  border: 1px solid #452b11;
}
.theme-swatch-amber .swatch-chord { color: #fbbf24; }
.theme-swatch-amber .swatch-lyric { color: #fef3c7; }

.theme-swatch-nordic {
  background: #070d18;
  border: 1px solid #164e63;
}
.theme-swatch-nordic .swatch-chord { color: #38bdf8; }
.theme-swatch-nordic .swatch-lyric { color: #f0f9ff; }

.theme-swatch-light {
  background: #ffffff;
  border: 1px solid #cbd5e1;
}
.theme-swatch-light .swatch-chord { color: #b45309; }
.theme-swatch-light .swatch-lyric { color: #0f172a; }

.theme-info {
  display: flex;
  flex-direction: column;
}
.theme-name {
  font-size: 0.82rem;
  font-weight: 700;
}
.theme-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Settings Header App Name Input & Chart Inputs */
.settings-input,
.chart-input {
  width: 100%;
  padding: 0.65rem 0.95rem;
  border-radius: 8px;
  background: var(--bg-surface-elevated, #1a1e2e) !important;
  border: 1px solid var(--border-color, #2d3748) !important;
  color: var(--text-primary, #f8fafc) !important;
  font-family: inherit;
  font-size: 0.95rem;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.settings-input:focus,
.chart-input:focus {
  outline: none;
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25) !important;
}

.settings-input::placeholder,
.chart-input::placeholder {
  color: var(--text-muted, #64748b);
  opacity: 0.7;
}

/* ========================================================
   ADMIN CONTROL CENTER & EXPERIMENTAL METRONOME SYNC
   ======================================================== */
.admin-only {
  display: none !important;
}

body.is-admin-account .admin-only {
  display: inline-flex !important;
}

body.is-admin-account .admin-only.btn-icon {
  display: inline-flex !important;
}

/* Toggle Switch Styles */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #2e384d;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #cbd5e1;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #ec4899;
  border-color: #f472b6;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(22px);
  background-color: #ffffff;
}

/* Band Badges in Song Library */
.song-band-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
  letter-spacing: 0.02em;
}

.song-band-badge.admin-band {
  background: rgba(236, 72, 153, 0.15);
  border-color: rgba(236, 72, 153, 0.35);
  color: #f472b6;
}

/* Empty state message */
.empty-library-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-library-banner h3 {
  font-size: 1.3rem;
  color: var(--text-primary);
  margin: 0.75rem 0 0.5rem 0;
}
.empty-library-banner p {
  font-size: 0.88rem;
  max-width: 420px;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}




