/* ==========================================================================
   Drive Players - CSS Design System
   Version: 2.9.4
   ========================================================================== */

/* ---------- CSS Variables / Design Tokens ---------- */
:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #242424;
    --bg-hover: #2a2a2a;
    --bg-active: #3a1a1a;
    
    --text-primary: #f1f1f1;
    --text-secondary: #aaaaaa;
    --text-muted: #717171;
    
    --accent: #ff4444;
    --accent-hover: #ff6666;
    --accent-glow: rgba(255, 68, 68, 0.3);
    --accent-gradient: linear-gradient(135deg, #ff6b6b, #ee5a24);
    
    --border-color: #303030;
    --border-subtle: #222222;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);
    
    --header-height: 60px;
    --sidebar-width: 420px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
}

input {
    font-family: inherit;
    border: none;
    outline: none;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ---------- Header ---------- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(26, 26, 26, 0.92);
}

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

.menu-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-primary);
    transition: background var(--transition-fast), color var(--transition-fast);
    position: relative;
}

.menu-toggle:hover {
    background: var(--bg-tertiary);
}

/* Accent colour on toggle button when sidebar is hidden */
body.sidebar-is-closed #menu-toggle {
    color: var(--accent);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity var(--transition-fast);
}

.logo:hover {
    opacity: 0.85;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    white-space: nowrap;
}

.logo-accent {
    color: var(--accent);
}

