:root {
  --bg: #fff6ec; --card: #ffffff; --fg: #2b2238; --mut: #7a6f86;
  --accent: #ff7a59; --accent2: #5b8def; --shadow: 0 4px 14px rgba(60, 30, 80, .12);
  --r: 22px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1d1826; --card: #2a2336; --fg: #f4eefc; --mut: #b4a9c4; --shadow: 0 4px 14px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 18px/1.3 "Nunito", "Comic Neue", system-ui, sans-serif; }
body { min-height: 100vh; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
img { -webkit-user-drag: none; }

#bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); }
#title { margin: 0; font-size: 1.6rem; font-weight: 800; letter-spacing: .5px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
#view { padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); }
.msg { text-align: center; color: var(--mut); font-size: 1.3rem; margin-top: 18vh; }
.msg button { margin-top: 16px; }

.round { border: 0; border-radius: 999px; min-width: 56px; height: 56px; font-size: 1.6rem;
  background: var(--accent); color: #fff; box-shadow: var(--shadow); cursor: pointer; }
.round.big { min-width: 72px; height: 72px; font-size: 2rem; }
.round:active { transform: scale(.94); }

h2.section { font-size: 1.1rem; color: var(--mut); margin: 22px 4px 10px; font-weight: 700; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid.videos { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden;
  border: 0; padding: 0; color: inherit; font: inherit; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; text-decoration: none; }
.card:active { transform: scale(.97); }
.card .label { padding: 10px 10px 14px; font-weight: 800; font-size: 1.05rem; }
/* Clamp on the inner span: on the padded box a third line peeked through the padding. */
.card .label > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  max-height: 2.6em; line-height: 1.3; overflow-wrap: anywhere; hyphens: auto; }
.row > .card .label { font-size: .95rem; padding: 10px 8px 14px; }
.chan img { width: 72%; aspect-ratio: 1; border-radius: 50%; object-fit: cover; margin: 16px auto 0;
  box-shadow: var(--shadow); }
.vid .thumb { position: relative; aspect-ratio: 16 / 9; background: #0002; }
.vid .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vid .dur { position: absolute; right: 8px; bottom: 8px; background: #000b; color: #fff;
  border-radius: 8px; padding: 2px 8px; font-size: .85rem; font-weight: 700; }
.vid .label { text-align: left; font-weight: 700; font-size: .95rem; }
.app { min-height: 120px; justify-content: center; color: #fff; font-size: 1.3rem; font-weight: 900; }
.app .label { font-size: 1.3rem; }

/* Player: full screen, our own controls. The iframe never receives a tap, so
   the YouTube logo, title and end-screen cards cannot be clicked. */
#player { position: fixed; inset: 0; z-index: 10; background: #000; display: flex; flex-direction: column; }
#player[hidden] { display: none; }
#stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#stage iframe { width: 100%; height: 100%; border: 0; pointer-events: none; }
#tap { position: absolute; inset: 0; }
#next { position: absolute; inset: 0; background: var(--bg); overflow-y: auto; padding: 16px; }
#next h2 { margin: 4px 4px 14px; font-size: 1.5rem; }
#controls { display: flex; align-items: center; gap: 10px;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); background: #000; }
#p-seek { flex: 1; min-width: 60px; height: 36px; accent-color: var(--accent); }
@media (orientation: landscape) and (max-height: 500px) {
  #controls { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, #000c); }
  .round.big { min-width: 60px; height: 60px; }
}

/* Language button (flags are images: emoji flags don't render on Windows) */
#lang[hidden], #clock[hidden] { display: none; }
#clock { margin-left: auto; display: flex; gap: 8px; }
#clock .pill { display: flex; align-items: center; gap: 6px; background: var(--card); box-shadow: var(--shadow);
  border-radius: 999px; padding: 4px 12px 4px 6px; font-weight: 800; white-space: nowrap; }
#clock .pill img { width: 32px; height: 32px; }
@media (max-width: 480px) { #clock .pill { padding: 2px 8px 2px 4px; font-size: .9rem; } #clock .pill img { width: 24px; height: 24px; } #title { font-size: 1.2rem; } }
#clock:not([hidden]) + #lang { margin-left: 0; }
.done { text-align: center; margin-top: 12vh; }
.done img { width: 160px; height: 160px; }
.done p { font-size: 1.6rem; font-weight: 800; margin: 16px; }
#lang { margin-left: auto; padding: 0; background: var(--card); overflow: hidden; }
.flagbtn img, .chip img.flag { width: 100%; height: 100%; display: block; }
.flagbtn { width: 56px; min-width: 56px; padding: 0; background: var(--card); }
.flagbtn.on { outline: 4px solid var(--accent); }
#langs { position: absolute; right: 12px; top: 100%; display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end;
  padding: 12px; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); max-width: calc(100vw - 24px); }
#langs[hidden] { display: none; }
.chip .ico img.flag { width: 1.9rem; height: 1.9rem; }

/* Fluent Emoji icon buttons: the icon is the button */
.round.ic { background: transparent; box-shadow: none; padding: 0; }
.round.ic img { width: 100%; height: 100%; display: block; filter: drop-shadow(0 3px 6px rgba(0,0,0,.25)); }
#bar .round.ic { width: 56px; }
#controls .round.ic { width: 56px; } #controls .round.big.ic { width: 72px; }
.chip .ico img.icon { width: 2.2rem; height: 2.2rem; display: block; }

/* Filter buttons on the home screen */
.filters { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 4px; }
.chips { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: flex; align-items: center; gap: 8px; border: 3px solid transparent; border-radius: 999px;
  padding: 6px 16px 6px 10px; min-height: 56px; background: var(--card); color: var(--fg); box-shadow: var(--shadow);
  font: inherit; font-weight: 800; cursor: pointer; }
.chip .ico { font-size: 1.9rem; line-height: 1; }
.chip .nm { font-size: .95rem; }
.chip.on { border-color: var(--accent); background: var(--accent); color: #fff; }
.chip:active { transform: scale(.95); }
.msg.small { margin-top: 6vh; font-size: 1.1rem; }

/* Home: one shelf per topic, scrolling sideways */
.shelf { margin: 6px 0 4px; }
.shelf h2.section { display: flex; align-items: center; gap: 10px; color: var(--fg); font-size: 1.25rem; margin: 18px 4px 8px; }
.shelf h2 .ico img { width: 2.6rem; height: 2.6rem; display: block; }
.shelf h2 .ico { font-size: 2rem; line-height: 1; }
.row { display: flex; gap: 14px; overflow-x: auto; padding: 4px 4px 12px; scroll-snap-type: x proximity;
  scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); }
.row::-webkit-scrollbar { display: none; }
.row > .card { flex: 0 0 148px; scroll-snap-align: start; }
.row > .card.app { min-height: 148px; }
.row > .card.more { justify-content: center; align-items: center; gap: 6px; min-height: 148px;
  background: var(--accent); color: #fff; }
.card.more img { width: 64px; height: 64px; filter: drop-shadow(0 3px 6px rgba(0,0,0,.25)); }
.card.more .label { font-size: 1.5rem; font-weight: 900; padding: 0 8px 8px; }
.shelf-link { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0;
  color: inherit; font: inherit; cursor: pointer; }
.shelf-link .count { background: var(--card); color: var(--mut); box-shadow: var(--shadow); border-radius: 999px;
  padding: 1px 10px; font-size: .9rem; }

/* Category bar: every topic visible at once (wraps, never scrolls sideways) */
.topics { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 8px; }
.topics .chip { min-height: 60px; }
.topics .chip[aria-current="page"] { border-color: var(--accent); background: var(--accent); color: #fff; }
@media (max-width: 640px) { .topics .chip { padding: 6px; gap: 0; } .topics .chip .nm { display: none; } }
.grid.shows { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); margin-top: 8px; }
.grid.shows .card .label { font-size: .95rem; padding: 10px 8px 14px; }

.versions { display: flex; gap: 12px; justify-content: center; margin: 4px 0 16px; }
.versions .flagbtn { width: 64px; height: 64px; min-width: 64px; }

/* Watching on the TV: the tablet is the remote */
#remote { position: fixed; inset: 0; z-index: 11; background: var(--bg); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
#remote[hidden] { display: none; }
#r-thumb { width: min(80vw, 520px); aspect-ratio: 16/9; object-fit: cover; border-radius: var(--r); box-shadow: var(--shadow); }
#r-title { font-size: 1.3rem; font-weight: 800; margin: 0; max-width: 600px; }
#r-state img { width: 72px; height: 72px; animation: pulse 1.4s ease-in-out infinite; }
#r-state[hidden] { display: none; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.r-controls { display: flex; gap: 16px; align-items: center; }
.r-controls .round.ic { width: 72px; } .r-controls .round.big.ic { width: 96px; height: 96px; }

.pair .code { font-size: 3rem; letter-spacing: 8px; font-family: ui-monospace, monospace; }
.tvlist { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.tvbtn { min-width: 200px; min-height: 110px; justify-content: center; font-size: 1.3rem; }
@media (max-width: 480px) { .grid.shows { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .grid.shows .card .label { font-size: .8rem; padding: 8px 4px 10px; } }

/* Search: a big box, results as show tiles and a video grid */
#title { flex: 1 1 auto; min-width: 0; }
#search[hidden] { display: none; }
.searchbox { display: flex; align-items: center; gap: 12px; margin: 8px 0 6px; padding: 8px 10px 8px 16px;
  background: var(--card); border-radius: 999px; box-shadow: var(--shadow); border: 3px solid transparent; }
.searchbox:focus-within { border-color: var(--accent); }
.searchbox img { width: 44px; height: 44px; flex: none; }
.searchbox input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--fg);
  font: inherit; font-size: 1.5rem; font-weight: 800; padding: 8px 0; user-select: text; -webkit-user-select: text; }
.searchbox input::placeholder { color: var(--mut); font-weight: 700; }
.searchbox input::-webkit-search-cancel-button { display: none; }
.searchbox .clear { flex: none; width: 48px; min-width: 48px; height: 48px; font-size: 1.4rem; padding: 0;
  background: var(--bg); color: var(--fg); box-shadow: none; }
.searchbox .clear[hidden] { display: none; }
