/* ============================================================================
   Learnyx Tube — design system
   Colours are YouTube's own: #0f0f0f / #212121 / #ff0000, with a light theme on
   the same token names so a single class on <html> flips the whole app.
   ========================================================================== */

:root {
  --bg: #0f0f0f;
  --bg-elevated: #212121;
  --bg-hover: #272727;
  --bg-chip: #272727;
  --bg-chip-active: #f1f1f1;
  --surface: #212121;
  --surface-2: #181818;
  --text: #f1f1f1;
  --text-2: #aaaaaa;
  --text-chip-active: #0f0f0f;
  --border: #303030;
  --divider: #272727;
  --red: #ff0000;
  --red-hover: #cc0000;
  --blue: #3ea6ff;
  --green: #2ba640;
  --skeleton: #272727;
  --skeleton-shine: #3a3a3a;
  --shadow: 0 4px 24px rgba(0, 0, 0, .55);
  --shadow-sm: 0 1px 6px rgba(0, 0, 0, .35);
  --scrim: rgba(0, 0, 0, .6);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --nav-h: 56px;
  --bar-h: 52px;
  --sidebar-w: 240px;
  --sidebar-mini: 72px;
  --ease: cubic-bezier(.2, 0, 0, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur-1: .12s;
  --dur-2: .22s;
  --dur-3: .34s;
}

html[data-theme='light'] {
  --bg: #ffffff;
  --bg-elevated: #f9f9f9;
  --bg-hover: #e9e9e9;
  --bg-chip: #f2f2f2;
  --bg-chip-active: #0f0f0f;
  --surface: #f2f2f2;
  --surface-2: #ffffff;
  --text: #0f0f0f;
  --text-2: #606060;
  --text-chip-active: #ffffff;
  --border: #e5e5e5;
  --divider: #e5e5e5;
  --skeleton: #e9e9e9;
  --skeleton-shine: #f5f5f5;
  --shadow: 0 4px 24px rgba(0, 0, 0, .14);
  --shadow-sm: 0 1px 6px rgba(0, 0, 0, .1);
  --scrim: rgba(0, 0, 0, .45);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

body.no-scroll { overflow: hidden; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; border: none; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
svg { display: block; }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --------------------------------------------------------------- scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ================================================================== layout */
#app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--bg);
  z-index: 90;
  transition: background var(--dur-2) var(--ease);
}
.topbar.scrolled { background: var(--bg-elevated); }

.topbar-left { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.topbar-center { flex: 1; display: flex; justify-content: center; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text);
  transition: background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
  position: relative;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.icon-btn.small svg { width: 20px; height: 20px; }

.logo { display: flex; align-items: center; gap: 5px; padding: 0 10px 0 6px; }
.logo svg { width: 92px; height: 20px; }
.logo:hover { opacity: .85; }

/* search ---------------------------------------------------------------- */
.searchwrap {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 640px;
  gap: 8px;
}
.searchbar {
  display: flex;
  flex: 1;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .04);
  overflow: hidden;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease);
  min-width: 0;
}
html[data-theme='light'] .searchbar { background: #fff; }
.searchbar:focus-within {
  border-color: #1c62b9;
  background: var(--bg-elevated);
  box-shadow: 0 1px 8px rgba(0, 0, 0, .25);
}
html[data-theme='light'] .searchbar:focus-within { background: #fff; }
.searchbar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 0 4px 0 18px;
  font-size: 16px;
  min-width: 0;
}
.searchbar input::placeholder { color: var(--text-2); }
.search-go {
  width: 62px;
  display: grid;
  place-items: center;
  background: var(--bg-chip);
  border-left: 1px solid var(--border);
  color: var(--text);
  transition: background var(--dur-1) var(--ease);
}
.search-go:hover { background: var(--bg-hover); }
.search-go svg { width: 22px; height: 22px; fill: currentColor; }
.search-clear { width: 40px; display: grid; place-items: center; color: var(--text-2); }
.search-clear:hover { color: var(--text); }
.mic-btn { background: var(--bg-chip); }
.mic-btn:hover { background: var(--bg-hover); }

/* search suggestions dropdown */
.suggest-panel {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 140px));
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 0;
  z-index: 95;
  max-height: 70vh;
  overflow-y: auto;
  animation: popIn var(--dur-2) var(--ease-out);
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 16px;
  width: 100%;
  text-align: left;
  font-size: 15px;
  border-radius: 0;
  transition: background var(--dur-1) var(--ease);
}
.suggest-item:hover, .suggest-item.active { background: var(--bg-hover); }
.suggest-item svg { width: 18px; height: 18px; fill: var(--text-2); flex-shrink: 0; }
.suggest-item .sug-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-item .sug-remove { opacity: 0; }
.suggest-item:hover .sug-remove { opacity: 1; }
.suggest-head {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
  padding: 12px 16px 6px;
}

