/* ==========================================================================
   SlideTube
   ========================================================================== */

:root {
  --bg: #f6f5f1;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #eeece6;
  --surface-3: #e4e1d9;
  --line: rgba(24, 20, 8, 0.09);
  --line-2: rgba(24, 20, 8, 0.17);
  --text: #18170f;
  --text-2: #54524a;
  --text-3: #7d7b72;
  --accent: #f5b300;
  --accent-ink: #1a1300;
  --accent-soft: rgba(245, 179, 0, 0.18);
  --accent-text: #8a6100;
  --live: #e5372b;
  --shadow: 0 1px 2px rgba(20, 16, 0, 0.06), 0 8px 24px rgba(20, 16, 0, 0.08);
  --shadow-lg: 0 12px 48px rgba(20, 16, 0, 0.18);
  --topbar-bg: rgba(246, 245, 241, 0.86);
  --sk: rgba(24, 20, 8, 0.07);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --top: 60px;
  --gutter: 24px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e10;
    --bg-elev: #151518;
    --surface: #18181b;
    --surface-2: #222226;
    --surface-3: #2c2c31;
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.15);
    --text: #f3f2ee;
    --text-2: #b3b2ab;
    --text-3: #83827b;
    --accent-soft: rgba(245, 179, 0, 0.14);
    --accent-text: #ffc933;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 56px rgba(0, 0, 0, 0.6);
    --topbar-bg: rgba(14, 14, 16, 0.84);
    --sk: rgba(255, 255, 255, 0.06);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e10;
  --bg-elev: #151518;
  --surface: #18181b;
  --surface-2: #222226;
  --surface-3: #2c2c31;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.15);
  --text: #f3f2ee;
  --text-2: #b3b2ab;
  --text-3: #83827b;
  --accent-soft: rgba(245, 179, 0, 0.14);
  --accent-text: #ffc933;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 56px rgba(0, 0, 0, 0.6);
  --topbar-bg: rgba(14, 14, 16, 0.84);
  --sk: rgba(255, 255, 255, 0.06);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
code, kbd { font-family: var(--mono); font-size: 0.86em; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; text-align: center;
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px;
  background: var(--surface); color: var(--text-2);
}
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--text-3); }

.i { width: 20px; height: 20px; fill: currentColor; flex: none; }
.ic-verified { width: 13px; height: 13px; margin-left: 4px; vertical-align: -1px; color: var(--text-3); }

.skip {
  position: absolute; left: 12px; top: -40px; z-index: 100; padding: 8px 12px;
  background: var(--accent); color: var(--accent-ink); border-radius: 8px; font-weight: 600;
}
.skip:focus { top: 12px; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-weight: 500;
  border: 1px solid transparent; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.98); }
