/* ===========================
   Nav Rail (Desktop - Left Side)
   =========================== */
#navRail {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 56px !important;
    height: 100% !important;
    background: var(--primary-color) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    padding: 8px 0 !important;
    z-index: 100 !important;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    overflow: visible !important;
}

/* When nav rail has .hidden class, respect it */
#navRail.hidden {
    display: none !important;
}

.nav-rail-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    border: none !important;
    background: transparent !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 18px !important;
    cursor: pointer;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease;
    position: relative;
    margin: 2px 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
}

.nav-rail-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
}

.nav-rail-btn:focus {
    outline: none !important;
    box-shadow: none !important;
}

.nav-rail-btn.active {
    background: var(--secondary-color) !important;
    color: #fff !important;
    box-shadow: 0 0 12px var(--glow-color) !important;
}

/* Two-panel mode: dot indicators */
.nav-rail-btn.active-left::after {
    content: '' !important;
    position: absolute !important;
    bottom: 2px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 6px !important;
    height: 6px !important;
    border-radius: 50% !important;
    background: var(--secondary-color) !important;
    display: block !important;
}

.nav-rail-btn.active-right::after {
    content: '' !important;
    position: absolute !important;
    bottom: 2px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 6px !important;
    height: 6px !important;
    border-radius: 50% !important;
    background: var(--accent-color) !important;
    display: block !important;
}

.nav-rail-btn.active-left.active-right::after {
    width: 6px !important;
    height: 6px !important;
    background: var(--secondary-color) !important;
    box-shadow: 10px 0 0 var(--accent-color) !important;
    left: calc(50% - 5px) !important;
}

/* CSS Tooltip (right side) */
.nav-rail-btn[data-title]::before {
    content: attr(data-title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 12px;
    font-weight: 400;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 200;
    line-height: 1.4;
}

.nav-rail-btn[data-title]:hover::before {
    opacity: 1;
}

.nav-rail-divider {
    width: 32px;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    margin: 6px 0;
    flex-shrink: 0;
}

.nav-rail-spacer {
    flex: 1;
}

/* ===========================
   Mobile Tab Bar (Bottom)
   =========================== */
#mobileTabBar {
    display: none !important; /* hidden by default; shown via media query on mobile */
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 56px !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
    background: var(--primary-color) !important;
    z-index: 100 !important;
    align-items: center !important;
    justify-content: space-around !important;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
    flex-direction: row !important;
}

.tab-bar-btn {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px !important;
    border: none !important;
    background: transparent !important;
    color: rgba(255, 255, 255, 0.6) !important;
    font-size: 18px !important;
    cursor: pointer;
    padding: 4px 0 !important;
    transition: color 0.2s ease;
    height: 100%;
}

.tab-bar-btn span {
    font-size: 10px !important;
    font-weight: 500;
}

.tab-bar-btn.active {
    color: var(--accent-color) !important;
}

.tab-bar-btn:hover {
    color: #fff !important;
}

.tab-bar-btn:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* More popup */
#morePopup {
    display: none !important;
    position: fixed !important;
    bottom: calc(56px + env(safe-area-inset-bottom)) !important;
    right: 8px !important;
    background: var(--control-panel-bg) !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25) !important;
    border: 1px solid var(--border-subtle, rgba(114, 90, 122, 0.2)) !important;
    padding: 8px !important;
    z-index: 150 !important;
    min-width: 160px !important;
    flex-direction: column !important;
}

#morePopup.show {
    display: flex !important;
}

#morePopup button {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 10px 12px !important;
    border: none !important;
    background: transparent !important;
    color: var(--text-color) !important;
    font-size: 14px !important;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px !important;
    transition: background 0.15s ease;
    text-align: left !important;
}

#morePopup button:hover {
    background: var(--surface-hover, #ebeef2) !important;
}

#morePopup button i {
    width: 20px;
    text-align: center;
    color: var(--secondary-color);
}

/* ===========================
   Menu Drawer (Slide-out)
   =========================== */
#menuDrawer {
    display: none !important;
}

#menuDrawer.open {
    display: block !important;
}

.menu-drawer-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.4) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease;
    z-index: 1199 !important;
}