.logo-version {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.3px;
    margin-left: 2px;
    vertical-align: middle;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

/* ---------- Search Bar ---------- */
.search-bar {
    flex: 1;
    max-width: 640px;
    margin: 0 auto;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 40px;
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.search-input {
    flex: 1;
    height: 40px;
    padding: 0 16px;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-btn {
    width: 56px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-left: 1px solid var(--border-color);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.search-btn:hover {
    background: var(--accent);
    color: white;
}

/* ---------- Header Right ---------- */
.header-right {
    flex-shrink: 0;
}

.video-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    white-space: nowrap;
}

/* ---------- Main Content ---------- */
.main-content {
    padding-top: var(--header-height);
    min-height: 100vh;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Landing page: no header, no top padding */
.page-landing .main-content {
    padding-top: 0;
}

/* ---------- Landing Section ---------- */
.landing {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
}

.landing-content {
    text-align: center;
    max-width: 600px;
    width: 100%;
    animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.landing-icon {
    margin-bottom: 24px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.landing-title {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: -2px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text-primary) 40%, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.landing-version {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid rgba(255, 68, 68, 0.25);
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.landing-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.6;
}

.landing-guide {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.9;
    margin-bottom: 32px;
    opacity: 0.85;
}

/* ---------- Landing Form ---------- */
.landing-form {
    margin-bottom: 32px;
}

.landing-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.landing-input {
    flex: 1;
    height: 52px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.landing-input:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.landing-input::placeholder {
    color: var(--text-muted);
}

.landing-submit {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 52px;
    padding: 0 24px;
    background: var(--accent-gradient);
    color: white;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-md);
    white-space: nowrap;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.landing-submit:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.landing-submit:active {
    transform: translateY(0);
}

/* ---------- Hint Cards ---------- */
.landing-hints {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.hint-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: transform var(--transition-normal), border-color var(--transition-normal);
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
}

.hint-card:nth-child(1) { animation-delay: 0.2s; }
.hint-card:nth-child(2) { animation-delay: 0.35s; }
.hint-card:nth-child(3) { animation-delay: 0.5s; }

.hint-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.hint-icon {
    font-size: 32px;
}

.hint-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: center;
}

.hint-text strong {
    font-size: 14px;
    color: var(--accent);
}

.hint-text span {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ---------- Watch History Section (Landing) ---------- */
.history-section {
    width: 100%;
    max-width: 600px;
    margin-top: 36px;
    text-align: left;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.history-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.history-clear {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--bg-tertiary);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.history-clear:hover {
    color: var(--accent);
    background: rgba(255, 68, 68, 0.1);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    transition: background var(--transition-fast);
    border-left: 3px solid transparent;
}

.history-item:hover {
    background: var(--bg-hover);
    border-left-color: var(--accent);
}

.history-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(255, 68, 68, 0.12);
    color: var(--accent);
}

.history-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.history-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.hi-res {
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
    padding: 1px 4px;
    border: 1px solid rgba(255,68,68,0.3);
    border-radius: 3px;
}

.hi-folder {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.hi-time {
    color: var(--text-muted);
    opacity: 0.7;
    margin-left: auto;
    white-space: nowrap;
    font-size: 11px;
}

/* ---------- Error Section ---------- */
.error-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-height));
    padding: 40px 20px;
}

.error-content {
    text-align: center;
    max-width: 500px;
    animation: fadeInUp 0.5s ease;
}

.error-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.error-content h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

.error-message {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.btn-retry {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: var(--accent-gradient);
    color: white;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-retry:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* ---------- Player Layout ---------- */
.player-layout {
    display: flex;
    gap: 0;
    padding: 24px;
    max-width: 1800px;
    margin: 0 auto;
    animation: fadeInUp 0.5s ease;
    transition: padding var(--transition-slow);
}

/* Level 2: sidebar hidden — video wider but not full */
.player-layout.sidebar-closed {
    max-width: 1200px;
}

/* Level 3: theater — full viewport width */
.player-layout.sidebar-theater {
    max-width: 100%;
    padding: 0;
}

/* ---------- Player Main ---------- */
.player-main {
    flex: 1 1 0;
    min-width: 0;
    width: 0;
    transition: flex var(--transition-slow);
}

.video-container {
    /* Modern, reliable 16:9 — works correctly in all flex/grid contexts */
    position: relative;
    width: 100%;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

/* Plyr fills its container naturally */
.video-container .plyr {
    border-radius: var(--radius-lg);
}

.video-container .plyr video {
    border-radius: var(--radius-lg);
}

/* Fallback iframe (when Plyr can't handle the stream) */
.video-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* When falling back to iframe, container needs aspect-ratio */
.video-container:has(.video-iframe) {
    aspect-ratio: 16 / 9;
}

/* ========== Plyr Theme Customization ========== */

/* Accent color override for Plyr */
:root {
    --plyr-color-main: var(--accent);
    --plyr-video-background: #000;
    --plyr-badge-background: var(--accent);
    --plyr-badge-text-color: #fff;
    --plyr-badge-border-radius: 4px;
    --plyr-control-icon-size: 18px;
    --plyr-control-spacing: 10px;
    --plyr-video-control-color: #fff;
    --plyr-video-control-color-hover: #fff;
    --plyr-video-control-background-hover: var(--accent);
    --plyr-audio-control-color: #fff;
    --plyr-audio-control-color-hover: #fff;
    --plyr-menu-background: rgba(26, 26, 26, 0.95);
    --plyr-menu-color: var(--text-primary);
    --plyr-menu-border-color: var(--border-color);
    --plyr-menu-shadow: var(--shadow-lg);
    --plyr-tooltip-background: var(--bg-tertiary);
    --plyr-tooltip-color: var(--text-primary);
    --plyr-tooltip-radius: 6px;
    --plyr-font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --plyr-font-size-base: 14px;
    --plyr-font-size-small: 12px;
    --plyr-font-size-large: 18px;
    --plyr-font-size-xlarge: 22px;
    --plyr-font-size-time: 13px;
    --plyr-range-thumb-height: 14px;
    --plyr-range-thumb-background: #fff;
    --plyr-range-thumb-shadow: 0 1px 4px rgba(0,0,0,0.4);
    --plyr-range-track-height: 4px;
    --plyr-range-fill-background: var(--accent);
    --plyr-progress-loading-background: rgba(255,255,255,0.15);
    --plyr-progress-loading-size: 25px;
}

/* Plyr big play button enhancement */
.plyr__control--overlaid {
    background: var(--accent-gradient) !important;
    border: none !important;
    box-shadow: 0 4px 20px rgba(255, 68, 68, 0.4) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    transform: translate(-50%, -50%) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    width: 84px !important;
    height: 84px !important;
}

.plyr__control--overlaid svg {
    display: block !important;
    margin: 0 auto !important;
}

/* Must include translate(-50%, -50%) to keep it centered when scaling */
.plyr__control--overlaid:hover,
.plyr__control--overlaid:focus {
    transform: translate(-50%, -50%) scale(1.1) !important;
    box-shadow: 0 6px 30px rgba(255, 68, 68, 0.6) !important;
}

/* Plyr controls bar glass effect */
.plyr--video .plyr__controls {
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85)) !important;
    padding: 24px 12px 12px !important;
}

/* Plyr menu styling for dark theme */
.plyr__menu__container {
    background: rgba(26, 26, 26, 0.96) !important;
    backdrop-filter: blur(12px) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-lg) !important;
    color: var(--text-primary) !important;
}

.plyr__menu__container .plyr__control {
    color: var(--text-primary) !important;
}

.plyr__menu__container .plyr__control--back {
    border-bottom: 1px solid var(--border-color);
}

.plyr__menu__container .plyr__control:hover,
.plyr__menu__container .plyr__control--forward:hover {
    background: var(--bg-hover) !important;
}

.plyr__menu__container .plyr__control[role=menuitemradio][aria-checked=true]::before {
    background: var(--accent) !important;
}

/* Tooltip overrides */
.plyr__tooltip {
    font-family: var(--plyr-font-family) !important;
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-radius: 6px !important;
    box-shadow: var(--shadow-md) !important;
    font-size: 12px !important;
    padding: 5px 10px !important;
}

.plyr__tooltip::before {
    border-top-color: var(--bg-tertiary) !important;
}

/* Progress bar hover effect */
.plyr--full-ui input[type=range] {
    color: var(--accent) !important;
}

/* Volume slider */
.plyr__volume input[type=range] {
    color: var(--accent) !important;
}


/* ---------- Fallback Notice Bar ---------- */
.fallback-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: rgba(255, 165, 0, 0.08);
    border: 1px solid rgba(255, 165, 0, 0.25);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    font-size: 13px;
    color: var(--text-secondary);
}

.fallback-notice span {
    flex: 1;
    min-width: 160px;
}

.btn-try-proxy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--accent-gradient);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    white-space: nowrap;
}

.btn-try-proxy:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.btn-open-drive {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
}

.btn-open-drive:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ---------- Video Info ---------- */
.video-info {
    padding: 16px 4px;
}

.video-title {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 16px;
    word-break: break-word;
}

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

.playback-switcher {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    width: fit-content;
    margin-bottom: 2px;
}

.playback-switch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 8px 14px;
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.playback-switch-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.playback-switch-btn.active {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 10px 24px rgba(255, 107, 107, 0.2);
}

.playback-switch-btn svg {
    flex-shrink: 0;
    opacity: 0.88;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    transition: background var(--transition-fast), transform var(--transition-fast);
    cursor: pointer;
}

.btn-action:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.btn-action svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

/* ---------- Mobile Sheet Helpers ---------- */
.mobile-sheet-backdrop,
.mobile-sheet-handle,
.mobile-sheet-grip,
.mobile-sheet-trigger-row,
.btn-mobile-sheet-trigger {
    display: none;
}

/* ---------- Breadcrumb Navigation ---------- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 4px 12px;
    flex-wrap: wrap;
    font-size: 13px;
}

.bc-home {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: var(--text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.bc-home:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.bc-sep {
    display: flex;
    align-items: center;
    color: var(--text-muted);
}

.bc-link {
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.bc-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.bc-current {
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Subfolder segment in breadcrumb (visual only, no link) */
.bc-subfolder {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.25);
    color: #ff8a8a;
    font-weight: 600;
    font-size: 13px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bc-subfolder svg {
    flex-shrink: 0;
    opacity: 0.8;
}

/* ---------- Folder-only placeholder ---------- */
.folder-only-placeholder {
    position: absolute;   /* fills the aspect-ratio .video-container */
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-muted);
    padding: 24px;
    text-align: center;
}

.folder-only-placeholder svg {
    opacity: 0.4;
}

.folder-only-placeholder p {
    font-size: 14px;
    line-height: 1.6;
}

/* ---------- Collapsible Folder Groups in Sidebar ---------- */
.collapse-folder {
    margin: 2px 4px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: background var(--transition-fast);
}

.collapse-folder + .collapse-folder {
    margin-top: 2px;
}

/* Folder header button */
.collapse-folder-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: left;
    color: inherit;
    font-family: inherit;
}

