:root {
  --bg: #0e1116;
  --panel: #171b22;
  --line: #262c36;
  --text: #eef1f5;
  --muted: #9aa4b2;
  --accent: #5fb3a1;
  --accent-ink: #0b1a16;
  --danger: #ff8b7b;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 18px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body.watching { overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; }

/* Sign in */
.center { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.card {
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 24px; padding: 32px 28px; display: grid; gap: 16px;
}
.logo { width: 64px; height: 64px; }
.card h1 { margin: 0; font-size: 30px; letter-spacing: -0.01em; }
.hint { margin: 0; color: var(--muted); }
label { display: grid; gap: 6px; color: var(--muted); font-size: 16px; }
input {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; min-height: 54px;
}
input:focus { border-color: var(--accent); outline: none; }
.primary {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 14px;
  min-height: 56px; font-weight: 650; font-size: 19px;
}
.error { color: var(--danger); margin: 0; min-height: 1.2em; }
.banner { padding: 12px 20px; }

/* Grid */
.bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 3vw, 40px); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.bar h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); letter-spacing: -0.01em; }
.quiet {
  background: none; border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px;
  color: var(--muted); font-size: 16px; min-height: 44px;
}
.grid {
  list-style: none; margin: 0; padding: 8px clamp(12px, 3vw, 40px) 40px;
  display: grid; gap: clamp(10px, 1.4vw, 18px);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
}
.tile {
  position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: var(--radius);
  overflow: hidden; background: var(--panel); aspect-ratio: 16 / 9;
  transition: transform .15s ease;
}
.tile:focus-visible { transform: scale(1.03); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile img:not([src]) { visibility: hidden; }
.tile-name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 14px 10px; text-align: left;
  font-weight: 600; font-size: 17px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .72));
}
.tile.offline::after {
  content: "Not available right now"; position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 16px;
}
@media (min-width: 1500px) {
  /* TVs: four across, bigger names */
  .grid { grid-template-columns: repeat(4, 1fr); }
  .tile-name { font-size: 22px; }
}

/* Live */
.live { position: fixed; inset: 0; z-index: 10; background: #000; display: grid; grid-template-rows: 1fr auto; }
.live-video { min-height: 0; display: grid; place-items: center; }
.live-video camera-player, .live-video video { width: 100%; height: 100%; display: block; }
.live-video video { object-fit: contain; background: #000; }
.live-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px clamp(12px, 3vw, 32px) calc(12px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
.live-bar h2 { flex: 1; margin: 0; font-size: clamp(18px, 2.4vw, 26px); min-width: 8em; }
.live-actions { display: flex; gap: 10px; }
.pill {
  min-height: 52px; min-width: 52px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); font-size: 19px; font-weight: 600;
}
#live-hd[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.live-status {
  position: fixed; top: 40%; left: 0; right: 0; text-align: center; margin: 0;
  color: var(--muted); pointer-events: none;
}