#menuDrawer.open .menu-drawer-backdrop {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.menu-drawer-content {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 280px !important;
    height: 100% !important;
    background: var(--control-panel-bg) !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s ease !important;
    z-index: 1200 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    pointer-events: auto !important;
}

#menuDrawer.open .menu-drawer-content {
    transform: translateX(0) !important;
}

.menu-drawer-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 16px !important;
    background: var(--primary-color) !important;
    color: #fff !important;
    font-size: 18px !important;
    font-weight: 600;
    flex-shrink: 0;
}

.menu-drawer-close {
    background: none !important;
    border: none !important;
    color: #fff !important;
    font-size: 24px !important;
    cursor: pointer;
    padding: 0 4px !important;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s ease;
}

.menu-drawer-close:hover {
    opacity: 1;
}

.menu-section {
    padding: 8px 12px;
}

.menu-section-label {
    font-size: 11px !important;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--tertiary-color) !important;
    padding: 8px 4px 4px;
    margin-bottom: 4px;
}

.menu-section button {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 10px 8px !important;
    border: none !important;
    background: transparent !important;
    color: var(--text-color) !important;
    font-size: 14px !important;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px !important;
    transition: background 0.15s ease;
    text-align: left !important;
}

.menu-section button:hover {
    background: var(--surface-hover, #ebeef2) !important;
}

.menu-section button i {
    width: 20px;
    text-align: center;
    color: var(--secondary-color);
    font-size: 15px;
}

.menu-footer {
    margin-top: auto;
    border-top: 1px solid rgba(114, 90, 122, 0.15);
    padding-top: 8px;
}

/* Drawer toggle row (for buzzer/danmaku inside drawer) */
.menu-toggle-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 10px 8px !important;
    border-radius: 8px;
}

.menu-toggle-row .menu-toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.menu-toggle-row .menu-toggle-label i {
    width: 20px;
    text-align: center;
    color: var(--secondary-color);
    font-size: 15px;
}

/* ===========================
   Panel Header (Uniform bar for each panel)
   =========================== */
.panel-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 12px !important;
    background: var(--primary-color) !important;
    color: #fff !important;
    flex-shrink: 0 !important;
    border-bottom: 2px solid var(--tertiary-color);
    font-size: 14px !important;
    font-weight: 600;
    box-sizing: border-box !important;
}

.panel-header-title {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    white-space: nowrap;
}

.panel-header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
}

/* ===========================
   Panel Transitions
   =========================== */
.panel-transitioning {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.panel-visible {
    opacity: 1;
    transition: opacity 0.15s ease;
}

/* ===========================
   Focused Pane Indicator
   =========================== */
.pane-focused {
    box-shadow: inset 0 0 0 2px var(--accent-color);
}

/* ===========================
   Two-panel popover (replaces modal)
   =========================== */
#panelPopover {
    display: none !important;
    position: fixed !important;
    background: var(--control-panel-bg) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
    border: 1px solid var(--border-subtle, rgba(114, 90, 122, 0.2)) !important;
    padding: 8px !important;
    z-index: 300 !important;
    min-width: 120px !important;
    flex-direction: column !important;
}

#panelPopover.show {
    display: flex !important;
}

#panelPopover button {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 8px 12px !important;
    border: none !important;
    background: transparent !important;
    color: var(--text-color) !important;
    font-size: 13px !important;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px !important;
    text-align: left !important;
    transition: background 0.15s ease;
}

#panelPopover button:hover {
    background: var(--surface-hover, #ebeef2) !important;
}

/* ===========================
   Responsive: Mobile (<= 768px)
   =========================== */
@media (max-width: 768px) {
    #navRail {
        display: none !important;
    }
    #mobileTabBar {
        display: flex !important;
    }
}

/* ===========================
   Responsive: Desktop (> 768px)
   =========================== */
@media (min-width: 769px) {
    #mobileTabBar {
        display: none !important;
    }
    #morePopup {
        display: none !important;
    }
    #morePopup.show {
        display: none !important;
    }
}

/* ===========================
   Legacy: Keep old #menu-pane and #controlPanel hidden
   =========================== */
#menu-pane {
    display: none !important;
}

#controlPanel {
    display: none !important;
}

/* ===========================
   Hide old bottom buttons bar
   =========================== */
#bottomButtons {
    display: none !important;
}
