:root{--bg:#0f0f0f;--panel:#181818;--fg:#eee;--muted:#bbb;--accent:#3ea6ff;--card:#121212;--border:#2a2a2a}
*{box-sizing:border-box}
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-track{background:#0f0f0f}
::-webkit-scrollbar-thumb{background:#3f3f3f;border-radius:5px;border:2px solid #0f0f0f}
::-webkit-scrollbar-thumb:hover{background:#555}
*{scrollbar-width:thin;scrollbar-color:#3f3f3f #0f0f0f}
body{margin:0;background:var(--bg);color:var(--fg);font:15px/1.5 system-ui,'Segoe UI',Roboto,Arial;overflow-x:hidden}
a{color:var(--accent);text-decoration:none}

/* Header */
.top{position:sticky;top:0;z-index:100;display:flex;align-items:center;gap:12px;background:var(--panel);border-bottom:1px solid var(--border);padding:10px 14px}
.hamburger{background:#1e1e1e;border:1px solid var(--border);border-radius:8px;color:#fff;padding:6px 10px;cursor:pointer;font-size:16px}
.brand{font-weight:900;font-size:22px;text-decoration:none}
.rgb{background:linear-gradient(90deg,#ff0044,#ffb300,#34d399,#38bdf8,#a78bfa,#ff0044);-webkit-background-clip:text;background-clip:text;color:transparent;animation:rgb 6s linear infinite;background-size:300%}
@keyframes rgb{to{background-position:200% 0}}
.search{display:flex;gap:8px;flex:1;max-width:640px;margin-left:10px}
.search-wrapper{position:relative;flex:1}
.search input{width:100%;height:40px;padding:9px 12px;border-radius:20px;border:1px solid var(--border);background:#0d0d0d;color:#fff;font-size:14px}
.search input:focus{outline:none;border-color:var(--accent)}
.search-suggestions{position:absolute;top:100%;left:0;right:0;background:#1a1a1a;border:1px solid var(--border);border-radius:12px;margin-top:8px;max-height:400px;overflow-y:auto;z-index:1000;display:none;box-shadow:0 4px 12px rgba(0,0,0,0.5)}
.search-suggestions.active{display:block}
.suggestion-item{padding:12px 16px;cursor:pointer;display:flex;align-items:center;gap:10px;border-bottom:1px solid var(--border);transition:background 0.15s}
.suggestion-item:last-child{border-bottom:none}
.suggestion-item:hover{background:#252525}
.suggestion-icon{font-size:16px;opacity:0.7}
.suggestion-text{flex:1;font-size:14px;color:#fff}
.suggestion-type{font-size:11px;color:#888;text-transform:uppercase;padding:2px 6px;background:#0f0f0f;border-radius:4px}
.btn{height:40px;padding:0 16px;border-radius:20px;border:1px solid var(--border);background:#1e1e1e;color:#fff;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;font-size:14px;transition:background 0.2s}
.btn:hover{background:#2a2a2a}
.btn:disabled{opacity:0.5;cursor:not-allowed}
.right{display:flex;gap:10px;margin-left:auto}

/* Sidebar */
.sidebar{position:fixed;top:52px;left:0;width:220px;height:calc(100vh - 52px);background:#131313;border-right:1px solid var(--border);padding:12px;overflow:auto;transform:translateX(-100%);transition:transform 0.25s ease;z-index:1000}
body.nav-open .sidebar{transform:translateX(0)}
.sidebar a{display:flex;justify-content:flex-start;align-items:center;gap:10px;color:#fff;padding:10px;border-radius:10px;margin-bottom:4px;cursor:pointer;transition:background 0.2s}
.sidebar a .new-indicator{margin-left:auto}
.sidebar a:hover{background:#1b1b1b}
.sidebar a.active{background:#2a2a2a}
.sidebar .sep{height:1px;background:var(--border);margin:10px 0}
.sidebar .head{color:var(--muted);font-size:12px;margin:6px 10px;text-transform:uppercase}
.channel-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px}
.channel-avatar-mini{width:24px;height:24px;border-radius:50%;object-fit:cover;flex-shrink:0;background:#2a2a2a;vertical-align:middle}
.channel-info{display:flex;align-items:center;gap:6px;margin-left:8px}
.video-count{background:#2a2a2a;padding:2px 8px;border-radius:12px;font-size:11px;font-weight:600;color:#bbb}
.new-indicator{width:8px;height:8px;background:#00ff66;border-radius:50%;animation:blink 2s ease-in-out infinite;box-shadow:0 0 4px #00ff66;flex-shrink:0}
@keyframes blink{0%,100%{opacity:1}50%{opacity:0.3}}

/* Main Content */
.container{margin-left:16px;max-width:1600px;padding:16px;transition:margin-left 0.25s ease}
body.nav-open .container{margin-left:236px}
.container h2{font-size:24px;margin-bottom:16px}

/* Video Grid */
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(320px,1fr));gap:16px}
.card{background:var(--card);border:1px solid var(--border);border-radius:12px;overflow:hidden;cursor:pointer;transition:transform 0.2s,box-shadow 0.2s}
.card:hover{transform:translateY(-4px);box-shadow:0 4px 12px rgba(0,0,0,0.5)}
.thumb{position:relative;width:100%;aspect-ratio:16/9;background:#000;overflow:hidden}
.thumb video,.thumb img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;border-bottom:1px solid var(--border)}
.thumb .placeholder{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:48px;opacity:0.3}
.video-duration{position:absolute;bottom:8px;right:8px;background:rgba(0,0,0,0.8);padding:2px 6px;border-radius:4px;font-size:12px;font-weight:600}
.resume-badge{position:absolute;bottom:8px;left:8px;background:rgba(0,120,255,0.9);color:#fff;padding:2px 8px;border-radius:4px;font-size:12px;font-weight:600;z-index:5}
.played-check{color:#00cc44;font-weight:700;font-size:13px;margin-left:2px}
.card-fav{background:none;border:none;font-size:12px;cursor:pointer;padding:0 2px;line-height:1;transition:transform 0.15s;vertical-align:middle}
.card-fav:hover{transform:scale(1.2)}
.meta{padding:12px}
.meta h3{margin:6px 0 4px;font-size:16px;color:#fff;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.sub{color:var(--muted);font-size:12px}
.video-meta{display:flex;gap:12px;margin:12px 0;color:var(--muted);font-size:14px}

/* Video Player */
.video-player-container{max-width:1400px;margin:0 auto 24px}
body:not(.nav-open) .video-player-container{max-width:none}
body:not(.nav-open) .container{padding-right:0}
.player-layout{display:flex;gap:16px;align-items:flex-start}
.player-main{flex:1;min-width:0}
.player-wrap{position:relative;background:#000;border:1px solid var(--border);border-radius:12px;overflow:hidden;margin-bottom:16px;display:flex;align-items:center;justify-content:center}
.player-wrap video{max-width:100%;max-height:80vh;width:auto;height:auto;display:block;margin:0 auto}
.player-wrap video:fullscreen,.player-wrap video:-webkit-full-screen{max-width:100vw;max-height:100vh;width:100vw;height:100vh;object-fit:contain;margin:0;background:#000}
.player-side{width:402px;flex-shrink:0;height:calc(100vh - 110px);overflow-y:auto;position:sticky;top:66px;padding-right:2px}
.upnext-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
.upnext-title{margin:0;font-size:16px;font-weight:700;color:#fff}
.upnext-tabs{display:flex;gap:6px}
.upnext-tab{background:#272727;border:none;color:#fff;font-size:12px;font-weight:500;padding:5px 12px;border-radius:8px;cursor:pointer;transition:background 0.15s}
.upnext-tab:hover{background:#3a3a3a}
.upnext-tab.active{background:#fff;color:#0f0f0f}
.upnext-list{display:flex;flex-direction:column;gap:6px}
.upnext-item{display:flex;gap:10px;padding:6px 6px;border-radius:10px;cursor:pointer;transition:background 0.15s}
.upnext-item:hover{background:rgba(255,255,255,0.06)}
.upnext-item.active{background:rgba(255,255,255,0.1)}
.upnext-thumb{position:relative;width:170px;flex-shrink:0;aspect-ratio:16/9;background:#000;border-radius:12px;overflow:hidden}
.upnext-thumb img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.upnext-thumb .video-duration{position:absolute;bottom:4px;right:4px;background:rgba(0,0,0,0.8);padding:1px 5px;border-radius:4px;font-size:11px;font-weight:600}
.upnext-thumb .resume-badge{position:absolute;bottom:4px;left:4px;background:rgba(0,120,255,0.9);color:#fff;padding:1px 6px;border-radius:4px;font-size:11px;font-weight:600;z-index:5}
.upnext-info{min-width:0;flex:1;padding-top:1px}
.upnext-info h4{margin:0 0 4px;font-size:15px;font-weight:500;color:#f1f1f1;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-height:1.35}
.upnext-info .sub{color:#aaa;font-size:12.5px;margin-top:2px;line-height:1.6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.upnext-info .resume-time{color:#4da6ff;font-weight:600}
.shorts-player{position:fixed;inset:0;background:#000;z-index:3000;display:flex;flex-direction:column}
.shorts-close{position:absolute;top:14px;right:14px;z-index:3100;background:rgba(30,30,30,0.8);border:1px solid var(--border);border-radius:50%;color:#fff;font-size:18px;width:40px;height:40px;cursor:pointer;display:flex;align-items:center;justify-content:center}
.shorts-feed{flex:1;overflow-y:auto;scroll-snap-type:y mandatory;scroll-behavior:smooth;scrollbar-width:none}
.shorts-feed::-webkit-scrollbar{display:none}
.shorts-item{height:100%;scroll-snap-align:start;display:flex;align-items:center;justify-content:center;position:relative;background:#000;overflow:hidden;flex-shrink:0}
.shorts-item video{max-height:100%;max-width:100%;width:auto;height:auto;object-fit:contain;position:relative;z-index:1}
.shorts-item .shorts-info{position:absolute;bottom:30px;left:24px;right:120px;text-align:left;color:#fff;text-shadow:0 1px 4px rgba(0,0,0,0.8);pointer-events:none}
.shorts-item .shorts-info h3{font-size:16px;margin:0 0 6px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-height:1.35}
.shorts-item .shorts-info .sub{font-size:13px;color:#ddd;margin-top:4px}
.shorts-item .shorts-actions{position:absolute;right:16px;bottom:40px;display:flex;flex-direction:column;gap:14px;z-index:3100;align-items:center}
.shorts-action-btn{background:rgba(30,30,30,0.85);border:1px solid var(--border);border-radius:50%;color:#fff;font-size:20px;width:46px;height:46px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background 0.15s;backdrop-filter:blur(4px)}
.shorts-action-btn:hover{background:#3a3a3a}
.shorts-action-btn.liked{background:rgba(255,50,80,0.25);border-color:#ff3250}
.shorts-action-label{font-size:11px;color:#ccc;margin-top:-10px}
@media (max-width:1100px){.player-layout{flex-direction:column}.player-side{width:100%;position:static;max-height:none;overflow:visible}}
.channel-header{background:var(--panel);border:1px solid var(--border);border-radius:14px;padding:18px 20px;margin-bottom:20px}
.channel-header-inner{display:flex;align-items:center;gap:16px}
.channel-avatar{width:80px;height:80px;border-radius:50%;object-fit:cover;flex-shrink:0;background:#272727}
.channel-avatar-placeholder{display:flex;align-items:center;justify-content:center;font-size:32px;font-weight:700;color:#fff;background:linear-gradient(135deg,#272727,#3a3a3a)}
.channel-header-info{min-width:0}
.channel-header-name{margin:0 0 6px;font-size:22px;font-weight:700;color:#fff}
.channel-header-meta{display:flex;align-items:center;gap:10px;flex-wrap:wrap;font-size:13px;color:#aaa}
.channel-handle{color:#fff}
.channel-subs{color:#aaa}
.channel-videos{color:#aaa}
.channel-header-meta span:not(:last-child)::after{content:"•";margin-left:10px;color:#555}
@media (max-width:600px){.channel-avatar{width:56px;height:56px}.channel-header-name{font-size:18px}}
.video-description{background:var(--panel);padding:12px;border-radius:8px;font-size:14px;line-height:1.6;white-space:pre-wrap;margin-top:12px}

/* Download Sidebar */
.download-sidebar{position:fixed;top:0;right:-420px;width:420px;height:100vh;background:var(--panel);box-shadow:-2px 0 8px rgba(0,0,0,0.5);transition:right 0.3s ease;z-index:200;display:flex;flex-direction:column;border-left:1px solid var(--border)}
.download-sidebar.open{right:0}
.sidebar-header{padding:16px;border-bottom:1px solid var(--border);display:flex;justify-content:space-between;align-items:center}
.sidebar-header h3{font-size:18px;margin:0}
.close-btn{background:none;border:none;color:#f1f1f1;font-size:24px;cursor:pointer;padding:4px 8px;line-height:1}
.sidebar-content{flex:1;padding:16px;overflow-y:auto}
.form-group{margin-bottom:16px}
.form-group label{display:block;margin-bottom:8px;font-size:14px;font-weight:500}
.form-group input,.form-group textarea,.form-group select,.form-control{width:100%;padding:10px 12px;background:#0f0f0f;border:1px solid var(--border);border-radius:8px;color:#fff;font-size:14px;font-family:inherit}
.form-group input:focus,.form-group textarea:focus,.form-group select:focus{outline:none;border-color:var(--accent)}
.download-queue{margin-top:24px}
.download-queue h4{font-size:14px;margin-bottom:12px;color:#aaa}
.sub-text{font-size:11px;font-weight:normal;color:#888}
.queue-list{display:flex;flex-direction:column;gap:8px}
.queue-item{background:#0f0f0f;padding:12px;border-radius:8px;font-size:13px;border:1px solid var(--border);display:flex;align-items:center;gap:12px}
.queue-url{color:var(--accent);margin-bottom:6px;word-break:break-all;font-size:12px}
.queue-status{display:flex;justify-content:space-between;align-items:center;font-size:11px;margin-top:6px}
.delete-btn{background:#2a0000;color:#ff4444;border:1px solid #440000;border-radius:6px;padding:6px 10px;cursor:pointer;font-size:16px;transition:all 0.2s;flex-shrink:0}
.delete-btn:hover{background:#440000;border-color:#660000}
.status-badge{padding:2px 8px;border-radius:4px;font-weight:500;font-size:10px;text-transform:uppercase}
.status-pending{background:#3a3a00;color:#ffaa00}
.status-processing{background:#003a3a;color:#00aaff}
.status-completed{background:#003a00;color:#00ff00}
.status-failed{background:#3a0000;color:#ff0000}
.status-active{background:#1a3a1a;color:#6aff6a}
.overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.7);z-index:150;display:none}
.overlay.active{display:block}
.loading{text-align:center;padding:40px;color:var(--muted)}

@media (max-width:768px){
    .sidebar{width:220px}
    .sidebar .head{display:none}
    .container{margin-left:8px}
    body.nav-open .container{margin-left:228px}
    .grid{grid-template-columns:repeat(auto-fill,minmax(250px,1fr))}
    .download-sidebar{width:100%;right:-100%}
}

/* Download Stats Modal */
.modal{display:none;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.8);z-index:2000;align-items:center;justify-content:center;padding:20px}
.modal-content{background:var(--panel);border:1px solid var(--border);border-radius:16px;max-width:800px;width:100%;max-height:90vh;overflow:auto;box-shadow:0 8px 32px rgba(0,0,0,0.8)}
.modal-header{display:flex;justify-content:space-between;align-items:center;padding:20px;border-bottom:1px solid var(--border)}
.modal-header h3{margin:0;font-size:20px}
.modal-body{padding:20px}
.close-btn{background:transparent;border:none;color:#fff;font-size:24px;cursor:pointer;padding:0;width:32px;height:32px;display:flex;align-items:center;justify-content:center;border-radius:8px;transition:background 0.2s}
.close-btn:hover{background:#2a2a2a}

/* Stats Grid */
.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px;margin-bottom:24px}
.stat-card{background:var(--card);border:1px solid var(--border);border-radius:12px;padding:16px;text-align:center}
.stat-label{font-size:12px;color:var(--muted);text-transform:uppercase;margin-bottom:8px}
.stat-value{font-size:24px;font-weight:700;color:var(--accent)}

/* Downloads List */
.downloads-list{display:flex;flex-direction:column;gap:12px}
.download-item{background:var(--card);border:1px solid var(--border);border-radius:12px;padding:16px}
.download-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}
.download-header strong{font-size:16px;color:#fff}
.download-progress{background:#2a2a2a;padding:4px 12px;border-radius:12px;font-size:13px;font-weight:600;color:var(--accent)}
.download-file{font-size:13px;color:var(--muted);margin-bottom:6px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.download-meta{font-size:12px;color:#888}

/* Health dot in top nav */
.health-dot-nav { width: 13px; height: 13px; border-radius: 50%; background: #555; display: inline-block; vertical-align: middle; flex-shrink: 0; transition: background 0.3s, box-shadow 0.3s; }
.health-dot-nav.green { background: #22c55e !important; box-shadow: 0 0 6px #22c55e; }
.health-dot-nav.red   { background: #ef4444 !important; box-shadow: 0 0 6px #ef4444; }

/* Health Panel — same as download-sidebar */
.health-panel { position: fixed; top: 0; right: -420px; width: 420px; height: 100vh; background: var(--panel); box-shadow: -2px 0 8px rgba(0,0,0,0.5); transition: right 0.3s ease; z-index: 200; display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.health-panel.open { right: 0; }

/* Health status rows */
.health-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px; background: #0f0f0f; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; }
.health-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.health-label { font-size: 13px; font-weight: 600; color: #fff; margin-bottom: 3px; }
.health-msg { font-size: 12px; color: #888; word-break: break-all; }
.health-badge { margin-left: auto; flex-shrink: 0; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 12px; text-transform: uppercase; align-self: center; }
.health-badge.ok       { background: #003a00; color: #00ee66; }
.health-badge.banned   { background: #3a0000; color: #ff4444; }
.health-badge.expired  { background: #3a0000; color: #ff4444; }
.health-badge.age_fail { background: #3a0000; color: #ff4444; }
.health-badge.missing  { background: #3a0000; color: #ff4444; }
.health-badge.error    { background: #3a1a00; color: #ff9800; }
.health-badge.invalid  { background: #3a1a00; color: #ff9800; }
.health-badge.checking { background: #2a2a2a; color: #888; }
.health-sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
