/* Same design tokens as latenightfix.it itself -- this is meant to read as
   a companion page, not a different product. */
:root {
  --canvas: #0A090C;
  --panel: #131317;
  --panel-2: #16151b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --fg: #F5F5F7;
  --muted: #9C9CA3;
  --faint: #7E7E86;
  --gold: #EAD151;
  --gold-dim: rgba(234, 209, 81, 0.16);
  --moon: #9FB9D4;
  --ok: #9BC49B;
  --err: #E08E8E;
  --r-md: 14px;
  --r-lg: 18px;

  --rail-w: 128px;
  --row-h: 60px;
  --head-h: 30px;
  --px-min: 4.4px;
  --app-max: 1180px;
}

@media (max-width: 640px) {
  :root {
    --rail-w: 92px;
    --row-h: 56px;
    --px-min: 3.4px;
  }
}

* { box-sizing: border-box; }

html {
  color-scheme: dark;
  height: 100%;
  /* The actual fix for the "elastic" feel on iOS: overflow:hidden on body
     alone does not stop Safari's document-level rubber-band bounce. Both
     html and body need to refuse to scroll themselves, leaving only the
     grid panes below able to move. */
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  height: 100dvh;
  background: var(--canvas);
  color: var(--fg);
  font: 15px/1.5 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
}

.app {
  width: 100%;
  max-width: var(--app-max);
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* --- top bar ---------------------------------------------------------- */

.bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 16px 8px;
  flex: 0 0 auto;
}

.brand { display: flex; align-items: baseline; gap: 7px; }
.brand-mark {
  font-family: 'Sora', 'Geist', system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  color: var(--fg);
}
.brand-word {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}
.clock {
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: var(--faint);
  letter-spacing: 0.02em;
}

/* --- day strip ---------------------------------------------------------- */

.days {
  display: flex;
  gap: 5px;
  /* Top padding matters here, not just for spacing: overflow-x:auto forces
     overflow-y to clip too (that's how the spec resolves one axis set and
     the other left "visible"), so the active day's glow -- which paints
     outside the button's own box -- needs real room above it or it gets
     cut off in a flat line right at the container's edge. */
  padding: 16px 12px 10px;
  overflow-x: auto;
  overflow-y: visible;
  flex: 0 0 auto;
  scrollbar-width: none;
}
.days::-webkit-scrollbar { display: none; }

