/* Colours. --accent is set per device (Settings > Appearance); the rest derive from it.
   Dark is the default; html[data-theme=light] swaps the palette. */
:root {
  --bg: #0e0f13; --panel: #171920; --line: #262935; --line-strong: #3a3f50; --text: #e8e9ee; --muted: #8b8fa3;
  --field: #1d2029; --chip: #262a36; --raised: #232634; --code-bg: #22252f; --hover: #30344280;
  --accent: #9b6bff; --mix-to: #fff;
  --accent-2: color-mix(in srgb, var(--accent) 72%, var(--mix-to));
  --accent-hover: color-mix(in srgb, var(--accent) 85%, #000);
  --accent-soft: color-mix(in srgb, var(--accent) 22%, var(--panel));
  --ok: #3ecf8e; --bad: #ff6b6b; --warn: #ffc857; --info: #7cc4ff;
  --ok-soft: #1b3a2d; --bad-soft: #3a1b1b; --warn-soft: #3a321b; --info-soft: #1b2d3a;
  --error-bg: #2a1616; --error-text: #ffb3b3; --callout-bg: #2a2614;
  --side-w: 13.5rem;
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f4f5f8; --panel: #ffffff; --line: #e1e3ea; --line-strong: #c9ccd6; --text: #16181f; --muted: #626779;
  --field: #f1f2f6; --chip: #e9ebf1; --raised: #eceef4; --code-bg: #eceef3; --hover: #dfe2ea;
  --mix-to: #000; --accent-2: color-mix(in srgb, var(--accent) 80%, #000);
  --accent-soft: color-mix(in srgb, var(--accent) 14%, #fff);
  --ok: #138a55; --bad: #d63a3a; --warn: #a86b00; --info: #1f6fb2;
  --ok-soft: #dcf5e8; --bad-soft: #fde2e2; --warn-soft: #fbefd5; --info-soft: #dcecfa;
  --error-bg: #fde8e8; --error-text: #9b1c1c; --callout-bg: #fdf5dc;
  color-scheme: light;
}
html[data-motion="reduced"] *, html[data-motion="reduced"] *::before { transition: none !important; animation: none !important; }
html[data-width="wide"] main { max-width: 1800px; }
* { box-sizing: border-box; }
/* 100% = the phone's own text size; --ui-scale = the Text size picked under Settings > This device */
html { font-size: calc(100% * var(--ui-scale, 1)); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 0.9375rem/1.5 system-ui, "Segoe UI", Roboto, sans-serif;
  /* room for the iPhone notch / home bar when opened from the Home Screen */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
h1, h2, h3 { margin: 1.2em 0 .5em; line-height: 1.2; }
h2 .count { font-size: 0.8125rem; color: var(--muted); font-weight: 500; margin-left: 6px; }
code { background: var(--code-bg); padding: 1px 6px; border-radius: 4px; }
.muted { color: var(--muted); } .small { font-size: 0.8125rem; } .bad { color: var(--bad); }

/* never let anything push the page wider than the screen (no side-to-side scrolling) */
html { overflow-x: hidden; }
img, video, svg, pre, table { max-width: 100%; }
/* only break a word when it can't fit on a line by itself (long links); never split normal words */
td, th, strong, p, li, dd { overflow-wrap: break-word; }
.mono, code, .error { overflow-wrap: anywhere; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); gap: 8px; }
.brand { font-weight: 800; font-size: 1.125rem; color: var(--text); letter-spacing: .3px; }
.top nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
.top nav a, .link { color: var(--muted); padding: 6px 12px; border-radius: 8px; }
.top nav a.on, .top nav a:hover { color: var(--text); background: var(--raised); text-decoration: none; }
.tabbar svg { display: none; }
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand img { border-radius: 7px; flex: none; }
.brand:hover { text-decoration: none; }
.side-toggle, .logout svg { display: none; }

/* PC / tablet: the menu becomes a vertical sidebar on the left or right (Settings > Appearance).
   It slides between full (icons + names) and slim (icons only). */
@media (min-width: 761px) {
  html[data-nav="left"] body:has(.top) { padding-left: var(--side-w); }
  html[data-nav="right"] body:has(.top) { padding-right: var(--side-w); }
  html[data-side="slim"] { --side-w: 4.5rem; }
  html[data-nav="left"] .top, html[data-nav="right"] .top {
    position: fixed; top: 0; bottom: 0; z-index: 30; width: var(--side-w); overflow: hidden auto;
    flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 4px;
    padding: 18px 12px 14px; border-bottom: 0; }
  html[data-nav="left"] .top { left: 0; border-right: 1px solid var(--line); }
  html[data-nav="right"] .top { right: 0; border-left: 1px solid var(--line); }
  html:is([data-nav="left"], [data-nav="right"]) .brand { padding: 0 9px 14px; font-size: 1.1875rem; gap: 10px; }
  html:is([data-nav="left"], [data-nav="right"]) .top nav.tabbar { flex: none; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 2px; }
  html:is([data-nav="left"], [data-nav="right"]) .top nav a,
  html:is([data-nav="left"], [data-nav="right"]) .side-toggle,
  html:is([data-nav="left"], [data-nav="right"]) .logout .link {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 10px;
    color: var(--muted); white-space: nowrap; text-align: left; background: none; border: 0; font-size: 0.9375rem; }
  html:is([data-nav="left"], [data-nav="right"]) .top nav a:hover,
  html:is([data-nav="left"], [data-nav="right"]) .side-toggle:hover,
  html:is([data-nav="left"], [data-nav="right"]) .logout .link:hover { background: var(--raised); color: var(--text); text-decoration: none; }
  html:is([data-nav="left"], [data-nav="right"]) .top nav a.on { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
  html:is([data-nav="left"], [data-nav="right"]) .tabbar svg,
  html:is([data-nav="left"], [data-nav="right"]) .side-toggle svg,
  html:is([data-nav="left"], [data-nav="right"]) .logout svg {
    display: block; flex: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  html:is([data-nav="left"], [data-nav="right"]) .side-toggle { margin-top: auto; }
  html:is([data-nav="left"], [data-nav="right"]) .side-toggle svg { transition: transform .25s ease; }
  html[data-nav="right"] .side-toggle svg { transform: scaleX(-1); }
  html[data-nav="left"][data-side="slim"] .side-toggle svg { transform: scaleX(-1); }
  html[data-nav="right"][data-side="slim"] .side-toggle svg { transform: none; }
  html:is([data-nav="left"], [data-nav="right"])[data-side="slim"] .top span { display: none; }
  html:is([data-nav="left"], [data-nav="right"])[data-side="slim"] .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  html:is([data-nav="left"], [data-nav="right"])[data-side="slim"] :is(.top nav a, .side-toggle, .logout .link) { justify-content: center; padding-left: 0; padding-right: 0; }
  /* the slide */
  .top, body { transition: width .25s ease, padding .25s ease; }
}
@media (display-mode: standalone) { .tabbar .get-app { display: none; } } /* already installed */

input, select, textarea, button { font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-width: 100%; }
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { cursor: pointer; background: var(--chip); }
button:hover { background: var(--hover); border-color: var(--line-strong); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); }
button.danger { color: var(--bad); }
button.link { background: none; border: 0; }
form { margin: 0; }
label { display: block; font-size: 0.8125rem; color: var(--muted); margin-bottom: 10px; }
label input, label select, label textarea { display: block; width: 100%; margin-top: 4px; color: var(--text); }
label.check { display: flex; gap: 8px; align-items: center; padding-top: 22px; }
label.check input { width: auto; display: inline; margin: 0; }

.flash { background: var(--accent-soft); border: 1px solid var(--accent); padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.card h3:first-child { margin-top: 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.login { max-width: 360px; margin: 12vh auto; }
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.inline input[name=url], .inline input[name=query] { flex: 1; min-width: 200px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.row > label { flex: 1; min-width: 120px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.clip { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; color: var(--text); display: flex; flex-direction: column; }
a.clip:hover { border-color: var(--accent); text-decoration: none; }
.thumb { position: relative; aspect-ratio: 9/16; background: #000; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dur { position: absolute; right: 6px; bottom: 6px; background: #000a; font-size: 0.75rem; padding: 1px 6px; border-radius: 4px; color: #fff; }
.ph { display: grid; place-items: center; height: 100%; color: var(--muted); text-transform: capitalize; }
.ph.tall { aspect-ratio: 9/16; background: #000; border-radius: 12px; }
.meta { padding: 10px; display: flex; flex-direction: column; gap: 4px; font-size: 0.8125rem; }
.meta strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta select { font-size: 0.75rem; padding: 4px 6px; width: 100%; }

.detail { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 24px; align-items: start; }
.player video { width: 100%; aspect-ratio: 9/16; background: #000; border-radius: 12px; }
.status { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--chip); font-size: 0.8125rem; text-transform: capitalize; margin-bottom: 12px; }
.s-ready { background: var(--ok-soft); color: var(--ok); } .s-failed { background: var(--bad-soft); color: var(--bad); }
.s-scheduled { background: var(--accent-soft); color: var(--accent-2); } .s-processing { background: var(--warn-soft); color: var(--warn); }
.error { background: var(--error-bg); color: var(--error-text); padding: 10px; border-radius: 8px; white-space: pre-wrap; font-size: 0.75rem; max-height: 200px; overflow: auto; }
.publish { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.publish h3 { width: 100%; margin: 0; }

.thumb.wide { aspect-ratio: 16/9; }
.grid .clip:has(.thumb.wide) .meta { flex: 1; }
.tag { display: inline-block; font-size: 0.6875rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
.tag.yt { background: #ff0033; color: #fff; } .tag.tw { background: #9146ff; color: #fff; }
.tag.corner { position: absolute; left: 6px; top: 6px; }
.pill { display: flex; align-items: center; gap: 6px; margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 0.875rem; }
.pill input { width: auto; margin: 0; display: inline; }
.card .stats { margin: 8px 0 12px; grid-template-columns: repeat(2, 1fr); }
.small-form { margin: 10px 0 0; }
.small-form summary { cursor: pointer; }
.small-form form { margin-top: 8px; }
.vods td .ok { color: var(--ok); }
.vods td .bad { color: var(--bad); }
.vods button.link { padding: 0; color: var(--accent-2); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }
.chips a { padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.8125rem; }
.chips a.on { color: var(--text); border-color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 16px 0 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; color: var(--muted); font-size: 0.8125rem; }
.stat span { display: block; font-size: 1.625rem; font-weight: 700; color: var(--text); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
.checks { list-style: none; padding: 0; margin: 0; }
.meta .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.meta .actions button { font-size: 0.75rem; padding: 4px 8px; }
.streamers td { vertical-align: middle; }
.streamers img { width: 32px; height: 32px; border-radius: 50%; vertical-align: middle; margin-right: 8px; }
.streamers form.row { align-items: center; gap: 12px; }
.streamers .pill { padding: 4px 8px; font-size: 0.8125rem; }
.streamers input[name=facecam_rect] { width: 150px; font-size: 0.8125rem; padding: 4px 8px; }
.streamers .off { opacity: .5; }
@media (max-width: 760px) { .streamers th:nth-child(2), .streamers td:nth-child(2) { display: none; } }
.install-hero { display: flex; gap: 16px; align-items: center; margin: 8px 0 16px; }
.install-hero img { border-radius: 18px; flex: none; }
.install-hero h1 { margin: 0 0 4px; }
.install-hero p { margin: 0; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { border-radius: 999px; padding: 8px 16px; }
.tabs button[aria-selected=true] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-panel h2 { margin-top: 0; }
.tab-panel h3 { margin-top: 1.4em; }
.steps { padding-left: 22px; }
.steps li { margin-bottom: 10px; }
.kbd { display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; background: var(--code-bg); }
.callout { border-left: 3px solid var(--warn); background: var(--callout-bg); padding: 10px 14px; border-radius: 8px; margin: 12px 0; }
a.button { display: inline-block; padding: 10px 18px; border-radius: 8px; background: var(--chip); color: var(--text); font-weight: 600; }
a.button.primary { background: var(--accent); color: #fff; }
a.button:hover { text-decoration: none; }
a.button.disabled { opacity: .4; cursor: not-allowed; }
label.confirm { padding-top: 4px; font-size: 0.9375rem; color: var(--text); margin: 16px 0 10px; }
.mono { font-family: ui-monospace, Consolas, monospace; word-break: break-all; }
.grid .clip { position: relative; }
.clip .pick { position: absolute; z-index: 2; right: 6px; top: 6px; margin: 0; background: #000a; border-radius: 6px; padding: 4px 6px; line-height: 0; }
.clip .pick input { width: 18px; height: 18px; margin: 0; }
.clip .del-one { position: absolute; z-index: 2; right: 40px; top: 6px; }
.clip .del-one button { background: #000a; border: 0; color: #fff; padding: 2px 9px; font-size: 1rem; line-height: 1.3; border-radius: 6px; }
.clip .del-one button:hover { background: var(--bad); }
.clip.selected { border-color: var(--bad); }
.bulk-bar { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--bad); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; }
.bulk-bar[hidden] { display: none; }
.history .card { margin-top: 8px; }
.checks li { padding: 4px 0; } .checks .ok { color: var(--ok); } .checks .bad { color: var(--bad); }
/* grid children may shrink below their content's width instead of widening the page */
.grid > *, .two > *, .detail > *, .stats > *, .row > * { min-width: 0; }

/* past streams */
.badge { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--chip); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-2); font-weight: 700; flex: none; }
.vod-list { padding: 4px 0; }
.vod-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--text); border-bottom: 1px solid var(--line); }
.vod-row:last-child { border-bottom: 0; }
.vod-row:hover { background: var(--field); text-decoration: none; }
.vod-row img { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.vod-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vod-text strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.875rem; font-weight: 600; }
.chev { color: var(--muted); font-size: 1.375rem; line-height: 1; }
.vod-head h1 { font-size: 1.25rem; margin: 12px 0 8px; }
.vod-who { display: flex; align-items: center; gap: 12px; }
.vod-who img { width: 48px; height: 48px; border-radius: 50%; }
.vod-who strong, .vod-who span { display: block; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 16px 0; }
.facts div { background: var(--field); border-radius: 10px; padding: 10px 12px; }
.facts dt { color: var(--muted); font-size: 0.75rem; }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.vod-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.vod-actions button { padding: 10px 18px; }
.jump { padding-left: 20px; font-size: 0.875rem; }
.jump li { margin-bottom: 6px; }
.jump a { font-variant-numeric: tabular-nums; margin-right: 6px; }

/* settings: version and change log */
.settings-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.version { font-size: 0.8125rem; font-weight: 600; padding: 3px 10px; border: 1px solid var(--accent); border-radius: 999px; }
.release { border-top: 1px solid var(--line); padding: 10px 0; }
.release summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; list-style-position: outside; }
.release summary::-webkit-details-marker { display: none; }
.release summary::before { content: '›'; color: var(--muted); font-size: 1.25rem; line-height: 1; width: 12px; transition: transform .15s; }
.release[open] summary::before { transform: rotate(90deg); }
.rel-version { font-weight: 700; font-variant-numeric: tabular-nums; }
.rel-title { flex: 1; min-width: 140px; }
.release ul { list-style: none; padding: 0; margin: 10px 0 2px; }
.release li { padding: 4px 0; font-size: 0.875rem; display: flex; gap: 8px; align-items: baseline; }
.kind { flex: none; width: 70px; text-align: center; font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; padding: 1px 0; border-radius: 6px; }
.k-new { background: var(--accent-soft); color: var(--accent-2); }
.k-improved { background: var(--info-soft); color: var(--info); }
.k-fix { background: var(--warn-soft); color: var(--warn); }

/* clips tab: posting schedule */
.schedule h2 { margin: 0; }
.schedule h3 { margin: 16px 0 8px; font-size: 0.9375rem; color: var(--muted); font-weight: 600; }
.schedule-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.sched-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.sched-stats div { background: var(--field); border-radius: 10px; padding: 8px 10px; color: var(--muted); font-size: 0.75rem; line-height: 1.3; }
.sched-stats span { display: block; font-size: 1.375rem; font-weight: 700; color: var(--text); }
.post-list { display: flex; flex-direction: column; gap: 6px; }
.post-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: var(--field); color: var(--text); }
.post-row:hover { text-decoration: none; outline: 1px solid var(--accent); }
.post-thumb { width: 2.6rem; aspect-ratio: 9/16; border-radius: 6px; overflow: hidden; background: #000; flex: none; }
.post-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.post-text strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.875rem; font-weight: 600; }
.post-when { flex: none; display: flex; flex-direction: column; align-items: flex-end; text-align: right; line-height: 1.25; padding-left: 4px; }
.pw-day { font-size: 0.75rem; color: var(--muted); }
.pw-time { font-size: 1.125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pw-rel { font-size: 0.6875rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; margin-top: 2px; }
.post-when.up .pw-time { color: var(--accent-2); }
.post-when.up .pw-rel { background: var(--accent-soft); color: var(--accent-2); }
.post-when.done .pw-rel { background: var(--ok-soft); color: var(--ok); }
.post-flag { position: absolute; left: 6px; top: 6px; font-size: 0.6875rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; color: #fff; }
.post-flag.up { background: #6d43d9e6; } .post-flag.done { background: #1f8a5ae6; }

.get-app-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.get-app-card img { border-radius: 14px; flex: none; }
.get-app-card > div { flex: 1; min-width: 180px; }
.get-app-card h3 { margin: 0 0 2px; }
.get-app-card p { margin: 0; }
@media (max-width: 760px) { .get-app-card .button { flex: 1 1 100%; text-align: center; } }

/* settings: this device */
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.seg label { display: flex; align-items: center; gap: 6px; margin: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); font-size: 0.875rem; }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.seg input { width: auto; margin: 0; display: inline; }
.display-form.is-auto .custom-only { opacity: .5; pointer-events: none; }

/* clips tab: minimum score */
#approval h2 { margin-bottom: .4em; }
.quality { display: flex; flex-direction: column; gap: 10px; }
.q-head { display: flex; align-items: baseline; justify-content: space-between; }
.q-head label { margin: 0; font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.q-head output { font-size: 1.5rem; font-weight: 800; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.quality input[type=range] { width: 100%; padding: 0; border: 0; background: none; height: 26px; accent-color: var(--accent);
  -webkit-appearance: none; appearance: none; cursor: pointer; }
.quality input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill, 0%), var(--chip) var(--fill, 0%)); }
.quality input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--panel); box-shadow: 0 0 0 1px var(--accent); }
.quality input[type=range]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--chip); }
.quality input[type=range]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
.quality input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 3px solid var(--panel); }
.quality input[type=range]:focus { outline: none; }
.quality input[type=range]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--text); outline-offset: 2px; }
.q-presets button { padding: 5px 12px; border-radius: 999px; font-size: 0.8125rem; background: none; }
.q-presets button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.q-note { margin: 0; }
.q-note .link { padding: 0 0 0 4px; color: var(--accent-2); font-size: inherit; }
.q-help summary { cursor: pointer; }
.q-help p { margin: 6px 0 0; }
.grid .clip.below { display: none; }
.grid.show-below .clip.below { display: flex; opacity: .45; }
.grid.show-below .clip.below:hover { opacity: 1; }

/* ---------------- calendar ---------------- */
.cal-bar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 6px; }
.cal-title { flex: 1; margin: 0; font-size: 1.5rem; min-width: 10rem; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav .button { padding: 8px 14px; }
.cal-nav .button.icon { font-size: 1.25rem; line-height: 1; padding: 7px 14px 9px; }
.seg-links { display: inline-flex; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-links a, .seg-links button { padding: 6px 14px; border-radius: 8px; color: var(--muted); font-size: 0.875rem; border: 0; background: none; font-weight: 600; }
.seg-links a:hover, .seg-links button:hover { color: var(--text); text-decoration: none; background: none; }
.seg-links .on { background: var(--accent); color: #fff; }
.seg-links .on:hover { color: #fff; background: var(--accent); }
.small-seg a, .small-seg button { padding: 4px 10px; font-size: 0.8125rem; }
.cal-sub { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.count-badge { display: inline-grid; place-items: center; min-width: 1.45rem; height: 1.45rem; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 0.75rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }

/* clip chips (draggable) */
.cc { display: flex; align-items: center; gap: 8px; padding: 5px; padding-right: 4px; border-radius: 9px; background: var(--panel);
  border: 1px solid var(--line); cursor: pointer; min-width: 0; position: relative; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; touch-action: manipulation; }
.cc[data-drag] { cursor: grab; }
.cc:hover { border-color: var(--accent); }
.cc:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cc-scheduled { border-left: 3px solid var(--accent); }
.cc-posted { border-left: 3px solid var(--ok); opacity: .75; }
.cc-thumb { width: 1.75rem; aspect-ratio: 9/16; border-radius: 4px; overflow: hidden; background: #000; flex: none; }
.cc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.cc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cc-title { font-size: 0.75rem; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cc-sub { font-size: 0.6875rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-grip { color: var(--muted); font-size: 0.75rem; letter-spacing: -2px; flex: none; opacity: .6; padding: 0 2px; }
.cc-dragging { opacity: .3; }
.cc-ghost { position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; box-shadow: 0 12px 32px #0008; border-color: var(--accent); opacity: .95; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }

/* drop targets */
.slot { display: flex; gap: 6px; align-items: flex-start; padding: 4px; border-radius: 9px; min-width: 0; transition: background .12s, outline-color .12s; outline: 2px dashed transparent; outline-offset: -2px; }
.slot-time { flex: none; width: 2.6rem; font-size: 0.75rem; font-weight: 700; color: var(--muted); padding-top: 6px; font-variant-numeric: tabular-nums; }
.slot-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.slot-free { display: block; padding: 6px 8px; border: 1px dashed var(--line-strong); border-radius: 8px; color: var(--muted); font-size: 0.75rem; }
.slot.past { opacity: .55; }
.slot.past .slot-free { border-style: solid; border-color: transparent; }
.slot.unplanned .slot-time { color: var(--warn); }
body.is-dragging [data-drop-when].free .slot-free { border-color: var(--accent); color: var(--accent-2); }
body.is-dragging [data-drop-date] { outline: 1px dashed var(--line-strong); }
.drop-over, body.is-dragging .drop-over { background: var(--accent-soft); outline: 2px dashed var(--accent) !important; }
.slot-none { margin: 6px 4px; }

/* tray of clips waiting to be scheduled */
.tray { padding: 12px 14px; }
.tray-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
.tray-head h3 { margin: 0; font-size: 1rem; }
.tray-list { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.tray-list .cc { flex: none; width: 15rem; scroll-snap-align: start; }
.tray-list .cc-thumb { width: 2.4rem; }
.tray-list .cc-title { font-size: 0.8125rem; }

/* week */
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.wk-day { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; min-width: 0; display: flex; flex-direction: column; padding: 6px; min-height: 14rem; }
.wk-day.today { border-color: var(--accent); }
.wk-day.past { opacity: .7; }
.wk-head { display: flex; align-items: center; gap: 6px; padding: 4px 6px 8px; color: var(--text); }
.wk-head:hover { text-decoration: none; color: var(--accent-2); }
.wk-dow { font-size: 0.75rem; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: .04em; }
.wk-num { font-size: 1.25rem; font-weight: 800; flex: 1; }
.wk-day.today .wk-num { color: var(--accent-2); }
.wk-slots { display: flex; flex-direction: column; gap: 2px; flex: 1; }
/* narrow columns: stack the time above the clip */
.cal-week .slot { flex-direction: column; gap: 2px; }
.cal-week .slot-time { width: auto; padding: 0 2px; }
.cal-week .cc-grip { display: none; }
.cal-week .cc-sub { display: none; }

/* day */
.cal-day { padding: 14px; }
.day-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.day-head h2 { margin: 0; }
.day-head .muted { flex: 1 1 100%; }
.day-slots { display: flex; flex-direction: column; }
.day-slots .slot { padding: 8px 4px; border-bottom: 1px solid var(--line); border-radius: 0; }
.day-slots .slot:last-child { border-bottom: 0; }
.day-slots .slot-time { width: 3.6rem; font-size: 0.9375rem; color: var(--text); padding-top: 10px; }
.day-slots .cc { padding: 7px; }
.day-slots .cc-thumb { width: 2.6rem; }
.day-slots .cc-title { font-size: 0.875rem; }
.day-slots .cc-sub { font-size: 0.75rem; }
.day-slots .slot-free { padding: 12px; font-size: 0.8125rem; }

/* month */
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-bottom: 10px; }
.mo-dow { text-align: center; font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.mo-cell { min-height: 6.5rem; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; color: var(--text);
  display: flex; flex-direction: column; gap: 4px; }
.mo-cell:hover { border-color: var(--accent); text-decoration: none; }
.mo-cell.other { opacity: .4; }
.mo-cell.past .mo-num { color: var(--muted); }
.mo-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mo-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.mo-num { font-weight: 700; font-size: 0.9375rem; }
.mo-cell.today .mo-num { color: var(--accent-2); }
.mo-times { display: flex; flex-wrap: wrap; gap: 3px; }
.mo-t { font-size: 0.6875rem; font-weight: 700; padding: 1px 5px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-2); font-variant-numeric: tabular-nums; }
.mo-t.mo-posted { background: var(--ok-soft); color: var(--ok); }
.mo-more { font-size: 0.6875rem; color: var(--muted); }
.mo-dots { display: none; gap: 3px; justify-content: center; margin-top: auto; }
.mo-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.mo-dots i.mo-posted { background: var(--ok); }

/* posting plan */
.plan { margin-top: 8px; }
.plan-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.plan-head h2 { margin: 0; font-size: 1.25rem; }
.plan-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 6px; }
.plan-presets button { padding: 5px 12px; border-radius: 999px; font-size: 0.8125rem; }
.plan-days { display: flex; flex-direction: column; }
.plan-day { display: grid; grid-template-columns: 7rem auto 1fr auto; align-items: center; gap: 8px 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plan-day.off .pd-name { color: var(--muted); }
.pd-name { font-weight: 600; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { border: 0; border-radius: 0; padding: 6px 12px; font-size: 1.0625rem; line-height: 1; background: var(--chip); }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper output { min-width: 2rem; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.pd-times { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.pd-times input { width: auto; padding: 6px 8px; }
.pd-copy { font-size: 0.8125rem; color: var(--accent-2); padding: 4px; white-space: nowrap; }
.plan-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
#plan-dirty { color: var(--warn); }

/* sheet, toast, busy */
.sheet { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 0; width: min(26rem, calc(100vw - 24px)); }
.sheet::backdrop { background: #0009; }
.sheet-inner { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.sheet-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.sheet-head .link { padding: 0 4px; font-size: 1.125rem; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sheet-actions > * { flex: 1 1 auto; text-align: center; }
.sheet [hidden] { display: none !important; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1100; max-width: min(32rem, calc(100vw - 24px));
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 0.875rem; box-shadow: 0 8px 24px #0006; }
.busy { position: fixed; inset: 0; z-index: 1050; background: #0007; display: grid; place-items: center; }
.busy[hidden] { display: none; }
.busy span { background: var(--panel); border: 1px solid var(--line); padding: 14px 20px; border-radius: 12px; }

/* tablets and small laptops: week becomes a two-column list of days, too narrow for 7 */
@media (max-width: 1100px) {
  .cal-week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wk-day { min-height: 0; }
  .cal-week .slot { flex-direction: row; gap: 6px; }
  .cal-week .slot-time { width: 2.6rem; padding-top: 6px; }
  .cal-week .cc-sub { display: block; }
}
/* phones */
@media (max-width: 760px) {
  .cal-bar { gap: 8px; }
  .cal-title { order: -1; flex: 1 1 100%; font-size: 1.25rem; }
  .cal-nav { flex: 1; }
  .cal-week { grid-template-columns: 1fr; }
  .wk-day.past:not(.today) .wk-slots { display: none; }  /* days already gone shrink to a header */
  .wk-day.past:not(.today) .wk-head { padding-bottom: 4px; }
  .cal-week .cc-grip { display: block; }
  .tray-list .cc { width: 13rem; }
  .mo-cell { min-height: 3.6rem; padding: 4px; border-radius: 8px; align-items: center; }
  .mo-top { flex-direction: column; gap: 2px; }
  .mo-num { font-size: 0.875rem; }
  .mo-times { display: none; }
  .mo-dots { display: flex; }
  .count-badge { min-width: 1.2rem; height: 1.2rem; font-size: 0.6875rem; padding: 0 4px; }
  .mo-cell .count-badge { order: 2; }
  .plan-day { grid-template-columns: 1fr auto; }
  .pd-times { grid-column: 1 / -1; }
  .pd-times input { flex: 1 1 6.5rem; }
  .pd-copy { grid-column: 1 / -1; justify-self: start; padding-left: 0; }
  .plan-foot .primary { flex: 1; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .sheet { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}

/* settings: appearance */
.look-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.look-row .seg { margin: 0; }
.look-label { width: 9rem; flex: none; font-size: 0.875rem; font-weight: 600; }
.look-form .muted.small { margin: 12px 0 0; }
.look-form.nav-top .side-only { opacity: .5; pointer-events: none; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { margin: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--c); cursor: pointer; position: relative;
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px transparent; transition: box-shadow .15s; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.swatch:has(input:checked) { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--c); }
.swatch:has(input:checked)::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 800; }
.swatch:has(input:focus-visible) { outline: 2px solid var(--text); outline-offset: 4px; }
@media (max-width: 760px) { .pc-only { display: none; } .look-label { width: 100%; } }

/* subtitle editor */
.sub-lines { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; }
.sub-line { display: grid; grid-template-columns: auto 1fr; gap: 6px 8px; align-items: center; padding: 8px; background: var(--field); border-radius: 10px; }
.sub-line[hidden] { display: none; }
.sub-line .seek { padding: 4px 6px; font-size: 0.8125rem; color: var(--accent-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub-line .sub-text { width: 100%; min-width: 0; }
.sub-times { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; }
.sub-times input { width: 6.5em; padding: 6px 8px; }
.sub-times .del-line { margin-left: auto; padding: 4px 8px; }

/* clip view picked per device (Settings > This device) */
html[data-cols="2"] .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html[data-cols="3"] .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
html[data-cols="auto"] .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
html[data-cols="list"] .grid { grid-template-columns: 1fr; gap: 8px; }
html[data-cols="list"] .grid .clip { flex-direction: row; align-items: stretch; }
html[data-cols="list"] .grid .thumb { width: 6.5rem; flex: none; aspect-ratio: 9/16; }
html[data-cols="list"] .grid .thumb.wide { width: 9.5rem; aspect-ratio: 16/9; align-self: flex-start; margin: 8px 0 8px 8px; border-radius: 8px; overflow: hidden; }
html[data-cols="list"] .grid .meta { flex: 1; min-width: 0; padding: 10px 12px; font-size: 0.875rem; justify-content: center; }
html[data-cols="list"] .grid .meta strong { -webkit-line-clamp: 3; }
html[data-cols="list"] .clip .pick { right: 6px; top: auto; bottom: 6px; }
html[data-cols="list"] .clip .del-one { right: 6px; top: 6px; }
html[data-cols="list"] .grid .clip:has(.pick) .meta { padding-right: 44px; }
/* spacing */
html[data-density="compact"] main { padding-left: 10px; padding-right: 10px; }
html[data-density="compact"] .card { padding: 12px; margin-bottom: 12px; border-radius: 12px; }
html[data-density="compact"] .grid { gap: 8px; }
html[data-density="compact"] h1, html[data-density="compact"] h2 { margin-top: .9em; }

@media (max-width: 760px) {
  body { font-size: 0.9375rem; }
  main { padding: 14px 12px 24px; }
  /* bottom tab bar, like a phone app */
  body:has(.tabbar) { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .top { padding: 10px 14px; position: sticky; top: 0; z-index: 10; }
  .top nav.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; flex-wrap: nowrap; gap: 0; justify-content: space-around;
    background: var(--panel); border-top: 1px solid var(--line); padding: 4px 4px env(safe-area-inset-bottom); }
  .top nav.tabbar a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 2px; font-size: 0.6875rem; border-radius: 10px; white-space: nowrap; }
  .top nav.tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .top nav.tabbar a.on { background: none; color: var(--accent-2); }
  .top nav.tabbar a:hover { background: none; }
  .tabbar svg { display: block; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .logout .link { padding: 6px 4px; font-size: 0.8125rem; }
  input, select, textarea { font-size: max(16px, 1rem); } /* stops iPhone zooming in on focus */
  .detail, .two { grid-template-columns: 1fr; }
  .grid { gap: 10px; }
  .stat span { font-size: 1.3125rem; }
  .card { padding: 14px; }
  .inline input, .inline select { min-width: 0; flex: 1 1 100%; }
  .inline button { flex: 1 1 auto; }
  .inline .pill { flex: 1 1 auto; justify-content: center; white-space: nowrap; }
  .row > label { min-width: 0; flex: 1 1 140px; }
  .row > button, .publish > button { flex: 1 1 auto; }
  .card .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 10px; }
  h1 { font-size: 1.375rem; } h2 { font-size: 1.1875rem; }
  .vod-list { padding: 0; }
  .vod-row { padding: 12px; }
}
