/* Layout: in-car media UI — settings-style group list left, channel cards right,
   player full-bleed with a media bar at the bottom. Tuned for the 2025 Model 3
   centre screen (1920x1200; ~1920x1000 usable in the browser), tapped at arm's length:
   64px+ targets, no blur/heavy shadows (cheap to paint on the car's browser). */
:root {
  --bg: #0a0a0b;
  --surface: #1c1d1f;         /* cards, list highlight */
  --surface-hi: #2a2b2e;      /* pressed */
  --line: #26272a;
  --text: #f4f4f5;
  --muted: #9b9ca1;
  --accent: #3e6ae1;          /* active/selected only */
  --accent-soft: rgba(62, 106, 225, .18);
  --radius: 12px;
  --tap: 64px;
  --font: "Gotham SSm", "Universal Sans Text", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 21px/1.35 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.screen { position: fixed; inset: 0; }

.brand {
  margin: 0; font-weight: 500; text-transform: uppercase; letter-spacing: .32em;
  font-size: 22px; white-space: nowrap;
}
.brand.small { font-size: 17px; letter-spacing: .3em; }

/* ── PIN ── */
#login { display: grid; place-items: center; }
.login-card { display: grid; justify-items: center; gap: clamp(14px, 2.6vh, 26px); }
.login-card .brand { font-size: 28px; }
.hint { margin: 0; color: var(--muted); min-height: 1.4em; text-align: center; }
.hint.error { color: #ff6b5e; }
.dots { display: flex; gap: 20px; }
.dots span { width: 18px; height: 18px; border-radius: 50%; background: var(--surface-hi); }
.dots span.on { background: var(--text); }
.dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }
.keypad {
  --key: clamp(72px, 10.5vh, 104px);
  display: grid; grid-template-columns: repeat(3, var(--key)); gap: clamp(12px, 2vh, 20px);
}
.keypad button {
  width: var(--key); height: var(--key); border-radius: 50%; background: var(--surface);
  font-size: calc(var(--key) * .36); font-weight: 400;
}
.keypad button:active { background: var(--surface-hi); }
.keypad .key-alt { background: transparent; font-size: 19px; color: var(--muted); }

/* ── Browser ── */
.topbar {
  height: 88px; display: flex; align-items: center; gap: 22px; padding: 0 28px;
}
#search {
  flex: 1; min-width: 0; height: 56px; border-radius: 28px; border: 0;
  background: var(--surface); color: var(--text); font: inherit; padding: 0 26px;
}
#search::placeholder { color: var(--muted); }
.switch { display: flex; flex: none; background: var(--surface); border-radius: 28px; padding: 4px; }
.switch button {
  height: 48px; padding: 0 24px; border-radius: 24px; color: var(--muted); font-weight: 500; white-space: nowrap;
}
.switch button.active { background: var(--surface-hi); color: var(--text); }
.ghost { height: 56px; padding: 0 22px; border-radius: 28px; color: var(--muted); }
.ghost:active { background: var(--surface); }

.layout { position: absolute; top: 88px; bottom: 0; left: 0; right: 0; display: flex; }
.rail {
  width: 340px; flex: none; overflow-y: auto; padding: 4px 14px 24px 20px;
  display: flex; flex-direction: column; gap: 2px;
}
.rail button {
  min-height: var(--tap); text-align: left; padding: 10px 18px; border-radius: var(--radius);
  display: flex; justify-content: space-between; gap: 12px; align-items: center; color: #d6d7da;
}
.rail button:active { background: var(--surface); }
.rail button .count { color: var(--muted); font-size: 16px; font-variant-numeric: tabular-nums; }
.rail button.active { background: var(--surface); color: var(--text); font-weight: 500; }
.rail button.active .count { color: var(--accent); }
.rail .sep { height: 1px; background: var(--line); margin: 10px 8px; flex: none; }