.day-btn {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--faint);
  font: inherit;
  cursor: pointer;
  min-width: 46px;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 0.15s ease;
}
.day-btn .dow { font-size: 0.6rem; letter-spacing: 0.08em; text-transform: uppercase; }
.day-btn .dom { font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.day-btn.active {
  background: var(--gold);
  border-color: var(--gold);
  /* The subtle glow the owner asked for -- matches how the main site uses
     a soft gold halo around its own primary controls. */
  box-shadow: 0 0 0 1px rgba(234, 209, 81, 0.35), 0 0 14px 1px rgba(234, 209, 81, 0.45);
}
.day-btn.active .dow, .day-btn.active .dom { color: #16150E; }
.day-btn.today:not(.active) {
  border-color: var(--gold);
  color: var(--gold);
}
.day-btn.today:not(.active) .dom { color: var(--gold); }

/* --- the grid: two independently-scrolling panes, synced by JS --------- */

.grid-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  border-top: 1px solid var(--line);
  overflow: hidden;
}

.rail-pane {
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  border-right: 1px solid var(--line);
  background: var(--canvas);
  /* The grid already had iOS's native momentum scrolling; the rail didn't,
     so a programmatic scrollTop write here was competing with a plainer,
     less fluid scroll model instead of one built for the same fast,
     inertial motion it's being asked to track. */
  -webkit-overflow-scrolling: touch;
  /* "contain" (used on .time-pane below) only stops the bounce from
     reaching the page behind it -- it does not stop the pane's OWN edges
     from rubber-banding. "none" is what actually kills that locally. */
  overscroll-behavior: none;
}
.rail-pane::-webkit-scrollbar { display: none; }

.rail-head {
  height: var(--head-h);
  border-bottom: 1px solid var(--line);
}

.chan {
  height: var(--row-h);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 0 9px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid var(--chan-color, var(--line));
}
.chan .num {
  font-size: 0.58rem;
  color: var(--faint);
  letter-spacing: 0.05em;
}
.chan .name {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.time-pane {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  position: relative;
  -webkit-overflow-scrolling: touch;
  /* "none", not "contain" -- see the note on .rail-pane above. This is the
     actual fix for "the grid itself still feels elastic": contain alone
     still let this pane rubber-band at its own edges, it just stopped
     that bounce from also dragging the page behind it along with it. */
  overscroll-behavior: none;
}

.timehead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--canvas);
  border-bottom: 1px solid var(--line);
  height: var(--head-h);
  white-space: nowrap;
}
.timehead .tick {
  position: absolute;
  top: 0; bottom: 0;
  display: flex;
  align-items: center;
  padding-left: 7px;
  font-size: 0.64rem;
  color: var(--faint);
  border-left: 1px solid var(--line);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.body {
  position: relative;
  white-space: nowrap;
}
.chan-row {
  position: relative;
  height: var(--row-h);
  border-bottom: 1px solid var(--line);
}
.hourline {
  position: absolute;
  top: 0; bottom: 0;
  border-left: 1px solid var(--line);
}

.cell {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--chan-color, var(--line));
  overflow: hidden;
  padding: 5px 8px;
  cursor: default;
}
.cell .t {
  font-size: 0.63rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.cell .s {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.2;
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell .e {
  font-size: 0.67rem;
  color: var(--muted);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell.premiere { background: var(--panel-2); border-color: var(--line-strong); }
.cell.premiere::after {
  content: "PREMIERE";
  position: absolute;
  top: 5px; right: 7px;
  font-size: 0.52rem;
  letter-spacing: 0.09em;
  color: var(--gold);
  font-weight: 700;
}
/* Below the medium tier, only the time and episode subtitle go -- the show
   name stays. Every real programme slot is long enough to show at least
   that; nothing should ever read as a blank box. */
.cell.compact .t, .cell.compact .e { display: none; }
.cell.compact .s { font-size: 0.7rem; }
.cell.bare .t, .cell.bare .e, .cell.bare .s { display: none; }

.nowline {
  position: absolute;
  top: var(--head-h);
  width: 2px;
  background: var(--err);
  z-index: 15;
  pointer-events: none;
}
.nowline::before {
  content: "";
  position: absolute;
  top: -5px; left: 50%;
  transform: translateX(-50%);
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--err);
}

.empty {
  padding: 36px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.foot {
  flex: 0 0 auto;
  padding: 7px 16px calc(7px + env(safe-area-inset-bottom));
  font-size: 0.65rem;
  color: var(--faint);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 6px;
}
.foot .dot { opacity: 0.5; }

/* --- listing detail: a tap is the only way to read a truncated title on
   a touchscreen, so every cell opens this. Bottom sheet on a phone (the
   natural, thumb-reachable place for it); a small centred card once
   there's room for one. --------------------------------------------- */

/* [hidden] and a class-based "display: flex" have identical specificity
   (0,1,0 apiece), and an author rule beats the UA default on a tie -- so
   an unconditional "display: flex" here silently overrides the hidden
   attribute and the backdrop never actually hides. This was the entire
   bug: the sheet wasn't getting stuck open, it was never closed at all,
   from the very first page load. */
.detail-backdrop[hidden] { display: none; }
.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in 0.15s ease;
}
@media (min-width: 641px) {
  .detail-backdrop { align-items: center; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.detail-sheet {
  width: 100%;
  max-width: 420px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  position: relative;
  animation: sheet-up 0.18s cubic-bezier(.2, .8, .3, 1);
}
@media (min-width: 641px) {
  .detail-sheet {
    border-radius: var(--r-lg);
    margin: 20px;
    animation: sheet-pop 0.15s cubic-bezier(.2, .8, .3, 1);
  }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes sheet-pop { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.detail-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.detail-chan {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--chan-color, var(--gold));
  margin-bottom: 8px;
  padding-right: 30px;
}
.detail-show {
  font-family: 'Sora', 'Geist', system-ui, sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.3;
}
.detail-ep {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}
.detail-time {
  font-size: 0.78rem;
  color: var(--faint);
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