/* sidebar --------------------------------------------------------------- */
.shell { display: flex; padding-top: var(--nav-h); min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: fixed;
  top: var(--nav-h);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 12px 90px;
  background: var(--bg);
  z-index: 80;
  transition: transform var(--dur-2) var(--ease);
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  text-align: left;
  transition: background var(--dur-1) var(--ease);
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { background: var(--bg-hover); font-weight: 600; }
.nav-item svg { width: 24px; height: 24px; fill: currentColor; flex-shrink: 0; }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; }
.nav-item .count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-2);
  font-weight: 600;
}
.nav-sep { height: 1px; background: var(--divider); margin: 12px 6px; }
.nav-title {
  font-size: 15px;
  font-weight: 600;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-title .tag { font-size: 11px; color: var(--text-2); font-weight: 500; }
.nav-sub {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  transition: background var(--dur-1) var(--ease);
}
.nav-sub:hover { background: var(--bg-hover); }
.nav-sub img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.nav-sub .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--blue);
  margin-left: auto;
  flex-shrink: 0;
}
.nav-sub .label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer {
  padding: 14px 12px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.7;
}
.sidebar-footer a:hover { text-decoration: underline; }

.collapsed .sidebar {
  width: var(--sidebar-mini);
  padding: 12px 4px;
}
.collapsed .sidebar .label,
.collapsed .sidebar .count,
.collapsed .sidebar .nav-title,
.collapsed .sidebar .nav-sep,
.collapsed .sidebar .sidebar-footer,
.collapsed .sidebar .nav-sub { display: none; }
.collapsed .sidebar .nav-item {
  flex-direction: column;
  gap: 6px;
  padding: 16px 2px 14px;
  font-size: 10px;
  text-align: center;
}
.collapsed .sidebar .nav-item .mini-label {
  display: block;
  font-size: 10px;
  line-height: 1.15;
}
.nav-item .mini-label { display: none; }

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  padding: 0 0 10px;
  transition: margin var(--dur-2) var(--ease);
}
.collapsed .main { margin-left: var(--sidebar-mini); }

.page {
  padding: 0 24px 40px;
  max-width: 2100px;
  margin: 0 auto;
  animation: fadeUp var(--dur-3) var(--ease-out);
}

/* ============================================================== components */
.chips {
  position: sticky;
  top: var(--nav-h);
  z-index: 40;
  display: flex;
  gap: 10px;
  padding: 12px 24px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
  margin: 0 -24px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  background: var(--bg-chip);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
  flex-shrink: 0;
}
.chip:hover { background: var(--bg-hover); }
.chip:active { transform: scale(.96); }
.chip.active { background: var(--bg-chip-active); color: var(--text-chip-active); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  background: var(--bg-chip);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: scale(.96); }
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.btn.primary { background: var(--text); color: var(--bg); }
.btn.primary:hover { background: #d9d9d9; }
html[data-theme='light'] .btn.primary:hover { background: #272727; }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover { background: var(--red-hover); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.sm { height: 32px; font-size: 13px; padding: 0 12px; }
.btn.sm svg { width: 18px; height: 18px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.pill-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* video grid ------------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px 16px;
  padding-top: 12px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  animation: fadeUp var(--dur-2) var(--ease-out);
  border-radius: var(--radius);
}
.card .thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  transform: translateZ(0);
}
.card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-3) var(--ease-out), opacity var(--dur-2) var(--ease);
}
.card:hover .thumb img { transform: scale(1.04); }
.card .thumb.loading img { opacity: 0; }
.duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, .8);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: .2px;
}
.badge-live {
  position: absolute;
  left: 8px;
  bottom: 6px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
  text-transform: uppercase;
}
.badge-live::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.6s infinite;
}
.progress-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, .25);
}
.progress-line span { display: block; height: 100%; background: var(--red); }

