:root {
  --bg: #070b1f;
  --panel: #0f1636;
  --panel-2: #16204a;
  --line: #26336b;
  --text: #eef1ff;
  --muted: #9aa5d6;
  --accent: #ffd23f;      /* guide-listing yellow */
  --accent-2: #39d0ff;    /* cyan */
  --live: #ff4d6d;
  --commercial: #3a2a5c;
  --radius: 10px;
  --px-per-min: 6px;      /* guide timeline scale */
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 10% -10%, #1a2a6c55, transparent),
    radial-gradient(900px 400px at 110% 0%, #6c1a5a44, transparent),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: 0.01em; }
h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0c1333, #0a0f2a);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px;
  background: var(--accent); color: #1b1300; font-weight: 900; font-size: 22px;
  box-shadow: 0 0 18px #ffd23f55;
}
.brand-name { font-weight: 800; font-size: 1.1rem; }
.brand-sub { color: var(--muted); font-size: 0.8rem; }
.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); }
.account { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }

.badge { padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.badge-live { background: var(--live); color: #fff; box-shadow: 0 0 12px #ff4d6d88; }
.badge-off { background: var(--panel-2); color: var(--muted); }

.button {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 8px;
  padding: 8px 14px; background: var(--accent); color: #1b1300;
}
.button-quiet { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.button:hover { filter: brightness(1.1); }
.button:focus-visible, .program:focus-visible, .guide:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 48px; display: grid; gap: 28px; }
/* Grid children default to their content's width; the 24-hour timeline is thousands of
   pixels wide, so let them shrink and have the timeline scroll inside its own box. */
main > *, .now > * { min-width: 0; }

.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.75rem; color: var(--accent-2); font-weight: 700; }

/* --- now playing --------------------------------------------------------------- */
.now {
  display: grid; grid-template-columns: 180px 1fr 260px; gap: 22px; align-items: start;
  background: linear-gradient(135deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: 14px; padding: 20px;
}
.now-poster, .details-poster {
  aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: #0b1130;
  display: grid; place-items: center; color: var(--muted); font-size: 2.5rem; font-weight: 900;
  box-shadow: 0 10px 30px #0008;
}
.now-poster img, .details-poster img, .program img, .list img { width: 100%; height: 100%; object-fit: cover; display: block; }
.now-title { font-size: clamp(1.5rem, 3vw, 2.3rem); margin: 4px 0 6px; }
.now-meta { color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rating { border: 1px solid var(--muted); border-radius: 4px; padding: 0 5px; font-size: 0.75rem; }
.part { background: #ffd23f22; color: var(--accent); border-radius: 4px; padding: 0 6px; font-size: 0.8rem; }
.now-summary { color: #cdd3f5; margin: 12px 0 16px; max-width: 70ch; }
.progress { height: 8px; border-radius: 99px; background: #ffffff14; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 0.9s linear; }
.now-times { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.85rem; margin-top: 6px; font-variant-numeric: tabular-nums; }
.now-remaining { color: var(--text); }
.next { border-left: 1px solid var(--line); padding-left: 20px; }
.next-body { margin-top: 8px; display: grid; gap: 4px; }
.next-title { font-weight: 700; font-size: 1.05rem; }
.next-time { color: var(--muted); font-size: 0.9rem; }

/* --- guide timeline ------------------------------------------------------------- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.guide {
  position: relative; overflow-x: auto; overflow-y: hidden; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel); padding-bottom: 6px; scroll-behavior: smooth;
}
.ruler { position: relative; height: 30px; border-bottom: 1px solid var(--line); }
.tick { position: absolute; top: 0; height: 100%; border-left: 1px solid var(--line); padding: 6px 8px; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.tick-hour { color: var(--text); font-weight: 700; }
.tick-day { color: var(--accent); }
.lane { position: relative; height: 128px; margin-top: 8px; }
.program {
  position: absolute; top: 0; height: 120px; border-radius: 8px; overflow: hidden; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); display: flex; gap: 8px; padding: 6px;
  text-align: left; color: var(--text); font: inherit;
}
.program:hover { border-color: var(--accent); }
.program.is-current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.program .thumb { flex: 0 0 72px; height: 106px; border-radius: 5px; overflow: hidden; background: #0b1130; }
.program .text { min-width: 0; display: grid; align-content: start; gap: 2px; }
.program .p-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.program .p-sub, .program .p-time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.program.commercials {
  background: repeating-linear-gradient(135deg, var(--commercial), var(--commercial) 6px, #2a1f45 6px, #2a1f45 12px);
  padding: 0; justify-content: center; align-items: center;
}
.program.commercials .text { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 0.7rem; color: #cdbff0; }
.program.narrow .thumb { display: none; }
.now-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--live); box-shadow: 0 0 8px var(--live); pointer-events: none; }
.hint { color: var(--muted); font-size: 0.82rem; margin: 8px 2px 0; }

/* --- coming up list ------------------------------------------------------------- */
.list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.list li {
  display: grid; grid-template-columns: 88px 44px 1fr; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer;
}
.list li:hover { border-color: var(--accent); }
.list .l-time { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; }
.list .l-thumb { width: 44px; height: 66px; border-radius: 4px; overflow: hidden; background: #0b1130; }
.list .l-title { font-weight: 700; }
.list .l-sub { color: var(--muted); font-size: 0.85rem; }
.list li.commercials { grid-template-columns: 88px 1fr; padding: 6px 12px; background: #1a1433; }
.list li.commercials .l-title { font-weight: 600; color: #cdbff0; }

/* --- dialogs -------------------------------------------------------------------- */
.details { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; padding: 16px; z-index: 20; }
.details[hidden] { display: none; }
.details-card { position: relative; width: min(720px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.details-grid { display: grid; grid-template-columns: 160px 1fr; gap: 20px; }
.details-time { color: var(--accent); margin: 8px 0; font-variant-numeric: tabular-nums; }
.close { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--muted); font-size: 1.6rem; cursor: pointer; }
.login-card { width: min(360px, 100%); display: grid; gap: 12px; }
.login-card label { display: grid; gap: 4px; color: var(--muted); font-size: 0.9rem; }
.login-card input { font: inherit; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: #0b1130; color: var(--text); }
.login-error { color: var(--live); min-height: 1.2em; font-size: 0.9rem; }

/* --- small screens -------------------------------------------------------------- */
@media (max-width: 860px) {
  .now { grid-template-columns: 110px 1fr; }
  .next { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); padding: 14px 0 0; }
}
@media (max-width: 520px) {
  .topbar { padding: 10px 16px; }
  .brand-sub, .clock { display: none; }
  .now { grid-template-columns: 1fr; }
  .now-poster { width: 140px; }
  .details-grid { grid-template-columns: 1fr; }
  .details-poster { width: 130px; }
  .list li { grid-template-columns: 70px 40px 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .guide { scroll-behavior: auto; }
  .progress-fill { transition: none; }
}
