/* ==========================================================
   LK TV — app stylesheet v3
   Night-indigo base, marigold brand, red reserved for "Live".
   ========================================================== */

:root {
  --font-display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;

  --nav-w: 232px;
  --top-h: 64px;
  --tab-h: 64px;
  --gutter: 16px;

  --ease: cubic-bezier(.2, .8, .2, 1);
}

:root,
:root[data-theme="dark"] {
  --bg: #0E1230;
  --bg-2: #121640;
  --panel: #171C44;
  --raise: #222A5C;
  --raise-2: #2C3570;
  --line: rgba(190, 198, 255, .12);
  --text: #EEF0FF;
  --muted: #9BA2D0;
  --faint: #6A72A6;
  --brand: #FFB627;
  --brand-ink: #1B1400;
  --brand-text: #FFC657;
  --live: #FF4D4D;
  --tile: #1D2350;
  --tile-hi: #283068;
  --shadow: 0 18px 40px -18px rgba(3, 5, 25, .7);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #F3F4FA;
  --bg-2: #EAECF6;
  --panel: #FFFFFF;
  --raise: #E6E8F4;
  --raise-2: #D9DCEE;
  --line: rgba(18, 22, 58, .1);
  --text: #12163A;
  --muted: #5A6190;
  --faint: #868CB3;
  --brand: #FFB627;
  --brand-ink: #1B1400;
  --brand-text: #9A6200;
  --live: #E5383B;
  --tile: #FFFFFF;
  --tile-hi: #F4F5FB;
  --shadow: 0 18px 40px -22px rgba(18, 22, 58, .35);
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--brand-text); }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; flex: none; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

.muted { color: var(--muted); }

/* ---------------- Layout ---------------- */

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}

.main {
  min-width: 0;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px);
}

.rail-nav { display: none; }

@media (min-width: 1024px) {
  .app { grid-template-columns: var(--nav-w) 1fr; }
  .main { padding-bottom: 48px; }
  :root { --gutter: 32px; }

  .rail-nav {
    display: flex;
    flex-direction: column;
    gap: 28px;
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 22px 16px;
    border-right: 1px solid var(--line);
    background: var(--bg-2);
  }
  .tabbar, .only-mobile, .brand-sm { display: none !important; }
}

/* ---------------- Brand ---------------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.brand-mark { color: var(--brand); display: grid; }
.brand-mark svg { width: 30px; height: 30px; }
.brand-name {
  white-space: nowrap;
  font: 800 21px/1 var(--font-display);
  letter-spacing: -.02em;
}

/* ---------------- Sidebar nav ---------------- */

.nav-list, .nav-foot { display: flex; flex-direction: column; gap: 4px; }
.nav-foot { margin-top: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.is-active { background: var(--panel); color: var(--text); }
.nav-item.is-active svg { color: var(--brand); }

.live-count {
  margin: 14px 14px 0;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.live-count b { color: var(--text); font-variant-numeric: tabular-nums; }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 60%, transparent);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---------------- Top bar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--gutter) 0;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}

.search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 560px;
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  transition: border-color .15s;
}
.search:focus-within { border-color: var(--brand); }
.search svg { width: 19px; height: 19px; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
}
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.search kbd {
  font: 600 12px var(--font-body);
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--faint);
}
@media (max-width: 1023px) { .search kbd { display: none; } }
@media (max-width: 480px) {
  .topbar { gap: 8px; }
  .brand-sm .brand-name { display: none; }
  .search { height: 40px; }
}
.app { overflow-x: clip; }

.top-actions { display: flex; gap: 4px; margin-left: auto; }

.icon-btn {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 6px;
  min-width: 40px;
  height: 40px;
  padding: 0 9px;
  border-radius: 12px;
  color: var(--text);
  transition: background .15s;
}
.icon-btn:hover { background: var(--raise); }
.icon-btn:disabled { opacity: .4; cursor: default; }

.install-btn {
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 700;
  font-size: 14px;
  padding: 0 14px 0 11px;
  border-radius: 999px;
}
.install-btn:hover { background: var(--brand); filter: brightness(1.06); }
.install-btn svg { width: 19px; height: 19px; }

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  transition: transform .12s, filter .15s, background .15s;
}
.btn svg { width: 19px; height: 19px; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: var(--raise); color: var(--text); }
.btn-ghost:hover { background: var(--raise-2); }
.btn-small { height: 34px; padding: 0 14px; font-size: 13px; }

