/* ═══════════════════════════════════════════
   StreamVerse  style.css  v9
   YouTube-style · Dark Mode · Speed Menu
═══════════════════════════════════════════ */

/* ── Variables ───────────────────────────── */
:root {
  --white:       #ffffff;
  --bg:          #f9f9f9;
  --bg2:         #f2f2f2;
  --bg3:         #e8e8e8;
  --border:      #e0e0e0;
  --text:        #0f0f0f;
  --text2:       #606060;
  --text3:       #aaaaaa;
  --brand:       #1a56db;
  --brand-dark:  #1446c0;
  --brand-bg:    #e8f0fe;
  --red:         #cc0000;
  --green:       #16a34a;

  --nav-h:    56px;
  --cat-h:    46px;
  --sbw:      240px;
  --sbw-mini: 72px;

  --r:    12px;
  --r-sm:  8px;
  --r-xs:  6px;

  --sh: 0 1px 4px rgba(0,0,0,.08);
  --sh-md: 0 4px 20px rgba(0,0,0,.12);
  --t: .16s ease;
}

/* ── Dark Mode Variables ─────────────────── */
html.dark {
  --white:      #212121;
  --bg:         #0f0f0f;
  --bg2:        #272727;
  --bg3:        #3f3f3f;
  --border:     #383838;
  --text:       #f1f1f1;
  --text2:      #aaaaaa;
  --text3:      #717171;
  --brand:      #3ea6ff;
  --brand-dark: #65b8ff;
  --brand-bg:   #263850;
  --sh:         0 1px 4px rgba(0,0,0,.4);
  --sh-md:      0 4px 20px rgba(0,0,0,.5);
}

/* ── Reset ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html  { scroll-behavior: smooth; font-size: 14px; }
body  {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}
a    { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
img  { display: block; max-width: 100%; }
h1,h2,h3 { font-weight: 700; line-height: 1.3; }
.hidden { display: none !important; }

/* scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
html.dark ::-webkit-scrollbar-thumb { background: #555; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ═══════════════════════════════════════════
   NAVBAR
═══════════════════════════════════════════ */
#navbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px 0 8px;
  gap: 8px;
  z-index: 300;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  transition: background .2s, border-color .2s;
}

/* Left */
.nav-left {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.menu-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--text);
  transition: background var(--t);
  flex-shrink: 0;
}
.menu-btn:hover { background: var(--bg2); }

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  padding: 0 8px;
}
.brand-icon { font-size: 20px; line-height: 1; }
.brand-name { color: var(--brand); letter-spacing: -.3px; }

/* Mid — search */
.nav-mid {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.search-wrap {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 520px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 40px;
  background: var(--white);
  transition: border-color var(--t), box-shadow var(--t);
  overflow: hidden;
}
.search-wrap:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-bg);
}

#search {
  flex: 1;
  border: none;
  outline: none;
  padding: 0 14px;
  font-size: 14px;
  background: transparent;
  color: var(--text);
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
}
#search::placeholder { color: var(--text3); }
#search::-webkit-search-cancel-button { display: none; }

.search-btn {
  width: 56px;
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  color: var(--text2);
  flex-shrink: 0;
  transition: background var(--t);
}
.search-btn:hover { background: var(--bg3); }

/* Right — load badge + dark toggle */
.nav-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.load-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  white-space: nowrap;
}

.ld-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ld-dot.pulsing { background: var(--brand); animation: dotPulse 1.2s ease-in-out infinite; }
.ld-dot.done    { background: var(--green); }
.ld-dot.err     { background: var(--red); }

@keyframes dotPulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:.4; transform:scale(.7); }
}

/* Dark mode toggle button */
.dark-toggle-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--text);
  transition: background var(--t), color var(--t);
  flex-shrink: 0;
}
.dark-toggle-btn:hover { background: var(--bg2); }

