        :root {
            --bg-main: #202020;
            --bg-card: #1e1e1e;
            --text-main: #f1f1f1;
            --text-muted: #aaaaaa;
            --accent: #ff4444;
            --border: #333333;
            --yt-red: #ff0000;
            --brand-blue: #3ea6ff;
            --modal-overlay: rgba(0, 0, 0, 0.9);
        }

        body {
            font-family: "Roboto", "Inter", -apple-system, sans-serif;
            background-color: var(--bg-main);
            color: var(--text-main);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            margin: 0;
            padding: 10px;
        }

        /* Top Navigation */
        .top-nav {
            position: fixed;
            top: 0;
            right: 0;
            padding: 15px;
            z-index: 100;
            display: flex;
            gap: 10px;
            align-items: center;
        }

        /* Fade-out gradient so content dissolves before hitting the nav pills */
        body::before {
            content: '';
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 70px;
            background: linear-gradient(to bottom, var(--bg-main) 40%, transparent);
            z-index: 99;
            pointer-events: none;
        }

        .nav-btn, .nav-icon-link {
            background: transparent;
            border: 1px solid var(--border);
            color: var(--text-muted);
            padding: 6px 12px;
            border-radius: 20px;
            cursor: pointer;
            font-size: 13px;
            font-weight: 500;
            transition: all 0.2s;
            text-decoration: none;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .nav-icon-link {
            padding: 6px;
            width: 32px;
            height: 32px;
            box-sizing: border-box;
        }

        .nav-btn:hover, .nav-icon-link:hover {
            color: var(--text-main);
            border-color: var(--text-muted);
            background: rgba(255,255,255,0.05);
        }

        .feedback-text {
            background: transparent;
            color: var(--text-muted);
            font-size: 13px;
            font-weight: 500;
            transition: all 0.2s;
            text-decoration: none;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: right; 
        }

        .search-container {
            width: 100%;
            max-width: 650px;
            transition: transform 0.3s ease;
            text-align: center;
        }

        .search-container.has-results {
            transform: translateY(-10px);
        }

        .hero-logo-container {
            margin-bottom: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        /* SEO Hidden content: Visible to Screen Readers & Google, not to users */
        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            border: 0;
        }

        .brand-header {
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-bottom: 10px;
        }

        .brand-title {
            color: #ffffff;
            font-weight: 900;
            font-size: 3.5rem;
            letter-spacing: -1px;
            line-height: 1;
            margin: 0;
        }

        .brand-title sup {
            font-size: 0.55em;
            top: -0.4em;
            margin-left: 2px;
            color: var(--yt-red);
        }

        .brand-slogan {
            font-weight: 700;
            font-size: 1rem;
            margin-top: 5px;
            letter-spacing: 0.5px;
            display: flex;
            gap: 6px;
        }

        .slogan-search { color: var(--yt-red); }
        .slogan-learn  { color: #ffffff; }
        .slogan-create { color: var(--brand-blue); }

        .hero-logo {
            width: 100%;
            max-width: 280px;
            height: auto;
            display: block;
            margin-top: 10px;
        }

        .search-box {
            position: relative;
            display: flex;
            align-items: center;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 4px 8px;
            margin-bottom: 10px;
            text-align: left;
        }

        input[type="text"] {
            flex: 1;
            padding: 12px 16px;
            font-size: 16px;
            background: transparent;
            border: none;
            color: var(--text-main);
            outline: none;
            font-family: inherit;
        }

        .search-btn, .filter-trigger {
            background: transparent;
            border: none;
            padding: 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
            fill: var(--text-main);
            color: var(--text-main);
            transition: color 0.2s;
        }

        .filter-trigger.active {
            color: var(--brand-blue);
            fill: var(--brand-blue);
        }

        /* Filter Menu Styles */
        #filter-menu {
            display: none;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 20px;
            text-align: left;
            grid-template-columns: repeat(3, 1fr);
            gap: 20px;
        }

        .filter-column h4 {
            margin: 0 0 12px 0;
            font-size: 12px;
            text-transform: uppercase;
            color: var(--text-main);
            letter-spacing: 0.5px;
        }

        .filter-option {
            display: block;
            color: var(--text-muted);
            font-size: 14px;
            padding: 6px 0;
            cursor: pointer;
            border: none;
            background: none;
            width: 100%;
            text-align: left;
            transition: color 0.2s;
        }

        .filter-option:hover { color: var(--text-main); }
        .filter-option.selected { 
            color: var(--brand-blue); 
            font-weight: 700;
        }

        .filter-actions {
            grid-column: 1 / -1;
            display: flex;
            justify-content: space-between;
            border-top: 1px solid var(--border);
            padding-top: 15px;
            margin-top: 5px;
        }

        .clear-btn {
            background: none;
            border: none;
            color: var(--accent);
            font-size: 12px;
            cursor: pointer;
            font-weight: 700;
        }

        #results-list {
            list-style: none;
            padding: 0;
            width: 100%;
            text-align: left;
        }

        .result-item {
            background: var(--bg-card);
            margin-bottom: 12px;
            display: flex;
            gap: 12px;
            padding: 12px;
            border-radius: 12px;
            border: 1px solid var(--border);
            cursor: pointer;
            transition: all 0.2s ease;
            align-items: flex-start;
        }


        .thumb-container {
            position: relative;
            width: 120px;
            height: 68px;
            flex-shrink: 0;
            border-radius: 6px;
            overflow: hidden;
            background: #000;
        }

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

        .result-info {
            flex: 1;
            min-width: 0;
        }

        .result-title {
            font-weight: 700;
            color: var(--text-main);
            margin-bottom: 2px;
            font-size: 0.9rem;
            display: block;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .result-meta {
            font-size: 12px;
            color: var(--brand-blue);
            margin-bottom: 4px;
            font-weight: 500;
            display: flex;
            gap: 8px;
            align-items: center;
        }

        .result-date {
            font-size: 11px;
            color: var(--text-muted);
            font-weight: 400;
            margin-bottom: 4px;
        }

        .result-description {
            font-size: 12px;
            color: var(--text-muted);
            line-height: 1.4;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        /* Generic Modal Styles */
        .modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--modal-overlay);
            z-index: 1000;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .modal-content {
            width: 100%;
            max-width: 1000px;
            aspect-ratio: 16 / 9;
            background: #000;
            position: relative;
        }

        /* About Modal Specific */
        .about-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 16px;
            max-width: 500px;
            width: 90%;
            padding: 24px;
            position: relative;
            box-shadow: 0 10px 30px rgba(0,0,0,0.5);
            text-align: left;
            box-sizing: border-box;
        }

        .about-card h2 {
            margin-top: 0;
            color: #fff;
            font-size: 1.5rem;
        }

        .about-card p {
            color: var(--text-muted);
            line-height: 1.6;
            font-size: 14px;
            margin-bottom: 16px;
        }

        .close-btn-generic {
            margin-top: 10px;
            width: 100%;
            padding: 12px;
            background: var(--yt-red);
            border: none;
            color: #fff;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 700;
            transition: opacity 0.2s;
        }

        .close-btn-generic:hover {
            opacity: 0.9;
        }

        #player {
            width: 100%;
            height: 100%;
        }

        .close-modal-player {
            position: absolute;
            top: -50px;
            left: 0px;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid var(--border);
            border-radius: 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
            color: var(--text-main);
            padding: 6px 12px;
            z-index: 1010;
        }

        /* ── Watch on YouTube hover overlay on thumbnail ── */
        .thumb-container .watch-btn {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(0,0,0,0.55);
            opacity: 0;
            transition: opacity 0.2s;
            border: none;
            cursor: pointer;
            width: 100%;
        }
        .thumb-container .watch-btn span {
            background: var(--yt-red);
            color: #fff;
            font-size: 11px;
            font-weight: 700;
            padding: 4px 8px;
            border-radius: 4px;
            white-space: nowrap;
            font-family: inherit;
            font-size: 14px;
        }
        @media (hover: hover) {
            .result-item:hover .watch-btn { opacity: 1; }
            .result-item:hover {
                border-color: var(--yt-red);
                background: #252525;
            }
        }
        /* On touch devices show it always since there's no hover */
        @media (hover: none) {
            .thumb-container .watch-btn { opacity: 1; background: rgba(0,0,0,0.35); }
        }

        .duration-badge {
            position: absolute;
            bottom: 5px;
            right: 5px;
            background: rgba(0, 0, 0, 0.8);
            color: white;
            padding: 2px 4px;
            font-size: 11px;
            font-weight: bold;
            border-radius: 2px;
            z-index: 10;
        }

        /* Paginering Styles */
        .pagination {
            display: flex;
            justify-content: center;
            gap: 20px;
            margin: 20px 0 40px;
            width: 100%;
        }

        .page-btn {
            background: var(--bg-card);
            border: 1px solid var(--border);
            color: var(--text-main);
            padding: 8px 16px;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 500;
        }

        .page-btn:disabled {
            opacity: 0.3;
            cursor: not-allowed;
        }

        .page-btn:hover:not(:disabled) {
            border-color: var(--brand-blue);
        }

        @media (max-width: 480px) {
            .modal-overlay { padding: 10px; }
            .about-card { padding: 16px; }
            #filter-menu { grid-template-columns: 1fr; }
            .fav-videos-grid { grid-template-columns: 1fr; }
        }


        /* ── Group picker popover ── */
        .group-popover {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 8px;
            z-index: 2000;
            min-width: 160px;
            box-shadow: 0 6px 20px rgba(0,0,0,0.6);
            display: none;
        }
        .group-popover.open { display: block; }
        .group-popover-title {
            font-size: 10px;
            text-transform: uppercase;
            color: var(--text-muted);
            letter-spacing: 0.5px;
            padding: 2px 6px 6px;
        }
        .group-pill {
            display: block;
            width: 100%;
            text-align: left;
            background: none;
            border: none;
            color: var(--text-main);
            font-size: 13px;
            font-family: inherit;
            padding: 6px 8px;
            border-radius: 6px;
            cursor: pointer;
            transition: background 0.15s;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .group-pill:hover { background: rgba(255,255,255,0.08); }
        .group-pill.new-group { color: var(--brand-blue); }
        .group-popover-divider {
            border: none;
            border-top: 1px solid var(--border);
            margin: 6px 0;
        }

        /* ── My Videos modal: group sections ── */
        .fav-group-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid var(--border);
            padding-bottom: 8px;
            margin-bottom: 10px;
            gap: 8px;
        }
        .fav-group-name {
            font-size: 13px;
            font-weight: 700;
            color: var(--brand-blue);
            flex: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .fav-group-rename-btn, .fav-group-delete-btn {
            background: none;
            border: none;
            cursor: pointer;
            font-size: 11px;
            color: var(--text-muted);
            padding: 2px 4px;
            font-family: inherit;
            transition: color 0.2s;
            flex-shrink: 0;
        }
        .fav-group-rename-btn:hover { color: var(--brand-blue); }
        .fav-group-delete-btn:hover { color: var(--accent); }
        .fav-group-rename-input {
            background: var(--bg-main);
            border: 1px solid var(--brand-blue);
            border-radius: 4px;
            color: var(--text-main);
            font-size: 13px;
            font-family: inherit;
            padding: 2px 6px;
            flex: 1;
            outline: none;
        }
        .fav-video-channel-link {
            font-size: 11px;
            color: var(--brand-blue);
            background: none;
            border: none;
            cursor: pointer;
            padding: 0;
            font-family: inherit;
            text-align: left;
            transition: color 0.2s;
        }
        .fav-video-channel-link:hover { color: #fff; }
        .fav-move-btn {
            background: none;
            border: none;
            cursor: pointer;
            font-size: 11px;
            color: var(--text-muted);
            font-family: inherit;
            padding: 0;
            transition: color 0.2s;
            text-align: left;
            position: relative;
        }
        .fav-move-btn:hover { color: var(--brand-blue); }

        /* ── Bookmark button inline in result-meta ── */
        .heart-btn {
            background: none;
            border: none;
            cursor: pointer;
            padding: 0 0 0 4px;
            line-height: 1;
            display: inline-flex;
            align-items: center;
            vertical-align: middle;
            transition: transform 0.15s ease;
        }
        .heart-btn:hover { transform: scale(1.25); }
        .heart-btn svg { display: block; transition: fill 0.2s, stroke 0.2s; }

        /* Unfilled (not saved) */
        .heart-btn svg { fill: none; stroke: var(--text-muted); stroke-width: 2; }

        /* Filled (saved) */
        .heart-btn.subscribed svg { fill: #ff4444; stroke: #ff4444; }

        /* ── Favorites modal channel sections ── */
        .fav-section { margin-bottom: 20px; }
        .fav-showall-btn:hover { color: #fff; }

        .fav-videos-grid {                      /* This determines the layout of the favorites grid */
            display: grid;
            grid-template-columns: 1fr;         /* CHANGE THIS TO repeat(2, 1fr) TO REDUCE SIZE */
            gap: 8px;
            width: 75%;   
            height: auto;                   
            margin: 20px auto; 
        }

        .fav-video-card {
            background: var(--bg-main);
            border: 1px solid var(--border);
            border-radius: 8px;
            overflow: hidden;
            cursor: pointer;
            transition: border-color 0.2s;
            position: relative;
        }
        
        .fav-video-card:hover { border-color: var(--yt-red); }
        .fav-video-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }   /* CHANGE THIS TO width: 100%, height: auto TO REDUCE SIZE */
        .fav-video-card-info { padding: 6px 8px 8px; }

        .fav-remove-btn {
            position: absolute;
            top: 4px;
            right: 4px;
            background: rgba(0,0,0,0.7);
            border: none;
            color: #fff;
            font-size: 13px;
            line-height: 1;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transition: opacity 0.15s, background 0.15s;
            z-index: 2;
        }
        .fav-video-card:hover .fav-remove-btn { opacity: 1; }
        .fav-remove-btn:hover { background: var(--accent); }
        .fav-video-title {
            font-size: 12px;
            font-weight: 600;
            color: var(--text-main);
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            line-height: 1.4;
            margin-bottom: 2px;
        }
        .fav-video-date { font-size: 11px; color: var(--text-muted); }
        .fav-empty { text-align: center; padding: 24px 0; color: var(--text-muted); font-size: 13px; }
        .fav-loading { color: var(--text-muted); font-size: 13px; padding: 8px 0; }

        #favorites-nav-btn {
            position: fixed;
            top: 15px;
            left: 15px;
        }

        .just-added-container {
            width: 100%;
            max-width: 800px; /* Aligns with your main content width */
            margin: 20px auto;
            padding: 0 10px;
            box-sizing: border-box;
        }

        .just-added-title {
            font-size: 0.9rem;
            color: #888;
            margin-bottom: 8px;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .carousel-wrapper {
            position: relative;
            display: flex;
            align-items: center;
        }

        .carousel-track {
            display: flex;
            gap: 10px;
            overflow-x: auto;
            scroll-behavior: smooth;
            scrollbar-width: none; /* Hides default scrollbar in Firefox */
        }

        .carousel-track::-webkit-scrollbar {
            display: none; /* Hides default scrollbar in Chrome/Safari */
        }

        /* Ensure the parent item can anchor absolute children */
        .carousel-item {
            position: relative; 
            flex: 0 0 calc((100% - 40px) / 5);
            min-width: 180px;
            aspect-ratio: 16 / 9;
            overflow: hidden;
            border-radius: 6px;
            cursor: pointer;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            background-color: #1a1a1a;
        }

        /* The Overlay Mask (Fades from completely transparent to a soft dark gradient) */
        .carousel-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.4) 70%, rgba(0, 0, 0, 0.1) 100%);
            display: flex;
            flex-direction: column;
            justify-content: flex-end; /* Pushes text strings cleanly to the bottom edge */
            padding: 8px;
            box-sizing: border-box;
            opacity: 1; /* Visible by default */
            transition: opacity 0.25s ease;
            z-index: 2;
        }

        /* Title text typography */
        .overlay-title {
            font-size: 0.7rem;
            color: #ffffff;
            font-weight: 500;
            line-height: 1.2;
            margin-bottom: 1px;
            display: -webkit-box;
            -webkit-line-clamp: 2; /* Truncates long titles automatically after 2 lines with ellipses (...) */
            -webkit-box-orient: vertical;
            overflow: hidden;
            text-shadow: 0 1px 2px rgba(0,0,0,0.8);
        }

        /* Channel text typography */
        .overlay-channel {
            font-size: 0.6rem;
            color: #ff4444; /* Uses Tinker2's accent color for the channel name */
            font-weight: 700;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            text-shadow: 0 1px 2px rgba(0,0,0,0.8);
        }

         /* Reveal overlay mask smoothly on item hover */
        carousel-item:hover .carousel-overlay {
            background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.7) 100%);
        }

        .carousel-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        /* Scroll Arrows Controls */
        .carousel-btn {
            position: absolute;
            background: rgba(0, 0, 0, 0.7);
            color: #fff;
            border: none;
            font-size: 1.5rem;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 10;
            transition: opacity 0.2s, background 0.2s;
            opacity: 0; /* Hidden by default, fades in on container hover */
        }

        .carousel-wrapper:hover .carousel-btn {
            opacity: 1;
        }

        .carousel-btn:hover {
            background: rgba(224, 36, 36, 0.9); /* Subtle tint using Tinker2's signature red accents */
        }

        .carousel-btn.prev { left: -16px; }
        .carousel-btn.next { right: -16px; }

        @media (max-width: 600px) {
            .carousel-item {
                flex: 0 0 calc((100% - 20px) / 3); /* Shows 3 items on small mobile devices */
            }
            .carousel-btn { display: none; } /* Rely on touch gestures on mobile devices */
        }