/* ---------------- Player stage ---------------- */

.stage {
  position: sticky;
  top: calc(var(--top-h) + env(safe-area-inset-top));
  z-index: 25;
  background: var(--bg);
  padding: 0 0 10px;
}
@media (min-width: 640px) { .stage { padding: 6px var(--gutter) 14px; } }
@media (min-width: 1024px) {
  .stage { position: relative; top: 0; z-index: 1; }
}

.player {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 72vh;
  width: 100%;
  margin: 0 auto;
  background: #000;
  overflow: hidden;
  outline: 0;
  color: #fff;
}
@media (min-width: 640px) {
  .player { border-radius: var(--radius-l); box-shadow: var(--shadow); }
}
@media (min-width: 1024px) {
  .player, .now-bar { max-width: calc(72vh * 16 / 9); }
}
.player:fullscreen { max-height: none; border-radius: 0; }

.player video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
#adVideo { z-index: 6; }

/* OSD: channel number typed on the remote — the signature element */
.osd {
  position: absolute;
  top: 18px;
  right: 22px;
  z-index: 9;
  font: 800 clamp(44px, 9vw, 84px)/1 var(--font-display);
  letter-spacing: -.03em;
  color: var(--brand);
  text-shadow: 0 2px 0 rgba(0,0,0,.35), 0 0 30px rgba(0,0,0,.5);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.osd small {
  display: block;
  text-align: right;
  font: 600 15px/1.3 var(--font-body);
  letter-spacing: 0;
  color: #fff;
  margin-top: 6px;
}

/* state + error */
.p-state, .p-error {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 20px;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(14,18,48,.55), rgba(0,0,0,.85));
}
.p-state p { margin: 0; font-weight: 600; color: rgba(255,255,255,.85); }
.spinner {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.18);
  border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.p-error { background: rgba(8, 10, 30, .92); z-index: 7; }
.p-error-ico { width: 40px; height: 40px; color: var(--brand); }
.p-error h3 { margin: 0; font: 700 clamp(18px, 3vw, 24px)/1.2 var(--font-display); }
.p-error p { margin: 0; max-width: 40ch; color: rgba(255,255,255,.75); font-size: 14px; }
.p-error-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.p-error .btn-ghost { background: rgba(255,255,255,.12); color: #fff; }

/* ad overlay */
.p-ad {
  position: absolute;
  inset: auto 14px 14px auto;
  z-index: 8;
  display: flex;
  gap: 10px;
  align-items: center;
}
.ad-tag {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.65);
  font-size: 13px;
  font-weight: 600;
}
.p-ad .btn-small { background: #fff; color: #000; }

/* controls */
.p-controls {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.6), transparent 28%),
    linear-gradient(to top, rgba(0,0,0,.75), transparent 38%);
  transition: opacity .25s var(--ease);
}
.player.idle .p-controls { opacity: 0; pointer-events: none; }
.player.idle { cursor: none; }
.player.ad-mode .p-controls { display: none; }

.p-top, .p-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
}
.p-controls .icon-btn { color: #fff; }
.p-controls .icon-btn:hover { background: rgba(255,255,255,.14); }
.p-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: var(--live);
  font-size: 12px;
  font-weight: 700;
}
.live-tag .dot { background: #fff; animation: none; width: 7px; height: 7px; }
.live-tag.behind { background: rgba(255,255,255,.2); }

.p-center {
  align-self: center;
  width: 68px; height: 68px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(14,18,48,.55);
  color: #fff;
  backdrop-filter: blur(6px);
  opacity: 0;
  transform: scale(.9);
  transition: opacity .2s, transform .2s var(--ease);
  pointer-events: none;
}
.p-center svg { width: 30px; height: 30px; }
.player.paused .p-center { opacity: 1; transform: none; pointer-events: auto; }

.spacer { flex: 1; }
.vol {
  width: 84px;
  accent-color: var(--brand);
}
.live-btn {
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  color: #fff;
}
.live-btn.at-live { display: none; }
.q-label { font-size: 12px; font-weight: 700; }

@media (max-width: 639px) {
  .vol, #pPrev, #pNext, #pStats { display: none; }
  .p-top, .p-bottom { padding: 6px 6px; gap: 2px; }
  .q-label { display: none; }
}

.pop-wrap { position: relative; }
.pop {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  min-width: 150px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(14, 18, 48, .96);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: var(--shadow);
  z-index: 10;
}
.pop button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}
.pop button:hover { background: rgba(255,255,255,.1); }
.pop button[aria-checked="true"] { color: var(--brand); }