.collapse-folder-header:hover {
    background: var(--bg-hover);
}

.collapse-folder.open > .collapse-folder-header {
    background: rgba(255, 107, 107, 0.06);
}

.collapse-folder-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 8px;
    background: rgba(255, 107, 107, 0.08);
    transition: background var(--transition-fast);
}

.collapse-folder.open > .collapse-folder-header .collapse-folder-icon {
    background: rgba(255, 107, 107, 0.15);
}

.collapse-folder-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.collapse-folder-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.collapse-folder-count {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

/* Chevron (rotates on open) */
.collapse-folder-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color var(--transition-fast);
}

.collapse-folder.open > .collapse-folder-header .collapse-folder-chevron {
    transform: rotate(180deg);
    color: var(--accent);
}

/* Collapsible body - uses grid trick for smooth animation */
.collapse-folder-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.collapse-folder.open > .collapse-folder-body {
    grid-template-rows: 1fr;
}

/* Inner wrapper - the ONLY direct child, overflow:hidden is required */
.collapse-folder-inner {
    overflow: hidden;
    border-left: 2px solid rgba(255, 107, 107, 0.2);
    margin-left: 16px;
    border-radius: 0 0 0 4px;
}

/* Fade in when open */
.collapse-folder-body .collapse-folder-inner {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.25s ease 0.05s, transform 0.25s ease 0.05s;
}

.collapse-folder.open > .collapse-folder-body .collapse-folder-inner {
    opacity: 1;
    transform: translateY(0);
}

/* Inner wrapper for videos */
.collapse-folder-inner .video-item {
    padding-left: 16px;
    margin: 0 4px 0 0;
    border-left: none;
    border-radius: var(--radius-sm);
}

.collapse-folder-inner .video-item.active {
    background: var(--bg-active);
    position: relative;
}

.collapse-folder-inner .video-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.collapse-folder-inner .video-item:last-child {
    margin-bottom: 4px;
}