/* ═══════════════════════════════════════════
   CATEGORY CHIPS BAR
═══════════════════════════════════════════ */
#cat-bar {
  position: fixed;
  top: var(--nav-h);
  left: 0; right: 0;
  height: var(--cat-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  z-index: 290;
  overflow: hidden;
  padding-left: var(--sbw-mini);
  transition: background .2s, border-color .2s;
}

.cats-scroll {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 8px;
  padding: 0 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cats-scroll::-webkit-scrollbar { display: none; }

.cat-chip {
  flex-shrink: 0;
  background: var(--bg2);
  color: var(--text);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border: none;
  transition: background var(--t), color var(--t);
}
.cat-chip:hover { background: var(--bg3); }
.cat-chip.on    { background: var(--text); color: var(--white); }

/* ═══════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════ */
#layout {
  display: flex;
  margin-top: calc(var(--nav-h) + var(--cat-h));
  min-height: calc(100vh - var(--nav-h) - var(--cat-h));
}

/* ═══════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════ */
#sidebar {
  position: fixed;
  left: 0;
  top: calc(var(--nav-h) + var(--cat-h));
  bottom: 0;
  width: var(--sbw-mini);
  background: var(--white);
  overflow: hidden;
  transition: width var(--t), background .2s, border-color .2s;
  z-index: 280;
  border-right: 1px solid var(--border);
  scrollbar-width: none;
}
#sidebar::-webkit-scrollbar { display: none; }

/* Expanded on hover (desktop) */
@media (hover: hover) {
  #sidebar:hover { width: var(--sbw); overflow-y: auto; }
  #sidebar:hover .sb-item span { opacity: 1; }
  #sidebar:hover ~ #mob-overlay { display: none !important; }
}

/* Expanded via JS (all screens) */
#sidebar.open { width: var(--sbw); overflow-y: auto; }
#sidebar.open .sb-item span { opacity: 1; }

.sb-nav { padding: 8px 0; }

.sb-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  height: 44px;
  border-radius: var(--r-sm);
  margin: 1px 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
  transition: background var(--t);
  user-select: none;
}
.sb-item:hover { background: var(--bg2); text-decoration: none; }
.sb-item.on    { background: var(--bg2); font-weight: 700; }

.sb-icon {
  width: 22px; height: 22px;
  flex-shrink: 0;
  color: var(--text);
}

.sb-item span {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t);
}

.sb-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 16px;
}

/* Mobile overlay */
#mob-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 270;
  backdrop-filter: blur(1px);
}
#mob-overlay.show { display: block; }

/* ═══════════════════════════════════════════
   MAIN CONTENT
═══════════════════════════════════════════ */
#main {
  flex: 1;
  margin-left: var(--sbw-mini);
  padding: 20px 16px 40px;
  min-width: 0;
}

/* ═══════════════════════════════════════════
   CHANNEL GRID
═══════════════════════════════════════════ */
.ch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

/* ── Channel Card ───────────────────── */
.ch-card {
  background: var(--white);
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  box-shadow: var(--sh);
  transition: transform var(--t), box-shadow var(--t), background .2s, border-color .2s;
  display: flex;
  flex-direction: column;
}
.ch-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}
.ch-card.active {
  border: 2px solid var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

/* ── Card Thumbnail ─────────────────── */
.card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg2);
  overflow: hidden;
  flex-shrink: 0;
}

/* Fallback: always present, shows colored initial */
.fb-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -1px;
  user-select: none;
}

/* Actual logo image — sits on top of fallback */
.card-thumb .card-img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 12px;
  background: var(--white);
}

/* LIVE badge */
.card-live {
  position: absolute;
  top: 6px; left: 6px;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .6px;
  padding: 2px 6px;
  border-radius: 3px;
  pointer-events: none;
  text-transform: uppercase;
}