.p-stats {
  position: absolute;
  top: 56px;
  left: 12px;
  z-index: 6;
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0,0,0,.72);
  display: grid;
  gap: 4px;
  font-size: 12.5px;
  min-width: 200px;
}
.p-stats div { display: flex; justify-content: space-between; gap: 18px; }
.p-stats dt { color: rgba(255,255,255,.65); }
.p-stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* now bar under the player */
.now-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 auto;
  padding: 12px var(--gutter) 0;
}
@media (min-width: 640px) { .now-bar { padding: 14px 4px 0; } }

.now-logo {
  width: 52px; height: 52px;
  flex: none;
  border-radius: 12px;
  background: var(--tile);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  overflow: hidden;
}
.now-logo img { width: 80%; height: 80%; object-fit: contain; }
.now-text { flex: 1; min-width: 0; }
.now-name {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font: 700 17px/1.25 var(--font-display);
  white-space: nowrap;
  overflow: hidden;
}
.now-name span:last-child { overflow: hidden; text-overflow: ellipsis; }
.now-prog {
  margin: 2px 0 0;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.now-progress, .prog-bar {
  height: 3px;
  margin-top: 7px;
  border-radius: 3px;
  background: var(--raise);
  overflow: hidden;
  max-width: 340px;
}
.now-progress i, .prog-bar i {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 3px;
}
.now-actions { display: flex; gap: 2px; }
.fav-btn.is-on { color: var(--live); }

.lcn {
  font: 800 13px/1 var(--font-display);
  color: var(--brand-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}

/* ---------------- Views ---------------- */

.views { padding: 4px 0 0; }
.view { animation: viewIn .28s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 18px var(--gutter) 8px;
}
.view-head h1 {
  margin: 0;
  font: 800 clamp(26px, 4vw, 38px)/1.05 var(--font-display);
  letter-spacing: -.025em;
}
.view-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* ----- Hero ----- */

.hero {
  position: relative;
  margin: 10px var(--gutter) 6px;
  padding: 22px 22px 22px;
  border-radius: var(--radius-l);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 55%),
    var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 18px;
  align-items: end;
  min-height: 210px;
}
.hero-num {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: start;
  font: 800 clamp(84px, 16vw, 168px)/.82 var(--font-display);
  letter-spacing: -.06em;
  color: transparent;
  -webkit-text-stroke: 2px color-mix(in srgb, var(--brand) 80%, transparent);
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.hero-kicker { margin: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.hero h2 {
  margin: 0;
  font: 800 clamp(28px, 4.6vw, 48px)/1.02 var(--font-display);
  letter-spacing: -.03em;
  max-width: 18ch;
}
.hero-prog { margin: 2px 0 0; color: var(--muted); font-size: 15px; max-width: 46ch; }
.hero-prog b { color: var(--text); font-weight: 600; }
.hero-actions { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.hero-logo {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--tile);
  display: grid; place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  margin-bottom: 6px;
}
.hero-logo img { width: 78%; height: 78%; object-fit: contain; }
.hero .prog-bar { max-width: 280px; }

@media (max-width: 560px) {
  .hero { grid-template-columns: 1fr; padding: 18px; min-height: 0; }
  .hero-num { position: absolute; right: 16px; top: 18px; font-size: 64px; -webkit-text-stroke-width: 1.5px; }
}

/* ----- Rails ----- */

.rail { margin-top: 22px; }
.rail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 var(--gutter);
  margin-bottom: 10px;
}
.rail-head h2 {
  margin: 0;
  font: 700 19px/1.2 var(--font-display);
  letter-spacing: -.01em;
}
.rail-head h2 small { font: 500 13px var(--font-body); color: var(--faint); margin-left: 8px; }
.see-all {
  text-decoration: none;
  color: var(--brand-text);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.see-all:hover { text-decoration: underline; }

.rail-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 148px;
  gap: 12px;
  overflow-x: auto;
  padding: 2px var(--gutter) 8px;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
}
.rail-track::-webkit-scrollbar { display: none; }
.rail-track > * { scroll-snap-align: start; }
@media (min-width: 1024px) { .rail-track { grid-auto-columns: 172px; } }

/* ----- Channel tile ----- */

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  min-width: 0;
}
.tile-screen {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-m);
  background: var(--tile);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: border-color .15s, background .15s, transform .15s var(--ease);
}
.tile:hover .tile-screen { background: var(--tile-hi); border-color: color-mix(in srgb, var(--brand) 55%, transparent); }
.tile:active .tile-screen { transform: scale(.97); }
.tile.is-playing .tile-screen { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.tile-screen img {
  width: 62%;
  height: 62%;
  object-fit: contain;
}
.mono {
  font: 800 26px/1 var(--font-display);
  letter-spacing: -.03em;
  color: var(--mono, var(--brand));
}
.tile-num {
  position: absolute;
  left: 8px; top: 7px;
  font: 800 12px/1 var(--font-display);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.tile-badges { position: absolute; right: 7px; top: 6px; display: flex; gap: 4px; }
.badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--raise);
  color: var(--muted);
}
.badge-hd { background: color-mix(in srgb, var(--brand) 22%, transparent); color: var(--brand-text); }
.tile-eq {
  position: absolute; right: 9px; bottom: 9px;
  display: none; gap: 2px; align-items: flex-end; height: 14px;
}
.tile.is-playing .tile-eq { display: flex; }
.tile-eq i { width: 3px; background: var(--brand); border-radius: 2px; animation: eq 1s infinite ease-in-out; }
.tile-eq i:nth-child(2) { animation-delay: -.3s; }
.tile-eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }

