/* Themes. The default is Netflix (dark). Set on <html data-theme="..."> by app.js.
   Each theme sets the same tokens; the rest of the file only uses tokens.
   Accent roles are per theme; see the comment in each block. */

/* Netflix (default, dark): red accent, system fonts. */
:root {
  --bg: #0b0b0f;
  --bg-rgb: 11,11,15;
  --panel: #16161d;
  --line: #262633;
  --text: #f1f1f5;
  --muted: #9a9ab0;
  --ink-soft: #c8c8d6;
  --accent: #e5484d;          /* primary buttons, active filter, progress, wordmark */
  --accent-text: #fff;
  --link: #e5484d;
  /* MathsKid four colours, used by the logo and accents in that theme */
  --c-blue: #1870c0;
  --c-yellow: #e8ab00;
  --c-red: #e23b2e;
  --c-green: #1fa85b;
  --new-bg: #e5484d;          /* NEW badge */
  --new-text: #fff;
  --done-bg: #3ecf8e;         /* Watched tag */
  --done-text: #05150d;
  --upto: #3ecf8e;            /* "✓ to here" */
  --danger: #e5484d;          /* Remove, "✕ from here", "Mark all unwatched", errors */
  --track: rgba(255,255,255,.2);
  --shadow: rgba(0,0,0,.6);
  --head: -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: -apple-system, "Segoe UI", Roboto, sans-serif;
  --wordmark-weight: 900;
  --wordmark-case: uppercase;
  --wordmark-tracking: 5px;
  color-scheme: dark;
}

/* MathsKid (light): cream card, ink text, Charter headings. Four colours, four jobs:
   blue = primary actions; yellow = NEW; green = Watched and "✓ to here"; red = Remove and errors. */
:root[data-theme="mathskid"] {
  --bg: #12151d;
  --bg-rgb: 18,21,29;
  --panel: #1b202c;
  --line: #272d39;
  --text: #f2efe8;
  --muted: #8f98ab;
  --ink-soft: #c3c9d6;
  --accent: #1870c0;
  --accent-text: #fff;
  --link: #5aa5e8;
  --new-bg: #e8ab00;
  --new-text: #141b2e;
  --done-bg: #3ec97a;
  --done-text: #05150d;
  --upto: #3ec97a;
  --danger: #ff6b5e;
  --track: rgba(255,255,255,.2);
  --shadow: rgba(0,0,0,.6);
  --c-blue: #5aa5e8;
  --c-yellow: #e8ab00;
  --c-red: #ff6b5e;
  --c-green: #3ec97a;
  color-scheme: dark;
}

/* MathsKid is the loud one: the logo alternates the four colours, a four-colour stripe runs under the header,
   and each card in a rail gets a coloured top edge in turn. */
:root[data-theme="mathskid"] header h1 span:nth-child(4n+1) { color: var(--c-blue); }
:root[data-theme="mathskid"] header h1 span:nth-child(4n+2) { color: var(--c-yellow); }
:root[data-theme="mathskid"] header h1 span:nth-child(4n+3) { color: var(--c-red); }
:root[data-theme="mathskid"] header h1 span:nth-child(4n+4) { color: var(--c-green); }
:root[data-theme="mathskid"] header { border-bottom: 0; }
:root[data-theme="mathskid"] header::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: linear-gradient(90deg, var(--c-blue) 0 25%, var(--c-yellow) 25% 50%, var(--c-red) 50% 75%, var(--c-green) 75%); }
:root[data-theme="mathskid"] .rail > .card:nth-child(4n+1) { border-top: 4px solid var(--c-blue); }
:root[data-theme="mathskid"] .rail > .card:nth-child(4n+2) { border-top: 4px solid var(--c-yellow); }
:root[data-theme="mathskid"] .rail > .card:nth-child(4n+3) { border-top: 4px solid var(--c-red); }
:root[data-theme="mathskid"] .rail > .card:nth-child(4n+4) { border-top: 4px solid var(--c-green); }

/* Mugenno (light, DESIGN.md): white, navy text, one deep-blue accent, Plus Jakarta Sans + Inter.
   The guide has no red; --danger is a darker red chosen to match it. */
