:root {
  --bg: #0f0f0f;
  --bg-elev: #1f1f1f;
  --bg-hover: #272727;
  --line: #303030;
  --text: #f1f1f1;
  --muted: #aaaaaa;
  --accent: #ff0033;       /* overridden by personalization */
  --link: #3ea6ff;
  --radius: 12px;
  --maxw: 1600px;
  --topbar-h: 56px;
  --yt-zoom: 1.22;         /* zoom the embed so YouTube's title bar/logo are clipped off-frame */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; }
::selection { background: var(--accent); color: #fff; }

/* ── Top bar ───────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 60; height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px;
  background: rgba(15,15,15,.92);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff7a7a);
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 60%, transparent);
}
.search { position: relative; flex: 1; max-width: 560px; margin: 0 auto; }
.search input {
  width: 100%; padding: 9px 40px 9px 16px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--line);
  color: var(--text); outline: none; font-size: 14px;
}
.search input:focus { border-color: var(--accent); }
.search-ico { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* ── Icon buttons ──────────────────────────────────────────── */
.icon-btn {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  background: transparent; border: 0; color: var(--text);
  cursor: pointer; display: grid; place-items: center;
  transition: background .15s;
}
.icon-btn:hover { background: var(--bg-hover); }

/* ── Drawer (side nav) ─────────────────────────────────────── */
.drawer {
  position: fixed; top: 0; left: 0; z-index: 80;
  width: 250px; max-width: 84vw; height: 100%;
  background: var(--bg); border-right: 1px solid var(--line);
  padding: 12px 8px; overflow-y: auto;
  transform: translateX(-100%); transition: transform .22s ease;
}
.drawer[hidden] { display: block; }   /* keep it in flow for the slide animation */
body.drawer-open .drawer { transform: translateX(0); }
.scrim { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .2s; }
.scrim[hidden] { display: none; }
body.drawer-open .scrim { opacity: 1; }
.d-section { display: flex; flex-direction: column; gap: 2px; }
.d-item {
  display: flex; align-items: center; gap: 16px; padding: 10px 12px;
  border-radius: 10px; cursor: pointer; color: var(--text); font-size: 14px;
}
.d-item:hover { background: var(--bg-hover); }
.d-item.active { background: var(--bg-hover); font-weight: 600; }
.d-item svg { color: var(--text); }
.d-av { width: 24px; height: 24px; border-radius: 50%; overflow: hidden; flex: 0 0 24px;
  background: var(--bg-hover); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.d-av img { width: 100%; height: 100%; object-fit: cover; }
.d-sep { height: 1px; background: var(--line); margin: 10px 4px; }
.d-head { color: var(--muted); font-size: 13px; padding: 4px 12px 8px; }

/* ── Chips (channel filter row) ────────────────────────────── */
.chips {
  position: sticky; top: var(--topbar-h); z-index: 40;
  display: flex; gap: 10px; overflow-x: auto; padding: 12px 20px;
  background: var(--bg); scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; padding: 7px 13px; border-radius: 8px;
  background: var(--bg-elev); border: 1px solid transparent; color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer; transition: background .15s;
}
.chip:hover { background: var(--bg-hover); }
.chip.active { background: var(--text); color: #0f0f0f; }

/* ── Layout ────────────────────────────────────────────────── */
.app { max-width: var(--maxw); margin: 0 auto; padding: 10px 24px 60px; }
.loading, .empty { color: var(--muted); padding: 60px 0; text-align: center; }

/* ── Video grid ────────────────────────────────────────────── */
.grid {
  display: grid; gap: 28px 16px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.card { cursor: pointer; }
.thumb-wrap {
  position: relative; aspect-ratio: 16/9; border-radius: var(--radius);
  overflow: hidden; background: var(--bg-elev);
}
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease, border-radius .2s; }
.card:hover .thumb-wrap img { transform: scale(1.04); }
.card-body { display: flex; gap: 12px; padding: 12px 2px 0; }
.card-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 36px;
  background: var(--bg-hover); display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: var(--muted); overflow: hidden;
}
.card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.card-title {
  font-weight: 500; font-size: 15px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.card-channel { color: var(--muted); font-size: 13px; }
.card-channel:hover { color: var(--text); }

/* ── Channel header ────────────────────────────────────────── */
.channel-head { display: flex; align-items: center; gap: 18px; margin: 8px 0 24px; }
.channel-head .avatar {
  width: 80px; height: 80px; border-radius: 50%; overflow: hidden; flex: 0 0 80px;
  background: var(--bg-hover); display: grid; place-items: center; font-size: 30px; font-weight: 700; color: var(--muted);
}
.channel-head .avatar img { width: 100%; height: 100%; object-fit: cover; }
.channel-head h1 { margin: 0; font-size: 26px; }
.channel-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ── Watch page ────────────────────────────────────────────── */
.watch { display: grid; grid-template-columns: minmax(0,1fr) 400px; gap: 24px; align-items: start; }
.watch-main { min-width: 0; }

/* ── Custom player ─────────────────────────────────────────── */
.player { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; }
.player.fs { border-radius: 0; }
.player-stage { position: relative; aspect-ratio: 16/9; overflow: hidden; }
.player.fs .player-stage { aspect-ratio: auto; height: 100vh; }
.player-stage > #player, .player-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* zoom the iframe a touch so YouTube's own title/share/logo chrome is clipped outside the frame */
.player-stage iframe { transform: scale(var(--yt-zoom)); transform-origin: center; }
/* transparent layer that catches clicks so YouTube's own UI never fires */
.click-catch { position: absolute; inset: 0; cursor: pointer; background: transparent; }

.center-play {
  position: absolute; inset: 0; margin: auto; width: 76px; height: 76px;
  display: grid; place-items: center; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; cursor: pointer;
  opacity: 0; transform: scale(.9); transition: opacity .18s, transform .18s; pointer-events: none;
}
.player:not(.is-playing):not(.is-buffering) .center-play { opacity: 1; transform: scale(1); pointer-events: auto; }

.spinner {
  position: absolute; inset: 0; margin: auto; width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.25); border-top-color: #fff; animation: spin 1s linear infinite;
  opacity: 0; pointer-events: none;
}
.player.is-buffering .spinner { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

.player-top {
  position: absolute; left: 0; right: 0; top: 0; padding: 14px 16px 30px;
  background: linear-gradient(rgba(0,0,0,.6), transparent);
  color: #fff; font-size: 15px; font-weight: 500; pointer-events: none;
  opacity: 0; transition: opacity .2s;
}
.player.show-ui .player-top, .player.fs.show-ui .player-top { opacity: 1; }
.pt-title { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

.player-error {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 14px;
  background: #000; color: var(--text); text-align: center; padding: 24px; z-index: 5;
}
.player-error[hidden] { display: none; }   /* author display:grid would otherwise beat the hidden attr */

/* control bar */
.ctrl-bar {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 0 12px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
}
.player.show-ui .ctrl-bar { opacity: 1; transform: none; }
.player:not(.is-playing) .ctrl-bar { opacity: 1; transform: none; }
.player.is-playing:not(.show-ui) { cursor: none; }

.scrub { padding: 10px 0; cursor: pointer; }
.scrub-track { position: relative; height: 4px; border-radius: 3px; background: rgba(255,255,255,.3); transition: height .12s; }
.scrub:hover .scrub-track { height: 6px; }
.scrub-buf { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,.4); border-radius: 3px; width: 0; }
.scrub-played { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 3px; width: 0; }
.scrub-knob {
  position: absolute; top: 50%; left: 0; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); transform: translate(-50%,-50%) scale(0); transition: transform .12s;
}
.scrub:hover .scrub-knob { transform: translate(-50%,-50%) scale(1); }

.ctrl-row { display: flex; align-items: center; gap: 6px; color: #fff; }
.cbtn {
  background: none; border: 0; color: #fff; cursor: pointer; padding: 6px;
  display: grid; place-items: center; border-radius: 8px; line-height: 0;
}
.cbtn:hover { background: rgba(255,255,255,.15); }
.cbtn-text { font-size: 13px; font-weight: 700; min-width: 34px; }
.ctime { font-size: 13px; color: #fff; margin-left: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ctrl-spacer { flex: 1; }
.vol { display: flex; align-items: center; }
.vol-range {
  width: 0; opacity: 0; transition: width .18s, opacity .18s; height: 4px; accent-color: #fff;
  -webkit-appearance: none; appearance: none; background: rgba(255,255,255,.3); border-radius: 3px; cursor: pointer;
}
.vol:hover .vol-range, .vol-range:focus { width: 78px; opacity: 1; margin: 0 6px 0 2px; }
.vol-range::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.vol-range::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff; }

/* watch meta */
.v-title { font-size: 20px; font-weight: 600; margin: 16px 0 12px; line-height: 1.3; }
.v-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.v-channel { display: flex; align-items: center; gap: 12px; min-width: 0; }
.v-channel .avatar { width: 42px; height: 42px; border-radius: 50%; overflow: hidden; flex: 0 0 42px; background: var(--bg-hover); display:grid; place-items:center; font-weight:700; color:var(--muted); }
.v-channel .avatar img { width:100%; height:100%; object-fit:cover; }
.v-channel-name strong { font-size: 15px; }
.v-channel-name:hover { color: var(--text); }
.v-actions { display: flex; align-items: center; gap: 8px; }
.like-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px;
  border-radius: 999px; background: var(--bg-elev); font-size: 14px; font-weight: 600;
}
.like-pill svg { opacity: .9; }

.desc {
  position: relative; white-space: pre-wrap; word-break: break-word; color: var(--text);
  font-size: 14px; background: var(--bg-elev); border-radius: var(--radius); padding: 14px 16px; margin-top: 14px; line-height: 1.55;
}
.desc-stats { font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.desc:not(.expanded) .desc-body {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.desc-link { color: var(--link); }
.desc-link:hover { text-decoration: underline; }
.desc-ts { color: var(--link); cursor: pointer; }
.desc-ts:hover { text-decoration: underline; }
.desc-toggle { margin-top: 8px; background: none; border: 0; color: var(--text); font-weight: 700; font-size: 13px; cursor: pointer; padding: 0; }

.sidebar h3 { font-size: 14px; color: var(--muted); margin: 0 0 12px; text-transform: uppercase; letter-spacing: .5px; }
.up-next { display: flex; flex-direction: column; gap: 10px; }
.up { display: flex; gap: 10px; cursor: pointer; border-radius: 10px; padding: 4px; }
.up:hover { background: var(--bg-elev); }
.up .t { position: relative; width: 168px; flex: 0 0 168px; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; background: var(--bg-elev); }
.up .t img { width:100%; height:100%; object-fit: cover; }
.up .info { min-width: 0; padding-top: 2px; }
.up .info .ut { font-size: 14px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.up .info .um { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* ── Password gate ─────────────────────────────────────────── */
.gate {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 600px at 50% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    var(--bg);
}
.gate[hidden] { display: none; }
.gate-box {
  width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center;
  gap: 14px; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 18px; padding: 34px 28px; text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.brand-dot.big { width: 22px; height: 22px; }
.gate-box h1 { margin: 6px 0 0; font-size: 22px; }
.gate-sub { margin: 0; color: var(--muted); font-size: 14px; }
.gate-box input {
  width: 100%; padding: 12px 14px; border-radius: 12px; font-size: 15px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text); outline: none;
}
.gate-box input:focus { border-color: var(--accent); }
.gate-box button {
  width: 100%; padding: 12px 14px; border-radius: 999px; border: 0; cursor: pointer;
  font-size: 15px; font-weight: 700; color: #fff; background: var(--accent);
}
.gate-box button:disabled { opacity: .6; cursor: default; }
.gate-err { color: #ff6b6b; font-size: 13px; min-height: 16px; }

/* ── Settings ──────────────────────────────────────────────── */
.settings { max-width: 760px; margin: 0 auto; }
.settings h1 { font-size: 26px; margin: 8px 0 20px; }
.settings .panel {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
}
.settings .panel h2 { font-size: 16px; margin: 0 0 14px; }
.settings .add-row { display: flex; gap: 10px; }
.settings .add-row input {
  flex: 1; padding: 11px 14px; border-radius: 10px; font-size: 14px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text); outline: none;
}
.settings .add-row input:focus { border-color: var(--accent); }
.settings .add-row button {
  padding: 0 20px; border-radius: 999px; border: 0; cursor: pointer; font-weight: 700;
  color: #fff; background: var(--accent);
}
.settings .hint { color: var(--muted); font-size: 13px; margin: 10px 2px 0; min-height: 16px; }
.chan-list { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chan-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
.chan-item .av { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; flex: 0 0 34px;
  background: var(--bg-hover); display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.chan-item .av img { width: 100%; height: 100%; object-fit: cover; }
.chan-item .nm { flex: 1; min-width: 0; }
.chan-item .nm b { display: block; font-size: 14px; }
.chan-item .nm small { color: var(--muted); font-size: 12px; }
.chan-item .rm { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.chan-item .rm:hover { color: #ff6b6b; background: var(--bg-hover); }

/* appearance fields */
.field { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; }
.field-label { font-size: 14px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; background: var(--sw); }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--sw); }
.toggle-field { cursor: pointer; }
.toggle-field input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch { position: relative; width: 44px; height: 24px; border-radius: 999px; background: var(--bg-hover); transition: background .18s; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .18s; }
.toggle-field input:checked + .switch { background: var(--accent); }
.toggle-field input:checked + .switch::after { transform: translateX(20px); }

/* empty-state action button */
.btn-primary {
  display: inline-block; margin-top: 14px; padding: 10px 18px; border-radius: 999px;
  border: 0; cursor: pointer; font-weight: 700; color: #fff; background: var(--accent);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .watch { grid-template-columns: 1fr; }
  .up .t { width: 160px; flex-basis: 160px; }
}
@media (max-width: 900px) {
  .app { padding: 8px 16px 60px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 22px 14px; }
}
@media (max-width: 640px) {
  .topbar { gap: 6px; padding: 0 10px; }
  .brand-name { display: none; }
  .search input { padding: 8px 38px 8px 14px; }
  .chips { padding: 10px 14px; }
  .app { padding: 6px 0 60px; }
  .grid { grid-template-columns: 1fr; gap: 16px; }
  .card { padding: 0; }
  .thumb-wrap { border-radius: 0; }
  .card-body { padding: 10px 12px 0; }
  .v-title, .v-row, .desc { margin-left: 12px; margin-right: 12px; }
  .player { border-radius: 0; --yt-zoom: 1.4; }
  .sidebar { padding: 0 12px; }
  .channel-head { padding: 0 12px; }
  .channel-head .avatar { width: 60px; height: 60px; flex-basis: 60px; font-size: 22px; }
  .channel-head h1 { font-size: 20px; }
  .settings { padding: 0 12px; }
  .vol:hover .vol-range { width: 60px; }
}