.card .meta { display: flex; gap: 12px; align-items: flex-start; }
.card .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface);
}
.card .texts { min-width: 0; flex: 1; }
.card .title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .byline {
  font-size: 12.5px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 5px;
}
.card .byline .verified { width: 13px; height: 13px; fill: var(--text-2); }
.card .byline .subs { opacity: .9; }
.card .menu-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
  color: var(--text);
  flex-shrink: 0;
}
.card:hover .menu-btn { opacity: 1; }
.card .menu-btn:hover { background: var(--bg-hover); }
.card .menu-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* horizontal shelf ------------------------------------------------------- */
.shelf { margin: 22px 0 8px; }
.shelf-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.shelf-head h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -.2px;
}
.shelf-head .more { margin-left: auto; }
.shelf-scroll {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.shelf-scroll::-webkit-scrollbar { height: 6px; }
.shelf-card {
  flex: 0 0 300px;
  scroll-snap-align: start;
}
/* videoCard() renders a plain .card, so give shelf children their own width */
.shelf-scroll > .card {
  flex: 0 0 320px;
  min-width: 0;
  scroll-snap-align: start;
}
.shelf-scroll > .card .title { font-size: 14px; }
.shelf-card .thumb { aspect-ratio: 16 / 9; }
.shelf-shorts .shelf-card { flex: 0 0 170px; }

/* shorts thumbnails */
.short-thumb {
  position: relative;
  aspect-ratio: 9 / 16;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.short-thumb img { width: 100%; height: 100%; object-fit: cover; }
.short-thumb .short-title {
  position: absolute;
  inset: auto 8px 8px 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .8);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.short-thumb::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 55%;
  background: linear-gradient(transparent, rgba(0, 0, 0, .75));
  pointer-events: none;
}
.short-thumb .short-title { z-index: 1; }

/* skeleton --------------------------------------------------------------- */
.sk { background: var(--skeleton); border-radius: var(--radius); position: relative; overflow: hidden; }
.sk::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
.sk-thumb { aspect-ratio: 16 / 9; border-radius: var(--radius); }
.sk-line { height: 12px; border-radius: 6px; margin-bottom: 8px; }
.sk-circle { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.sk-card { display: flex; flex-direction: column; gap: 12px; }
.sk-card .row { display: flex; gap: 12px; }

/* empty / error states --------------------------------------------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 70px 24px;
  color: var(--text-2);
  animation: fadeUp var(--dur-3) var(--ease-out);
}
.empty svg { width: 72px; height: 72px; fill: var(--text-2); opacity: .5; }
.empty h3 { color: var(--text); font-size: 18px; margin: 0; font-weight: 500; }
.empty p { margin: 0; max-width: 420px; font-size: 14px; line-height: 1.55; }

/* ==================================================================== watch */
.watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 402px;
  gap: 24px;
  padding-top: 8px;
  align-items: start;
}
.watch-main { min-width: 0; }
.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-radius var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.player-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}
.player-wrap.ambient::after {
  content: '';
  position: absolute;
  inset: -24px;
  background: radial-gradient(circle at 50% 50%, rgba(255, 60, 60, .28), transparent 70%);
  filter: blur(40px);
  z-index: -1;
  pointer-events: none;
  opacity: .9;
}

/* controls */
.pc {
  position: absolute;
  inset: 0;
  opacity: 1;
  transition: opacity var(--dur-2) var(--ease);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: linear-gradient(transparent 55%, rgba(0, 0, 0, .82));
}
.player-wrap.idle .pc { opacity: 0; }
.player-wrap.idle { cursor: none; }
.pc-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(rgba(0, 0, 0, .6), transparent);
  color: #fff;
  font-size: 14px;
}
.pc-top .pc-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.pc-bottom { padding: 0 12px 8px; }
.scrub {
  position: relative;
  height: 16px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}