.btn .i { width: 18px; height: 18px; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-sm .i { width: 16px; height: 16px; }
.btn-ghost { background: transparent; border-color: var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: #ffc21f; }
.btn-pill.on { background: var(--accent-soft); color: var(--accent-text); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; height: 32px; padding: 0 14px;
  border-radius: 999px; background: var(--surface-2); color: var(--text);
  font-weight: 500; font-size: 13px; white-space: nowrap; transition: background 0.15s;
}
.chip:hover { background: var(--surface-3); }
.chip.on { background: var(--text); color: var(--bg); }

/* --------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: grid; grid-template-columns: auto minmax(0, 640px) auto; justify-content: space-between;
  align-items: center; gap: 20px; height: var(--top); padding: 0 var(--gutter);
  background: var(--topbar-bg); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand-mark { display: flex; }
.logo-mark { width: 30px; height: 30px; }

.search { position: relative; width: 100%; }
.search-box {
  display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 8px 0 14px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-ic { display: flex; color: var(--text-3); }
.search-box input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; font-size: 15px;
}
.search-box input::-webkit-search-cancel-button { display: none; }
.search-box input::placeholder { color: var(--text-3); }
.search-clear { display: flex; padding: 6px; border-radius: 999px; color: var(--text-2); }
.search-clear:hover { background: var(--surface-2); }
.search-kbd { margin-right: 4px; }
.search-box:focus-within .search-kbd { display: none; }

.suggest {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; margin: 0; padding: 6px;
  list-style: none; background: var(--bg-elev); border: 1px solid var(--line-2);
  border-radius: 16px; box-shadow: var(--shadow-lg); z-index: 60;
}
.sug-head { padding: 8px 12px 4px; font-size: 12px; color: var(--text-3); font-weight: 500; }
.sug {
  display: flex; align-items: center; gap: 12px; padding: 0 8px 0 12px; height: 40px;
  border-radius: 10px; cursor: pointer; color: var(--text);
}
.sug .i { width: 18px; height: 18px; color: var(--text-3); }
.sug.recent .sug-text { color: var(--accent-text); }
.sug.link .i { color: var(--accent); }
.sug-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.sug-text b { font-weight: 600; }
.sug:hover, .sug.active { background: var(--surface-2); }
.sug-del { display: flex; padding: 6px; border-radius: 999px; color: var(--text-3); }
.sug-del:hover { background: var(--surface-3); color: var(--text); }

.top-nav { display: flex; gap: 4px; }
.top-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.top-btn:hover { background: var(--surface-2); color: var(--text); }
.top-btn.on { background: var(--accent-soft); color: var(--accent-text); }

/* --------------------------------------------------------------- pages */
#view { outline: none; }
.page { max-width: 1680px; margin: 0 auto; padding: 24px var(--gutter) 96px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; margin: 8px 0 24px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.page-head .btn { margin-left: auto; }

/* home */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px;
  padding: 40px 0 36px; margin-bottom: 8px; border-bottom: 1px solid var(--line);
}
.hero h1 {
  margin: 0; font-size: clamp(32px, 5vw, 56px); line-height: 1.02; letter-spacing: -0.035em; font-weight: 700;
}
.hero h1 span { color: var(--text-3); }
.lede { max-width: 620px; margin: 16px 0 0; font-size: 16px; color: var(--text-2); }
.topics { display: flex; flex-wrap: wrap; gap: 8px; }

.shelf { margin-top: 36px; }
.shelf > header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.shelf h2 { margin: 0; font-size: 19px; letter-spacing: -0.015em; }
.shelf > header a { color: var(--text-2); font-weight: 500; font-size: 13px; }
.shelf > header a:hover { color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 28px 16px; }
.empty-inline { color: var(--text-3); margin: 0; grid-column: 1 / -1; }

/* --------------------------------------------------------------- cards */
.card { position: relative; min-width: 0; }
.thumb {
  position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: var(--radius); background: var(--surface-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s ease; }
.card:hover .thumb img { transform: scale(1.03); }
.badge {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 6px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.78); color: #fff; font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 4px;
}
.badge-live { background: var(--live); }
.badge .i { width: 14px; height: 14px; }
.watched { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, 0.35); }
.watched::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--p); background: var(--accent); }
.thumb-actions {
  position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 6px;
  opacity: 0; transform: translateY(-4px); transition: opacity 0.15s, transform 0.15s;
}
.card:hover .thumb-actions, .card:focus-within .thumb-actions { opacity: 1; transform: none; }
@media (hover: none) { .thumb-actions { opacity: 1; transform: none; } }
.ta {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.72); color: #fff; backdrop-filter: blur(4px);
}
.ta .i { width: 18px; height: 18px; }
.ta:hover { background: rgba(0, 0, 0, 0.9); }
.ta.on { color: var(--accent); }