/* ── Card Body ──────────────────────── */
.card-body {
  padding: 10px 12px 11px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.card-cat {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-bg);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-lang {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
}

/* Grid status note */
.grid-footer {
  text-align: center;
  color: var(--text2);
  font-size: 13px;
  padding: 20px 12px;
}

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}
.empty-state .es-icon { font-size: 3.5rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 17px; color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ═══════════════════════════════════════════
   WATCH VIEW
═══════════════════════════════════════════ */
#watch-view {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

/* Player column */
.watch-main {
  flex: 1;
  min-width: 0;
}

/* Player box — true 16:9 */
#player-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--r);
  overflow: hidden;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  background: #000;
}

/* Player overlays */
.poverlay {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  background: rgba(0,0,0,.78);
  color: #fff;
  z-index: 20;
  text-align: center;
  padding: 20px;
}
.poverlay.show { display: flex; }

.spinner {
  width: 42px; height: 42px;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.poverlay > span { font-size: 13px; opacity: .75; }

/* Error overlay */
.err-pov { background: rgba(0,0,0,.88); }
.err-ico  { font-size: 2.8rem; }
.err-h    { font-size: 17px; font-weight: 700; margin-top: 4px; }
.err-p    { font-size: 12px; opacity: .65; max-width: 320px; margin-top: 4px; }
.err-btns {
  display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; justify-content: center;
}
.err-btns button {
  padding: 8px 18px;
  border-radius: var(--r-xs);
  font-size: 13px;
  font-weight: 600;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  transition: background var(--t);
}
.err-btns button:hover { background: rgba(255,255,255,.22); }
.btn-retry {
  background: var(--brand) !important;
  border-color: var(--brand) !important;
}
.btn-retry:hover { background: var(--brand-dark) !important; }

/* Channel info bar below player */
#ch-info-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

#cib-logo {
  width: 48px; height: 48px;
  border-radius: var(--r-sm);
  background: var(--bg2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--brand);
}
#cib-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }

.cib-text { flex: 1; min-width: 0; }
#cib-name {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cib-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 4px; }

.pill-live {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: .5px;
  flex-shrink: 0;
}
.pill-tag {
  background: var(--bg2);
  color: var(--text2);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 20px;
}
.pill-tag:empty { display: none; }

.close-btn {
  flex-shrink: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--r-xs);
  transition: background var(--t);
}
.close-btn:hover { background: var(--bg3); }

/* ── Watch sidebar (Up Next) ──────── */
.watch-sidebar {
  width: 360px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--nav-h) + var(--cat-h) + 12px);
  max-height: calc(100vh - var(--nav-h) - var(--cat-h) - 24px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.ws-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
}
.ws-browse-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  background: none;
  border: 1px solid var(--brand);
  padding: 4px 12px;
  border-radius: 20px;
  transition: background var(--t), color var(--t);
}
.ws-browse-btn:hover { background: var(--brand); color: #fff; }

/* Up-next items */
.up-next-list { display: flex; flex-direction: column; gap: 6px; }

.un-item {
  display: flex;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px;
  cursor: pointer;
  transition: background var(--t), border-color .2s;
  align-items: center;
  text-decoration: none;
  color: var(--text);
}
.un-item:hover { background: var(--bg2); text-decoration: none; }
.un-item.active { border-color: var(--brand); background: var(--brand-bg); }

.un-thumb {
  width: 96px;
  height: 54px;
  border-radius: 6px;
  background: var(--bg2);
  flex-shrink: 0;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  position: relative;
}
.un-thumb img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 6px;
  background: var(--white);
}

.un-info { flex: 1; min-width: 0; }
.un-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.un-cat  { font-size: 11px; color: var(--text2); margin-top: 2px; }
.un-live { font-size: 10px; font-weight: 700; color: var(--red); margin-top: 2px; letter-spacing: .4px; }

/* ═══════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════ */
#footer {
  background: var(--white);
  border-top: 1px solid var(--border);
  margin-top: 48px;
  transition: background .2s, border-color .2s;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px 28px;
}

.footer-top {
  display: flex;
  gap: 40px;
  margin-bottom: 32px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
}
.fb-icon  { font-size: 36px; line-height: 1; }
.fb-name  { font-size: 18px; font-weight: 700; color: var(--brand); }
.fb-tagline { font-size: 12px; color: var(--text2); margin-top: 2px; }