.tile-name {
  margin: 0;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-sub {
  margin: -6px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----- Browse ----- */

.filters {
  position: sticky;
  top: calc(var(--top-h) + env(safe-area-inset-top));
  z-index: 15;
  background: var(--bg);
  padding: 4px 0 10px;
}
.stage:not([hidden]) ~ .views .filters { position: static; }

.seg {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.seg button {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.seg button[aria-checked="true"], .seg button.is-on { background: var(--raise-2); color: var(--text); }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px var(--gutter) 2px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { color: var(--text); }
.chip.is-on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip small { font-weight: 500; opacity: .7; margin-left: 4px; }

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 var(--gutter);
  flex-wrap: wrap;
}
.result-count { color: var(--muted); font-size: 14px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 18px 12px;
  padding: 10px var(--gutter) 0;
}
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 22px 16px; } }
@media (max-width: 380px) { .grid { grid-template-columns: repeat(2, 1fr); } }

.sentinel { height: 1px; }

.empty {
  margin: 34px var(--gutter);
  padding: 28px 22px;
  border-radius: var(--radius-l);
  border: 1px dashed var(--line);
  text-align: center;
  color: var(--muted);
}
.empty h3 { margin: 0 0 6px; color: var(--text); font: 700 19px/1.3 var(--font-display); }
.empty p { margin: 0 auto 14px; max-width: 42ch; }

/* skeleton */
.skel .tile-screen, .skel-line {
  background: linear-gradient(90deg, var(--panel), var(--raise), var(--panel));
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
  border-color: transparent;
}
.skel-line { height: 12px; border-radius: 6px; width: 70%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ----- Guide ----- */

.guide-list { padding: 6px var(--gutter) 0; display: grid; gap: 2px; }
.g-row {
  display: grid;
  grid-template-columns: 44px 1fr minmax(0, .8fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 10px;
  border-radius: 14px;
  text-align: left;
  transition: background .15s;
}
.g-row:hover { background: var(--panel); }
.g-row .now-logo { width: 44px; height: 44px; border-radius: 10px; }
.g-main { min-width: 0; }
.g-ch {
  display: flex; gap: 8px; align-items: baseline;
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden;
}
.g-ch span:last-child { overflow: hidden; text-overflow: ellipsis; }
.g-title {
  margin: 1px 0 0;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.g-main .prog-bar { margin-top: 6px; max-width: none; }
.g-next { min-width: 0; font-size: 13.5px; color: var(--muted); }
.g-next b { display: block; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-time { font-variant-numeric: tabular-nums; }
@media (max-width: 639px) {
  .g-row { grid-template-columns: 44px 1fr auto; }
  .g-next { display: none; }
}

/* ----- My list ----- */

.list-tabs { padding: 4px var(--gutter) 6px; }
.rem-list { padding: 6px var(--gutter); display: grid; gap: 8px; }
.rem {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.rem div { flex: 1; min-width: 0; }
.rem b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rem small { color: var(--muted); }

/* ---------------- Tab bar ---------------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--faint);
}
.tab svg { width: 24px; height: 24px; }
.tab.is-active { color: var(--text); }
.tab.is-active svg { color: var(--brand); }

/* ---------------- Sheets ---------------- */

.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5, 7, 22, .55);
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed;
  z-index: 61;
  left: 0; right: 0; bottom: 0;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 8px 20px calc(24px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
  box-shadow: 0 -20px 50px -20px rgba(0,0,0,.5);
  animation: sheetUp .3s var(--ease);
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
.sheet-tall { height: 80dvh; display: flex; flex-direction: column; }

@media (min-width: 720px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: min(460px, 92vw);
    transform: translate(-50%, -50%);
    border-radius: 24px;
    border: 1px solid var(--line);
    padding-bottom: 24px;
    animation: pop .25s var(--ease);
  }
  .sheet-tall { width: min(620px, 92vw); height: min(78dvh, 760px); }
  .sheet-grip { display: none; }
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(.98); } }

.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--raise-2); margin: 2px auto 10px; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px;
}
.sheet-head h2 { margin: 0; font: 800 22px/1.2 var(--font-display); letter-spacing: -.02em; }
.sheet-head p { margin: 2px 0 0; font-size: 13.5px; }

/* keypad */
.kp-display {
  display: grid;
  justify-items: center;
  padding: 10px 0 18px;
}
.kp-display span {
  font: 800 64px/1 var(--font-display);
  letter-spacing: .02em;
  color: var(--brand-text);
  font-variant-numeric: tabular-nums;
}
.kp-display small { color: var(--muted); margin-top: 8px; font-size: 14px; min-height: 1.5em; text-align: center; }
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 320px;
  margin: 0 auto;
}
.keypad button {
  height: 60px;
  border-radius: 18px;
  background: var(--raise);
  font: 700 24px var(--font-display);
  transition: background .12s, transform .1s;
}
.keypad button:hover { background: var(--raise-2); }
.keypad button:active { transform: scale(.95); }
.keypad .kp-ok { background: var(--brand); color: var(--brand-ink); font-size: 19px; }
.kp-tip { text-align: center; color: var(--faint); font-size: 13px; margin: 16px 0 0; }

/* settings */
.set-group { margin-bottom: 8px; }
.set-label { margin: 0 0 8px; font-weight: 600; color: var(--muted); font-size: 13.5px; }
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
}
.set-row span { display: grid; gap: 2px; }
.set-row small { color: var(--muted); font-size: 13px; }
.set-btn svg { color: var(--faint); }
.set-foot { color: var(--faint); font-size: 13px; margin: 16px 0 0; }

