@import url('https://fonts.googleapis.com/css2?family=Stack+Sans+Notch:wght@200..700&family=Space+Grotesk:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent}

/* ─── THEME TOKENS ─── */
[data-theme="dark"]{
  --bg:#101010;--bg2:#151515;--bg3:#1c1c1e;
  --fg:#fff;--fg2:#e4e4e4;--muted:#8a8a8e;--muted2:#6a6a6e;
  --surface:#1c1c1e;--surface2:#242426;--surface3:#2d2d2f;
  --glass-bg:#1c1c1e;--glass-bg2:#242426;
  --border:#2d2d2f;--border2:#3a3a3c;--border3:#4a4a4c;
  --accent:#fff;--accent-fg:#101010;--accent-bg:#242426;
  --overlay:rgba(0,0,0,.82);
  --red:#f87171;--red-bg:rgba(248,113,113,.12);
  --green:#4ade80;--green-bg:rgba(74,222,128,.12);
  --blue:#38bdf8;--blue-bg:rgba(56,189,248,.12);
  --yellow:#facc15;--yellow-bg:rgba(250,204,21,.12);
  --purple:#c084fc;--purple-bg:rgba(192,132,252,.12);
}
[data-theme="light"]{
  --bg:#f0f2f5;--bg2:#e8eaed;--bg3:#dde0e5;
  --fg:#212529;--fg2:#495057;--muted:#6c757d;--muted2:#8a8a8e;
  --surface:#fff;--surface2:#f8f9fa;--surface3:#e9ecef;
  --glass-bg:#fff;--glass-bg2:#f7f7f7;
  --border:#dee2e6;--border2:#ced4da;--border3:#adb5bd;
  --accent:#1a1a1a;--accent-fg:#fff;--accent-bg:#f0f0f0;
  --overlay:rgba(255,255,255,.85);
  --red:#dc2626;--red-bg:rgba(220,38,38,.08);
  --green:#16a34a;--green-bg:rgba(22,163,74,.08);
  --blue:#0284c7;--blue-bg:rgba(2,132,199,.08);
  --yellow:#ca8a04;--yellow-bg:rgba(202,138,4,.08);
  --purple:#9333ea;--purple-bg:rgba(147,51,234,.08);
}

html{scroll-behavior:smooth}
body{
  font-family:'Space Grotesk',system-ui,sans-serif;
  background:var(--bg);color:var(--fg);
  min-height:100dvh;-webkit-font-smoothing:antialiased;
  transition:background .2s,color .2s;overflow-x:hidden;
  padding-top:72px;padding-bottom:calc(90px + env(safe-area-inset-bottom));
  position:relative;
}
h1,h2,h3,h4,h5,h6{font-family:'Stack Sans Notch','Space Grotesk',sans-serif}
a{color:inherit;text-decoration:none}
button{font-family:inherit}
img{max-width:100%;display:block}

body::before{
  content:"";position:fixed;inset:0;width:100vw;height:100vh;
  background-image:radial-gradient(var(--border) 1px,transparent 1px);
  background-size:40px 40px;z-index:-1;pointer-events:none;
  animation:movePattern 60s linear infinite;
}
@keyframes movePattern{0%{background-position:0 0}100%{background-position:40px 40px}}
@media(prefers-reduced-motion:reduce){body::before{animation:none}}

::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--border2);border-radius:6px}
::selection{background:var(--blue);color:#000}

/* ─── HEADER ─── */
.header{
  position:fixed;top:0;left:0;right:0;z-index:200;height:72px;
  background:var(--surface);border-bottom:1px solid var(--border);
  transition:background-color .3s,border-color .3s;
}
.header-inner{
  max-width:1100px;margin:0 auto;height:100%;
  padding:0 16px;display:flex;align-items:center;gap:14px;
}
.logo{display:flex;align-items:center;gap:9px;flex-shrink:0;cursor:pointer}
.logo-badge{
  width:32px;height:32px;border-radius:9px;background:var(--accent);color:var(--accent-fg);
  display:flex;align-items:center;justify-content:center;flex-shrink:0;
}
.logo-badge svg{width:18px;height:18px;fill:currentColor}
.logo-text{font-size:1.15rem;font-weight:700;letter-spacing:-.01em;white-space:nowrap}
.logo-text span{color:var(--muted);font-weight:500}

.header-search{flex:1;max-width:640px;margin:0 auto;position:relative}
.header-search svg{position:absolute;left:14px;top:50%;transform:translateY(-50%);width:16px;height:16px;stroke:var(--muted);fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
.header-search input{
  width:100%;height:42px;background:var(--surface2);border:1px solid var(--border);
  border-radius:999px;padding:0 42px 0 40px;font-size:13.5px;font-family:inherit;
  color:var(--fg);outline:none;transition:all .2s;
}
.header-search input:focus{border-color:var(--border3);background:var(--surface)}
.header-search input::placeholder{color:var(--muted)}
.header-search-clear{
  position:absolute;right:6px;top:50%;transform:translateY(-50%);
  width:30px;height:30px;border-radius:50%;border:none;background:transparent;
  color:var(--muted);display:none;align-items:center;justify-content:center;cursor:pointer;
}
.header-search-clear.show{display:flex}
.header-search-clear:hover{background:var(--surface3);color:var(--fg)}

.header-right{display:flex;align-items:center;gap:8px;flex-shrink:0}
.icon-btn{
  width:38px;height:38px;border:1px solid var(--border);border-radius:10px;
  background:var(--surface2);color:var(--fg);
  display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .15s;flex-shrink:0;
}
.icon-btn:hover{background:var(--surface3);border-color:var(--border2)}
.icon-btn svg{width:17px;height:17px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
[data-theme="dark"] .icon-btn .sun{display:block}[data-theme="dark"] .icon-btn .moon{display:none}
[data-theme="light"] .icon-btn .sun{display:none}[data-theme="light"] .icon-btn .moon{display:block}

.mobile-search-toggle{display:none}
@media(max-width:720px){
  .header-inner{padding:0 12px;gap:8px}
  .logo-text{font-size:1rem}
  .header-search{display:none}
  .header-search.active{
    display:flex;position:fixed;top:0;left:0;right:0;height:64px;padding:0 10px;
    background:var(--surface);z-index:210;align-items:center;max-width:none;margin:0;
  }
  .mobile-search-toggle{display:flex}
}

/* ─── BOTTOM NAV ─── */
.bottom-nav{
  position:fixed;left:50%;bottom:12px;transform:translateX(-50%);z-index:150;
  width:min(420px,calc(100% - 24px));display:flex;gap:2px;padding:6px;
  background:color-mix(in srgb,var(--surface) 92%,transparent);
  border:1px solid var(--border);border-radius:16px;
  backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);
  box-shadow:0 12px 34px rgba(0,0,0,.18);
}
.bottom-nav-btn{
  flex:1;border:none;background:none;cursor:pointer;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;
  padding:9px 6px;border-radius:11px;color:var(--muted);
  font-family:inherit;font-size:10px;font-weight:700;transition:all .15s;
}
.bottom-nav-btn svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.bottom-nav-btn:hover{color:var(--fg2)}
.bottom-nav-btn.active{background:var(--accent);color:var(--accent-fg)}

/* ─── MAIN ─── */
.main{max-width:1100px;margin:0 auto;padding:20px 16px 24px;min-height:60vh}
@media(max-width:720px){.main{padding:14px 12px 20px}}
.hidden{display:none!important}

@keyframes fadeInUp{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
.fade-in{animation:fadeInUp .3s ease}

/* ─── HERO / LANDING ─── */
.hero{
  background:var(--surface);border:1px solid var(--border);border-radius:16px;
  padding:32px 24px;margin-bottom:22px;text-align:center;
}
.hero-title{font-size:clamp(22px,5vw,32px);font-weight:800;letter-spacing:-.03em;margin-bottom:8px}
.hero-sub{font-size:13.5px;color:var(--muted);max-width:480px;margin:0 auto 20px}
.hero-form{display:flex;gap:8px;max-width:560px;margin:0 auto}
.hero-form input{
  flex:1;height:48px;background:var(--surface2);border:1px solid var(--border);
  border-radius:12px;padding:0 16px;font-size:14px;color:var(--fg);outline:none;font-family:inherit;
}
.hero-form input:focus{border-color:var(--border3)}
.hero-hint{margin-top:12px;font-size:11px;color:var(--muted)}

.section-head{display:flex;align-items:center;justify-content:space-between;margin:4px 0 14px}
.section-head h2{font-size:16px;font-weight:700;letter-spacing:-.01em;display:flex;align-items:center;gap:8px}
.section-head h2 svg{width:16px;height:16px;stroke:var(--fg);fill:none;stroke-width:1.8}

/* ─── TABS ─── */
.tabbar{display:flex;gap:6px;margin-bottom:16px;background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:4px}
.tabbar-btn{
  flex:1;border:none;background:transparent;color:var(--muted);cursor:pointer;
  font-family:inherit;font-size:12.5px;font-weight:700;padding:9px 10px;border-radius:9px;
  display:flex;align-items:center;justify-content:center;gap:6px;transition:all .15s;
}
.tabbar-btn svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:1.8}
.tabbar-btn.active{background:var(--accent);color:var(--accent-fg)}

/* ─── BUTTONS ─── */
.btn{
  padding:9px 16px;border-radius:10px;border:none;font-size:12.5px;font-weight:600;
  cursor:pointer;font-family:inherit;transition:all .15s;white-space:nowrap;
  display:inline-flex;align-items:center;gap:6px;
}
.btn svg{width:13px;height:13px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.btn-primary{background:var(--accent);color:var(--accent-fg)}
.btn-primary:hover{opacity:.88}
.btn-primary:disabled{opacity:.4;cursor:not-allowed}
.btn-secondary{background:var(--surface2);color:var(--fg);border:1px solid var(--border)}
.btn-secondary:hover{border-color:var(--border2);background:var(--surface3)}

/* ─── VIDEO GRID / CARDS ─── */
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:16px}
@media(max-width:560px){.grid{grid-template-columns:1fr 1fr;gap:10px}}
@media(max-width:400px){.grid{grid-template-columns:1fr;gap:12px}}

.v-card{cursor:pointer;transition:transform .15s}
.v-thumb{
  position:relative;width:100%;aspect-ratio:16/9;border-radius:12px;overflow:hidden;
  background:var(--surface2);border:1px solid var(--border);margin-bottom:8px;
}
.v-thumb img{width:100%;height:100%;object-fit:cover;transition:transform .3s}
.v-card:hover .v-thumb img{transform:scale(1.04)}
.v-duration{
  position:absolute;right:6px;bottom:6px;background:rgba(0,0,0,.82);color:#fff;
  font-size:10.5px;font-weight:700;padding:2px 6px;border-radius:5px;
  font-family:'JetBrains Mono',monospace;letter-spacing:.02em;
}
.v-playlist-badge{
  position:absolute;inset:0;background:linear-gradient(0deg,rgba(0,0,0,.55),transparent 40%);
  display:flex;align-items:flex-end;justify-content:flex-end;padding:6px;
}
.v-count{
  background:rgba(0,0,0,.82);color:#fff;font-size:10.5px;font-weight:700;
  padding:3px 8px;border-radius:6px;display:flex;align-items:center;gap:4px;
}
.v-count svg{width:11px;height:11px;stroke:#fff;fill:none;stroke-width:2}
.v-meta{display:flex;gap:9px}
.v-avatar{
  width:34px;height:34px;border-radius:50%;background:var(--surface3);flex-shrink:0;
  display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;color:var(--muted);
  overflow:hidden;
}
.v-info{min-width:0;flex:1}
.v-title{
  font-size:13.5px;font-weight:600;line-height:1.35;color:var(--fg);
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin-bottom:3px;
}
.v-channel{font-size:11.5px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.v-sub{font-size:11px;color:var(--muted2)}

.skeleton{background:linear-gradient(90deg,var(--surface) 25%,var(--surface2) 50%,var(--surface) 75%);background-size:200% 100%;animation:skel 1.4s infinite;border-radius:12px}
@keyframes skel{0%{background-position:200% 0}100%{background-position:-200% 0}}
.sk-thumb{aspect-ratio:16/9;margin-bottom:8px}
.sk-line{height:11px;border-radius:5px;margin-bottom:6px}

.empty-state{
  text-align:center;padding:56px 20px;color:var(--muted);
}
.empty-state svg{width:40px;height:40px;stroke:var(--muted);fill:none;stroke-width:1.4;margin-bottom:12px}
.empty-state strong{display:block;color:var(--fg);font-size:14px;margin-bottom:4px}
.empty-state p{font-size:12px}

/* ─── WATCH PAGE ─── */
.watch-layout{display:grid;grid-template-columns:1fr;gap:20px}
@media(min-width:920px){.watch-layout{grid-template-columns:2fr 1fr;align-items:start}}

.player-wrap{
  position:relative;width:100%;aspect-ratio:16/9;background:#000;border-radius:14px;overflow:hidden;
  border:1px solid var(--border);
}
.player-wrap video{width:100%;height:100%;object-fit:contain;background:#000}
.player-overlay{
  position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  background:rgba(0,0,0,.55);color:#fff;flex-direction:column;gap:10px;font-size:12px;text-align:center;padding:20px;
}
.spinner{width:34px;height:34px;border:3px solid rgba(255,255,255,.25);border-top-color:#fff;border-radius:50%;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

.watch-title{font-size:18px;font-weight:700;letter-spacing:-.01em;line-height:1.3;margin:14px 0 10px}
.watch-toolbar{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin-bottom:14px}
.watch-channel{display:flex;align-items:center;gap:10px;min-width:0}
.watch-channel-name{font-size:13px;font-weight:600}
.watch-channel-sub{font-size:11px;color:var(--muted)}
.watch-actions{display:flex;gap:8px;flex-wrap:wrap}

.dropdown{position:relative}
.dropdown-menu{
  position:absolute;top:calc(100% + 6px);right:0;min-width:220px;background:var(--surface);
  border:1px solid var(--border);border-radius:12px;padding:6px;z-index:60;
  box-shadow:0 12px 30px rgba(0,0,0,.25);display:none;
}
.dropdown-menu.show{display:block}
.dropdown-item{
  display:flex;align-items:center;justify-content:space-between;gap:10px;padding:9px 10px;border-radius:8px;
  font-size:12.5px;font-weight:500;color:var(--fg2);cursor:pointer;transition:background .15s;
}
.dropdown-item:hover{background:var(--surface2)}
.dropdown-item.active{color:var(--fg);font-weight:700}
.dropdown-item .tag-mini{font-size:9.5px;color:var(--muted);font-family:'JetBrains Mono',monospace}
.dropdown-divider{height:1px;background:var(--border);margin:5px 2px}

.panel{background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:16px;margin-bottom:14px}
.watch-desc{font-size:12.5px;color:var(--fg2);line-height:1.6;white-space:pre-wrap}
.watch-desc.clamped{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.watch-desc-toggle{margin-top:8px;font-size:11.5px;font-weight:700;color:var(--muted);cursor:pointer}
.watch-desc-toggle:hover{color:var(--fg)}

.queue-list{display:flex;flex-direction:column;gap:6px;max-height:70vh;overflow-y:auto}
.queue-item{
  display:flex;gap:10px;padding:8px;border-radius:10px;cursor:pointer;transition:background .15s;
  border:1px solid transparent;
}
.queue-item:hover{background:var(--surface2)}
.queue-item.active{background:var(--surface2);border-color:var(--border2)}
.queue-thumb{position:relative;width:110px;flex-shrink:0;aspect-ratio:16/9;border-radius:8px;overflow:hidden;background:var(--surface3)}
.queue-thumb img{width:100%;height:100%;object-fit:cover}
.queue-index{
  position:absolute;left:4px;top:4px;background:rgba(0,0,0,.75);color:#fff;font-size:9px;font-weight:700;
  padding:1px 5px;border-radius:4px;font-family:'JetBrains Mono',monospace;
}
.queue-playing{position:absolute;inset:0;background:rgba(0,0,0,.5);display:flex;align-items:center;justify-content:center}
.queue-playing svg{width:16px;height:16px;stroke:#fff;fill:#fff}
.queue-info{min-width:0;flex:1}
.queue-title{font-size:12px;font-weight:600;line-height:1.35;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.queue-sub{font-size:10.5px;color:var(--muted);margin-top:3px}

/* ─── MINI AUDIO PLAYER ─── */
.mini-player{
  position:fixed;left:50%;bottom:78px;transform:translateX(-50%) translateY(140%);
  width:min(560px,calc(100% - 24px));background:var(--surface);border:1px solid var(--border);
  border-radius:14px;padding:10px 12px;z-index:140;display:flex;align-items:center;gap:10px;
  box-shadow:0 14px 34px rgba(0,0,0,.28);transition:transform .3s ease;
}
.mini-player.show{transform:translateX(-50%) translateY(0)}
.mini-thumb{width:44px;height:44px;border-radius:9px;overflow:hidden;flex-shrink:0;background:var(--surface3)}
.mini-thumb img{width:100%;height:100%;object-fit:cover}
.mini-info{min-width:0;flex:1;cursor:pointer}
.mini-title{font-size:12px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mini-sub{font-size:10.5px;color:var(--muted);display:flex;align-items:center;gap:5px}
.mini-opus-tag{
  font-size:8.5px;font-weight:800;color:var(--purple);background:var(--purple-bg);
  padding:1px 5px;border-radius:4px;letter-spacing:.03em;
}
.mini-controls{display:flex;align-items:center;gap:4px;flex-shrink:0}
.mini-btn{
  width:32px;height:32px;border-radius:50%;border:none;background:transparent;color:var(--fg);
  display:flex;align-items:center;justify-content:center;cursor:pointer;transition:background .15s;
}
.mini-btn:hover{background:var(--surface2)}
.mini-btn svg{width:16px;height:16px;stroke:currentColor;fill:currentColor}
.mini-btn.play svg{width:20px;height:20px}
.mini-progress{
  position:absolute;left:12px;right:12px;bottom:2px;height:2px;background:var(--border);border-radius:2px;overflow:hidden;
}
.mini-progress-fill{height:100%;background:var(--accent);width:0%;transition:width .1s linear}

@media(max-width:520px){
  .mini-player{bottom:76px;padding:8px 10px}
  .mini-sub{display:none}
}

/* ─── TOAST ─── */
.toast{
  position:fixed;bottom:calc(96px + env(safe-area-inset-bottom));left:50%;
  transform:translateX(-50%) translateY(20px);background:var(--surface2);
  border:1px solid var(--border2);color:var(--fg);padding:11px 18px;border-radius:12px;
  font-size:12.5px;font-weight:600;opacity:0;transition:all .3s;z-index:999;
  white-space:nowrap;pointer-events:none;box-shadow:0 8px 32px rgba(0,0,0,.3);
}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}

.badge-opus{
  display:inline-flex;align-items:center;gap:4px;font-size:10px;font-weight:800;
  color:var(--purple);background:var(--purple-bg);padding:3px 8px;border-radius:6px;letter-spacing:.02em;
}
.badge-live{
  display:inline-flex;align-items:center;gap:5px;font-size:10px;font-weight:800;
  color:var(--red);background:var(--red-bg);padding:3px 8px;border-radius:6px;
}
.badge-live .dot{width:5px;height:5px;border-radius:50%;background:var(--red);animation:pulse 1.4s infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.35}}

@media(max-width:720px){
  body{padding-top:64px}
  .header{height:64px}
  .header-inner{height:64px}
}