.footer-nav   { display: flex; gap: 32px; flex-wrap: wrap; }
.fn-col       { display: flex; flex-direction: column; gap: 9px; min-width: 110px; }
.fn-col strong { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.fn-col a     { font-size: 13px; color: var(--text2); transition: color var(--t); }
.fn-col a:hover { color: var(--brand); text-decoration: none; }

/* Disclaimer */
.disclaimer-box {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--r);
  padding: 24px;
  margin-bottom: 28px;
  transition: background .2s, border-color .2s;
}
html.dark .disclaimer-box {
  background: #2a2200;
  border-color: #6b4c00;
}
.disc-title {
  font-size: 15px;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 14px;
}
html.dark .disc-title { color: #fbbf24; }
.disclaimer-box p {
  font-size: 12.5px;
  color: #7c4c00;
  line-height: 1.75;
  margin-bottom: 10px;
}
html.dark .disclaimer-box p { color: #d4a93a; }
.disclaimer-box p:last-child { margin-bottom: 0; }
.disclaimer-box a { color: var(--brand); }
.disclaimer-box strong { font-weight: 700; }

/* Footer bottom */
.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  text-align: center;
}
.footer-bottom p {
  font-size: 11.5px;
  color: var(--text3);
  margin-bottom: 4px;
}
.footer-bottom a { color: var(--brand); }

/* ── SEO content block ── */
.seo-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px 28px;
  margin-bottom: 28px;
  transition: background .2s, border-color .2s;
}
.seo-block h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.seo-block p {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.75;
  margin-bottom: 14px;
}
.seo-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.seo-cats span {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  transition: background .2s, border-color .2s;
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE-FIRST
═══════════════════════════════════════════ */

/* ── ≤ 1024px (small laptop / tablet landscape) ── */
@media (max-width: 1024px) {
  .watch-sidebar { width: 300px; }
  .ch-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
}

/* ── ≤ 768px (tablet portrait) ── */
@media (max-width: 768px) {
  :root {
    --sbw-mini: 0px;
  }

  .nav-right  { gap: 4px; }
  .load-badge { display: none; } /* hide on mobile */
  .nav-mid    { margin: 0 4px; }

  #cat-bar    { padding-left: 0; }
  #main { margin-left: 0; padding: 14px 12px 32px; }

  #sidebar {
    width: 0;
    border-right: none;
  }
  #sidebar.open  { width: var(--sbw); border-right: 1px solid var(--border); }
  #sidebar .sb-item span { opacity: 0; }
  #sidebar.open .sb-item span { opacity: 1; }

  #watch-view { flex-direction: column; }
  .watch-sidebar {
    width: 100%;
    position: static;
    max-height: none;
    margin-top: 0;
  }

  .ch-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

  #cib-name  { font-size: 15px; }
  .footer-top { gap: 24px; }
}

/* ── ≤ 540px (mobile landscape / large phones) ── */
@media (max-width: 540px) {
  :root { --nav-h: 52px; --cat-h: 42px; }

  #navbar { padding: 0 8px; gap: 6px; }
  .brand-name { font-size: 16px; }
  .brand-icon { font-size: 18px; }

  .ch-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  #main { padding: 10px 8px 24px; }
  .card-body { padding: 8px 10px 10px; }
  .card-name { font-size: 12px; }

  .err-btns { flex-direction: column; gap: 8px; }
  .err-btns button { width: 100%; text-align: center; }

  .footer-inner { padding: 28px 14px 20px; }
  .footer-nav { gap: 20px; }
}

/* ── ≤ 380px (small phones) ── */
@media (max-width: 380px) {
  .brand-name { display: none; }
  .ch-grid { grid-template-columns: repeat(2, 1fr); gap: 5px; }
  #main { padding: 8px 6px 20px; }

  .un-thumb { width: 76px; height: 43px; }
}

/* ── ≥ 1280px (wide screens) ── */
@media (min-width: 1280px) {
  .ch-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .watch-sidebar { width: 400px; }
}

