*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

        :root {
            --yt-bg: #0f0f0f;
            --yt-action-size: 48px;
            --video-max-h: calc(100dvh - 56px);
            --video-max-w: calc(var(--video-max-h) * 9 / 16);
            
            --bg:           #0f0f0f;
            --header-bg:    #0f0f0f;
            --header-border:rgba(255,255,255,0.06);
            --text:         #ffffff;
            --icon-fill:    #ffffff;
            --btn-hover:    rgba(255,255,255,0.1);
        }

        [data-theme="light"] {
            --bg:           #f5f5f5;
            --header-bg:    #ffffff;
            --header-border:rgba(0,0,0,0.08);
            --text:         #0f0f0f;
            --icon-fill:    #0f0f0f;
            --btn-hover:    rgba(0,0,0,0.06);
        }

        
        [data-theme="light"] .action-icon {
            background: rgba(0,0,0,0.12);
        }
        [data-theme="light"] .action-btn:hover .action-icon {
            background: rgba(0,0,0,0.22);
        }
        [data-theme="light"] .action-btn svg {
            fill: #1a1a1a;
            filter: none;
        }
        [data-theme="light"] .action-btn span {
            color: #1a1a1a;
        }
        [data-theme="light"] .nav-arrow {
            background: rgba(0,0,0,0.1);
        }
        [data-theme="light"] .nav-arrow:hover {
            background: rgba(0,0,0,0.2);
        }
        [data-theme="light"] .nav-arrow svg {
            fill: #1a1a1a;
        }

        html, body {
            height: 100%;
            overflow: hidden;
            background: var(--bg);
            font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
            color: var(--text);
        }

        .yt-header {
            position: fixed;
            top: 0; left: 0; right: 0;
            height: 56px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 16px;
            background: var(--header-bg);
            z-index: 200;
            border-bottom: 1px solid var(--header-border);
        }

        .yt-header .logo {
            display: flex;
            align-items: center;
            gap: 8px;
            text-decoration: none;
        }

        .yt-header .logo img { height: 28px; }

        .yt-header .header-right {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .yt-icon-btn {
            width: 40px; height: 40px;
            border: none; background: transparent;
            border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            cursor: pointer;
            transition: background 0.15s;
            color: var(--icon-fill);
        }
        .yt-icon-btn:hover { background: var(--btn-hover); }
        .yt-icon-btn svg { width: 22px; height: 22px; fill: currentColor; }

        .shorts-page {
            position: fixed;
            top: 56px; left: 0; right: 0; bottom: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .swiper {
            width: 100%;
            height: 100%;
        }

        .swiper-slide {
            display: flex;
            align-items: center;
            justify-content: center;
            background: #000;
            position: relative;
            overflow: hidden;
        }

        @media (min-width: 740px) {
            .swiper-slide {
                background: transparent;
            }

            .slide-inner {
                display: flex;
                align-items: flex-end;
                gap: 16px;
                height: var(--video-max-h);
                max-height: 100%;
            }

            .video-col {
                display: flex;
                flex-direction: column;
                height: 100%;
                position: relative;
            }

            .video-stack {
                position: relative;
                flex: 1;
                min-height: 0;
                width: var(--video-max-w);
                max-width: min(var(--video-max-w), 56vw);
                border-radius: 12px;
                overflow: hidden;
                background: #000;
                flex-shrink: 1;
            }

            
            .video-meta-below {
                display: block;
                position: absolute;
                bottom: 0; left: 0;
                width: var(--video-max-w);
                max-width: min(var(--video-max-w), 56vw);
                padding: 50px 14px 28px;
                background: linear-gradient(to top, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.5) 60%, transparent 100%);
                border-radius: 0 0 12px 12px;
                pointer-events: none;
                z-index: 11;
            }

            .video-meta-below .username {
                font-size: 17px;
                font-weight: 700;
                opacity: 1;
                margin-bottom: 4px;
                color: #fff;
                text-shadow: 0 1px 3px rgba(0,0,0,0.6);
            }

            .video-meta-below .description {
                font-size: 18px;
                opacity: 0.9;
                color: #fff;
                text-shadow: 0 1px 3px rgba(0,0,0,0.6);
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
                overflow: hidden;
            }

            .video-actions {
                display: flex !important;
                flex-direction: column;
                align-items: center;
                gap: 20px;
                padding-bottom: 8px;
                position: static !important;
                right: auto !important;
                bottom: auto !important;
            }

            .video-info { display: none !important; }

            .video-top-controls {
                position: absolute;
                top: 10px; left: 10px;
                display: flex;
                gap: 6px;
                z-index: 30;
                opacity: 0;
                transition: opacity 0.2s;
            }

            .video-stack.bounds-ready:hover .video-top-controls { opacity: 1; }
            .video-stack.bounds-ready:hover .video-top-right    { opacity: 1; }

            .nav-arrows {
                display: flex !important;
            }
        }

        @media (max-width: 739px) {
            .shorts-page {
                top: 0;
            }

            .yt-header { display: none; }

            .slide-inner {
                display: contents;
            }

            .video-col,
            .video-stack {
                position: absolute;
                inset: 0;
                width: 100%;
                height: 100%;
                border-radius: 0;
            }

            .video-meta-below { display: none; }

            .video-info { display: block !important; }

            .video-actions {
                position: absolute !important;
                right: 12px !important;
                bottom: 120px !important;
            }

            .video-top-controls { display: flex; }
            .video-stack.bounds-ready .video-top-controls { opacity: 1; }
            .video-stack.bounds-ready .video-top-right    { opacity: 1; }

            .nav-arrows { display: none !important; }

            
            .action-icon {
                background: rgba(255,255,255,0.12) !important;
            }
            .action-btn:hover .action-icon {
                background: rgba(255,255,255,0.22) !important;
            }
            .action-btn svg {
                fill: white !important;
                filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)) !important;
            }
            .action-btn span {
                color: rgba(255,255,255,0.85) !important;
                text-shadow: 0 1px 3px rgba(0,0,0,0.6) !important;
            }

            
            .video-info .username,
            .video-info .description {
                color: #fff !important;
                text-shadow: 0 1px 3px rgba(0,0,0,0.6) !important;
            }
        }

        .video-background {
            position: absolute;
            top: 50%; left: 50%;
            transform: translate(-50%, -50%);
            min-width: 100%; min-height: 100%;
            width: auto; height: auto;
            object-fit: cover;
            filter: blur(30px) saturate(1.5) brightness(0.9);
            opacity: 0.15;
            z-index: 0;
            pointer-events: none;
        }

        .video-wrapper {
            position: relative;
            width: 100%; height: 100%;
            display: flex;
            justify-content: center;
            z-index: 2;
        }

        .video-wrapper video.main-video {
            max-width: 100%; max-height: 100%;
            width: auto; height: auto;
            object-fit: contain;
        }

        .video-actions {
            display: flex;
            flex-direction: column;
            gap: 20px;
            z-index: 10;
        }

        .action-btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            cursor: pointer;
            transition: transform 0.15s;
            text-shadow: 0 1px 3px rgba(0,0,0,0.6);
        }

        .action-btn:active { transform: scale(0.88); }

        .action-icon {
            width: var(--yt-action-size);
            height: var(--yt-action-size);
            background: rgba(255,255,255,0.12);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s;
        }

        .action-btn:hover .action-icon { background: rgba(255,255,255,0.22); }

        @media (min-width: 740px) {
            .action-icon {
                background: rgba(255,255,255,0.1);
                border: none;
                width: 48px; height: 48px;
            }
            .action-btn span {
                font-size: 12px;
                font-weight: 500;
                color: rgba(255,255,255,0.85);
                text-shadow: none;
            }
        }

        .action-btn svg {
            width: 24px; height: 24px;
            fill: white;
            filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
        }

        .action-btn.liked .action-icon { background: rgba(6,95,212,0.25); }
        .action-btn.liked svg { fill: #4e9eff; }

        .video-info {
            position: absolute;
            bottom: var(--vid-top, 0px);
            left:   var(--vid-left, 0px);
            right:  var(--vid-left, 0px);
            padding: 60px 16px 28px;
            background: linear-gradient(to top, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.5) 60%, transparent 100%);
            z-index: 10;
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        .video-info .username {
            font-weight: 700;
            font-size: 17px;
            margin-bottom: 4px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .subscribe-btn-inline {
            font-size: 12px;
            font-weight: 600;
            background: #fff;
            color: #000;
            border: none;
            border-radius: 4px;
            padding: 3px 10px;
            cursor: pointer;
            line-height: 1.4;
            transition: opacity 0.15s;
        }
        .subscribe-btn-inline:hover { opacity: 0.85; }

        .video-info .description {
            font-size: 18px;
            line-height: 1.45;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            opacity: 0.9;
        }

        
        .video-top-controls {
            position: absolute;
            top: calc(var(--vid-top, 0px) + 10px);
            left: calc(var(--vid-left, 0px) + 10px);
            display: flex;
            gap: 6px;
            z-index: 30;
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        .video-top-right {
            position: absolute;
            top: calc(var(--vid-top, 0px) + 10px);
            right: calc(var(--vid-left, 0px) + 10px);
            display: flex;
            gap: 6px;
            z-index: 30;
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        .ctrl-btn {
            width: 40px; height: 40px;
            background: rgba(0,0,0,0.35);
            border: none;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background 0.15s;
            color: #fff;
            filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
        }

        .ctrl-btn:hover { background: rgba(0,0,0,0.55); }
        .ctrl-btn svg { width: 20px; height: 20px; fill: white; }

        
        
        .volume-wrap {
            position: relative;
            display: flex;
            align-items: center;
            height: 40px;
            width: 40px;
            overflow: hidden;
            border-radius: 20px;
            background: rgba(0,0,0,0.35);
            transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
            background 0.15s;
            cursor: pointer;
            padding-right: 0;
            transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
            background 0.15s,
            padding-right 0.25s;
        }

        .volume-wrap:hover {
            width: 180px;
            background: rgba(0,0,0,0.55);
            padding-right: 12px;
        }

        
        .volume-wrap .ctrl-btn {
            background: transparent !important;
            flex-shrink: 0;
            width: 40px; height: 40px;
            border-radius: 20px;
        }
        .volume-wrap .ctrl-btn:hover {
            background: transparent !important;
        }

        
        .volume-slider {
            -webkit-appearance: none;
            appearance: none;
            writing-mode: unset;
            direction: unset;
            flex: 1;           
            min-width: 0;
            height: 4px;
            flex-shrink: 1;
            margin-right: 0;
            background: rgba(255,255,255,0.35);
            border-radius: 2px;
            outline: none;
            cursor: pointer;
        }

        .volume-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 14px; height: 14px;
            border-radius: 50%;
            background: #fff;
            cursor: pointer;
            box-shadow: 0 1px 3px rgba(0,0,0,0.4);
            opacity: 0;
            transition: opacity 0.2s;
        }

        .volume-wrap:hover .volume-slider::-webkit-slider-thumb {
            opacity: 1;
        }

        .volume-slider::-moz-range-thumb {
            width: 14px; height: 14px;
            border-radius: 50%;
            background: #fff;
            border: none;
            cursor: pointer;
            opacity: 0;
            transition: opacity 0.2s;
        }

        .volume-wrap:hover .volume-slider::-moz-range-thumb {
            opacity: 1;
        }

        
        .volume-slider {
            background: linear-gradient(
                    to right,
                    rgba(255,255,255,0.9) 0%,
                    rgba(255,255,255,0.9) calc(var(--vol-pct, 80%) ),
                    rgba(255,255,255,0.3) calc(var(--vol-pct, 80%) )
            );
        }

        .nav-arrows {
            position: fixed;
            right: 28px;
            top: 50%;
            transform: translateY(-50%);
            display: none;
            flex-direction: column;
            gap: 12px;
            z-index: 150;
        }

        .nav-arrow {
            width: 48px; height: 48px;
            background: rgba(255,255,255,0.1);
            border: none;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background 0.15s, transform 0.15s;
            color: #fff;
        }

        .nav-arrow:hover {
            background: rgba(255,255,255,0.2);
            transform: scale(1.08);
        }

        .nav-arrow svg { width: 22px; height: 22px; fill: currentColor; }

        .progress-container {
            position: absolute;
            bottom: var(--vid-top, 0px);
            left:   var(--vid-left, 0px);
            right:  var(--vid-left, 0px);
            height: 24px;
            z-index: 20;
            cursor: pointer;
            display: flex;
            align-items: flex-end;
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        .progress-track {
            width: 100%;
            height: 3px;
            background: rgba(255,255,255,0.3);
            position: relative;
            transition: height 0.15s ease;
        }

        .progress-container:hover .progress-track,
        .progress-container.dragging .progress-track { height: 8px; }

        .progress-bar {
            height: 100%;
            background: #fff;
            width: 0%;
            position: relative;
        }

        .progress-bar::after {
            content: '';
            position: absolute;
            right: -6px; top: 50%;
            transform: translateY(-50%) scale(0);
            width: 12px; height: 12px;
            background: white;
            border-radius: 50%;
            transition: transform 0.15s ease;
        }

        .progress-container:hover .progress-bar::after,
        .progress-container.dragging .progress-bar::after { transform: translateY(-50%) scale(1); }

        .time-tooltip {
            position: absolute;
            bottom: 28px; left: 0;
            background: rgba(0,0,0,0.8);
            color: white;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: 500;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.15s;
            transform: translateX(-50%);
            white-space: nowrap;
        }

        .progress-container:hover .time-tooltip,
        .progress-container.dragging .time-tooltip { opacity: 1; }

        .play-pause-indicator {
            position: absolute;
            top: 50%; left: 50%;
            transform: translate(-50%, -50%);
            width: 72px; height: 72px;
            background: rgba(0,0,0,0.55);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transition: opacity 0.25s;
            pointer-events: none;
            z-index: 15;
        }

        .play-pause-indicator.show { opacity: 1; }
        .play-pause-indicator svg { width: 36px; height: 36px; fill: white; }

        .loading-spinner {
            position: absolute;
            top: 50%; left: 50%;
            transform: translate(-50%, -50%);
            width: 44px; height: 44px;
            border: 3px solid rgba(255,255,255,0.25);
            border-top-color: white;
            border-radius: 50%;
            animation: spin 0.9s linear infinite;
            z-index: 5;
        }

        @keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

        .search-overlay {
            position: fixed; inset: 0;
            background: rgba(0,0,0,0.97);
            z-index: 300;
            display: none;
            flex-direction: column;
            padding: 16px;
        }
        .search-overlay.active { display: flex; }

        .search-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 20px;
        }

        .search-input-wrapper { flex: 1; position: relative; }

        .search-input {
            width: 100%; height: 44px;
            background: rgba(255,255,255,0.1);
            border: 1px solid rgba(255,255,255,0.2);
            border-radius: 22px;
            padding: 0 16px 0 44px;
            color: white; font-size: 16px; outline: none;
            transition: border-color 0.2s, background 0.2s;
        }
        .search-input:focus { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.4); }
        .search-input::placeholder { color: rgba(255,255,255,0.5); }
        .search-input-wrapper svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; fill: rgba(255,255,255,0.5); }
        .search-close { color: white; background: none; border: none; font-size: 15px; cursor: pointer; padding: 8px; opacity: 0.7; }
        .search-close:hover { opacity: 1; }
        .search-results { flex: 1; overflow-y: auto; }
        .search-placeholder { color: rgba(255,255,255,0.4); text-align: center; margin-top: 40px; font-size: 14px; }

        .search-result-item {
            display: flex; align-items: center; gap: 12px;
            padding: 12px; border-radius: 8px; cursor: pointer;
            transition: background 0.2s;
        }
        .search-result-item:hover { background: rgba(255,255,255,0.08); }
        .search-result-thumb { width: 80px; height: 120px; background: #333; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
        .search-result-username { font-weight: 600; color: white; font-size: 14px; margin-bottom: 4px; }
        .search-result-description { color: rgba(255,255,255,0.7); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

        
        .shorts-page:fullscreen,
        .shorts-page:-webkit-full-screen {
            top: 0 !important;
            background: #000;
        }

        
        .shorts-page:fullscreen .slide-inner,
        .shorts-page:-webkit-full-screen .slide-inner {
            display: contents;
        }

        .shorts-page:fullscreen .video-col,
        .shorts-page:fullscreen .video-stack,
        .shorts-page:-webkit-full-screen .video-col,
        .shorts-page:-webkit-full-screen .video-stack {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            border-radius: 0;
            max-width: none;
        }

        .shorts-page:fullscreen .video-meta-below,
        .shorts-page:-webkit-full-screen .video-meta-below { display: none !important; }

        .shorts-page:fullscreen .video-info,
        .shorts-page:-webkit-full-screen .video-info { display: block !important; }

        .shorts-page:fullscreen .video-actions,
        .shorts-page:-webkit-full-screen .video-actions {
            position: absolute !important;
            right: 12px !important;
            bottom: 120px !important;
        }

        .shorts-page:fullscreen .video-top-controls,
        .shorts-page:fullscreen .video-top-right,
        .shorts-page:-webkit-full-screen .video-top-controls,
        .shorts-page:-webkit-full-screen .video-top-right { opacity: 1; }

        .debug-panel {
            position: fixed; top: 68px; left: 10px;
            background: rgba(0,0,0,0.85);
            color: #0f0; padding: 8px 10px;
            font-size: 10px; font-family: monospace;
            border-radius: 8px; z-index: 500; display: none;
        }