:root {
  --bg: #0e0f14;
  --bg-soft: #161822;
  --bg-card: #1b1e2b;
  --bg-card-2: #222637;
  --line: #2a2f42;
  --text: #eef0f7;
  --muted: #9aa3bd;
  --muted-2: #6b7391;
  --accent: #ff2d46;
  --accent-soft: #ff2d4622;
  --live: #21d07a;
  --now-line: #ffd23f;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --ff: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 85% -10%, #2a1030 0%, transparent 55%),
    radial-gradient(1000px 500px at -10% 0%, #10233a 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--ff);
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
}

a { color: inherit; }

#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px 90px;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px 12px;
  background: linear-gradient(180deg, var(--bg) 55%, transparent);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand__dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft), 0 0 22px var(--accent);
}
.brand__title { font-size: 20px; margin: 0; letter-spacing: -.02em; font-weight: 800; }
.brand__sub { margin: 0; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }

.topbar__right { display: flex; align-items: center; gap: 10px; }
.clock {
  font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 18px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--line);
}

/* ---------- Buttons ---------- */
.btn {
  cursor: pointer; border: 1px solid var(--line);
  background: var(--bg-card); color: var(--text);
  padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 14px;
  transition: .15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn--live { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--live:hover { filter: brightness(1.08); }

/* ---------- Day pills ---------- */
.days {
  display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 10px;
  scrollbar-width: none;
}
.days::-webkit-scrollbar { display: none; }
.day {
  flex: 0 0 auto; cursor: pointer;
  min-width: 62px; text-align: center;
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--line);
  transition: .15s ease;
}
.day:hover { border-color: var(--muted-2); }
.day.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.day.is-today { position: relative; }
.day.is-today::after {
  content: ""; position: absolute; top: 6px; right: 8px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--live);
}
.day__dow { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.day.is-active .day__dow { color: #ffd7dc; }
.day__num { font-size: 18px; font-weight: 800; line-height: 1.1; color: var(--text); }
.day__cnt { font-size: 10px; color: var(--muted-2); }
.day.is-active .day__cnt { color: #ffd7dc; }

/* ---------- Controls ---------- */
.controls { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 14px; }
.controls__row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search { flex: 1 1 260px; }
.search input {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--line); color: var(--text);
  font-size: 15px; outline: none;
}
.search input:focus { border-color: var(--accent); }

.viewtoggle { display: flex; background: var(--bg-card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.viewtoggle__btn {
  cursor: pointer; border: 0; background: transparent; color: var(--muted);
  padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 14px;
}
.viewtoggle__btn.is-active { background: var(--accent); color: #fff; }

.controls__row--time { gap: 14px; }
.livechk, .stageschk { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.livechk input, .stageschk input { accent-color: var(--accent); width: 16px; height: 16px; }
.timeslider { flex: 1 1 200px; accent-color: var(--now-line); }
.timeLabel {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 15px;
  min-width: 52px; text-align: center; color: var(--now-line);
}

/* ---------- Theme chips ---------- */
.themes { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  cursor: pointer; font-size: 12.5px; font-weight: 600;
  padding: 6px 11px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--line); color: var(--muted);
  display: inline-flex; align-items: center; gap: 7px; transition: .12s ease;
}
.chip:hover { color: var(--text); }
.chip__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, #888); }
.chip.is-on { color: #fff; border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 22%, var(--bg-card)); }

/* ---------- Now & Next view ---------- */
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 20px 2px 12px; }
.section-head h2 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.section-head .pill {
  font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .06em;
}
.pill--live { background: var(--live); color: #062; }
.pill--soon { background: #ffb020; color: #402; }
.section-head .count { color: var(--muted-2); font-size: 13px; font-weight: 600; }

.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px;
}
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: .15s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--muted-2); box-shadow: var(--shadow); }
.card__media { position: relative; aspect-ratio: 16/10; background: var(--bg-card-2); overflow: hidden; }
.card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__media--empty { display: flex; align-items: center; justify-content: center; color: var(--muted-2); font-size: 34px; font-weight: 800; opacity: .35; }
.card__cat { position: absolute; top: 10px; left: 10px; z-index: 2; }
.card__badge {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  font-size: 11px; font-weight: 800; padding: 4px 9px; border-radius: 999px;
  backdrop-filter: blur(4px);
}
.badge--live { background: rgba(33,208,122,.9); color: #043; }
.badge--soon { background: rgba(255,176,32,.92); color: #402; }
.card__progress { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--live); z-index: 2; }
.card__body { padding: 12px 13px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card__title { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.card__meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; flex-wrap: wrap; margin-top: auto; }
.card__time { font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.tagcat { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); }
.tagcat__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, #888); }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty strong { color: var(--text); }

/* ---------- Guide grid ---------- */
.guide-wrap {
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: auto; background: var(--bg-soft); position: relative;
  max-height: calc(100vh - 240px);
}
.guide {
  position: relative;
  display: grid;
  align-items: stretch;
  /* first column channels, second column timeline */
}
.guide__timehead {
  position: sticky; top: 0; z-index: 20;
  height: 34px; background: var(--bg-soft); border-bottom: 1px solid var(--line);
}
.guide__timehead .tick { position: absolute; top: 0; height: 34px; border-left: 1px solid var(--line); padding: 8px 0 0 6px; font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.guide__corner {
  position: sticky; left: 0; top: 0; z-index: 30;
  background: var(--bg-soft); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 12px; font-size: 12px; color: var(--muted); font-weight: 700;
}
.chan {
  position: sticky; left: 0; z-index: 15;
  background: var(--bg-soft); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  padding: 6px 12px;
}
.chan__name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 14px; }
.chan__tag { font-size: 10px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .05em; }
.chan.is-stage .chan__name { color: #fff; }
.lane { position: relative; border-bottom: 1px solid var(--line); }
.block {
  position: absolute; top: 5px; bottom: 5px;
  background: var(--bg-card-2); border: 1px solid var(--line);
  border-left: 3px solid var(--c, var(--accent));
  border-radius: 8px; padding: 5px 8px; overflow: hidden; cursor: pointer;
  transition: .12s ease;
}
.block:hover { background: var(--bg-card); border-color: var(--muted-2); z-index: 5; }
.block.is-live { background: color-mix(in srgb, var(--c, var(--accent)) 24%, var(--bg-card)); border-color: var(--c, var(--accent)); }
.block__t { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.block__n { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nowline { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--now-line); z-index: 18; pointer-events: none; box-shadow: 0 0 10px var(--now-line); }
.nowline::before { content: ""; position: absolute; top: 34px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--now-line); }

/* ---------- Footer ---------- */
.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 22px; color: var(--muted-2); font-size: 12px; }
.foot a { color: var(--muted); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.modal__card {
  position: relative; z-index: 2; width: min(560px, 100%); max-height: 88vh; overflow: auto;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.modal__close { position: absolute; top: 10px; right: 12px; z-index: 3; background: rgba(0,0,0,.5); color: #fff; border: 0; width: 34px; height: 34px; border-radius: 50%; font-size: 22px; cursor: pointer; }
.m-media { aspect-ratio: 16/9; background: var(--bg-card-2); }
.m-media img { width: 100%; height: 100%; object-fit: cover; }
.m-body { padding: 18px 20px 22px; }
.m-title { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.m-sub { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.m-sub b { color: var(--text); }
.m-cats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.m-desc { color: #d7dbec; font-size: 14.5px; line-height: 1.6; }
.m-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.m-actions a { text-decoration: none; }

@media (max-width: 620px) {
  .brand__title { font-size: 17px; }
  .viewtoggle__btn { padding: 7px 12px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