@media (min-width: 1600px) {
  .ch-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* ── Hover-capable devices: sidebar hover expand ── */
@media (hover: hover) and (min-width: 769px) {
  #sidebar:hover {
    width: var(--sbw);
    overflow-y: auto;
    box-shadow: var(--sh-md);
  }
  #sidebar:hover .sb-item span { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════
   YOUTUBE-STYLE CUSTOM VIDEO PLAYER CONTROLS
   ─────────────────────────────────────────────────────── */

/* ── Outer container (absolutely covers player-box) ── */
.yt-ctrl {
  position: absolute;
  inset: 0;
  z-index: 15;
  cursor: none;
}
.yt-ctrl.show { cursor: default; }

/* ── Bottom gradient fog ── */
.ytc-bot-fog {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 110px;
  background: linear-gradient(to top,
    rgba(0,0,0,.90) 0%,
    rgba(0,0,0,.40) 60%,
    transparent 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity .22s ease;
}
.yt-ctrl.show      .ytc-bot-fog,
.yt-ctrl.paused    .ytc-bot-fog { opacity: 1; }

/* ── Center click zone ── */
.ytc-center {
  position: absolute;
  inset: 0;
  bottom: 64px;
  cursor: pointer;
}

/* ── Double-click ripple flash ── */
.ytc-ripple {
  position: absolute;
  border-radius: 50%;
  width: 64px; height: 64px;
  background: rgba(255,255,255,.25);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  transition: none;
}
.ytc-ripple.pop {
  animation: ripplePop .4s ease-out forwards;
}
@keyframes ripplePop {
  0%   { transform: translate(-50%,-50%) scale(.5); opacity: .6; }
  100% { transform: translate(-50%,-50%) scale(2);  opacity: 0; }
}

/* ── Bottom control bar ── */
.ytc-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 0 10px 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.yt-ctrl.show   .ytc-bar,
.yt-ctrl.paused .ytc-bar {
  opacity: 1;
  pointer-events: auto;
}

/* ══ Progress / Seek bar ══ */
.ytc-prog {
  width: 100%;
  padding: 8px 0 4px;
  cursor: pointer;
  position: relative;
}

.ytc-prog-track {
  position: relative;
  height: 3px;
  background: rgba(255,255,255,.28);
  border-radius: 2px;
  transition: height .18s;
  overflow: visible;
}
.ytc-prog:hover .ytc-prog-track,
.ytc-prog.scrubbing .ytc-prog-track {
  height: 5px;
}

/* Buffered */
.ytc-buf {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  background: rgba(255,255,255,.4);
  border-radius: 2px;
  pointer-events: none;
  transition: width .3s linear;
}

/* Played (red) */
.ytc-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 100%;
  background: #ff0000;
  border-radius: 2px;
  pointer-events: none;
}

/* Scrubber knob */
.ytc-knob {
  position: absolute;
  left: 100%;
  top: 50%;
  width: 13px; height: 13px;
  background: #ff0000;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform .15s;
  pointer-events: none;
  will-change: transform;
}
.ytc-prog:hover .ytc-knob,
.ytc-prog.scrubbing .ytc-knob {
  transform: translate(-50%, -50%) scale(1);
}

/* ══ Button row ══ */
.ytc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
  gap: 2px;
}
.ytc-left, .ytc-right {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ── Base button ── */
.ytc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  padding: 6px;
  color: #fff;
  flex-shrink: 0;
  transition: background .12s, transform .1s;
  position: relative;
  outline: none;
}
.ytc-btn:hover  { background: rgba(255,255,255,.16); }
.ytc-btn:active { transform: scale(.88); }
.ytc-btn svg    { width: 100%; height: 100%; display: block; }

/* Tooltip on button hover */
.ytc-btn::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28,28,28,.95);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9;
}
.ytc-btn:hover::after { opacity: 1; }

/* Speed button — wider to fit text */
.ytc-speed-btn {
  width: 44px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
}

