        :root {
            --live-bg: #090d16;
            --live-surface: #111827;
            --live-card: #162032;
            --live-border: #1f2d44;
            --live-text: #f3f4f6;
            --live-chord: #38bdf8;
            --live-accent: #ef4444;
        }

        body.light-theme {
            --live-bg: #f8fafc;
            --live-surface: #ffffff;
            --live-card: #ffffff;
            --live-border: #e2e8f0;
            --live-text: #0f172a;
            --live-chord: #0284c7;
            --live-accent: #dc2626;
        }

        * {
            box-sizing: border-box;
        }

        html, body {
            margin: 0;
            padding: 0;
            background-color: var(--live-bg);
            color: var(--live-text);
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            height: 100%;
            overflow: hidden;
            user-select: none;
        }

        /* Top Bar */
        .live-topbar {
            height: 60px;
            background-color: var(--live-surface);
            border-bottom: 1px solid var(--live-border);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 1rem;
            z-index: 1000;
        }

        .live-badge {
            background-color: rgba(239, 68, 68, 0.2);
            color: #ef4444;
            border: 1px solid rgba(239, 68, 68, 0.4);
            font-weight: 700;
            letter-spacing: 0.05em;
            padding: 0.2rem 0.6rem;
            border-radius: 9999px;
            font-size: 0.75rem;
            display: inline-flex;
            align-items: center;
            gap: 0.4rem;
        }

        .live-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background-color: #ef4444;
            animation: pulse-dot 1.5s infinite;
        }

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

        /* Main Stage Layout */
        .live-layout {
            display: flex;
            height: calc(100vh - 60px - 72px);
            position: relative;
        }

        /* Setlist Drawer / Sidebar */
        .live-setlist-drawer {
            width: 320px;
            background-color: var(--live-surface);
            border-right: 1px solid var(--live-border);
            overflow-y: auto;
            flex-shrink: 0;
            transition: transform 0.25s ease, margin-left 0.25s ease;
        }

        .live-setlist-drawer.collapsed {
            margin-left: -320px;
        }

        .setlist-item {
            display: flex;
            align-items: center;
            padding: 0.9rem 1rem;
            border-bottom: 1px solid var(--live-border);
            cursor: pointer;
            transition: background 0.15s;
            color: var(--live-text);
            text-decoration: none;
        }

        .setlist-item:hover {
            background-color: rgba(255, 255, 255, 0.04);
            color: var(--live-text);
        }

        .setlist-item.active {
            background-color: rgba(56, 189, 248, 0.15);
            border-left: 4px solid #38bdf8;
        }

        .setlist-number {
            width: 26px;
            height: 26px;
            border-radius: 6px;
            background: var(--live-border);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.8rem;
            font-weight: 700;
            margin-right: 0.75rem;
            flex-shrink: 0;
        }

        .setlist-item.active .setlist-number {
            background: #38bdf8;
            color: #090d16;
        }

        /* Viewer / Song Canvas */
        .live-viewer {
            flex-grow: 1;
            height: 100%;
            overflow-y: auto;
            padding: 2rem 3rem;
            scroll-behavior: smooth;
            background: var(--live-bg);
            user-select: text;
        }

        .live-song-header {
            margin-bottom: 2rem;
            border-bottom: 1px solid var(--live-border);
            padding-bottom: 1.25rem;
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            flex-wrap: wrap;
            gap: 1rem;
        }

        .live-song-title {
            font-size: 2.2rem;
            font-weight: 700;
            margin: 0;
            color: var(--live-text);
            font-family: 'Chakra Petch', sans-serif;
            letter-spacing: -0.02em;
        }

        .live-song-artist {
            font-size: 1.1rem;
            color: #94a3b8;
            margin-top: 0.25rem;
        }

        .live-key-badge {
            background-color: var(--live-surface);
            border: 1px solid var(--live-border);
            padding: 0.4rem 0.8rem;
            border-radius: 8px;
            font-size: 1rem;
            font-weight: 700;
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
        }

        .live-key-badge select {
            background: transparent;
            border: none;
            color: #38bdf8;
            font-weight: 800;
            font-size: 1.1rem;
            cursor: pointer;
            outline: none;
        }

        /* Lyrics / Chords Content */
        pre.live-lyrics {
            font-family: 'Ayuthaya', monospace;
            line-height: 1.35;
            font-size: 1.4rem;
            background: transparent;
            border: none;
            color: var(--live-text);
            white-space: pre;
            padding: 0;
            margin: 0;
        }

        /* Style Chord tags with interactive hover/click */
        .cs-chord, .chord {
            color: var(--live-chord) !important;
            font-weight: 700;
            cursor: pointer;
            border-radius: 4px;
            padding: 0 2px;
            transition: background 0.15s, color 0.15s;
        }

        .cs-chord:hover, .chord:hover {
            background-color: rgba(56, 189, 248, 0.25);
            text-decoration: underline;
        }

        /* Chord Voicing Popover */
        .chord-popover {
            position: fixed;
            z-index: 2500;
            width: 175px;
            background-color: var(--live-card);
            border: 1px solid #38bdf8;
            border-radius: 12px;
            padding: 0.75rem;
            box-shadow: 0 12px 35px rgba(0,0,0,0.8);
            color: var(--live-text);
            animation: popoverZoomIn 0.15s ease-out;
        }

        @keyframes popoverZoomIn {
            from { opacity: 0; transform: scale(0.88); }
            to { opacity: 1; transform: scale(1); }
        }

        .chord-popover-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--live-border);
            padding-bottom: 0.35rem;
            margin-bottom: 0.5rem;
        }

        .chord-popover svg {
            background: #ffffff;
            border-radius: 8px;
            padding: 4px;
            display: block;
            margin: 0 auto;
        }

        /* Audience / Projector Mode */
        body.mode-projector pre.live-lyrics {
            font-family: 'Inter', 'Chakra Petch', sans-serif !important;
            font-size: 3rem !important;
            text-align: center !important;
            line-height: 1.6 !important;
            white-space: pre-wrap !important;
        }

        body.mode-projector .live-song-header {
            text-align: center;
            display: block;
            border: none;
        }

        body.mode-projector .live-song-title {
            font-size: 3rem;
            color: #f8fafc;
        }

        body.mode-projector .live-song-artist,
        body.mode-projector .live-key-controls,
        body.mode-projector .cs-chord,
        body.mode-projector .chord {
            display: none !important;
        }

        /* Bottom Live Controller Dock */
        .live-dock {
            height: 72px;
            background-color: var(--live-surface);
            border-top: 1px solid var(--live-border);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 1.5rem;
            z-index: 1000;
        }

        .btn-live {
            background: var(--live-card);
            border: 1px solid var(--live-border);
            color: var(--live-text);
            padding: 0.5rem 1rem;
            border-radius: 8px;
            font-weight: 600;
            display: inline-flex;
            align-items: center;
            gap: 0.4rem;
            transition: all 0.15s;
        }

        .btn-live:hover:not(:disabled) {
            background: rgba(255, 255, 255, 0.1);
            color: #fff;
            border-color: #475569;
        }

        .btn-live:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        .btn-live.active {
            background: #38bdf8;
            color: #090d16;
            border-color: #38bdf8;
        }

        /* Auto Scroll indicator */
        .autoscroll-bar {
            position: fixed;
            top: 60px;
            left: 0;
            height: 3px;
            background: #ef4444;
            width: 0%;
            z-index: 1050;
            transition: width 0.1s linear;
        }

        /* 2-Column Mode for Large Screens */
        body.two-column pre.live-lyrics {
            column-count: 2;
            column-gap: 3rem;
            column-rule: 1px solid var(--live-border);
        }

        /* Metronome Floating Panel & Beat Indicators */
        .metronome-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: rgba(0, 0, 0, 0.4);
            backdrop-filter: blur(2px);
            z-index: 1200;
        }

        .metronome-panel {
            position: fixed;
            bottom: 85px;
            left: 50%;
            transform: translateX(-50%);
            width: 360px;
            max-width: 92vw;
            background-color: var(--live-card);
            border: 1px solid var(--live-border);
            border-radius: 12px;
            padding: 1.25rem;
            box-shadow: 0 15px 35px rgba(0,0,0,0.6);
            z-index: 1250;
            animation: metronomeSlideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        }

        @keyframes metronomeSlideUp {
            from { opacity: 0; transform: translate(-50%, 20px); }
            to { opacity: 1; transform: translate(-50%, 0); }
        }

        .metronome-beats {
            display: flex;
            justify-content: center;
            gap: 0.6rem;
        }

        .beat-dot {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: var(--live-border);
            border: 2px solid transparent;
            transition: all 0.08s ease;
        }

        .beat-dot.accent {
            border-color: #ef4444;
        }

        .beat-dot.active {
            background: #38bdf8 !important;
            transform: scale(1.25);
            box-shadow: 0 0 12px rgba(56, 189, 248, 0.8);
        }

        .beat-dot.active.accent {
            background: #ef4444 !important;
            box-shadow: 0 0 15px rgba(239, 68, 68, 0.9);
        }

        .btn-tap-tempo {
            border-radius: 12px;
            min-width: 90px;
            transition: transform 0.05s ease, background 0.15s;
            user-select: none;
        }

        .btn-tap-tempo:active {
            transform: scale(0.92);
        }

        .metronome-dock-pulse {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background-color: #64748b;
            display: inline-block;
            transition: all 0.08s ease;
        }

        .metronome-dock-pulse.running {
            background-color: #ef4444;
        }

        .metronome-dock-pulse.active-beat {
            background-color: #38bdf8;
            transform: scale(1.6);
            box-shadow: 0 0 8px #38bdf8;
        }

        .metronome-dock-pulse.active-beat.accent {
            background-color: #ef4444;
            transform: scale(1.8);
            box-shadow: 0 0 10px #ef4444;
        /* Stage HUD Toast */
        .stage-hud {
            position: fixed;
            top: 75px;
            right: 20px;
            background: rgba(15, 23, 42, 0.92);
            border: 1px solid var(--live-border);
            color: #fff;
            padding: 0.6rem 1.2rem;
            border-radius: 9999px;
            font-size: 0.9rem;
            font-weight: 600;
            z-index: 2000;
            box-shadow: 0 10px 25px rgba(0,0,0,0.5);
            pointer-events: none;
            opacity: 0;
            transform: translateY(-8px);
            transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        }

        .stage-hud.show {
            opacity: 1;
            transform: translateY(0);
        }

        /* Stage Blackout Overlay */
        .stage-blackout {
            position: fixed;
            inset: 0;
            background: #000000 !important;
            z-index: 99999;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            user-select: none;
        }

        .stage-blackout-msg {
            color: #475569;
            font-size: 0.9rem;
            font-weight: 600;
            letter-spacing: 0.1em;
            text-transform: uppercase;
            text-align: center;
        }

        /* Pedal Help Modal Card */
        .pedal-modal-panel {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 480px;
            max-width: 92vw;
            background-color: var(--live-card);
            border: 1px solid var(--live-border);
            border-radius: 14px;
            padding: 1.5rem;
            box-shadow: 0 20px 45px rgba(0,0,0,0.7);
            z-index: 1300;
            animation: pedalModalFade 0.2s ease;
        }

        @keyframes pedalModalFade {
            from { opacity: 0; transform: translate(-50%, -46%); }
            to { opacity: 1; transform: translate(-50%, -50%); }
        }

        @media (max-width: 768px) {
            .live-viewer {
                padding: 1.25rem 1rem;
            }
            .live-song-title {
                font-size: 1.5rem;
            }
            pre.live-lyrics {
                font-size: 1.1rem;
            }
            .live-setlist-drawer {
                position: absolute;
                top: 0;
                bottom: 0;
                left: 0;
                z-index: 1100;
                box-shadow: 10px 0 25px rgba(0,0,0,0.5);
            }
        @media print {
            @page {
                size: A4 portrait;
                margin: 1.2cm 1cm 1.2cm 1cm;
            }
            html, body {
                background: #ffffff !important;
                color: #000000 !important;
                height: auto !important;
                overflow: visible !important;
            }
            .live-topbar, .live-dock, .autoscroll-bar, .live-setlist-drawer,
            .stage-hud, .stage-blackout, .btn, .btn-live, .live-key-controls,
            .metronome-overlay, .metronome-panel, .pedal-modal-panel {
                display: none !important;
            }
            .live-layout {
                height: auto !important;
                display: block !important;
            }
            .live-viewer {
                height: auto !important;
                overflow: visible !important;
                padding: 0 !important;
                background: #ffffff !important;
            }
            .song-slide {
                display: block !important;
                page-break-before: always !important;
                break-before: page !important;
                margin-bottom: 2cm !important;
            }
            .song-slide:first-of-type {
                page-break-before: avoid !important;
                break-before: avoid !important;
            }
            .live-song-header {
                border-bottom: 2px solid #000000 !important;
                padding-bottom: 0.5rem !important;
                margin-bottom: 1rem !important;
            }
            .live-song-title {
                color: #000000 !important;
                font-size: 1.8rem !important;
            }
            .live-song-artist {
                color: #475569 !important;
            }
            pre.live-lyrics {
                font-family: 'Ayuthaya', monospace !important;
                color: #000000 !important;
                line-height: 1.35 !important;
                white-space: pre-wrap !important;
                font-size: 11pt !important;
            }
            body.two-column pre.live-lyrics {
                column-count: 2 !important;
                column-gap: 2rem !important;
                column-rule: 1px dashed #cbd5e1 !important;
            }
            .cs-chord, .chord {
                color: #0369a1 !important;
                font-weight: 700 !important;
            }
        }

/* Unified Modal Backdrop & Smooth Panels */
.live-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2100;
    animation: liveFadeIn 0.2s ease-out;
}

@keyframes liveFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Tools Dropdown & Menu */
.live-tools-dropdown .dropdown-menu {
    background: var(--live-card);
    border: 1px solid var(--live-border);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
    border-radius: 12px;
    padding: 0.5rem;
    min-width: 230px;
    z-index: 2050;
}

.live-tools-dropdown .dropdown-item {
    color: var(--live-text);
    padding: 0.55rem 0.85rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    transition: all 0.15s ease;
}

.live-tools-dropdown .dropdown-item:hover,
.live-tools-dropdown .dropdown-item:focus {
    background: rgba(56, 189, 248, 0.12);
    color: var(--live-chord);
}

.live-tools-dropdown .dropdown-divider {
    border-color: var(--live-border);
    margin: 0.4rem 0;
}

/* QR Code Display Container */
.qr-code-container {
    background: #ffffff;
    padding: 12px;
    border-radius: 12px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.qr-code-container img,
.qr-code-container canvas,
.qr-code-container svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Screen Wake Lock Indicator */
.wake-lock-pill {
    font-size: 0.7rem;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.wake-lock-pill.disabled {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
    border-color: rgba(148, 163, 184, 0.2);
}

.wake-lock-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: livePulse 2s infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}