.channels {
  flex: 1; min-width: 0; overflow-y: auto; padding: 4px 28px 28px 10px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px;
  align-content: start;
}
.card {
  display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: center;
  min-height: 108px; padding: 14px 18px 16px 14px; border-radius: var(--radius);
  background: var(--surface); text-align: left; position: relative; overflow: hidden;
}
.card:active { background: var(--surface-hi); }
.logo {
  /* Dark tile: most logos in these lists are white-on-transparent, made for dark UIs. */
  width: 96px; height: 64px; border-radius: 8px; background: var(--surface-hi); display: grid; place-items: center;
  overflow: hidden; font-weight: 600; color: var(--muted); padding: 6px;
}
.logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.card .meta { min-width: 0; }
.card .name { font-weight: 500; font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .now { color: var(--muted); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.card .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }
.card .star { position: absolute; top: 8px; right: 12px; color: var(--accent); font-size: 17px; }
.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 6px 0 0; }
.chips-title { width: 100%; color: var(--muted); font-size: 17px; margin-bottom: 4px; }
.chip { height: 56px; padding: 0 24px; border-radius: 28px; background: var(--surface); }
.chip:active { background: var(--surface-hi); }
.ghost-chip { background: transparent; color: var(--muted); }
.empty { grid-column: 1 / -1; color: var(--muted); padding: 48px; text-align: center; }
.more { grid-column: 1 / -1; height: 1px; }

/* ── Guide grid: channel column sticky left, time header sticky top ── */
.channels.guide { display: block; padding: 0 0 28px 10px; overflow: auto; }
.g-head, .g-row { display: flex; width: max-content; }
.g-head { position: sticky; top: 0; z-index: 3; background: var(--bg); height: 52px; align-items: stretch; }
.g-corner, .g-chan { position: sticky; left: 0; z-index: 2; flex: none; width: 300px; background: var(--bg); }
.g-times { position: relative; flex: none; }
.g-tick { position: absolute; top: 0; height: 100%; padding: 14px 0 0 10px; color: var(--muted); font-size: 16px;
  border-left: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.g-row { height: 92px; margin-top: 8px; }
.g-chan { display: grid; grid-template-columns: 84px 1fr; gap: 12px; align-items: center; padding: 0 14px 0 4px; text-align: left; }
.g-chan .logo { width: 84px; height: 56px; }
.g-chan .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-track { position: relative; flex: none; }
.g-cell {
  position: absolute; top: 0; bottom: 0; padding: 12px 16px; border-radius: 10px; overflow: hidden;
  background: var(--surface); text-align: left; border: 2px solid var(--bg);
}
.g-cell.live { background: var(--surface-hi); box-shadow: inset 3px 0 0 var(--accent); }
.g-cell:active { background: #34363a; }
.g-title { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-time { font-size: 15px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.g-empty { color: var(--muted); padding: 30px 16px; font-size: 17px; }
.g-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); z-index: 1; pointer-events: none; }

/* ── Player ── */
#player { background: #000; }
video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.status {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%);
  background: rgba(20, 20, 22, .92); padding: 22px 30px; border-radius: var(--radius);
  max-width: 70%; text-align: center; font-size: 22px;
}
.controls {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between;
  transition: opacity .25s;
}
.controls.hide { opacity: 0; pointer-events: none; }
.controls-top { display: flex; justify-content: space-between; padding: 24px 28px; }
.controls-bottom {
  display: flex; align-items: center; gap: 18px; padding: 18px 24px;
  margin: 0 24px 24px; border-radius: 20px; background: rgba(18, 18, 20, .9);
}
.round {
  width: 68px; height: 68px; flex: none; border-radius: 50%; background: rgba(18, 18, 20, .9);
  font-size: 30px;
}
#fav.on { color: var(--accent); }
.np { flex: 1; min-width: 0; order: -1; }
.np-channel { font-size: 17px; color: var(--muted); }
.np-title { font-size: 28px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-next { font-size: 17px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-tech { font-size: 15px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.pill {
  min-width: 132px; height: 68px; padding: 0 24px; border-radius: 34px; flex: none;
  background: var(--surface); font-weight: 500;
}
.pill:active, .round:active { background: var(--surface-hi); }

@media (prefers-reduced-motion: reduce) {
  .dots.shake { animation: none; }
  .controls { transition: none; }
}
@media (max-width: 1100px) {
  .rail { width: 250px; }
  .channels { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .controls-bottom { flex-wrap: wrap; }
}