.scrub-track {
  position: relative;
  height: 3.5px;
  width: 100%;
  background: rgba(255, 255, 255, .3);
  border-radius: 2px;
  transition: height var(--dur-1) var(--ease);
}
.scrub:hover .scrub-track { height: 5px; }
.scrub-buffer {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  background: rgba(255, 255, 255, .45);
  border-radius: 2px;
  width: 0;
}
.scrub-played {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  background: var(--red);
  border-radius: 2px;
  width: 0;
}
.scrub-knob {
  position: absolute;
  top: 50%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--red);
  transform: translate(-50%, -50%) scale(0);
  transition: transform var(--dur-1) var(--ease);
}
.scrub:hover .scrub-knob, .scrub.dragging .scrub-knob { transform: translate(-50%, -50%) scale(1); }
.tooltip-time {
  position: absolute;
  bottom: 26px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, .85);
  color: #fff;
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-1) var(--ease);
  white-space: nowrap;
}
.scrub:hover .tooltip-time { opacity: 1; }

.pc-row {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #fff;
  height: 40px;
}
.pc-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  transition: background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
  flex-shrink: 0;
}
.pc-btn:hover { background: rgba(255, 255, 255, .16); }
.pc-btn:active { transform: scale(.9); }
.pc-btn svg { width: 22px; height: 22px; fill: currentColor; }
.pc-btn.wide { width: auto; padding: 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .3px; }
.pc-time { font-size: 12.5px; margin: 0 8px; font-variant-numeric: tabular-nums; opacity: .95; }
.pc-spacer { flex: 1; }
.vol-slider {
  width: 0;
  opacity: 0;
  overflow: hidden;
  transition: width var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease);
  display: flex;
  align-items: center;
}
.vol-wrap:hover .vol-slider, .vol-slider:focus-within { width: 74px; opacity: 1; }
.vol-slider input { width: 74px; accent-color: #fff; height: 3px; }

/* chapters on the scrub bar */
.chapter-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(0, 0, 0, .55);
  pointer-events: none;
}

/* centre feedback (double tap / gestures) */
.pc-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
}
.pc-flash.show { animation: flashIn .75s var(--ease-out); }
.ripple-seek {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 32%;
  background: radial-gradient(circle at center, rgba(255, 255, 255, .28), transparent 70%);
  opacity: 0;
  pointer-events: none;
}
.ripple-seek.left { left: 0; }
.ripple-seek.right { right: 0; }
.ripple-seek.show { animation: ripple .55s var(--ease-out); }

