:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #15181d;
  --muted: #5f6672;
  --line: #e2e5ea;
  --accent: #2459d6;
  --accent-soft: #e6edfc;
  --now: #0f8a4b;
  --on-accent: #ffffff;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --card: #181c22;
    --text: #e8eaee;
    --muted: #9aa2ae;
    --line: #2a3039;
    --accent: #7aa2ff;
    --accent-soft: #1d2a47;
    --now: #4cd18b;
    --on-accent: #0f1216;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Header */
.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 8px; }
.brand { font-weight: 700; font-size: 18px; text-decoration: none; }
select, input[type="search"] {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
}
.countries { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: thin; }
.countries a {
  flex: none; text-decoration: none; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); white-space: nowrap;
}
.countries a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0 12px; }
.toolbar h1 { font-size: 22px; margin: 0; flex: 1 1 auto; }
.toolbar input[type="search"] { flex: 1 1 220px; max-width: 320px; }

/* Channel grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; text-decoration: none; display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.card:hover { border-color: var(--accent); }
.ch { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ch b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo {
  width: 40px; height: 30px; flex: none; object-fit: contain; border-radius: 6px;
  background: var(--accent-soft); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--accent);
}
.now-line { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.now-line .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); flex: none; font-size: 13px; }
.badge { font-size: 11px; font-weight: 700; color: var(--now); text-transform: uppercase; letter-spacing: .04em; flex: none; }
.bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--now); }
.next { font-size: 13px; }

/* Channel page */
.back { text-decoration: none; color: var(--accent); }
.days { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.days button {
  font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; white-space: nowrap;
}
.days button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list details { padding: 10px 14px; }
.list summary { display: flex; gap: 14px; align-items: baseline; cursor: pointer; list-style: none; }
.list summary::-webkit-details-marker { display: none; }
.list .time { width: 72px; font-size: 14px; white-space: nowrap; }
.list .past { opacity: .55; }
.list .on { background: var(--accent-soft); }
.list .meta { font-size: 13px; color: var(--muted); }
.list p { margin: 6px 0 0 86px; color: var(--muted); }
.list li { scroll-margin-top: 140px; }
.empty { padding: 30px; text-align: center; }

.foot { padding-top: 24px; padding-bottom: 32px; font-size: 13px; }

@media (max-width: 520px) {
  .brand span { display: none; }
  .list p { margin-left: 0; }
  .list .time { width: 64px; font-size: 13px; }
  .list summary { gap: 10px; }
}
