/* xmltv.live – dark, responsive program guide UI (vanilla CSS) */
:root {
  --bg: #0a0e16;
  --bg2: #0f1521;
  --panel: #131a28;
  --panel2: #182134;
  --line: #222c40;
  --line2: #2b3750;
  --text: #e7ecf5;
  --muted: #8a97ad;
  --dim: #5d6a80;
  --acc1: #22d3ee;
  --acc2: #8b5cf6;
  --acc: linear-gradient(90deg, var(--acc1), var(--acc2));
  --live: #f43f5e;
  --ok: #34d399;
  --radius: 14px;
  --topbar: 64px;
  --chcol: 210px;     /* timeline channel column */
  --pph: 240px;       /* timeline pixels per hour (JS reads this) */
  --rowh: 64px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -200px, rgba(139,92,246,.12), transparent 60%),
              radial-gradient(900px 500px at -10% -100px, rgba(34,211,238,.10), transparent 60%), var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--acc1); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar);
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px;
  background: rgba(10,14,22,.82);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text .bt { display: flex; align-items: baseline; }
.brand-text b { font-size: 20px; letter-spacing: -.02em; }
.brand-text i { font-style: normal; font-size: 20px; font-weight: 700; background: var(--acc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-text small { font-size: 11px; color: var(--muted); letter-spacing: .02em; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.tab { display: flex; align-items: center; gap: 8px; padding: 7px 14px; border: 0; background: transparent; border-radius: 9px; color: var(--muted); font-weight: 600; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 0 rgba(244,63,94,.6); animation: pulse 1.8s infinite; flex: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(244,63,94,.55);} 70% { box-shadow: 0 0 0 7px rgba(244,63,94,0);} 100% { box-shadow: 0 0 0 0 rgba(244,63,94,0);} }

.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 0 12px; height: 38px; width: 260px; color: var(--muted); transition: border-color .15s, box-shadow .15s; }
.search:focus-within { border-color: var(--acc1); box-shadow: 0 0 0 3px rgba(34,211,238,.15); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; padding: 7px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); letter-spacing: .02em; }
.lang { position: relative; }
.lang-btn { display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border-radius: 11px; background: var(--panel); border: 1px solid var(--line); font-weight: 700; font-size: 13px; }
.lang-menu { position: absolute; right: 0; top: 46px; min-width: 210px; background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; padding: 6px; box-shadow: var(--shadow); display: none; }
.lang.open .lang-menu { display: block; }
.lang-menu button { display: flex; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border: 0; background: transparent; border-radius: 8px; color: var(--muted); }
.lang-menu button b { color: var(--text); min-width: 44px; }
.lang-menu button:hover, .lang-menu button.active { background: var(--panel2); color: var(--text); }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 256px minmax(0, 1fr); gap: 0; min-height: calc(100vh - var(--topbar) - 50px); }
.sidebar { position: sticky; top: var(--topbar); align-self: start; height: calc(100vh - var(--topbar)); overflow: auto; padding: 18px 12px 18px 16px; border-right: 1px solid var(--line); }
.sidebar h3 { margin: 4px 8px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--dim); }
.country-list { display: flex; flex-direction: column; gap: 3px; }
.country { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; border: 1px solid transparent; background: transparent; text-align: left; color: var(--muted); width: 100%; }
.country:hover { background: var(--panel); color: var(--text); }
.country.active { background: linear-gradient(90deg, rgba(34,211,238,.12), rgba(139,92,246,.08)); border-color: rgba(34,211,238,.25); color: var(--text); }
.country .cn { flex: 1; min-width: 0; line-height: 1.25; font-weight: 600; }
.country .cc { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.flag { width: 24px; height: 17px; border-radius: 3px; object-fit: cover; flex: none; background: var(--panel2); box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
.flag-lg { width: 36px; height: 25px; border-radius: 4px; }

.main { min-width: 0; padding: 18px 22px 30px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.cur-country { display: flex; align-items: center; gap: 12px; }
.cur-country h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.cur-country .sub { color: var(--muted); font-size: 12.5px; }
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.toolbar > * { min-width: 0; }
.stat { color: var(--muted); font-size: 12.5px; }
.stat:empty { display: none; }
.days { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 3px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.days button { border: 0; background: transparent; color: var(--muted); padding: 6px 11px; border-radius: 8px; white-space: nowrap; font-weight: 600; font-size: 13px; }
.days button.active { background: var(--panel2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }
.btn { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; border: 1px solid var(--line2); background: var(--panel); border-radius: 10px; padding: 7px 13px; font-weight: 600; }
.btn:hover { border-color: var(--acc1); }

.other-results { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 14px; color: var(--muted); font-size: 12.5px; }
.other-results button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 10px 4px 6px; font-size: 12.5px; }
.other-results button:hover { border-color: var(--acc1); }
.other-results .flag { width: 18px; height: 13px; }

/* ---------- Logos ---------- */
.logo { width: 56px; height: 40px; border-radius: 9px; background: #f4f6fa; display: grid; place-items: center; overflow: hidden; flex: none; padding: 4px; }
.logo.dark { background: #1d2638; box-shadow: inset 0 0 0 1px var(--line2); }
.logo img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.logo.ph { background: var(--ph, #334); color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .02em; padding: 0; text-shadow: 0 1px 2px rgba(0,0,0,.3); }

/* ---------- "Now" cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
  cursor: pointer; min-height: 196px; min-width: 0;
}
.card:hover { transform: translateY(-2px); border-color: var(--line2); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; }
.ch-name { font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge-live { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; color: #fff; background: rgba(244,63,94,.16); border: 1px solid rgba(244,63,94,.4); padding: 3px 8px; border-radius: 999px; }
.badge-live .dot-live { width: 6px; height: 6px; }
.now-title { font-size: 16.5px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: rgba(139,92,246,.14); color: #c4b5fd; border: 1px solid rgba(139,92,246,.25); white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.progress { position: relative; height: 6px; border-radius: 99px; background: #1e2738; overflow: hidden; }
.progress > span { position: absolute; inset: 0 auto 0 0; background: var(--acc); border-radius: inherit; transition: width 1s linear; box-shadow: 0 0 12px rgba(34,211,238,.45); }
.prog-row { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; margin-top: -4px; }
.prog-row .left { color: var(--text); font-weight: 600; }
.next { margin-top: auto; display: flex; gap: 8px; align-items: baseline; padding-top: 10px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 13px; min-width: 0; }
.next .lbl { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--acc1); flex: none; }
.next .tm { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; flex: none; }
.next .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.next:hover .tt { color: var(--text); }
.card.noinfo .now-title { color: var(--dim); font-weight: 500; font-size: 14px; }

/* ---------- Timeline grid ---------- */
.grid-wrap { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg2); overflow: hidden; }
.grid-scroll { position: relative; overflow: auto; max-height: calc(100vh - var(--topbar) - 140px); overscroll-behavior: contain; }
.grid-inner { position: relative; }
.g-head { position: sticky; top: 0; z-index: 6; display: flex; height: 40px; background: rgba(15,21,33,.96); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.g-corner { position: sticky; left: 0; z-index: 7; width: var(--chcol); flex: none; background: #0f1521; border-right: 1px solid var(--line); display: flex; align-items: center; padding: 0 14px; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.g-hours { position: relative; flex: none; }
.g-hour { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); padding: 11px 8px; font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.g-hour.half { border-left-style: dashed; border-left-color: #1a2335; color: var(--dim); font-weight: 500; }
.g-row { display: flex; height: var(--rowh); border-bottom: 1px solid #182033; }
.g-ch { position: sticky; left: 0; z-index: 4; width: var(--chcol); flex: none; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: #0f1521; border-right: 1px solid var(--line); }
.g-ch .logo { width: 48px; height: 34px; border-radius: 7px; }
.g-ch .n { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.g-track { position: relative; flex: none; }
.g-prog {
  position: absolute; top: 5px; bottom: 5px;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--cat, #3b4a66);
  border-radius: 8px; padding: 6px 9px; overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  transition: background .12s, border-color .12s;
}
.g-prog:hover { background: var(--panel2); border-color: var(--line2); z-index: 2; }
.g-prog .t { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-prog .s { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums; }
.g-prog.past { opacity: .45; }
.g-prog.live { background: linear-gradient(90deg, rgba(34,211,238,.16) var(--pct, 0%), var(--panel2) var(--pct, 0%)); border-color: rgba(34,211,238,.45); }
.g-prog.live .t::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--live); margin-right: 6px; vertical-align: middle; }
.g-prog.tiny { padding: 0; border-left-width: 2px; }
.g-prog.tiny > * { display: none; }
.now-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--live); z-index: 5; pointer-events: none; box-shadow: 0 0 10px rgba(244,63,94,.7); }
.now-tag { position: absolute; top: 9px; transform: translateX(-50%); z-index: 2; background: var(--live); color: #fff; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; box-shadow: 0 2px 10px rgba(244,63,94,.5); pointer-events: none; }
.now-line::before { display: none; content: attr(data-time); position: sticky; top: 8px; display: inline-block; transform: translateX(-50%); margin-left: 1px; background: var(--live); color: #fff; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* category colours (left border / chip) */
.cat-sport  { --cat: #22c55e; } .cat-movie { --cat: #f59e0b; } .cat-news { --cat: #38bdf8; }
.cat-kids   { --cat: #f472b6; } .cat-docu  { --cat: #a3e635; } .cat-series { --cat: #a78bfa; }
.cat-music  { --cat: #fb7185; } .cat-ent   { --cat: #facc15; }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; color: var(--muted); padding: 60px 20px; border: 1px dashed var(--line2); border-radius: var(--radius); }
.skeleton { background: linear-gradient(90deg, var(--panel) 25%, var(--panel2) 37%, var(--panel) 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: var(--radius); min-height: 196px; border: 1px solid var(--line); }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3,6,12,.7); backdrop-filter: blur(4px); animation: fade .15s ease; }
.modal-card { position: relative; width: min(640px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.6); animation: pop .18s ease; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-close { position: absolute; right: 12px; top: 12px; z-index: 3; width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); background: rgba(10,14,22,.6); font-size: 22px; line-height: 1; color: #fff; }
.m-hero { position: relative; height: 200px; background: linear-gradient(135deg, rgba(34,211,238,.35), rgba(139,92,246,.35)); overflow: hidden; }
.m-hero img.bg { width: 100%; height: 100%; object-fit: cover; display: block; }
.m-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, var(--panel) 100%); }
.m-hero.noimg { height: 96px; }
.m-ch { position: absolute; left: 22px; bottom: 14px; z-index: 2; display: flex; align-items: center; gap: 10px; font-weight: 700; }
.m-content { padding: 6px 22px 22px; }
.m-content h2 { margin: 6px 0 2px; font-size: 22px; line-height: 1.25; letter-spacing: -.02em; }
.m-alt { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.m-time { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; color: var(--muted); margin: 10px 0; font-variant-numeric: tabular-nums; }
.m-time b { color: var(--text); }
.m-progress { margin: 6px 0 4px; }
.m-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.m-desc { color: #cdd5e3; font-size: 14.5px; line-height: 1.6; white-space: pre-line; }
.m-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; }
.m-facts dt { color: var(--dim); }
.m-facts dd { margin: 0; color: var(--text); }
.state { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line2); color: var(--muted); }

/* ---------- Footer ---------- */
.footer { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 16px 22px; color: var(--dim); font-size: 12px; border-top: 1px solid var(--line); margin-left: 256px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .search { width: 190px; }
  .brand-text small { display: none; }
}
@media (max-width: 860px) {
  :root { --topbar: 112px; --chcol: 72px; --pph: 200px; --rowh: 60px; }
  .topbar { flex-wrap: wrap; height: auto; min-height: var(--topbar); padding: 10px 14px; gap: 10px; }
  .brand img { width: 30px; height: 30px; }
  .tabs { order: 3; flex: 1 0 100%; }
  .tab { flex: 1; justify-content: center; }
  .top-right { gap: 8px; }
  .search { order: 4; width: auto; flex: 1 0 100%; display: none; }
  .clock { font-size: 13px; padding: 6px 9px; }
  .layout { display: block; }
  .sidebar { position: sticky; top: var(--topbar); z-index: 30; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 10px; background: rgba(10,14,22,.92); backdrop-filter: blur(10px); }
  .sidebar h3 { display: none; }
  .country-list { flex-direction: row; overflow-x: auto; scrollbar-width: none; gap: 6px; }
  .country { width: auto; flex: none; padding: 6px 10px; border-color: var(--line); background: var(--panel); }
  .country .cc { display: none; }
  .main { padding: 14px 12px 24px; }
  .toolbar { margin-bottom: 12px; }
  .cur-country h1 { font-size: 18px; }
  .m-search { display: flex !important; }
  .cards { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .toolbar-right { width: 100%; }
  .days { flex: 1; }
  .card { min-height: 0; }
  .footer { margin-left: 0; }
  .g-ch .n { display: none; }
  .g-ch { justify-content: center; padding: 0 6px; }
  .g-corner { padding: 0 8px; }
  .modal { padding: 0; align-items: end; }
  .modal-card { border-radius: 18px 18px 0 0; max-height: 92vh; }
}
.m-search { display: none; margin-bottom: 12px; }
.m-search .search { display: flex; width: 100%; }
.footer .credit { color: var(--text, #e5e7eb); opacity: .85; } .footer .credit a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Paging (big countries) ---------- */
.card { content-visibility: auto; contain-intrinsic-size: auto 196px; }
.more { display: flex; justify-content: center; margin: 18px 0 4px; }
.more[hidden], .g-more[hidden] { display: none; }
.g-more { position: sticky; left: 0; display: flex; justify-content: center; padding: 14px 0; }
.more .btn, .g-more .btn { color: var(--muted); }
.more .btn:disabled, .g-more .btn:disabled { opacity: .7; cursor: progress; }