.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 46px; height: 28px;
  border-radius: 999px;
  background: var(--raise-2);
  position: relative;
  cursor: pointer;
  transition: background .2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s var(--ease);
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(18px); }

/* schedule */
.sc-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sc-body { overflow-y: auto; flex: 1; margin: 0 -8px; padding: 0 8px; }
.sc-day { margin: 14px 0 6px; font: 700 15px var(--font-display); color: var(--muted); }
.sc-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  padding: 11px 10px;
  border-radius: 12px;
  align-items: start;
}
.sc-item.is-now { background: var(--raise); }
.sc-item.is-past { opacity: .5; }
.sc-time { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; padding-top: 1px; }
.sc-item h4 { margin: 0; font-size: 15px; font-weight: 700; }
.sc-item p { margin: 3px 0 0; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sc-item .prog-bar { max-width: 220px; }
.bell { color: var(--muted); }
.bell.is-on { color: var(--brand-text); }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(92vw, 440px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toastIn .25s var(--ease);
}
.toast.is-bad { background: var(--live); color: #fff; }
@media (min-width: 1024px) { .toast { bottom: 28px; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------------- Motion preferences ---------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ---------------- refinements ---------------- */
.player.has-error .p-bottom,
.player.has-error .p-center,
.player.has-error .osd { display: none; }
.stage:not([hidden]) ~ .views .hero { display: none; }
.sc-item { grid-template-columns: 74px 1fr auto; }
.sc-time { white-space: nowrap; }
.now-logo .mono { font-size: 17px; }
.hero-logo .mono { font-size: 20px; }
:root[data-theme="light"] .mono { color: color-mix(in srgb, var(--mono) 62%, #12163A); }
:root[data-theme="light"] .tile-screen { box-shadow: 0 1px 2px rgba(18, 22, 58, .06); }