.spinner-big {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border: 3px solid rgba(255, 255, 255, .2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  pointer-events: none;
}

/* watch metadata --------------------------------------------------------- */
.watch-title {
  font-size: 20px;
  font-weight: 700;
  margin: 14px 0 6px;
  line-height: 1.3;
}
.watch-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}
.channel-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
  flex-wrap: wrap;
}
.channel-strip .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  cursor: pointer;
}
.channel-strip .who { min-width: 0; flex: 1; cursor: pointer; }
.channel-strip .who .name {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.channel-strip .who .subs { font-size: 12px; color: var(--text-2); }
.channel-strip .who .name svg { width: 13px; height: 13px; fill: var(--text-2); }

.btn-sub { background: var(--text); color: var(--bg); }
.btn-sub:hover { background: #d9d9d9; }
.btn-sub.subscribed { background: var(--bg-chip); color: var(--text); }
.btn-sub.subscribed:hover { background: var(--bg-hover); }

.like-group { display: flex; align-items: center; background: var(--bg-chip); border-radius: var(--radius-pill); overflow: hidden; }
.like-group .btn { background: transparent; border-radius: 0; height: 36px; }
.like-group .btn:hover { background: var(--bg-hover); }
.like-group .divider { width: 1px; height: 22px; background: var(--border); }
.btn.active-like svg { fill: var(--text); transform: scale(1.12); }
.btn.liked { color: var(--blue); }
.btn.liked svg { fill: var(--blue); }

.desc-box {
  background: var(--bg-chip);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 14px 0;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.5;
  transition: background var(--dur-1) var(--ease);
  white-space: pre-wrap;
  word-break: break-word;
}
.desc-box:hover { background: var(--bg-hover); }
.desc-box.collapsed {
  max-height: 84px;
  overflow: hidden;
  position: relative;
}
.desc-box.collapsed::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 46px;
  background: linear-gradient(transparent, var(--bg-chip));
}
.desc-box .desc-meta { font-weight: 600; margin-bottom: 8px; }
.desc-box .hash { color: var(--blue); }
.desc-box a.ext { color: var(--blue); text-decoration: none; word-break: break-all; }
.desc-box a.ext:hover { text-decoration: underline; }
.desc-toggle { font-weight: 600; font-size: 14px; margin-top: 6px; color: var(--text); }

/* chapters list */
.chapters { margin: 14px 0; }
.chapter-row {
  display: flex;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  transition: background var(--dur-1) var(--ease);
}
.chapter-row:hover { background: var(--bg-hover); }
.chapter-row.active { background: var(--bg-chip); font-weight: 600; }
.chapter-row .t { color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 44px; }
.chapter-row.active .t { color: var(--red); }

/* comments --------------------------------------------------------------- */
.comments { margin-top: 22px; }
.comments-head { display: flex; align-items: center; gap: 22px; margin-bottom: 18px; }
.comments-head h3 { font-size: 20px; margin: 0; font-weight: 600; }
.sort-btn { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.sort-btn svg { width: 20px; height: 20px; fill: currentColor; }
.comment { display: flex; gap: 14px; margin-bottom: 18px; animation: fadeUp var(--dur-2) var(--ease-out); }
.comment .avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--surface); }
.comment .body { min-width: 0; flex: 1; }
.comment .who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 2px;
}
.comment .who .name { font-weight: 600; }
.comment .who .when { color: var(--text-2); font-size: 12px; }
.comment .who .heart {
  background: var(--text-2);
  color: var(--bg);
  border-radius: 50%;
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  font-size: 8px;
}
.comment .text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; margin: 2px 0 8px; }
.comment .acts { display: flex; align-items: center; gap: 6px; }
.comment .acts button { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); padding: 4px 8px; border-radius: var(--radius-pill); }
.comment .acts button:hover { background: var(--bg-hover); color: var(--text); }
.comment .acts button svg { width: 16px; height: 16px; fill: currentColor; }
.comment .acts .liked { color: var(--blue); }
.comment .acts .liked svg { fill: var(--blue); }
.comment .pinned-tag { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.comment .pinned-tag svg { width: 14px; height: 14px; fill: currentColor; }
.replies-btn { font-size: 13px; font-weight: 600; color: var(--blue); display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: var(--radius-pill); }
.replies-btn:hover { background: rgba(62, 166, 255, .12); }
.replies-list { margin-top: 12px; padding-left: 18px; border-left: 2px solid var(--divider); }

/* related sidebar -------------------------------------------------------- */
.related { display: flex; flex-direction: column; gap: 10px; }
.related-card { display: flex; gap: 10px; cursor: pointer; border-radius: var(--radius-sm); transition: background var(--dur-1) var(--ease); }
.related-card:hover { background: var(--bg-hover); }
.related-card .thumb {
  position: relative;
  width: 168px;
  flex-shrink: 0;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.related-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.related-card .info { min-width: 0; flex: 1; padding: 2px 0; }
.related-card .title {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.32;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}
.related-card .by { font-size: 12px; color: var(--text-2); }
.related-card .by .dotsep { margin: 0 3px; }

/* =================================================================== shorts */
.shorts-page {
  position: fixed;
  inset: var(--nav-h) 0 var(--bar-h) var(--sidebar-w);
  background: #000;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  z-index: 30;
}
.collapsed .shorts-page { left: var(--sidebar-mini); }
.shorts-page::-webkit-scrollbar { display: none; }
.short-item {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.short-stage {
  position: relative;
  height: 100%;
  aspect-ratio: 9 / 16;
  max-width: 100%;
  background: #000;
  overflow: hidden;
}
.short-stage video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.short-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 60px 14px 18px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .85));
  color: #fff;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}
.short-overlay .info { flex: 1; min-width: 0; }
.short-overlay .who { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.short-overlay .who img { width: 34px; height: 34px; border-radius: 50%; border: 2px solid #fff; object-fit: cover; }
.short-overlay .who .n { font-weight: 600; font-size: 13.5px; }
.short-overlay .who .sub {
  margin-left: 6px;
  background: #fff;
  color: #0f0f0f;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}
.short-overlay .who .sub.on { background: rgba(255,255,255,.22); color: #fff; }
.short-overlay .cap { font-size: 13.5px; line-height: 1.4; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.short-overlay .audio { display: flex; align-items: center; gap: 7px; font-size: 12.5px; opacity: .9; }
.short-rail {
  position: absolute;
  right: 8px;
  bottom: 84px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  color: #fff;
  z-index: 2;
}
.short-rail button { display: flex; flex-direction: column; align-items: center; gap: 3px; color: #fff; font-size: 11.5px; font-weight: 600; }
.short-rail svg { width: 30px; height: 30px; fill: #fff; filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); transition: transform var(--dur-1) var(--ease); }
.short-rail button:active svg { transform: scale(1.25); }
.short-rail .liked svg { fill: var(--red); }
.short-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.2); z-index: 3; }
.short-progress span { display: block; height: 100%; background: #fff; width: 0; }

/* ================================================================ channel */
.channel-banner {
  width: 100%;
  aspect-ratio: 6.2 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 16px;
}
.channel-banner img { width: 100%; height: 100%; object-fit: cover; }
.channel-head { display: flex; gap: 24px; align-items: flex-start; padding: 0 4px 20px; flex-wrap: wrap; }
.channel-head .avatar { width: 128px; height: 128px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.channel-head .info { flex: 1; min-width: 240px; }
.channel-head h1 { font-size: 34px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.5px; }
.channel-head .stats { color: var(--text-2); font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.channel-head .desc {
  color: var(--text-2);
  font-size: 14px;
  margin-top: 10px;
  max-width: 640px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.channel-tabs {
  display: flex;
  gap: 26px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.channel-tabs::-webkit-scrollbar { display: none; }
.channel-tab {
  padding: 12px 2px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.channel-tab:hover { color: var(--text); }
.channel-tab.active { color: var(--text); border-color: var(--text); }

/* ===================================================================== you */
.you-grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 26px; }
.you-menu { display: flex; flex-direction: column; gap: 2px; }
.you-menu button {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14.5px;
  text-align: left;
  transition: background var(--dur-1) var(--ease);
}
.you-menu button:hover { background: var(--bg-hover); }
.you-menu button.active { background: var(--bg-hover); font-weight: 600; }
.you-menu svg { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; }
.list-row {
  display: flex;
  gap: 14px;
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease);
  align-items: flex-start;
}
.list-row:hover { background: var(--bg-hover); }
.list-row .thumb {
  width: 168px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  background: var(--surface);
}
.list-row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.list-row .info { flex: 1; min-width: 0; }
.list-row .t { font-size: 15px; font-weight: 500; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.list-row .s { font-size: 12.5px; color: var(--text-2); }
.list-row .del { opacity: 0; }
.list-row:hover .del { opacity: 1; }

/* =================================================================== modal / sheet */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 200;
  animation: fadeIn var(--dur-2) var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.sheet {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: min(520px, 100%);
  max-height: min(78vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sheetUp var(--dur-3) var(--ease-out);
}
.sheet.wide { width: min(720px, 100%); }
.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--divider);
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}
.sheet-head .close { margin-left: auto; }
.sheet-body { overflow-y: auto; padding: 10px 0 14px; }
.sheet-body.pad { padding: 16px 18px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 11px 18px;
  font-size: 14px;
  text-align: left;
  transition: background var(--dur-1) var(--ease);
}
.menu-item:hover { background: var(--bg-hover); }
.menu-item svg { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; }
.menu-item .sub { font-size: 12px; color: var(--text-2); }
.menu-item.danger { color: #ff6b6b; }
.menu-item .check { margin-left: auto; color: var(--red); }
.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  width: 100%;
  text-align: left;
}
.opt-row:hover { background: var(--bg-hover); }
.opt-row .lbl { font-size: 14.5px; }
.opt-row .hint { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.opt-row .val { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.seg {
  display: inline-flex;
  background: var(--bg-chip);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}
.seg button {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.seg button.on { background: var(--text); color: var(--bg); font-weight: 600; }
.switch {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  transition: background var(--dur-2) var(--ease);
  flex-shrink: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--dur-2) var(--ease-out);
}
.switch.on { background: var(--red); }
.switch.on::after { transform: translateX(20px); }

/* quality / speed list rows */
.q-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 18px;
  font-size: 14px;
  text-align: left;
}
.q-row:hover { background: var(--bg-hover); }
.q-row .tick { margin-left: auto; color: var(--red); font-weight: 700; }
.q-row .dim { color: var(--text-2); font-size: 12px; }

/* toast ------------------------------------------------------------------ */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-h) + 20px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
  align-items: center;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn var(--dur-3) var(--ease-out);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 92vw;
}
.toast.out { animation: toastOut var(--dur-2) var(--ease) forwards; }
.toast button { font-weight: 700; color: var(--red); }
html[data-theme='light'] .toast button { color: #c00; }

/* miniplayer ------------------------------------------------------------- */
.miniplayer {
  position: fixed;
  right: 20px;
  bottom: calc(var(--bar-h) + 18px);
  width: 360px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 150;
  animation: miniIn var(--dur-3) var(--ease-out);
}
.miniplayer .vid { position: relative; aspect-ratio: 16 / 9; background: #000; cursor: pointer; }
.miniplayer video { width: 100%; height: 100%; object-fit: contain; }
.miniplayer .bar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; }
.miniplayer .bar .t { flex: 1; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.miniplayer .bar button { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; }
.miniplayer .bar button:hover { background: var(--bg-hover); }
.miniplayer .bar svg { width: 18px; height: 18px; fill: currentColor; }
.miniplayer .prog { height: 2px; background: var(--border); }
.miniplayer .prog span { display: block; height: 100%; background: var(--red); width: 0; }

/* bottom bar (mobile) ---------------------------------------------------- */
.bottom-bar {
  display: none;
  position: fixed;
  inset: auto 0 0 0;
  height: var(--bar-h);
  background: var(--bg);
  border-top: 1px solid var(--divider);
  z-index: 100;
  align-items: stretch;
}
.bottom-bar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  color: var(--text-2);
  transition: color var(--dur-1) var(--ease);
}
.bottom-bar button.active { color: var(--text); font-weight: 600; }
.bottom-bar svg { width: 22px; height: 22px; fill: currentColor; }
.bottom-bar .avatar-mini { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }

/* pull to refresh -------------------------------------------------------- */
.ptr {
  position: sticky;
  top: 0;
  display: grid;
  place-items: center;
  height: 0;
  overflow: hidden;
  color: var(--text-2);
  transition: height var(--dur-2) var(--ease);
}
.ptr.show { height: 48px; }
.ptr .spin {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* notifications ---------------------------------------------------------- */
.notif {
  display: flex;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease);
  align-items: flex-start;
}
.notif:hover { background: var(--bg-hover); }
.notif.unread { background: rgba(62, 166, 255, .08); }
.notif .avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.notif .body { flex: 1; min-width: 0; font-size: 13.5px; }
.notif .body .when { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.notif .thumb { width: 86px; aspect-ratio: 16 / 9; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.badge-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

/* search results --------------------------------------------------------- */
.search-head { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 18px; }
.channel-row {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}
.channel-row .avatar { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.channel-row .info { flex: 1; min-width: 0; }
.channel-row .info .n { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.channel-row .info .s { font-size: 12.5px; color: var(--text-2); margin: 3px 0 6px; }
.channel-row .info .d { font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

/* downloaded list -------------------------------------------------------- */
.file-row {
  display: flex;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  margin-bottom: 10px;
  align-items: center;
}
.file-row .info { flex: 1; min-width: 0; }
.file-row .info .n { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .info .s { font-size: 12px; color: var(--text-2); }

/* ==================================================================== misc */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title { font-size: 20px; font-weight: 600; margin: 24px 0 12px; }

/* =============================================================== animations */
@keyframes shimmer { 100% { transform: translateX(100%); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(.98); } to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
@keyframes sheetUp { from { opacity: 0; transform: translateY(26px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes miniIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes flashIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.8); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes ripple {
  0% { opacity: 0; }
  25% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes heartPop {
  0% { transform: scale(.4); opacity: 0; }
  45% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================================== responsive */
@media (max-width: 1400px) {
  .watch-layout { grid-template-columns: minmax(0, 1fr) 360px; }
}
@media (max-width: 1200px) {
  .watch-layout { grid-template-columns: minmax(0, 1fr); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}
@media (max-width: 1000px) {
  .you-grid { grid-template-columns: 1fr; }
  .you-menu { flex-direction: row; overflow-x: auto; gap: 8px; padding-bottom: 8px; }
  .you-menu button { white-space: nowrap; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
    box-shadow: var(--shadow);
    background: var(--bg-elevated);
    z-index: 120;
  }
  .sidebar.open { transform: none; }
  .main, .collapsed .main { margin-left: 0; }
  .scrim-nav {
    position: fixed;
    inset: var(--nav-h) 0 0 0;
    background: var(--scrim);
    z-index: 110;
    animation: fadeIn var(--dur-2) var(--ease);
  }
  .page { padding: 0 14px 30px; }
  .chips { padding: 12px 14px; margin: 0 -14px; }
  .bottom-bar { display: flex; }
  .main { padding-bottom: var(--bar-h); }
  .shorts-page, .collapsed .shorts-page { left: 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 12px; }
  .miniplayer { width: min(320px, calc(100vw - 24px)); right: 12px; bottom: calc(var(--bar-h) + 12px); }
}
@media (max-width: 640px) {
  .topbar { padding: 0 6px; }
  .topbar-center { position: static; }
  .logo svg { width: 78px; }
  .grid { grid-template-columns: 1fr; }
  .watch-title { font-size: 17px; }
  .player-wrap { border-radius: 0; margin: 0 -14px; width: calc(100% + 28px); }
  .watch-actions { gap: 6px; }
  .channel-head .avatar { width: 84px; height: 84px; }
  .channel-head h1 { font-size: 24px; }
  .list-row .thumb { width: 128px; }
  .related-card .thumb { width: 140px; }
  .searchbar input { font-size: 16px; }
  .sheet { max-height: 86vh; }
  .overlay { padding: 0; align-items: flex-end; }
  .sheet { width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 88vh; }
}

/* mobile search mode: the bar takes over the top row */
@media (max-width: 760px) {
  .topbar.searching .topbar-left,
  .topbar.searching .topbar-right { display: none; }
  .topbar.searching .topbar-center { width: 100%; }
  .topbar:not(.searching) .topbar-center { justify-content: flex-end; }
  .topbar:not(.searching) .searchwrap { display: none; }
  .topbar:not(.searching) .mobile-search-btn { display: grid; }
  .mobile-search-btn { display: none; }
  .suggest-panel { width: calc(100vw - 16px); left: 8px; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* fullscreen / theatre */
.player-wrap.theatre {
  border-radius: 0;
  margin: 0 calc(-1 * max(0px, (100vw - 100% - var(--sidebar-w)) / 2));
  width: calc(100% + max(0px, 100vw - 100% - var(--sidebar-w)));
  max-width: 100vw;
}
.player-wrap.fs {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  z-index: 400;
  border-radius: 0;
  background: #000;
}
.player-wrap.fs video { height: 100%; }
body.fs-lock { overflow: hidden; }
