/* Encore TV. The base (tokens, top bar, buttons, fields, chips, sign-in, menus, toasts) is copied from
   Encore's web/style.css so both pages look like one family; video layout is below. */
:root {
  --bg: #0f0f10;
  --bg2: #19191b;
  --card: #232326;
  --line: #36363b;
  --text: #f1f1f3;
  --muted: #a3a3aa;
  --accent: #ff4d5a;
  --accent2: #5cb8ff;
  --danger: #e2675b;
  --on-accent: #ffffff;
  --topbar-bg: rgba(15, 15, 16, .92);
  --player-bg: rgba(27, 27, 29, .97);
  --shadow: rgba(0, 0, 0, .5);
  --radius: 12px;
  --player-h: 0px;
  --nav-h: 0px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
/* no pull-to-refresh: a stray swipe down shouldn't reload the app and stop the music */
html, body { overscroll-behavior-y: contain; }
body { padding-bottom: calc(var(--player-h) + var(--nav-h) + 16px + env(safe-area-inset-bottom)); -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }

/* ------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--topbar-bg); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { text-decoration: none; font-weight: 800; letter-spacing: .01em; font-size: 1.2rem; display: inline-flex; align-items: center; gap: 8px; flex: none; }
.logo { width: 30px; height: 30px; flex: none; }
.lg-ring { fill: var(--accent); }
.lg-disc { fill: var(--bg); }
.lg-play { fill: var(--text); }
.side-nav { display: flex; gap: 4px; }
.side-nav a, .bottom-nav a { text-decoration: none; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.side-nav a { padding: 7px 14px; border-radius: 999px; }
.side-nav a.active { background: var(--card); color: var(--text); }
.side-nav .ni svg { width: 20px; height: 20px; }
.badge { background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 0 7px; font-size: .75rem; font-weight: 700; }
.top-search { position: relative; flex: 1; max-width: 520px; margin-left: auto; display: flex; align-items: center; }
.top-search input { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px 9px 40px; }
.top-search input:focus { outline: none; border-color: var(--muted); background: var(--card); }
.ts-icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.ts-icon svg { width: 18px; height: 18px; }
.sugg { position: absolute; top: calc(100% + 4px); left: 0; right: 0; list-style: none; margin: 0; padding: 6px; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px var(--shadow); z-index: 30; }
.sugg li button { width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.sugg li button:hover, .sugg li button:focus-visible { background: var(--card); outline: none; }
.sugg svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent2); color: var(--bg); display: grid; place-items: center;
  font-weight: 800; text-decoration: none; flex: none; overflow: hidden; font-size: .95rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; display: none; background: var(--player-bg);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); backdrop-filter: blur(10px); }
.bottom-nav a { flex: 1; flex-direction: column; gap: 2px; padding: 8px 0 6px; font-size: .72rem; font-weight: 600; justify-content: center; }
.bottom-nav a.active { color: var(--text); }
.bottom-nav .ni svg { width: 24px; height: 24px; }

main { max-width: 1200px; margin: 0 auto; padding: 16px 20px; outline: none; }
h1 { font-size: 1.6rem; margin: 4px 0 6px; }
h2 { font-size: 1.2rem; margin: 26px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 16px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn svg { width: 18px; height: 18px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 700; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 12px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; padding: 0; }
.icon-btn:hover { background: var(--card); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; }
input.field, select.field, textarea.field { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
input.field:focus, textarea.field:focus, select.field:focus { outline: none; border-color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 8px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--bg2); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: .9rem; text-decoration: none; }
.chip.active { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 700; }
.toggle { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); }
.panel { background: var(--card); border-radius: var(--radius); padding: 14px 16px; }
.panel + .panel { margin-top: 8px; }
.panel ol { padding-left: 20px; line-height: 1.6; }
.panel code { background: var(--bg2); border-radius: 4px; padding: 1px 5px; font-size: .9em; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { background: linear-gradient(90deg, var(--bg2), var(--card), var(--bg2)); background-size: 200% 100%; animation: skel 1.2s ease infinite; border-radius: 8px; }
@keyframes skel { to { background-position: -200% 0; } }
.toast { position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 10px; z-index: 90; box-shadow: 0 8px 30px var(--shadow); max-width: calc(100% - 32px); font-weight: 600; }
img.fallback { object-fit: contain !important; padding: 18%; background: var(--card); }

/* ---------------------------------------------------- sign-in / setup */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-box { width: min(380px, 100%); display: grid; gap: 12px; }
.gate-box .logo { width: 64px; height: 64px; margin: 0 auto 4px; }
.gate-box h1 { text-align: center; margin: 0; }
.gate-box p { text-align: center; margin: 0 0 6px; }
.gate-box label { display: grid; gap: 6px; font-size: .9rem; color: var(--muted); }
.gate-box .btn { justify-content: center; padding: 11px; }
.err { color: var(--danger); font-size: .9rem; min-height: 1.2em; text-align: center; }

/* --------------------------------------------------------- menu sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 80; }
.menu-sheet { position: fixed; z-index: 81; left: 50%; bottom: 0; transform: translateX(-50%); width: min(480px, 100%); max-height: 80vh; overflow-y: auto;
  background: var(--bg2); border-radius: 18px 18px 0 0; padding: 8px 8px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px var(--shadow); }
.menu-head { display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: center; padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head img { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--card); }
.menu-head .t-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-head .t-sub { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-item { width: 100%; display: flex; gap: 16px; align-items: center; background: none; border: 0; padding: 12px 14px; border-radius: 10px; cursor: pointer; text-align: left; }
.menu-item:hover, .menu-item:focus-visible { background: var(--card); outline: none; }
.menu-item svg { width: 22px; height: 22px; color: var(--muted); flex: none; }
.menu-item.danger { color: var(--danger); }
.menu-title { font-weight: 700; padding: 10px 14px; }

.search-box { position: relative; display: flex; align-items: center; margin-bottom: 4px; }
.search-box input { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px 11px 40px; }
.search-box .ts-icon { position: absolute; left: 12px; }
.search-box .sugg { position: static; margin-top: 6px; box-shadow: none; }
.ctl { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; color: var(--text); cursor: pointer; padding: 0; flex: none; transition: background .15s, transform .1s; }
.ctl svg { width: 26px; height: 26px; display: block; }
.ctl:hover { background: var(--card); }
.ctl:active { transform: scale(.94); }
.ctl.small { width: 38px; height: 38px; } .ctl.small svg { width: 22px; height: 22px; }

/* ----------------------------------------------------------- Encore TV */
.brand .tv { color: var(--accent); font-weight: 800; }
.btn svg { width: 18px; height: 18px; }
.chips.wrap { flex-wrap: wrap; }
.sugg.static { position: static; margin-top: 6px; box-shadow: none; }
.search-box.big { max-width: 640px; margin: 18px 0 8px; }
.search-box.big input { padding: 14px 14px 14px 44px; font-size: 1.05rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px 16px; margin: 12px 0 20px; }
.grid.channels { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.vcard, .ccard { text-decoration: none; display: block; min-width: 0; border-radius: var(--radius); outline-offset: 4px; }
.vcard:focus-visible, .ccard:focus-visible { outline: 3px solid var(--accent); }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: var(--card); margin-bottom: 8px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge { position: absolute; right: 6px; bottom: 6px; background: rgba(0, 0, 0, .8); color: #fff; font-size: .75rem; font-weight: 700;
  padding: 2px 6px; border-radius: 5px; }
.badge.live { background: #d4202c; }
.v-title { font-weight: 650; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.v-sub { color: var(--muted); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ccard { text-align: center; }
.ccard img { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; background: var(--card); margin: 0 auto 8px; display: block; }
/* "list" grids: thumbnail left, text right (watch page sidebar, playlists) */
.grid.list { grid-template-columns: 1fr; gap: 10px; }
.grid.list .vcard { display: grid; grid-template-columns: 168px minmax(0, 1fr); column-gap: 10px; align-items: start; }
.grid.list .thumb { grid-row: span 3; margin: 0; border-radius: 8px; }
.grid.list .v-title { font-size: .92rem; }

/* watch page */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; }
.stage-slot { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
.stage { position: relative; width: 100%; height: 100%; background: #000; }
.stage video { width: 100%; height: 100%; display: block; background: #000; }
.stage-msg { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; text-align: center; padding: 20px; background: rgba(0, 0, 0, .75); color: #fff; }
.stage-msg .btn { justify-self: center; }
.w-title { font-size: 1.3rem; margin: 12px 0 8px; }
.w-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.w-channel { font-weight: 700; text-decoration: none; }
.w-actions { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.select { width: auto; padding: 6px 10px; }
.w-desc { background: var(--card); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; }
.w-desc summary { cursor: pointer; font-weight: 600; }
.w-desc p { overflow-wrap: anywhere; line-height: 1.5; }
.w-desc a { color: var(--accent2); }
.ts { background: none; border: 0; color: var(--accent2); padding: 0; cursor: pointer; text-decoration: underline; }
.chapters { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.w-side-h { margin-top: 0; }
body.native .stage-slot { display: none; }   /* the app shows the video above the page */

/* the video while you browse: a small player in the corner */
.dock { position: fixed; z-index: 45; right: 16px; bottom: calc(16px + var(--nav-h) + env(safe-area-inset-bottom)); width: 360px;
  background: var(--bg2); border-radius: var(--radius); overflow: hidden; box-shadow: 0 12px 40px var(--shadow); border: 1px solid var(--line); }
.dock .stage { aspect-ratio: 16 / 9; height: auto; }
.dock video::-webkit-media-controls { display: none !important; }
body.native .dock .stage { display: none; }
.dock-bar { display: flex; align-items: center; gap: 2px; padding: 4px 6px; }
.dock-open { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 6px; cursor: pointer; display: grid; }
.dock-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-sub { color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.has-dock main { padding-bottom: 260px; }
body.native.has-dock main { padding-bottom: 80px; }

/* channel / playlist headers */
.banner { aspect-ratio: 6 / 1; border-radius: var(--radius); overflow: hidden; background: var(--card); margin-bottom: 14px; }
.banner img { width: 100%; height: 100%; object-fit: cover; }
.ch-head, .pl-head { display: flex; gap: 18px; align-items: center; margin: 8px 0 12px; }
.ch-avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: var(--card); flex: none; }
.pl-head { align-items: flex-start; }
.pl-head > img { width: min(360px, 40vw); aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); background: var(--card); }

@media (max-width: 1000px) {
  .watch { grid-template-columns: 1fr; }
}
@media (max-width: 899px) {
  .side-nav, .top-search { display: none; }
  .topbar { justify-content: space-between; padding: 8px 14px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .bottom-nav:not([hidden]) { display: flex; }
  :root { --nav-h: 58px; }
  main { padding: 12px 14px; }
  h1 { font-size: 1.35rem; }
  .grid { grid-template-columns: 1fr; }
  .grid.channels { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  body.watching main { padding-top: 0; }
  body.watching .stage-slot { margin: 0 -14px; border-radius: 0; position: sticky; top: 0; z-index: 15; }
  body.watching .topbar { display: none; }
  .dock { left: 8px; right: 8px; width: auto; display: grid; grid-template-columns: 128px 1fr; }
  .dock .stage { height: 72px; aspect-ratio: auto; }
  body.native .dock { grid-template-columns: 1fr; }
  .pl-head { flex-direction: column; }
  .pl-head > img { width: 100%; }
  .w-actions { margin-left: 0; }
}
/* placeholder art in round avatars: fixed padding (a percentage would follow the page width) */
.ch-avatar.fallback, .ccard img.fallback, .avatar img.fallback { padding: 22px; }

/* TV boxes (remote control): a clear focus ring, and bigger tiles for across the room */
body.tvmode :focus { outline: 3px solid var(--accent); outline-offset: 3px; }
body.tvmode .vcard:focus .thumb { transform: scale(1.04); transition: transform .12s ease; }
body.tvmode main { max-width: none; padding: 20px 48px; }
body.tvmode .grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
body.tvmode .bottom-nav { display: none !important; }

/* library */
.watched { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--accent); }
.lib-links { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 6px; }
.shelf-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mine-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.grid.list.mine .vcard { display: grid; grid-template-columns: 168px minmax(0, 1fr); column-gap: 10px; }
.sub-btn { margin-left: 4px; }
.ch-head .sub-btn { margin: 6px 0; }
.job { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.job .v-title { flex: 1; min-width: 0; }
.note { background: var(--card); border-left: 3px solid var(--accent2); padding: 8px 12px; border-radius: 8px; margin: 10px 0; }

/* channel tools: sort chips and search */
.ch-tools { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.ch-tools .chips { margin: 0; }
.ch-search { flex: 0 1 320px; margin: 0; }
.more-row { display: flex; justify-content: center; margin: 8px 0 24px; }

/* comments */
.w-comments { background: var(--card); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; }
.w-comments summary { cursor: pointer; font-weight: 600; }
.comment { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.comment:first-child { border-top: 0; }
.cm-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--accent2); color: var(--bg);
  display: grid; place-items: center; font-weight: 800; }
.cm-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.cm-head a, .cm-head span:first-child { font-weight: 650; text-decoration: none; }
.cm-up { background: var(--bg2); border-radius: 999px; padding: 0 8px; }
.cm-tag { font-size: .75rem; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; color: var(--muted); }
.cm-tag.heart { color: var(--accent); border-color: var(--accent); }
.cm-text { overflow-wrap: anywhere; line-height: 1.45; margin: 4px 0; }
.cm-text a { color: var(--accent2); }
.comment .muted svg { width: 14px; height: 14px; display: inline; vertical-align: -2px; }

/* For you */
.rec { position: relative; min-width: 0; }
.rec-why { margin-top: 2px; }
.rec-x { position: absolute; right: 2px; top: 4px; background: rgba(0, 0, 0, .55); color: #fff; width: 36px; height: 36px; }
.rec-x:hover { background: rgba(0, 0, 0, .8); color: #fff; }
.toast-act { background: none; border: 0; color: var(--accent); font-weight: 800; cursor: pointer; margin-left: 8px; padding: 0; }
.hid-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.bottom-nav a { min-width: 0; }