:root[data-theme="mugenno"] {
  --bg: #0f172a;
  --bg-rgb: 15,23,42;
  --panel: #1e293b;
  --line: #334155;
  --text: #f8f9fa;
  --muted: #94a3b8;
  --ink-soft: #cbd5e1;
  --accent: #0b5196;
  --accent-text: #fff;
  --link: #6fb0ea;
  --new-bg: #0b5196;
  --new-text: #fff;
  --done-bg: #1e3a5f;
  --done-text: #9cc4ec;
  --upto: #6fb0ea;
  --danger: #f87171;
  --track: rgba(255,255,255,.15);
  --shadow: rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--body); }
button { font: inherit; color: var(--text); cursor: pointer; border: 0; border-radius: 8px; padding: 10px 16px; background: var(--panel); }
button.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
button.ghost { background: transparent; border: 1px solid var(--line); }
button:disabled { opacity: .4; cursor: default; }
button:hover { filter: brightness(.96); }
/* Keyboard and remote: a ring on whichever control has focus */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
button.primary:hover { filter: brightness(1.08); }
input { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.muted { color: var(--muted); }
/* Locked: show only the brand and the passcode prompt */
body.locked #addBtn, body.locked #sync { display: none; }
.err { color: var(--danger); min-height: 1.4em; margin: 6px 0; }

header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; position: sticky; top: 0; z-index: 5; background: linear-gradient(rgba(var(--bg-rgb),.9), transparent); transition: background .3s, box-shadow .3s; }
header.scrolled { background: var(--bg); box-shadow: 0 2px 12px var(--shadow); }
header h1 { margin: 0; font-family: var(--head); font-size: 22px; font-weight: var(--wordmark-weight); letter-spacing: var(--wordmark-tracking); text-transform: var(--wordmark-case); color: var(--link); }
h1, h2, h3, .hero h2, .banner h2 { font-family: var(--head); }
.actions { display: flex; align-items: center; gap: 12px; }
.sync { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.sync.busy::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border: 2px solid var(--muted); border-right-color: transparent; border-radius: 50%; vertical-align: -1px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Shown when the server cannot be reached; changes are still saved on the device */
.offline-bar { text-align: center; font-size: 14px; padding: 8px 16px; background: var(--panel); color: var(--text); border-bottom: 2px solid var(--danger); }
[hidden] { display: none !important; }
footer { padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); text-align: center; color: var(--muted); font-size: 14px; }
footer .footer-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px 28px; }
footer label { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
footer .version { margin: 14px 0 0; font-size: 12px; letter-spacing: .04em; opacity: .7; }
#themePick { width: auto; padding: 8px 10px; font-size: 14px; }

main, #detail, #history { padding: 0 16px 48px; max-width: 1400px; margin: 0 auto; }
h2.row-title { font-size: 18px; margin: 24px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.empty { text-align: center; margin: 80px 0; color: var(--muted); }

.filters { margin: 16px 0 0; font-size: 14px; }
.filter-body { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.filter-row > span { color: var(--muted); width: 56px; flex: none; }
.filter-row .seg { flex: none; }

/* Horizontal rails */
.rail { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; padding: 10px 10px 16px; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
/* Rails: edge fades when more cards are off screen; arrows for mouse users only (hidden on touch and TV) */
.rail-wrap { position: relative; }
.rail-wrap::before, .rail-wrap::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40px; z-index: 1; pointer-events: none; opacity: 0; transition: opacity .2s; }
.rail-wrap::before { left: 0; background: linear-gradient(to right, var(--bg), transparent); }
.rail-wrap::after { right: 0; background: linear-gradient(to left, var(--bg), transparent); }
.rail-wrap:not(.at-start)::before, .rail-wrap:not(.at-end)::after { opacity: 1; }
.rail-nav { display: none; position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 28px; line-height: 1; color: #fff; background: rgba(0,0,0,.7); border: 1px solid rgba(255,255,255,.3); }
.rail-nav.prev { left: 6px; }
.rail-nav.next { right: 6px; }
.rail-wrap.at-start .prev, .rail-wrap.at-end .next { visibility: hidden; }
@media (hover: hover) and (pointer: fine) { .rail-wrap:hover .rail-nav { display: block; } }
html.tv .rail-nav { display: none !important; }
.rail > .card { flex: 0 0 230px; scroll-snap-align: start; }

/* Billboard and show banner: the photo fades into the theme's background */
.hero, .banner { position: relative; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 12px; overflow: hidden; background: #000; isolation: isolate; }
.hero { min-height: 340px; margin: 8px 0 16px; }
.banner { min-height: 300px; margin: 8px 0 20px; }
.hero::before, .banner::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, var(--bg) 4%, rgba(var(--bg-rgb),.6) 55%, rgba(var(--bg-rgb),.15)), linear-gradient(to right, rgba(var(--bg-rgb),.7), transparent 70%); }
.hero-body, .banner-body { position: relative; z-index: 1; padding: 24px; }
.hero-body { max-width: 560px; }
.hero h2, .banner h2 { margin: 0 0 6px; font-size: clamp(1.7rem, 4vw, 2.6rem); line-height: 1.15; }
.hero .sub, .banner .muted { margin: 0; color: var(--ink-soft); }
/* Anime or Drama: looks like a label, a tap flips it */
.type-chip { padding: 1px 8px; margin-left: 2px; border-radius: 999px; font: inherit; color: inherit; cursor: pointer; }
/* Show description: three lines, tap or press Enter to show all of it */
.banner .desc { margin: 10px 0 0; max-width: 720px; color: var(--ink-soft); font-size: 15px; white-space: pre-line; cursor: pointer; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.banner .desc.open { display: block; }
.btns { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.back { margin-bottom: 8px; }
.detail-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.detail-top .back { margin-bottom: 0; }
.timing { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.timing input { width: 72px; padding: 6px 8px; }

@media (max-width: 560px) {
  header h1 { font-size: 19px; letter-spacing: 3px; }
  #addBtn { white-space: nowrap; }
  .rail > .card { flex-basis: 160px; }
  .hero { min-height: 280px; }
  .hero-body, .banner-body { padding: 16px; }
}
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border-radius: 0; background: transparent; padding: 6px 12px; font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--accent-text); }
select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
#addDlg select { width: 100%; margin-top: 10px; }
.add-preview { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.add-preview img { width: 120px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; flex: none; }
.add-preview strong { display: block; }
.add-results { display: grid; gap: 6px; margin-top: 12px; max-height: 50vh; overflow-y: auto; }
.add-results button { display: flex; gap: 10px; align-items: center; text-align: left; width: 100%; padding: 6px; }
.add-results img { width: 96px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; flex: none; }
.add-results strong { display: block; font-weight: 600; }

.card { background: var(--panel); border-radius: 10px; overflow: hidden; cursor: pointer; position: relative; border: 1px solid var(--line); box-shadow: 0 1px 3px var(--shadow); transition: transform .2s, box-shadow .2s; }
.card:focus-visible { transform: scale(1.04); box-shadow: 0 10px 30px var(--shadow); z-index: 2; }
/* Hover zoom only where a pointer can hover, so a tap on a phone does not leave a card enlarged */
@media (hover: hover) { .card:hover { transform: scale(1.04); box-shadow: 0 10px 30px var(--shadow); z-index: 2; } }
.thumb { position: relative; aspect-ratio: 16/9; background: #000; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Thumbnail tags: NEW and Watched, coloured per theme */
.badge, .check { position: absolute; top: 10px; z-index: 2; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; line-height: 1; padding: 5px 9px; border-radius: 999px; box-shadow: 0 2px 6px var(--shadow); }
.badge { left: 10px; background: var(--new-bg); color: var(--new-text); }
.check { right: 10px; background: var(--done-bg); color: var(--done-text); }
/* Episode length, bottom-right of the thumbnail like YouTube */
.len { position: absolute; right: 8px; bottom: 10px; z-index: 2; font-size: 12px; font-weight: 600; line-height: 1; padding: 4px 6px; border-radius: 4px; background: rgba(0, 0, 0, .75); color: #fff; font-variant-numeric: tabular-nums; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--track); }
.bar > i { display: block; height: 100%; background: var(--accent); }
.meta { padding: 10px 12px 12px; }
.meta .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .s { color: var(--muted); font-size: 14px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

#detail .top { display: flex; gap: 12px; align-items: center; margin: 8px 0 16px; flex-wrap: wrap; }
#detail h2 { margin: 0; flex: 1; min-width: 200px; }
.ep { display: grid; grid-template-columns: 28px 160px 1fr auto; gap: 12px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 8px; }
.marks { display: flex; gap: 8px; align-items: center; }
/* One ⋯ button per episode row (44px tap target); its menu lists the actions with labels */
.ep-more { width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 22px; line-height: 1; color: var(--text); background: transparent; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; }
.ep-more:active { transform: scale(.92); }
.ep-menu-list { display: flex; flex-direction: column; gap: 8px; }
.ep-menu-list button { text-align: left; min-height: 44px; }
.ep-menu-list [data-act="upto"] { color: var(--upto); border-color: var(--upto); }
.ep-menu-list [data-act="from"] { color: var(--danger); border-color: var(--danger); }
.ep:hover, .ep:focus-visible { background: var(--panel); }
.ep .n { color: var(--muted); text-align: center; }
.ep .name { font-weight: 500; }
.ep .sub { color: var(--muted); font-size: 13px; }
.history-remove { width: 44px; height: 44px; padding: 0; border-radius: 50%; color: var(--muted); }
.ep.current { outline: 2px solid var(--accent); }
.ep .mark { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
[data-act="upto"], [data-act="markall"] { color: var(--upto); border-color: var(--upto); }
[data-act="from"], [data-act="unmarkall"], [data-act="remove"] { color: var(--danger); border-color: var(--danger); }

#player { position: fixed; inset: 0; background: #000; z-index: 20; display: flex; flex-direction: column; }
#player[hidden], #detail[hidden] { display: none; }
.player-bar { display: flex; gap: 12px; align-items: center; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); color: #fff; }
#player button.ghost { color: #fff; border-color: rgba(255,255,255,.4); background: transparent; }
.now-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frame { flex: 1; min-height: 0; background: #000; }
.frame iframe { width: 100%; height: 100%; border: 0; }
.player-nav { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
#player .timing-set { font-size: 14px; padding: 8px 12px; color: #fff; border-color: rgba(255,255,255,.4); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; width: min(460px, 92vw); padding: 20px; box-shadow: 0 20px 50px var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h2 { margin: 0 0 8px; }
.row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }

@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .ep { grid-template-columns: 22px 96px minmax(0, 1fr); gap: 4px 10px; }
  .ep .marks { grid-column: 2 / -1; justify-content: flex-end; }
}

/* Big TV sizing (html.tv-big, not set by default): bigger type, targets and rails for a screen viewed from across the room. TV mode (html.tv) keeps normal size. */
html.tv-big body { font-size: 20px; }
html.tv-big header { padding: 22px 48px; }
html.tv-big header h1 { font-size: 30px; }
html.tv-big main, html.tv-big #detail, html.tv-big #history { padding: 0 48px 64px; }
html.tv-big h2.row-title { font-size: 26px; }
html.tv-big button { padding: 14px 26px; font-size: 20px; }
html.tv-big .rail > .card { flex-basis: 320px; }
html.tv-big .meta .t { font-size: 20px; }
html.tv-big .hero { min-height: 480px; }
html.tv-big .banner { min-height: 420px; }
html.tv-big .mark-icon { width: 56px; height: 56px; font-size: 24px; }
html.tv-big .ep { grid-template-columns: 36px 240px 1fr auto; padding: 14px 10px; }
html.tv-big .ep .name { font-size: 20px; }
html.tv-big footer { font-size: 18px; }

/* ---------- round 1: toolbar, billboard, placeholders, toast, player extras ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; max-width: 1400px; margin: 0 auto; padding: 0 16px; }
.toolbar input[type="search"] { flex: 1; min-width: 0; }
.toolbar select { flex: none; }

/* Billboard dots are buttons: a 24px tap target around an 8px dot */

.skeleton-block, .skeleton-card { background: var(--panel); animation: pulse 1.4s ease-in-out infinite; }
.skeleton-block { min-height: 300px; margin: 8px 0 20px; border-radius: 12px; }
.skeleton-card { flex: 0 0 230px; height: 130px; border-radius: 10px; }
.rail .skeleton-card { flex: 0 0 230px; }
@keyframes pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

h3.sub-title { font-size: 16px; margin: 20px 0 8px; color: var(--ink-soft); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; display: flex; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; box-shadow: 0 10px 30px var(--shadow); max-width: calc(100vw - 32px); }
.toast button { padding: 6px 12px; color: var(--link); border-color: var(--link); }

.ctl { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: #fff; }
.ctl select { font-size: 14px; padding: 6px 8px; }
.player-bar { flex-wrap: nowrap; }

.skip { position: absolute; right: 18px; bottom: 18px; z-index: 5; background: rgba(0,0,0,.75); color: #fff; border: 1px solid rgba(255,255,255,.6); padding: 10px 18px; }
.frame { position: relative; }

.upnext { position: absolute; right: 18px; bottom: 18px; z-index: 6; width: min(420px, calc(100% - 36px)); background: rgba(0,0,0,.85); color: #fff; border-radius: 12px; padding: 16px; }
.upnext h3 { margin: 0 0 4px; font-size: 18px; }
.upnext p { margin: 0 0 10px; color: #ddd; }
.upnext .row { margin-top: 10px; }
.upnext .row button.ghost { color: #fff; border-color: rgba(255,255,255,.5); }
.upnext-list { display: flex; flex-direction: column; gap: 8px; }
.upnext-list .up { display: flex; gap: 10px; align-items: center; text-align: left; padding: 6px; background: rgba(255,255,255,.08); color: #fff; }
.upnext-list .up img { width: 96px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; flex: none; }
.upnext-list .up span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.field.check { flex-direction: row; align-items: center; }
.field.check input { width: auto; }
.resume .row { margin-top: 16px; }

.banner .desc { margin: 10px 0 0; max-width: 720px; color: var(--ink-soft); font-size: 15px; white-space: pre-line; cursor: pointer; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.banner .desc.open { display: block; }

/* Text size (html.text-large / html.text-xlarge) and high contrast (html.contrast), set in Settings */
html.text-large { zoom: 1.15; }
html.text-xlarge { zoom: 1.3; }
html.contrast { --muted: #d4d4e0; --ink-soft: #f4f4f8; --line: #6a6a82; --track: rgba(255,255,255,.35); }
html.contrast .card, html.contrast .seg, html.contrast .ep, html.contrast button.ghost { border-color: var(--line); }
html.contrast .meta .s { color: var(--ink-soft); }

/* Phones: header actions on their own row, all three visible; footer controls stacked and centred */
@media (max-width: 560px) {
  header { flex-wrap: wrap; row-gap: 6px; padding: 8px 12px 6px; }
  header h1 { width: 100%; text-align: center; }
  .actions { width: 100%; gap: 8px; }
  .actions button { flex: 1 1 0; min-width: 0; padding: 8px 6px; font-size: 14px; min-height: 40px; white-space: nowrap; }
  .toolbar { padding: 0 12px; gap: 8px; }
  .toolbar select { max-width: 42%; font-size: 14px; }
  .filters { font-size: 13px; }
  .filter-row > span { width: 48px; }
  footer { padding: 20px 12px calc(20px + env(safe-area-inset-bottom)); }
  footer .footer-row { flex-direction: column; gap: 12px; }
  footer label { justify-content: center; }
  footer .footer-row button { width: 100%; max-width: 280px; }
  #themePick { font-size: 15px; }
}
.banner .desc-en { display: block; margin-top: 6px; color: var(--muted); }

/* ---------- round 3: UI audit fixes ---------- */
/* Billboard and banner pictures sit behind the gradient; the image is set by bgImg() in app.js */
.hero > img.bg, .banner > img.bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; }
.t-zh { display: block; }
.t-en { display: block; margin-top: 4px; font-size: .5em; font-weight: 600; color: var(--ink-soft); }

/* Show page and filters: the less-used controls sit behind a summary line, so episodes start near the top */
.filters > summary, .more > summary { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; list-style: none; color: var(--text); background: transparent; }
.filters > summary::-webkit-details-marker, .more > summary::-webkit-details-marker { display: none; }
.more { width: 100%; margin-top: 12px; }
/* More sits in the button row beside Resume; when open its menu takes the next full row */
.btns .more { width: auto; margin-top: 0; }
.btns .more[open] { flex-basis: 100%; }
.more-menu { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.range-row { margin: 12px 0; }
.pager { display: flex; gap: 10px; align-items: center; }
.pager select { flex: 1; min-width: 0; }
.pager button { flex: none; }
.pager-end { margin: 24px 0 12px; }
.pager-end button { flex: 1; min-height: 44px; }

/* Touch targets: selects, timing boxes and checkboxes are at least 44px */
select, .timing input { min-height: 44px; }
input[type="checkbox"] { width: 20px; height: 20px; }
#settingsDlg #themePick { width: 100%; padding: 10px 12px; font-size: 16px; }

/* Full screen keeps the video filling the screen */
#player.cinema .player-bar, #player.cinema .player-nav { display: none; }
/* Cinema, pointer: the TV remote's arrows move a cursor, so moving it (or pressing OK) shows the bars over the video for a few seconds. */
#player.cinema.peek .player-bar, #player.cinema.peek .player-nav { display: flex; position: absolute; left: 0; right: 0; z-index: 8; background: rgba(0,0,0,.8); }
#player.cinema.peek .player-bar { top: 0; }
#player.cinema.peek .player-nav { bottom: 0; }
/* A clear layer over the video in cinema, so the page, not the video frame, receives the cursor. */
#player.cinema .frame::after { content: ""; position: absolute; inset: 0; z-index: 4; }
#player:fullscreen .frame { flex: 1; aspect-ratio: auto; }
/* Real full screen (phone and computer): the video has the whole screen and YouTube's controls stay. A touch or click on the video, or the cursor
   at the top edge, shows the bars over it for a few seconds (app.js: peekBars). Leave with Esc, the system gesture or YouTube's button. */
#player:fullscreen .player-bar, #player:fullscreen .player-nav { display: none; }
#player:fullscreen.peek .player-bar, #player:fullscreen.peek .player-nav { display: flex; position: absolute; left: 0; right: 0; z-index: 8; background: rgba(0,0,0,.8); }
#player:fullscreen.peek .player-bar { top: 0; }
#player:fullscreen.peek .player-nav { bottom: 0; }
/* The bar covers the bottom of the video while it shows: lift Skip intro above it (--skip-lift is set in peekBars). */
#player.cinema.peek .skip, #player:fullscreen.peek .skip { bottom: calc(var(--skip-lift, 0px) + 18px); }
@media (pointer: fine) {
  #player:fullscreen .frame::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 72px; z-index: 4; }
}

@media (max-width: 560px) {
  /* Card titles may take two lines */
  .meta .t { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .seg button { min-height: 40px; }
  /* Player: one compact bar; the video keeps its shape, so Previous and Next stay on screen */
  .player-bar { flex-wrap: nowrap; gap: 8px; padding: 8px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .player-bar .ctl span, .player-bar #fullscreenBtn { display: none; }
  .now-title { flex: 1; min-width: 0; font-size: 14px; }
  .frame { flex: none; aspect-ratio: 16 / 9; }
  /* Show page: the banner shrinks to its text so the first episode is on screen */
  .banner { min-height: 0; }
  .banner .desc { font-size: 14px; }
  .banner .btns { margin-top: 10px; }
  .more { margin-top: 6px; }
}

/* TV: use the full width and bigger secondary text */
html.tv-big main, html.tv-big #detail, html.tv-big #history, html.tv-big .toolbar { max-width: none; }
html.tv-big .meta .s, html.tv-big .banner .desc { font-size: 18px; }
html.tv-big .ep .sub { font-size: 16px; }
html.tv-big .badge, html.tv-big .check { font-size: 14px; }
html.tv-big .hero h2, html.tv-big .banner h2 { font-size: clamp(2.2rem, 3.6vw, 3.2rem); }
html.tv-big .filters > summary, html.tv-big .more > summary { font-size: 20px; }