.card-body { display: flex; gap: 12px; padding-top: 12px; }
.avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; background: var(--surface-2); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.card-text { min-width: 0; flex: 1; }
.card-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-weight: 600; font-size: 15px; line-height: 1.35; letter-spacing: -0.005em;
}
.card-title:hover { color: var(--accent-text); }
.card-channel {
  display: inline-flex; align-items: center; margin-top: 4px; color: var(--text-2); font-size: 13px; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-channel:hover { color: var(--text); }
.card-channel img { width: 22px; height: 22px; border-radius: 50%; margin-right: 8px; }
.card-sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.card-snippet {
  margin: 10px 0 0; color: var(--text-3); font-size: 13px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* search-result rows */
.card-row { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 18px; }
.card-row .card-body { padding-top: 2px; }
.card-row .card-title { font-size: 17px; font-weight: 500; -webkit-line-clamp: 2; }
.card-row .card-channel { margin: 10px 0 0; order: 3; }
.card-row .card-text { display: flex; flex-direction: column; }
.card-row .card-sub { order: 2; }
.card-row .card-snippet { order: 4; }

/* compact (up next) */
.card-compact { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 10px; }
.card-compact .thumb { border-radius: 8px; }
.card-compact .card-body { padding: 0; }
.card-compact .card-title { font-size: 14px; }
.card-compact .card-channel, .card-compact .card-sub { font-size: 12px; }
.card-compact .badge { font-size: 11px; right: 4px; bottom: 4px; }
.card-compact .thumb-actions { top: 4px; right: 4px; gap: 4px; }
.card-compact .ta { width: 28px; height: 28px; }

/* playlists, channels, shorts */
.pl-overlay {
  position: absolute; inset: 0 0 0 auto; width: 38%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; background: rgba(0, 0, 0, 0.72);
  color: #fff; font-size: 13px; font-weight: 600; text-align: center; padding: 0 6px;
}
.card-chan {
  display: flex; align-items: center; gap: 24px; padding: 16px; border-radius: var(--radius);
  transition: background 0.15s;
}
.card-chan:hover { background: var(--surface-2); }
.card-chan img { width: 112px; height: 112px; border-radius: 50%; object-fit: cover; flex: none; margin-left: clamp(0px, 8vw, 120px); }
.card-chan b { font-size: 18px; display: flex; align-items: center; }
.card-chan small { color: var(--text-3); font-size: 13px; display: block; margin-top: 2px; }
.card-chan p { margin: 8px 0 0; color: var(--text-2); font-size: 13px; max-width: 560px; }

.shorts-shelf { padding: 8px 0 4px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.shorts-shelf h3 { display: flex; align-items: center; gap: 8px; margin: 10px 0 14px; font-size: 17px; }
.shorts-shelf h3 .i { color: var(--live); }
.shorts-row { display: grid; grid-auto-flow: column; grid-auto-columns: 180px; gap: 12px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: thin; }
.short { position: relative; display: block; aspect-ratio: 9 / 16; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.short img { width: 100%; height: 100%; object-fit: cover; }
.short-text {
  position: absolute; inset: auto 0 0 0; padding: 40px 10px 10px; color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
}
.short-text b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; line-height: 1.3; }
.short-text small { font-size: 12px; opacity: 0.8; }

/* skeletons */
.sk .thumb, .sk-block { background: var(--sk); animation: pulse 1.4s ease-in-out infinite; }
.sk .card-text i, .w-desc.loading i {
  display: block; height: 12px; border-radius: 6px; background: var(--sk); margin-top: 8px; animation: pulse 1.4s ease-in-out infinite;
}
.sk .card-text i:first-child { width: 90%; height: 14px; margin-top: 0; }
.sk .card-text i:nth-child(2) { width: 60%; }
.sk .card-text i:nth-child(3) { width: 40%; }
.sk-line { min-height: 1.2em; width: 60%; border-radius: 8px; background: var(--sk); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* --------------------------------------------------------------- search page */
.filters {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 14px; margin-bottom: 8px;
  scrollbar-width: none; position: sticky; top: var(--top); z-index: 5; background: var(--bg);
  padding-top: 10px; margin-top: -10px;
}
.filters::-webkit-scrollbar { display: none; }
.search-note { margin: 0 0 16px; color: var(--text-2); }
.search-note a { color: var(--accent-text); font-weight: 600; font-style: italic; }
.results { display: flex; flex-direction: column; gap: 18px; max-width: 1180px; }
.sentinel { display: grid; place-items: center; height: 80px; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 72px 16px; color: var(--text-2); }
.empty > .i { width: 44px; height: 44px; color: var(--text-3); margin-bottom: 8px; }
.empty h3 { margin: 0; color: var(--text); font-size: 18px; }
.empty p { margin: 0 0 8px; }

/* --------------------------------------------------------------- channel */
.ch-head { margin-bottom: 28px; }
.ch-head.sk-block { height: 220px; border-radius: 16px; }
.ch-banner { aspect-ratio: 6.2 / 1; border-radius: 16px; overflow: hidden; background: var(--surface-2); margin-bottom: 20px; }
.ch-banner img { width: 100%; height: 100%; object-fit: cover; }
.ch-info { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.ch-info > div { flex: 1; min-width: 220px; }
.ch-avatar { width: 112px; height: 112px; border-radius: 50%; object-fit: cover; }
.ch-info h1 { margin: 0; font-size: 32px; letter-spacing: -0.025em; }
.ch-meta { margin: 4px 0 0; color: var(--text-2); }
.ch-desc { margin: 8px 0 0; color: var(--text-3); max-width: 640px; }

/* --------------------------------------------------------------- library / settings */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; }
.tab { padding: 6px 14px; border-radius: 999px; font-weight: 500; color: var(--text-2); }
.tab:hover { color: var(--text); }
.tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.search-list { list-style: none; padding: 0; margin: 0; max-width: 640px; }
.search-list a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; }
.search-list a:hover { background: var(--surface-2); }
.search-list .i { color: var(--text-3); }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.set-card { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.set-card h2 { margin: 0 0 6px; font-size: 17px; letter-spacing: -0.01em; }
.set-sub { margin: 20px 0 8px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.set-note { margin: 0 0 14px; color: var(--text-2); }
.radio-cards { display: grid; gap: 8px; }
.radio-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.radio-card:hover { background: var(--surface-2); }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { margin: 3px 0 0; accent-color: var(--accent); }
.radio-card b, .toggle-row b, .select-row b { display: block; font-weight: 600; }
.radio-card small, .toggle-row small { display: block; color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.toggle-row, .select-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-top: 1px solid var(--line); cursor: pointer;
}
.set-card .toggle-row:first-of-type { margin-top: 16px; }
select {
  height: 34px; padding: 0 30px 0 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface-2); appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat;
}

.switch {
  appearance: none; flex: none; width: 40px; height: 24px; border-radius: 999px; margin: 0;
  background: var(--surface-3); position: relative; cursor: pointer; transition: background 0.2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
.switch-sm { width: 32px; height: 18px; }
.switch-sm::after { width: 14px; height: 14px; top: 2px; left: 2px; }
.switch-sm:checked::after { transform: translateX(14px); }


/* --------------------------------------------------------------- watch page */
.watch {
  display: grid; max-width: 1760px; margin: 0 auto; padding: 24px var(--gutter) 80px;
  grid-template-columns: minmax(0, 1fr) 402px; grid-template-areas: "player side" "main side";
  grid-template-rows: auto 1fr; gap: 0 24px;
}
.w-player { grid-area: player; min-width: 0; }
.w-main { grid-area: main; min-width: 0; padding-top: 16px; }
.w-side { grid-area: side; min-width: 0; }
.watch.theater { grid-template-areas: "player player" "main side"; }
.watch.theater .w-side { padding-top: 16px; }
.watch.theater #player { width: min(100%, calc((100vh - var(--top) - 64px) * 16 / 9)); margin: 0 auto; }
.watch.theater .w-player { background: #000; margin: -24px calc(var(--gutter) * -1) 0; padding: 0; }
.watch.theater:not(.mini) #player:not(.is-fs) { border-radius: 0; }

body:not(.watching) .watch:not(.mini) { display: none; }

.w-title { margin: 0 0 12px; font-size: 21px; line-height: 1.3; letter-spacing: -0.015em; font-weight: 650; }
.w-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.w-channel { display: flex; align-items: center; gap: 12px; min-width: 0; }
.w-channel img, .w-avatar-ph { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; }
.w-channel b { display: flex; align-items: center; font-size: 15px; }
.w-channel small { display: block; color: var(--text-3); font-size: 12.5px; }
.w-channel:hover b { color: var(--accent-text); }
.w-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.w-playlist {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 16px; padding: 12px 14px;
  border-radius: 12px; border: 1px solid var(--line-2); color: var(--text-2);
}
.w-playlist > span { flex: 1; min-width: 200px; }
.w-playlist > .i { color: var(--accent); }
.w-desc {
  position: relative; margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2);
  font-size: 14px; line-height: 1.55;
}
.w-stats { font-weight: 600; margin-bottom: 6px; }
.w-desc-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 6.2em; overflow: hidden; color: var(--text); }
.w-desc.open .w-desc-text { max-height: none; }
.w-desc-text a { color: var(--accent-text); }
.w-desc-text a:hover { text-decoration: underline; }
.ts { color: var(--accent-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.ts:hover { text-decoration: underline; }
.w-more { margin-top: 8px; font-weight: 600; color: var(--text); }

.side-sec { margin-bottom: 20px; }
.side-sec > header { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.side-sec h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 16px; }
.side-sec .count { font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }
.queue-sec { padding: 14px; border: 1px solid var(--line-2); border-radius: 14px; }
.side-list { display: flex; flex-direction: column; gap: 10px; }
.mini-toggle { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; cursor: pointer; }

/* --------------------------------------------------------------- mini player */
.mini-bar { display: none; }
.watch.mini {
  position: fixed; right: 16px; bottom: 16px; z-index: 50; display: block; padding: 0; margin: 0;
  width: min(420px, calc(100vw - 32px)); background: var(--bg-elev); border-radius: 14px; overflow: hidden;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line-2); animation: pop 0.22s ease;
}
@keyframes pop { from { transform: translateY(12px) scale(0.98); opacity: 0; } }
.watch.mini .w-main, .watch.mini .w-side { display: none; }
.watch.mini .w-player { margin: 0; background: none; }
.watch.mini #player { width: 100%; border-radius: 0; }
.watch.mini .mini-bar { display: flex; align-items: center; gap: 2px; padding: 8px 6px 8px 12px; }
.mini-info { flex: 1; min-width: 0; text-align: left; display: grid; }
.mini-title { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-bar .pb { color: var(--text); }
.mini-bar .pb:hover { background: var(--surface-2); }
.mini-bar .ic-pause { display: none; }
.watch[data-playing="1"] .mini-bar .ic-pause { display: block; }
.watch[data-playing="1"] .mini-bar .ic-play { display: none; }

/* --------------------------------------------------------------- player */
.ply {
  position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; overflow: hidden;
  border-radius: var(--radius); color: #fff; user-select: none; -webkit-user-select: none;
  --ply-accent: var(--accent);
}
.ply.is-fs { border-radius: 0; aspect-ratio: auto; width: 100vw; height: 100vh; }
.ply-frame, .ply-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ply-shield { position: absolute; inset: 0 0 0 0; z-index: 2; cursor: pointer; }
.ply.direct .ply-shield, .ply.native .ply-shield { display: none; }
.ply.native .ply-controls, .ply.native .ply-osd { display: none; }
.ply:not(.ui)[data-state="playing"] { cursor: none; }
.ply:not(.ui)[data-state="playing"] .ply-shield { cursor: none; }

.ply-poster { position: absolute; inset: 0; z-index: 4; cursor: pointer; background: #000; }
.ply-poster img { width: 100%; height: 100%; object-fit: cover; opacity: 0.92; }
.ply-poster::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at center, rgba(0,0,0,.05), rgba(0,0,0,.45)); }
.ply-bigplay {
  position: absolute; left: 50%; top: 50%; z-index: 1; width: 76px; height: 76px; margin: -38px 0 0 -38px;
  display: grid; place-items: center; border-radius: 50%; background: var(--ply-accent); color: var(--accent-ink);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45); transition: transform 0.18s ease;
}
.ply-bigplay .i { width: 34px; height: 34px; margin-left: 4px; }
.ply-poster:hover .ply-bigplay { transform: scale(1.07); }
.ply-poster-meta { position: absolute; left: 14px; top: 14px; z-index: 1; }
.ply-poster-meta .chip { background: rgba(0, 0, 0, 0.7); color: #fff; gap: 6px; }
.ply-poster-meta .i { width: 16px; height: 16px; }

.ply-spinner { position: absolute; inset: 0; display: none; place-items: center; z-index: 3; pointer-events: none; }
.ply-spinner span {
  width: 54px; height: 54px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.2); border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
.ply[data-state="loading"]:not(.poster):not(.native) .ply-spinner,
.ply[data-state="buffering"] .ply-spinner { display: grid; }

.ply-osd { position: absolute; left: 50%; top: 50%; z-index: 6; transform: translate(-50%, -50%); pointer-events: none; opacity: 0; }
.ply-osd.show { animation: osd 0.7s ease forwards; }
.osd-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: rgba(0, 0, 0, 0.6); }
.osd-icon .i { width: 32px; height: 32px; }
.osd-text { display: block; padding: 8px 14px; border-radius: 10px; background: rgba(0, 0, 0, 0.72); font-weight: 600; font-size: 15px; white-space: nowrap; }
@keyframes osd { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.85); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.06); } }

.ply-msg { position: absolute; inset: 0; z-index: 7; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.82); }
.ply-msg-card { max-width: 460px; text-align: center; display: grid; justify-items: center; gap: 6px; }
.ply-msg-card > .i { width: 36px; height: 36px; color: var(--accent); }
.ply-msg-card p { margin: 0 0 8px; font-size: 15px; line-height: 1.5; }
.ply-msg-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ply-msg .btn { background: rgba(255, 255, 255, 0.14); color: #fff; }
.ply-msg .btn:hover { background: rgba(255, 255, 255, 0.24); }
.ply-msg .btn-ghost { background: transparent; border-color: rgba(255, 255, 255, 0.3); }

.ply-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; padding: 40px 12px 6px;
  /* solid bottom band: covers the embed's own logo / "More videos" overlays under our buttons */
  background: linear-gradient(to top, rgba(10, 10, 12, 0.97) 0, rgba(10, 10, 12, 0.97) 52px, rgba(10, 10, 12, 0.55) 74px, transparent);
  opacity: 0; transform: translateY(4px); transition: opacity 0.22s, transform 0.22s; pointer-events: none;
}
.ply.ui .ply-controls, .ply:not([data-state="playing"]):not(.poster) .ply-controls, .ply.dragging .ply-controls {
  opacity: 1; transform: none; pointer-events: auto;
}
.ply.poster .ply-controls { display: none; }