/* Empty subfolder state */
.collapse-folder-empty {
    padding: 10px 16px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

/* ---------- List Divider ---------- */
.list-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px;
    margin: 4px 4px;
}

.list-divider::before,
.list-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

.list-divider span {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    white-space: nowrap;
}

/* ---------- Empty Folder State ---------- */
.empty-folder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 24px;
    color: var(--text-muted);
    text-align: center;
}

.empty-folder svg {
    opacity: 0.35;
}

.empty-folder p {
    font-size: 13px;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    margin-left: 24px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--header-height) - 48px);
    position: sticky;
    top: calc(var(--header-height) + 24px);
    /* Collapse transition */
    transition:
        width var(--transition-slow),
        margin-left var(--transition-slow),
        opacity var(--transition-slow);
    overflow: hidden;
}

/* Closed state — applied on player-layout */
.player-layout.sidebar-closed .sidebar {
    width: 0;
    margin-left: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Expand player when sidebar is closed */
.player-layout.sidebar-closed .player-main {
    max-width: 100%;
}

/* Theater mode: video even wider (full layout) */
.player-layout.sidebar-theater .sidebar {
    width: 0;
    margin-left: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

.player-layout.sidebar-theater .player-main {
    max-width: 100%;
}

/* ---------- Sidebar Open Button (floating, shown when sidebar closed) ---------- */
.sidebar-open-btn {
    display: none; /* hidden by default */
    align-items: center;
    gap: 8px;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    padding: 10px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.sidebar-open-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: transparent;
    transform: translateY(-2px);
}

/* Only show when sidebar is closed, on desktop */
@media (min-width: 1025px) {
    .page-player .player-layout.sidebar-closed ~ * .sidebar-open-btn,
    .player-layout.sidebar-closed .sidebar-open-btn {
        display: flex;
    }
}

/* Show as floating pill regardless of position in DOM */
.page-player.sidebar-is-closed .sidebar-open-btn {
    display: flex;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    min-height: 56px;
}

/* Back button in sidebar */
.sidebar-back {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.sidebar-back:hover {
    background: var(--accent);
    color: white;
    transform: translateX(-2px);
}

.sidebar-title-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    min-width: 0;
}

.sidebar-folder-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

.sidebar-count {
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    flex-shrink: 0;
}

/* ---------- Sidebar Toggle Button ---------- */
.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    margin-left: 4px;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-normal);
}

.sidebar-toggle-btn:hover {
    background: var(--accent);
    color: #fff;
}

/* Rotate arrow when sidebar is closed */
.sidebar-closed .sidebar-toggle-btn svg {
    transform: rotate(180deg);
}

/* ---------- Sidebar Search ---------- */
.sidebar-search {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-bottom: none;
}

.filter-input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color var(--transition-fast);
}

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

.filter-input::placeholder {
    color: var(--text-muted);
}

/* ---------- Video List ---------- */
.video-list {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    padding: 4px 0;
}

.video-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: 0 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    cursor: pointer;
    border-left: 3px solid transparent;
}

.video-item:hover {
    background: var(--bg-hover);
}

.video-item.active {
    background: var(--bg-active);
    border-left-color: var(--accent);
}

.video-item-index {
    width: 24px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Playing Animation */
.playing-indicator {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    height: 16px;
}

.playing-indicator span {
    width: 3px;
    background: var(--accent);
    border-radius: 1px;
    animation: playingBar 1.2s ease-in-out infinite;
}

.playing-indicator span:nth-child(1) {
    height: 60%;
    animation-delay: 0s;
}

.playing-indicator span:nth-child(2) {
    height: 100%;
    animation-delay: 0.2s;
}

.playing-indicator span:nth-child(3) {
    height: 40%;
    animation-delay: 0.4s;
}

@keyframes playingBar {
    0%, 100% { transform: scaleY(0.5); }
    50% { transform: scaleY(1); }
}

/* ---------- Video Thumbnail ---------- */
.video-item-thumb {
    position: relative;
    width: 168px;
    height: 94px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-tertiary);
}

.video-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-play-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.video-item:hover .thumb-play-icon {
    opacity: 1;
}

/* ---------- Video Item Info ---------- */
.video-item-info {
    flex: 1;
    min-width: 0;
    padding: 0;
}

.video-item-title {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 3px;
}

.video-item-ext {
    font-size: 11px;
    color: var(--text-muted);
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border-radius: 4px;
}

/* ---------- Video Item Meta ---------- */
.video-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.item-duration {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: var(--text-secondary);
}

.item-duration svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.item-resolution {
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
    padding: 1px 5px;
    border: 1px solid rgba(255, 68, 68, 0.3);
    border-radius: 3px;
}

.item-size {
    font-size: 11px;
    color: var(--text-muted);
}

