:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --panel-2: #1c2128;
  --line: #262c35;
  --text: #eef1f4;
  --muted: #8d96a3;
  --accent: #e8483b;
  --accent-2: #ff6a5c;
  --ok: #3fb68b;
  --radius: 14px;
  --tap: 56px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }

/* ---------- buttons ---------- */
.btn {
  min-height: var(--tap); padding: 0 24px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-2); font-weight: 600; letter-spacing: .01em;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 44px; padding: 0 16px; font-size: 15px; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(420px, 100%); display: grid; gap: 14px; padding: 36px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
}
.login-card label { color: var(--muted); font-size: 15px; }
.login-card input { height: var(--tap); padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.err { color: #ff8a80; min-height: 1.4em; margin: 0; }

/* ---------- top bar ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: -.02em; }
.brand.big { font-size: 30px; margin-bottom: 8px; }
.brand-mark { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); box-shadow: 0 0 18px var(--accent); }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; background: rgba(11, 13, 16, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 6px; flex: 1; justify-content: center; }
.tab {
  min-height: var(--tap); padding: 0 28px; border: 0; border-radius: 999px; background: transparent;
  color: var(--muted); font-weight: 700; font-size: 18px;
}
.tab[aria-selected="true"] { background: var(--panel-2); color: var(--text); }
.warn { margin: 12px 24px 0; padding: 12px 16px; border-radius: 12px; background: #3a2a10; color: #ffd28a; }

main { padding: 20px 24px 48px; }
.searchbar {
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 18px; margin-bottom: 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
}
.searchbar .ic { width: 22px; height: 22px; color: var(--muted); flex: none; }
.searchbar input { flex: 1; min-width: 0; height: var(--tap); border: 0; background: transparent; outline: none; font-size: 19px; }
.section-head { display: flex; align-items: center; justify-content: space-between; }
h2 { font-size: 20px; margin: 4px 0 14px; }
.status { color: var(--muted); margin-bottom: 12px; min-height: 1.4em; }

/* ---------- grids ---------- */
.grid { display: grid; gap: 18px; }
.videos { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.channels { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }

.card { all: unset; display: flex; flex-direction: column; justify-content: flex-start; cursor: pointer; border-radius: var(--radius); }
.card:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: var(--panel-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 7px; border-radius: 6px;
  background: rgba(0, 0, 0, .8); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.badge.live { background: var(--accent); }
.progress { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--accent); }
.card-title { margin-top: 10px; font-weight: 650; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { color: var(--muted); font-size: 15px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chan {
  position: relative; display: grid; grid-template-rows: 84px auto; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; text-align: left;
}
.chan:active { background: var(--panel-2); }
.chan .logo { display: grid; place-items: center; background: #0f1215; border-radius: 10px; overflow: hidden; }
.chan .logo img { max-width: 80%; max-height: 64px; object-fit: contain; }
.chan .logo span { color: var(--muted); font-weight: 800; font-size: 22px; padding: 0 8px; text-align: center; }
.chan .name { font-weight: 650; font-size: 15px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan .num { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.fav {
  position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border: 0; border-radius: 10px;
  background: transparent; color: #4a525e; display: grid; place-items: center;
}
.fav svg { width: 22px; height: 22px; }
.fav.on { color: #ffc84a; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: none; }
.chip {
  flex: none; min-height: 46px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); font-weight: 600; font-size: 15px;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- podcasts ---------- */
.pods { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.pod-art { aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--panel-2); }
.pod-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.icon-btn.small { width: 48px; height: 48px; background: var(--panel-2); }
.icon-btn.small svg { width: 22px; height: 22px; }
.pod-show { display: flex; gap: 22px; align-items: flex-start; margin-bottom: 18px; }
.pod-show img { width: 180px; height: 180px; border-radius: var(--radius); object-fit: cover; flex: none; background: var(--panel-2); }
.pod-show-text { min-width: 0; }
.pod-show h2 { font-size: 26px; margin: 0 0 4px; }
.pod-show p { color: var(--muted); font-size: 15px; margin: 10px 0 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ep-list { display: grid; gap: 10px; margin-bottom: 26px; }
.ep {
  display: flex; align-items: center; gap: 16px; width: 100%; padding: 14px 16px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.ep:active { background: var(--panel-2); }
.ep.done .ep-title { color: var(--muted); }
.ep-art { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; flex: none; }
.ep-main { flex: 1; min-width: 0; }
.ep-meta { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-title { font-weight: 650; margin: 2px 0; }
.ep-sum { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ep-foot { display: flex; align-items: center; gap: 12px; margin-top: 6px; color: var(--muted); font-size: 14px; font-weight: 600; }
.ep-bar { width: 120px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.ep-bar span { display: block; height: 100%; background: var(--accent); }
.ep-play { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--panel-2); }
.ep-play svg { width: 22px; height: 22px; }

/* ---------- player ---------- */
.p-art { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #1f2630, #000 70%); }
.p-art img { width: min(46vh, 70vw); aspect-ratio: 1; object-fit: cover; border-radius: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.player { position: fixed; inset: 0; z-index: 20; background: #000; user-select: none; }
.stage { position: absolute; inset: 0; display: grid; place-items: center; }
.video-canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.p-msg {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  color: #fff; font-size: 19px; text-align: center; padding: 24px; pointer-events: none;
}
.p-msg button { pointer-events: auto; }
.p-msg.error .spinner { display: none; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .2); border-top-color: #fff; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.controls { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; transition: opacity .25s; pointer-events: none; }
.controls.hide { opacity: 0; }
.controls.hide * { pointer-events: none !important; }
.ctl-top, .ctl-bottom { display: flex; align-items: center; gap: 12px; padding: 16px 20px; pointer-events: auto; }
.ctl-top { background: linear-gradient(rgba(0, 0, 0, .75), transparent); }
.ctl-bottom { background: linear-gradient(transparent, rgba(0, 0, 0, .8)); padding-bottom: 22px; }
.p-title { flex: 1; min-width: 0; }
#p-title { font-weight: 700; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#p-sub { color: #b9c0c9; font-size: 15px; }
.icon-btn {
  position: relative; width: 60px; height: 60px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff;
}
.icon-btn:active { background: rgba(255, 255, 255, .25); }
.icon-btn svg { width: 28px; height: 28px; }
.icon-btn.big { width: 72px; height: 72px; background: rgba(255, 255, 255, .2); }
.icon-btn.big svg { width: 34px; height: 34px; }
.icon-btn span { position: absolute; font-size: 10px; font-weight: 800; top: 50%; left: 50%; transform: translate(-50%, -18%); }
.p-time { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.seek { flex: 1; min-width: 80px; height: 44px; accent-color: var(--accent); background: transparent; }
.live-badge { margin-left: auto; padding: 6px 12px; border-radius: 8px; background: var(--accent); font-weight: 800; letter-spacing: .06em; }

@media (max-width: 700px) {
  .topbar { gap: 10px; padding: 10px 16px; }
  .brand { display: none; }
  main { padding: 16px; }
  .tab { padding: 0 18px; }
  .videos { grid-template-columns: 1fr; }
  .channels { grid-template-columns: repeat(2, 1fr); }
  #p-rew, #p-fwd { display: none; }
  .pods { grid-template-columns: repeat(2, 1fr); }
  .pod-show img { width: 110px; height: 110px; }
  .ep-sum { display: none; }
}