.ply-seek { position: relative; height: 18px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
.ply-rail { position: relative; width: 100%; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.24); transition: height 0.12s; }
.ply-seek:hover .ply-rail, .ply.dragging .ply-rail { height: 6px; }
.ply-rail > div { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; }
.ply-buf { background: rgba(255, 255, 255, 0.36); }
.ply-hover { background: rgba(255, 255, 255, 0.28); opacity: 0; }
.ply-seek:hover .ply-hover { opacity: 1; }
.ply-prog { background: var(--ply-accent); z-index: 1; }
.ply-clip { z-index: 2; height: 100%; background: transparent; box-shadow: inset 0 0 0 1.5px #fff; border-radius: 2px !important; opacity: 0.75; }
.ply-knob {
  position: absolute; top: 50%; z-index: 3; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: var(--ply-accent); transform: scale(0); transition: transform 0.12s;
}
.ply-seek:hover .ply-knob, .ply.dragging .ply-knob { transform: scale(1); }
.ply-tip {
  position: absolute; bottom: 22px; transform: translateX(-50%); padding: 3px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.85); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  opacity: 0; pointer-events: none; white-space: nowrap;
}
.ply-seek:hover .ply-tip, .ply.dragging .ply-tip { opacity: 1; }

.ply-row { display: flex; align-items: center; gap: 2px; height: 46px; }
.pb {
  display: grid; place-items: center; min-width: 40px; height: 40px; padding: 0 8px; border-radius: 10px; color: #fff;
  transition: background 0.12s, color 0.12s;
}
.pb:hover { background: rgba(255, 255, 255, 0.14); }
.pb .i { width: 24px; height: 24px; }
.pb.on { color: var(--ply-accent); }
.pb-text { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.pb-main .i { width: 28px; height: 28px; }
.pb-main .ic-pause, .pb-main .ic-replay { display: none; }
.ply[data-state="playing"] .pb-main .ic-play, .ply[data-state="buffering"] .pb-main .ic-play { display: none; }
.ply[data-state="playing"] .pb-main .ic-pause, .ply[data-state="buffering"] .pb-main .ic-pause { display: block; }
.ply[data-state="ended"] .pb-main .ic-play { display: none; }
.ply[data-state="ended"] .pb-main .ic-replay { display: block; }
.ply .ic-vlow, .ply .ic-voff { display: none; }
.ply[data-vol="low"] .ic-vhigh, .ply[data-vol="off"] .ic-vhigh { display: none; }
.ply[data-vol="low"] .ic-vlow, .ply[data-vol="off"] .ic-voff { display: block; }
.ply .ic-fsx, .ply.is-fs .ic-fs { display: none; }
.ply.is-fs .ic-fsx { display: block; }

.ply-vol { display: flex; align-items: center; }
.ply-vol input {
  -webkit-appearance: none; appearance: none; width: 0; height: 4px; border-radius: 4px; margin: 0; opacity: 0;
  background: linear-gradient(to right, #fff var(--v, 100%), rgba(255, 255, 255, 0.3) var(--v, 100%));
  transition: width 0.18s, opacity 0.18s, margin 0.18s; cursor: pointer;
}
.ply-vol:hover input, .ply-vol:focus-within input { width: 72px; opacity: 1; margin: 0 10px 0 4px; }
.ply-vol input::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: #fff; }
.ply-vol input::-moz-range-thumb { width: 13px; height: 13px; border: 0; border-radius: 50%; background: #fff; }
.ply-time { padding: 0 8px; font-size: 13.5px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; color: rgba(255, 255, 255, 0.92); }
.ply-time .sep { opacity: 0.6; }
.live-pill { display: none; align-items: center; gap: 4px; margin-left: 8px; font-weight: 700; font-size: 12px; }
.live-pill .i { width: 16px; height: 16px; color: var(--live); }
.ply.is-live .live-pill { display: inline-flex; }
.ply.is-live .ply-time .sep, .ply.is-live .ply-time .dur { display: none; }
.ply-spacer { flex: 1; }

.ply-menu {
  position: absolute; right: 12px; bottom: 64px; z-index: 8; min-width: 200px; max-height: calc(100% - 80px); overflow: auto;
  padding: 8px; border-radius: 14px; background: rgba(22, 22, 24, 0.94); backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); border: 1px solid rgba(255, 255, 255, 0.1); animation: pop 0.16s ease;
}
.menu-title { padding: 6px 10px 8px; font-weight: 600; font-size: 13.5px; }
.menu-title .muted { color: rgba(255, 255, 255, 0.5); font-weight: 500; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; text-align: left; color: #fff; }
.menu-item:hover { background: rgba(255, 255, 255, 0.1); }
.menu-item .ic-check { width: 18px; height: 18px; visibility: hidden; color: var(--ply-accent); }
.menu-item.on .ic-check { visibility: visible; }

.ply-options { width: min(380px, calc(100% - 24px)); padding: 10px 12px 12px; }
.opt-group { margin: 6px 0 12px; }
.opt-label { font-size: 12px; color: rgba(255, 255, 255, 0.6); margin: 0 0 6px 2px; font-weight: 500; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); }
.seg-3 { grid-template-columns: repeat(3, 1fr); }
.seg button { height: 30px; border-radius: 8px; font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, 0.8); }
.seg button:hover { color: #fff; }
.seg button.on { background: #fff; color: #111; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.opt-field { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 6px; }
.opt-field > span { grid-column: 1 / -1; font-size: 12px; color: rgba(255, 255, 255, 0.6); margin-left: 2px; }
.opt-field input {
  min-width: 0; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06); color: #fff; font-family: var(--mono); font-size: 13px; outline: none;
}
.opt-field input:focus { border-color: var(--ply-accent); }
.mini-btn { height: 32px; padding: 0 9px; border-radius: 8px; background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.mini-btn:hover { background: rgba(255, 255, 255, 0.18); }
.mini-btn .i { width: 16px; height: 16px; }
.opt-check { display: flex; align-items: center; gap: 10px; padding: 6px 2px; font-size: 13.5px; cursor: pointer; }
.opt-check input { width: 16px; height: 16px; accent-color: var(--ply-accent); margin: 0; }
.opt-url { display: flex; gap: 6px; align-items: center; margin: 4px 0 12px; }
.opt-url code {
  flex: 1; min-width: 0; padding: 7px 9px; border-radius: 8px; background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.7); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.opt-actions { display: flex; justify-content: flex-end; gap: 8px; }
.ply-options .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.ply-options .btn-ghost:hover { background: rgba(255, 255, 255, 0.1); }

/* mini player trims the control bar */
.watch.mini .ply .hide-mini, .watch.mini .ply [data-act="direct"], .watch.mini .ply [data-act="cc"],
.watch.mini .ply [data-act="speed"], .watch.mini .ply [data-act="options"], .watch.mini .ply .ply-vol input { display: none; }
.watch.mini .ply-controls { padding: 30px 6px 2px; background: linear-gradient(to top, rgba(10, 10, 12, 0.97) 0, rgba(10, 10, 12, 0.97) 40px, rgba(10, 10, 12, 0.5) 58px, transparent); }
.watch.mini .ply-msg-card p { font-size: 13px; }
.watch.mini .ply-msg-card > .i { width: 26px; height: 26px; }
.watch.mini .ply-row { height: 38px; }
.watch.mini .pb { min-width: 34px; height: 34px; padding: 0 5px; }
.watch.mini .pb .i { width: 20px; height: 20px; }
.watch.mini .ply-time { font-size: 12px; padding: 0 4px; }
.watch.mini .ply-bigplay { width: 56px; height: 56px; margin: -28px 0 0 -28px; }
.watch.mini .ply-bigplay .i { width: 26px; height: 26px; }

/* --------------------------------------------------------------- toasts & dialog */
.toasts { position: fixed; left: 50%; bottom: 20px; z-index: 90; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 16px; border-radius: 12px;
  background: #1d1d20; color: #f3f2ee; box-shadow: var(--shadow-lg); pointer-events: auto;
  font-weight: 500; animation: toast-in 0.22s ease; max-width: 100%;
}
.toast > span { padding-right: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.toast.out { animation: toast-out 0.22s ease forwards; }
.toast-btn { padding: 6px 10px; border-radius: 8px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.toast-btn:hover, .toast-x:hover { background: rgba(255, 255, 255, 0.1); }
.toast-x { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: #aaa; }
.toast-x .i { width: 18px; height: 18px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

.keys-dialog {
  width: min(560px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-2); border-radius: 18px;
  background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-lg);
}
.keys-dialog::backdrop { background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); }
.keys-inner { padding: 18px 20px 22px; }
.keys-inner header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.keys-inner h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 18px; }
.keys-inner .pb { color: var(--text); }
.keys-inner .pb:hover { background: var(--surface-2); }
.keys-inner dl { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 24px; margin: 0; }
.keys-inner dl div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.keys-inner dt { display: flex; gap: 4px; flex: none; }
.keys-inner dd { margin: 0; color: var(--text-2); text-align: right; font-size: 13px; }

/* --------------------------------------------------------------- access gate */
body.locked .search, body.locked .top-nav { visibility: hidden; }
body.locked .brand { pointer-events: none; }
.gate { display: grid; place-items: center; min-height: calc(100vh - var(--top)); padding: 24px var(--gutter); }
.gate-card {
  width: min(380px, 100%); display: grid; gap: 12px; padding: 32px 28px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.gate-mark { display: flex; justify-content: center; margin-bottom: 4px; }
.gate-mark .logo-mark { width: 44px; height: 44px; }
.gate-card h1 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.gate-card p { margin: 0; color: var(--text-2); }
.gate-card input {
  height: 44px; padding: 0 14px; margin-top: 8px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--bg); font-size: 15px; outline: none; text-align: center; letter-spacing: 0.04em;
}
.gate-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.gate-card .btn { height: 44px; border-radius: 12px; }
.gate-card .btn:disabled { opacity: 0.6; cursor: progress; }
.gate-err { color: var(--live) !important; font-size: 13px; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .watch, .watch.theater { grid-template-columns: minmax(0, 1fr); grid-template-areas: "player" "main" "side"; }
  .w-side { padding-top: 24px; }
  .watch.theater .w-player { margin: 0; background: none; }
  .watch.theater #player { width: 100%; }
  .watch.theater:not(.mini) #player:not(.is-fs) { border-radius: var(--radius); }
  .ply [data-act="theater"] { display: none; }
}
@media (max-width: 760px) {
  :root { --gutter: 16px; --top: 56px; }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; }
  .brand-name { display: none; }
  .search-kbd { display: none; }
  .top-nav { gap: 0; }
  .top-btn { width: 36px; height: 36px; }
  #theme-btn { display: none; }
  .card-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .card-row .card-body { padding-top: 10px; }
  .card-row .card-title { font-size: 15px; font-weight: 600; }
  .card-row .card-snippet { display: none; }
  .card-chan { gap: 16px; padding: 8px 0; }
  .card-chan img { width: 72px; height: 72px; margin-left: 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 22px 12px; }
  .hero { padding-top: 20px; }
  .lede { font-size: 15px; }
  .watch { padding-top: 0; }
  .watch:not(.mini) .w-player { margin: 0 calc(var(--gutter) * -1); position: sticky; top: var(--top); z-index: 20; }
  .watch:not(.mini) #player:not(.is-fs) { border-radius: 0; }
  .w-title { font-size: 18px; }
  .w-actions { width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .btn-pill span { display: none; }
  .btn-pill { width: 40px; padding: 0; }
  .ply-time { font-size: 12.5px; padding: 0 4px; }
  .ply .pb { min-width: 36px; padding: 0 6px; }
  .ply [data-act="mini"], .ply [data-act="direct"], .ply [data-act="prev"] { display: none; }
  .ply-vol input { display: none; }
  .ch-info h1 { font-size: 24px; }
  .ch-avatar { width: 72px; height: 72px; }
  .keys-inner dl { grid-template-columns: 1fr; }
  .page-head .btn { margin-left: 0; }
  .watch.mini { left: 8px; right: 8px; bottom: 8px; width: auto; }
}
@media (max-width: 420px) {
  .ply [data-act="cc"] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