.item-date {
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.8;
    margin-left: auto;
}

/* ---------- Thumb Duration ---------- */
.thumb-duration {
    position: absolute;
    bottom: 4px;
    right: 4px;
    padding: 1px 6px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    font-size: 11px;
    font-weight: 500;
    border-radius: 3px;
    letter-spacing: 0.3px;
    z-index: 2;
}

/* ---------- Video Meta Badges ---------- */
.video-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.meta-badge.quality {
    background: rgba(255, 68, 68, 0.15);
    color: var(--accent);
    border: 1px solid rgba(255, 68, 68, 0.25);
    font-weight: 700;
}

.meta-badge.duration {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.meta-badge.size {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.meta-badge.ext {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---------- Subfolders Section ---------- */
.subfolders {
    margin-top: 24px;
    padding: 0 4px;
}

.subfolders-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.subfolders-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.subfolder-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.subfolder-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* ---------- API Key Notice ---------- */
.api-key-notice {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    text-align: left;
    padding: 16px 20px;
    margin-bottom: 32px;
    background: rgba(255, 193, 7, 0.08);
    border: 1px solid rgba(255, 193, 7, 0.25);
    border-radius: var(--radius-md);
}

.notice-icon {
    font-size: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

.notice-content {
    flex: 1;
}

.notice-content strong {
    display: block;
    font-size: 14px;
    color: #ffc107;
    margin-bottom: 4px;
}

.notice-content p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.notice-content code {
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--accent);
}

/* ---------- Error Actions ---------- */
.error-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* ---------- Toast Notification ---------- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    padding: 12px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all var(--transition-normal);
    z-index: 1000;
    pointer-events: none;
}

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

/* ========================================================================== 
   Responsive Design
   ========================================================================== */

@media (max-width: 1200px) {
    .sidebar {
        width: 360px;
    }
}

/* ==================== Tablet (≤ 1024px) ==================== */
@media (max-width: 1024px) {
    .player-layout {
        flex-direction: column;
        padding: 0;
        gap: 0;
    }

    .player-main {
        width: 100%;
    }

    .sidebar {
        width: 100%;
        margin-left: 0;
        margin-top: 0;
        position: static;
        max-height: 50vh;
        border-radius: 0;
        /* Mobile collapse: height-based instead of width-based */
        transition:
            max-height var(--transition-slow),
            opacity var(--transition-slow),
            margin-top var(--transition-slow);
    }

    .sidebar-header {
        border-radius: 0;
    }

    /* On mobile: collapse by height, not width */
    .player-layout.sidebar-closed .sidebar {
        width: 100%;
        margin-left: 0;
        max-height: 0;
        margin-top: 0;
        opacity: 0;
        pointer-events: none;
    }

    .video-item-thumb {
        width: 140px;
        height: 79px;
    }

    /* No border-radius on video for seamless look */
    .video-container {
        border-radius: 0;
    }

    .video-container .plyr,
    .video-container .plyr video {
        border-radius: 0;
    }

    /* Video info padding */
    .video-info {
        padding: 12px 16px;
    }

    /* Breadcrumb inside padding */
    .breadcrumb {
        padding: 8px 16px;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .breadcrumb::-webkit-scrollbar {
        display: none;
    }
}

/* ==================== Phone (≤ 768px) ==================== */
@media (max-width: 768px) {
    :root {
        --header-height: 48px;
    }

    body.mobile-sheet-lock {
        overflow: hidden;
        overscroll-behavior: none;
    }

    .header {
        padding: 0 10px;
        gap: 8px;
        height: var(--header-height);
    }

    .logo-text {
        display: none;
    }

    .logo-version {
        display: none;
    }

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

    .menu-toggle {
        width: 36px;
        height: 36px;
    }

    .search-bar {
        max-width: none;
    }

    .search-input {
        height: 36px;
        font-size: 13px;
        padding: 0 10px;
    }

    .search-btn {
        width: 44px;
        height: 36px;
    }

    .video-count {
        display: none;
    }

    body:has(.mobile-sheet-trigger-row) .sidebar-open-btn,
    body:has(.mobile-sheet-trigger-row) .page-player.sidebar-is-closed .sidebar-open-btn,
    body:has(.mobile-sheet-trigger-row) .player-layout.sidebar-closed .sidebar-open-btn {
        display: none !important;
    }

    /* --- Player layout --- */
    .player-layout {
        padding: 0;
    }

    .player-main {
        width: 100%;
        position: relative;
        z-index: 1;
    }

    .video-container {
        border-radius: 14px;
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
        margin: 0 10px;
    }

    .video-container .plyr,
    .video-container .plyr video {
        border-radius: 14px;
    }

    /* --- Video title & info --- */
    .video-title {
        font-size: 15px;
        line-height: 1.3;
        margin-bottom: 0;
    }

    .video-info {
        display: grid;
        gap: 10px;
        padding: 10px 12px 14px;
    }

    .video-meta {
        margin-bottom: 0;
        gap: 5px;
    }

    .playback-switcher {
        width: 100%;
        justify-content: center;
    }

    .playback-switch-btn {
        flex: 1 1 0;
        min-height: 40px;
        padding: 8px 10px;
        font-size: 11px;
    }

    .meta-badge {
        padding: 3px 7px;
        font-size: 10px;
        min-height: 24px;
    }

    .meta-badge svg {
        width: 11px;
        height: 11px;
    }

    /* --- Action buttons --- */
    .video-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .btn-action {
        width: 100%;
        min-height: 42px;
        padding: 9px 12px;
        border-radius: 14px;
        display: inline-flex;
        align-items: center;
        justify-content: flex-start;
        gap: 6px;
        font-size: 12px;
    }

    .btn-action span {
        display: inline;
        line-height: 1.2;
    }

    .mobile-sheet-trigger-row {
        display: flex;
        padding: 8px 10px 0;
        position: relative;
        z-index: 2;
    }

    .btn-mobile-sheet-trigger {
        display: inline-flex;
        width: 100%;
        justify-content: center;
        min-height: 42px;
        padding: 10px 14px;
        border-radius: 16px;
        background: linear-gradient(180deg, rgba(42, 42, 42, 0.96), rgba(26, 26, 26, 0.98));
        border: 1px solid rgba(255, 107, 107, 0.18);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.24);
    }

    .btn-mobile-sheet-trigger span {
        display: inline;
    }

    .mobile-sheet-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(5, 5, 5, 0.58);
        backdrop-filter: blur(6px);
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-normal);
        z-index: 250;
    }

    body.mobile-sheet-open .mobile-sheet-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-sheet-handle {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px 0 6px;
        background: linear-gradient(180deg, rgba(36, 36, 36, 0.98), rgba(26, 26, 26, 0.98));
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
        cursor: pointer;
    }

    .mobile-sheet-grip {
        display: block;
        width: 44px;
        height: 5px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.24);
    }

    /* --- Sidebar as phone bottom sheet --- */
    .sidebar {
        width: auto;
        max-height: min(72vh, 560px);
        height: auto;
        margin: 0;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        z-index: 260;
        border-radius: 24px 24px 0 0;
        background: linear-gradient(180deg, rgba(36, 36, 36, 0.99), rgba(15, 15, 15, 0.995));
        box-shadow: 0 -18px 48px rgba(0, 0, 0, 0.52);
        transform: translateY(calc(100% + 16px));
        opacity: 0;
        pointer-events: none;
        overflow: hidden;
        overscroll-behavior: contain;
        transition:
            transform var(--transition-slow),
            opacity var(--transition-normal),
            box-shadow var(--transition-normal);
    }

    .player-layout.sidebar-closed .sidebar,
    .player-layout.sidebar-theater .sidebar {
        width: auto;
        max-height: min(72vh, 560px);
        height: auto;
        margin: 0;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        transform: translateY(calc(100% + 16px));
        overflow: hidden;
    }

    body.mobile-sheet-open .sidebar,
    body.mobile-sheet-open .player-layout.sidebar-closed .sidebar,
    body.mobile-sheet-open .player-layout.sidebar-theater .sidebar {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
        max-height: min(72vh, 560px);
        margin: 0;
    }

    .sidebar-header {
        padding: 12px 14px;
        min-height: 54px;
        background: rgba(26, 26, 26, 0.98);
        border-left: none;
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: 0;
    }

    .sidebar-title {
        font-size: 13px;
    }

    .sidebar-folder-name {
        max-width: 130px;
    }

    .sidebar-count {
        font-size: 11px;
        padding: 3px 8px;
    }

    .sidebar-search {
        padding: 8px 12px;
        background: rgba(26, 26, 26, 0.98);
    }

    .filter-input {
        height: 38px;
        font-size: 12px;
    }

    /* --- Video list items: compact --- */
    .video-list {
        padding: 6px 0 calc(env(safe-area-inset-bottom, 0px) + 12px);
        overscroll-behavior: contain;
    }

    .video-item {
        padding: 8px 10px;
        gap: 8px;
        margin: 0 4px;
    }

    .video-item-thumb {
        width: 110px;
        height: 62px;
        border-radius: 6px;
    }

    .video-item-title {
        font-size: 12px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        margin-bottom: 4px;
    }

    .video-item-meta {
        gap: 6px;
    }

    .item-resolution {
        font-size: 9px;
        padding: 1px 4px;
    }

    .item-size {
        font-size: 10px;
    }

    .thumb-duration {
        font-size: 10px;
        padding: 1px 4px;
    }

    /* --- Collapsible folder items compact --- */
    .collapse-folder {
        margin: 1px 2px;
    }

    .collapse-folder-header {
        padding: 8px 10px;
        gap: 8px;
    }

    .collapse-folder-icon {
        width: 28px;
        height: 28px;
    }

    .collapse-folder-icon svg {
        width: 16px;
        height: 16px;
    }

    .collapse-folder-name {
        font-size: 12px;
    }

    .collapse-folder-count {
        font-size: 10px;
    }

    .collapse-folder-inner .video-item {
        padding-left: 10px;
    }

    /* --- Breadcrumb --- */
    .breadcrumb {
        padding: 4px 10px 2px;
        font-size: 11px;
        gap: 1px;
    }

    .bc-home {
        width: 24px;
        height: 24px;
    }

    .bc-link,
    .bc-current {
        padding: 2px 5px;
        font-size: 11px;
        max-width: 124px;
    }

    .bc-subfolder {
        max-width: 132px;
        padding: 3px 7px;
        font-size: 10px;
    }

    /* --- Landing page --- */
    .landing {
        align-items: flex-start;
        padding: 20px 14px 32px;
        min-height: calc(100vh - var(--header-height));
    }

    .landing-content {
        max-width: 100%;
        text-align: left;
    }

    .landing-icon {
        margin-bottom: 16px;
        display: flex;
        justify-content: flex-start;
    }

    .landing-icon svg {
        width: 52px;
        height: 52px;
    }

    .landing-title {
        font-size: 28px;
        letter-spacing: -1.2px;
        margin-bottom: 6px;
    }

    .landing-subtitle {
        font-size: 14px;
        margin-bottom: 18px;
        line-height: 1.55;
        max-width: 28ch;
    }

    .landing-version {
        font-size: 11px;
        margin-bottom: 10px;
    }

    .landing-guide {
        margin-bottom: 22px;
        padding: 14px 16px;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 18px;
        font-size: 13px;
        line-height: 1.8;
        opacity: 1;
    }

    .landing-input-group {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .landing-input {
        height: 56px;
        font-size: 14px;
        padding: 12px 16px;
        border-radius: 16px;
        box-shadow: 0 10px 26px rgba(0, 0, 0, 0.2);
    }

    .landing-submit {
        width: 100%;
        height: 52px;
        justify-content: center;
        border-radius: 16px;
        font-size: 14px;
    }

    .landing-form {
        margin-bottom: 20px;
    }

    .landing-hints {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .hint-card {
        flex-direction: row;
        align-items: flex-start;
        gap: 12px;
        padding: 14px 14px;
        text-align: left;
        border-radius: 16px;
    }

    .hint-icon {
        font-size: 22px;
        line-height: 1;
    }

    .hint-text {
        text-align: left;
    }

    .hint-text strong {
        font-size: 13px;
    }

    .hint-text span {
        font-size: 12px;
        line-height: 1.45;
    }

    .history-section {
        margin-top: 24px;
        max-width: 100%;
    }

    .history-header {
        align-items: flex-start;
        gap: 10px;
    }

    .history-title {
        font-size: 13px;
    }

    .history-clear {
        flex-shrink: 0;
        font-size: 11px;
        padding: 5px 8px;
    }

    .history-list {
        border-radius: 16px;
    }

    .history-item {
        align-items: flex-start;
        gap: 10px;
        padding: 10px 12px;
    }

    .history-item-icon {
        width: 30px;
        height: 30px;
    }

    .history-item-name {
        font-size: 12px;
        white-space: normal;
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .history-item-meta {
        gap: 4px 6px;
        font-size: 10px;
    }

    .hi-folder {
        max-width: 100%;
    }

    .hi-time {
        margin-left: 0;
    }

    /* --- Toast on mobile --- */
    .toast {
        left: 12px;
        right: 12px;
        bottom: 16px;
        transform: translateY(80px);
        text-align: center;
        font-size: 13px;
        padding: 10px 16px;
    }

    .toast.show {
        transform: translateY(0);
    }

    /* --- API key notice --- */
    .api-key-notice {
        padding: 12px 14px;
        gap: 10px;
    }

    .notice-icon {
        font-size: 20px;
    }

    .notice-content strong {
        font-size: 13px;
    }

    .notice-content p {
        font-size: 12px;
    }

    /* Plyr mobile tweaks */
    .plyr--video .plyr__controls {
        display: flex !important;
        padding: 18px 8px 8px !important;
        gap: 6px;
        align-items: center;
        flex-wrap: nowrap;
    }

    .plyr--video .plyr__control {
        padding: 6px !important;
        min-width: 32px;
        min-height: 32px;
    }

    .plyr--video .plyr__controls__item {
        display: flex;
        align-items: center;
        align-self: center;
        margin: 0;
        min-width: 0;
    }

    .plyr--video .plyr__controls__item.plyr__control[data-plyr="restart"],
    .plyr--video .plyr__controls__item.plyr__control[data-plyr="rewind"],
    .plyr--video .plyr__controls__item.plyr__control[data-plyr="fast-forward"],
    .plyr--video .plyr__controls__item.plyr__time,
    .plyr--video .plyr__controls__item.plyr__control[data-plyr="mute"],
    .plyr--video .plyr__controls__item.plyr__volume,
    .plyr--video .plyr__controls__item.plyr__menu,
    .plyr--video .plyr__controls__item.plyr__control[data-plyr="pip"],
    .plyr--video .plyr__controls__item.plyr__control[data-plyr="airplay"] {
        display: none !important;
    }

    .plyr--video .plyr__control svg {
        display: block;
    }

    .plyr--full-ui input[type=range] {
        --plyr-range-track-height: 6px;
    }

    .plyr__progress {
        flex: 1 1 auto;
        margin-inline: 4px;
    }

    .plyr__controls__item.plyr__progress__container {
        flex: 1 1 auto;
        min-width: 0;
        width: 100%;
    }

    .plyr--video .plyr__controls__item.plyr__control[data-plyr="fullscreen"] {
        margin-left: auto;
    }

    .plyr__progress input[type=range] {
        height: 28px;
    }

    .plyr__control--overlaid {
        width: 48px !important;
        height: 48px !important;
    }
}

/* ==================== Small Phone (≤ 480px) ==================== */
@media (max-width: 480px) {
    .landing {
        padding: 18px 12px 28px;
    }

    .landing-title {
        font-size: 26px;
    }

    .landing-input {
        height: 54px;
        font-size: 13px;
    }

    .landing-submit {
        height: 50px;
    }

    .landing-guide {
        padding: 12px 14px;
        font-size: 12px;
    }

    .video-container {
        margin: 0 8px;
        border-radius: 12px;
    }

    .video-container .plyr,
    .video-container .plyr video {
        border-radius: 12px;
    }

    .video-item-index {
        display: none;
    }

    .video-item-thumb {
        width: 90px;
        height: 51px;
    }

    .video-item-title {
        font-size: 11px;
    }

    .video-item-meta {
        margin-top: 2px;
    }

    .video-title {
        font-size: 14px;
    }

    .video-info {
        gap: 8px;
        padding: 8px 10px 12px;
    }

    .btn-action {
        min-height: 40px;
        padding: 8px 10px;
        border-radius: 13px;
    }

    .mobile-sheet-trigger-row {
        padding: 6px 8px 0;
    }

    .btn-mobile-sheet-trigger {
        min-height: 40px;
        padding: 9px 12px;
    }

    .sidebar,
    .player-layout.sidebar-closed .sidebar,
    .player-layout.sidebar-theater .sidebar {
        max-height: min(78vh, 520px);
    }

    .breadcrumb {
        padding: 4px 8px;
        font-size: 11px;
    }

    .bc-link,
    .bc-current {
        max-width: 100px;
    }
}

/* ==================== Landscape Phone ==================== */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --header-height: 40px;
    }

    .header {
        height: var(--header-height);
    }

    .video-container {
        border-radius: 0;
    }

    .video-container .plyr,
    .video-container .plyr video {
        border-radius: 0;
    }

    .video-info {
        display: none;
    }

    .breadcrumb {
        display: none;
    }
}