/* ── Volume group ── */
.ytc-vol-group {
  display: flex;
  align-items: center;
  gap: 0;
}

.ytc-vol-rail {
  width: 0;
  overflow: hidden;
  transition: width .2s ease;
  display: flex;
  align-items: center;
}
.ytc-vol-group:hover .ytc-vol-rail,
.ytc-vol-group:focus-within .ytc-vol-rail {
  width: 64px;
}
.ytc-vol-track {
  position: relative;
  width: 56px; height: 4px;
  background: rgba(255,255,255,.28);
  border-radius: 2px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 2px;
}
.ytc-vol-track:hover { height: 5px; }
.ytc-vol-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 100%;
  background: #fff;
  border-radius: 2px;
  pointer-events: none;
}
.ytc-vol-knob {
  position: absolute;
  top: 50%; left: 100%;
  width: 11px; height: 11px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* ── LIVE badge ── */
.ytc-live {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
  margin-left: 4px;
}
.ytc-live:hover { background: rgba(255,255,255,.1); }

.ldot {
  width: 7px; height: 7px;
  background: #ff4444;
  border-radius: 50%;
  flex-shrink: 0;
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1;  transform: scale(1); }
  50%       { opacity: .4; transform: scale(.7); }
}
.ltxt {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .8px;
}

/* At live edge: solid red bg */
.ytc-live.at-live            { background: #ff0000; }
.ytc-live.at-live .ldot      { display: none; }
.ytc-live.at-live:hover      { background: #cc0000; }

/* DVR offset label */
.ytc-dvr {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,.8);
  white-space: nowrap;
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}

/* ── Speed Menu ───────────────────────────── */
.speed-menu {
  position: absolute;
  bottom: 58px;
  right: 88px;
  background: rgba(20,20,20,.97);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--r-sm);
  padding: 6px 0;
  min-width: 160px;
  z-index: 50;
  opacity: 0;
  transform: translateY(8px) scale(.96);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  backdrop-filter: blur(8px);
}
.speed-menu.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.speed-menu-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.5);
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 4px 16px 8px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 4px;
}

.speed-opt {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,.85);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background .12s, color .12s;
  font-family: inherit;
}
.speed-opt:hover { background: rgba(255,255,255,.1); color: #fff; }
.speed-opt.on {
  color: #ff0000;
  font-weight: 700;
}
.speed-opt.on::before {
  content: "✓";
  margin-right: 8px;
  font-size: 12px;
}
.speed-opt:not(.on)::before {
  content: "";
  display: inline-block;
  width: 20px;
}

/* ── Theater mode ── */
#watch-view.theater                { flex-direction: column; }
#watch-view.theater .watch-sidebar { width: 100%; position: static; max-height: none; }
#watch-view.theater #player-box   {
  border-radius: 0;
  aspect-ratio: unset;
  height: min(56.25vw, calc(100vh - var(--nav-h) - var(--cat-h) - 60px));
  width: 100%;
}

/* ── Fullscreen tweaks ── */
#player-box:-webkit-full-screen .ytc-bar { padding-bottom: 14px; }
#player-box:fullscreen          .ytc-bar { padding-bottom: 14px; }
#player-box:-webkit-full-screen #speed-menu { bottom: 70px; }
#player-box:fullscreen          #speed-menu { bottom: 70px; }

/* ── Mobile: hide non-essential buttons ── */
@media (max-width: 540px) {
  .ytc-pip-btn,
  .ytc-th-btn       { display: none; }

  .ytc-bar          { padding: 0 6px 6px; }
  .ytc-btn          { width: 30px; height: 30px; padding: 5px; }
  .ytc-speed-btn    { width: 36px; }
  .ytc-vol-group:hover .ytc-vol-rail { width: 44px; }
  .ytc-vol-track    { width: 36px; }
  .ytc-live         { padding: 2px 6px; }
  .ltxt             { font-size: 11px; }
  .speed-menu       { right: 4px; min-width: 140px; }
}
