:root {
  --bg: #0b0f0c;
  --bg2: #0f1612;
  --panel: #121a15;
  --wall: #1f2e26;
  --line: #243a30;
  --ink: #d8e6dc;
  --dim: #7a9388;
  --soft: #97b1a4;
  --accent: #4ea96b;
  --hot: #e0464a;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ── top bar ─────────────────────────────────────────────────── */
.bar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px; background: var(--bg2);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 800; font-size: 19px; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.topnav { display: flex; gap: 2px; }
.topnav a { padding: 6px 10px; border-radius: 6px; color: var(--soft); font-weight: 500; font-size: 13px; }
.topnav a:hover { background: var(--wall); color: var(--ink); }
.topnav a.active { color: var(--ink); background: var(--wall); }
.spacer { flex: 1; }
.search input {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; min-width: 220px; outline: none;
}
.search input:focus { border-color: var(--accent); }
.lang { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }

/* ── views ──────────────────────────────────────────────────── */
.view.hidden { display: none !important; }

/* ── home ───────────────────────────────────────────────────── */
#home { max-width: 1400px; margin: 0 auto; padding: 32px 22px 48px; }
.hero { padding: 14px 0 28px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.hero h1 { font-size: 32px; font-weight: 800; margin: 0 0 8px; letter-spacing: -0.02em; }
.hero p { color: var(--soft); margin: 0; font-size: 15px; }
.section-h { font-size: 12px; text-transform: uppercase; color: var(--dim); letter-spacing: 0.1em; font-weight: 700; margin: 0 0 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; cursor: pointer; transition: transform .12s, border-color .12s;
  display: flex; flex-direction: column;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .thumb {
  position: relative; aspect-ratio: 16/9;
  background: linear-gradient(135deg, #0e2018, #1a3a2a 60%, #244a36);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.card.audio .thumb { background: linear-gradient(135deg, #1a1a30, #3a2848 70%, #482a40); }
.card .logo-big { font-size: 64px; font-weight: 900; color: rgba(255,255,255,.92); letter-spacing: -0.04em; text-shadow: 0 4px 18px rgba(0,0,0,.5); }
.card.audio .logo-big { font-size: 48px; }
.card .live-tag { position: absolute; top: 10px; left: 10px; background: var(--hot); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: 0.06em; padding: 3px 7px; border-radius: 3px; display: inline-flex; align-items: center; gap: 5px; }
.card .live-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse 1.5s ease-in-out infinite; }
.card .v-tag { position: absolute; bottom: 10px; right: 10px; background: rgba(0,0,0,.7); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 3px; font-variant-numeric: tabular-nums; }
.card .quality-tag { position: absolute; bottom: 10px; left: 10px; background: rgba(0,0,0,.7); color: var(--accent); font-size: 10px; font-weight: 800; padding: 3px 6px; border-radius: 3px; letter-spacing: 0.04em; }
.card .meta { padding: 14px; }
.card .n { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.card .d { color: var(--soft); font-size: 12px; line-height: 1.4; }
.card .tag-row { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.card .tag-row span { background: var(--wall); color: var(--soft); font-size: 11px; padding: 2px 8px; border-radius: 4px; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* tiny equalizer animation for audio thumb */
.card .eq {
  position: absolute; bottom: 14px; display: flex; gap: 3px; align-items: flex-end;
  height: 28px;
}
.card .eq span {
  width: 4px; background: rgba(255,255,255,.7); border-radius: 1px;
  animation: eq 1s ease-in-out infinite;
}
.card .eq span:nth-child(1) { animation-delay: -0.6s; }
.card .eq span:nth-child(2) { animation-delay: -0.4s; }
.card .eq span:nth-child(3) { animation-delay: -0.2s; }
.card .eq span:nth-child(4) { animation-delay: -0.0s; }
.card .eq span:nth-child(5) { animation-delay: -0.3s; }
.card .eq span:nth-child(6) { animation-delay: -0.5s; }
@keyframes eq {
  0%, 100% { height: 6px; }
  50%      { height: 26px; }
}

/* ── player view ────────────────────────────────────────────── */
#player-view {
  display: grid; grid-template-columns: minmax(0,1fr) 340px;
  gap: 18px; padding: 18px; max-width: 1600px; margin: 0 auto;
}
@media (max-width: 960px) { #player-view { grid-template-columns: 1fr; } .side { order: 3; } }

.stage-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ── player stage ────────────────────────────────────────────── */
.stage { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 16/9; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.stage video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.stage.audio { aspect-ratio: auto; height: 180px; background: radial-gradient(ellipse at center, #1a1a30 0%, #0b0b18 70%, #050510 100%); }
.stage audio video { display: none; }

/* ── custom player controls ───────────────────────────────────── */
.player-controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 10px 8px;
  background: linear-gradient(0deg, rgba(0,0,0,.75) 0%, rgba(0,0,0,.35) 60%, transparent 100%);
  opacity: 0; transition: opacity .2s; z-index: 10;
}
.stage:hover .player-controls,
.player-controls.show { opacity: 1; }

/* DPRK flag seek bar:
   blue (#024FA2) | white | red (#EE1C25) | white | blue */
.seek-bar {
  position: relative; height: 6px; border-radius: 3px;
  margin-bottom: 8px; cursor: pointer;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}
.seek-buffered {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: rgba(255,255,255,.12); border-radius: 3px;
  pointer-events: none;
}
.seek-played {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 3px; pointer-events: none;
  background: linear-gradient(to right,
    #024FA2 0%, #024FA2 12%,
    #ffffff 12%, #ffffff 18%,
    #EE1C25 18%, #EE1C25 82%,
    #ffffff 82%, #ffffff 88%,
    #024FA2 88%, #024FA2 100%
  );
  background-size: var(--seek-bg-scale, 200%) 100%;
  background-position: left center;
  box-shadow: 0 0 6px rgba(238,28,37,.4);
}
.seek-flag {
  position: absolute; inset: 0; border-radius: 3px;
  background: linear-gradient(to right,
    rgba(2,79,162,.25) 0%, rgba(2,79,162,.25) 12%,
    rgba(255,255,255,.15) 12%, rgba(255,255,255,.15) 18%,
    rgba(238,28,37,.2) 18%, rgba(238,28,37,.2) 82%,
    rgba(255,255,255,.15) 82%, rgba(255,255,255,.15) 88%,
    rgba(2,79,162,.25) 88%, rgba(2,79,162,.25) 100%
  );
  pointer-events: none;
}
.seek-thumb {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 14px; height: 14px; border-radius: 50%;
  background: #EE1C25; border: 2px solid #fff;
  box-shadow: 0 0 4px rgba(0,0,0,.5);
  pointer-events: none; display: none;
}
.seek-bar:hover .seek-thumb { display: block; }

.controls-row { display: flex; align-items: center; gap: 8px; }
.ctrl-btn {
  background: none; border: none; color: var(--ink);
  padding: 4px; border-radius: 4px; display: flex; align-items: center; justify-content: center;
  opacity: .85; transition: opacity .12s, background .12s;
}
.ctrl-btn:hover { opacity: 1; background: rgba(255,255,255,.1); }
.ctrl-time { font-size: 12px; color: var(--soft); font-variant-numeric: tabular-nums; user-select: none; }
.ctrl-spacer { flex: 1; }
.vol-slider {
  -webkit-appearance: none; appearance: none;
  width: 70px; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,.2); outline: none; cursor: pointer;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}
.vol-slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: none; cursor: pointer;
}

.viz {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  width: 100%; height: 80%;
  display: none; pointer-events: none;
}
.stage.audio .viz { display: block; }
.stage-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center;
  background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.55));
  color: var(--ink); transition: opacity .2s; pointer-events: none;
}
.stage-overlay.hidden { opacity: 0; }
.stage-overlay .sub { margin-top: 12px; color: var(--soft); font-size: 13px; }
.loader { width: 36px; height: 36px; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── info row under the video ────────────────────────────────── */
.info-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 4px;
}
.title-block { min-width: 0; flex: 1; }
.ch-title { font-weight: 700; font-size: 17px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-sub { color: var(--soft); font-size: 13px; margin-top: 2px; }

.viewers {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--hot); font-weight: 700; font-size: 14px;
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.viewers .vlabel { color: var(--soft); font-weight: 500; }

/* ── channel quick switcher ──────────────────────────────────── */
.channels { display: flex; gap: 6px; flex-wrap: wrap; }
.channels button { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13px; }
.channels button.active { background: var(--accent); border-color: var(--accent); color: #06120a; font-weight: 600; }
.channels button:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

/* ── side ────────────────────────────────────────────────────── */
.side { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; align-self: start; }
.side h2 { font-size: 11px; text-transform: uppercase; color: var(--dim); letter-spacing: 0.1em; margin: 0 0 10px; font-weight: 700; }
.side h2:not(:first-child) { margin-top: 22px; }

/* recommended channel list */
.recs { list-style: none; padding: 0; margin: 0; }
.recs li { display: flex; gap: 10px; padding: 7px 4px; border-radius: 6px; cursor: pointer; transition: background .12s; }
.recs li:hover { background: var(--wall); }
.recs .av { width: 32px; height: 32px; border-radius: 50%; background: var(--wall); color: var(--accent); font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.recs .info { min-width: 0; flex: 1; }
.recs .n { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recs .g { font-size: 11px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recs .v { font-size: 11px; color: var(--hot); font-weight: 700; display: flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.recs .v::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--hot); }

/* schedule */
.sched { list-style: none; padding: 0; margin: 0; }
.sched li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 12px; }
.sched li:last-child { border-bottom: 0; }
.sched .t { color: var(--accent); min-width: 46px; font-variant-numeric: tabular-nums; font-weight: 600; }
.sched .name { color: var(--soft); }
.sched li.now .t { color: var(--hot); }
.sched li.now .name { color: var(--ink); font-weight: 600; }
.sched li.sec { padding: 10px 0 4px; border-bottom: 0; display: flex; justify-content: space-between; align-items: baseline; }
.sched li.sec:first-child { padding-top: 0; }
.sched .sec-name { color: var(--ink); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.sched .sec-tz { color: var(--dim); font-size: 10px; font-variant-numeric: tabular-nums; }

/* categories */
.cats { list-style: none; padding: 0; margin: 0; }
.cats li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 12px; color: var(--soft); }
.cats .dot { width: 8px; height: 8px; border-radius: 50%; }

.foot { color: var(--dim); font-size: 11px; line-height: 1.5; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