@media (max-height: 500px) and (orientation: landscape) and (min-width: 769px) {
    .player-layout {
        flex-direction: row;
        padding: 0;
    }

    .player-main {
        flex: 1;
        min-width: 0;
    }

    .sidebar {
        width: 280px;
        max-height: calc(100vh - var(--header-height));
        margin: 0;
        position: static;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        z-index: auto;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        transform: none;
        opacity: 1;
        pointer-events: auto;
        overflow: hidden;
    }
}

@media (max-height: 500px) and (orientation: landscape) and (max-width: 768px) {
    .player-layout {
        flex-direction: column;
        padding: 0;
    }

    .player-main {
        width: 100%;
    }

    .mobile-sheet-trigger-row {
        padding: 8px 12px 0;
    }

    .sidebar,
    .player-layout.sidebar-closed .sidebar,
    .player-layout.sidebar-theater .sidebar {
        max-height: min(82vh, 340px);
    }
}

/* =========================================================================
   Cache Download Fallback UI
   ========================================================================= */

.cache-download-ui {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    padding: 2rem;
    text-align: center;
}

.cache-dl-icon {
    width: 48px;
    height: 48px;
    color: var(--accent-light);
    margin-bottom: 1rem;
    animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.cache-dl-title {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.cache-dl-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.cache-dl-progress-box {
    width: 60%;
    max-width: 400px;
    height: 6px;
    background: var(--surface-light, #333);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.cache-dl-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color, #ff6b6b), var(--accent-light, #ff8e8e));
    transition: width 0.3s ease;
    border-radius: 4px;
}

.cache-dl-stats {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
