:root {
  --bg: #0d0d12;
  --panel: #16161d;
  --panel-2: #1e1e27;
  --panel-3: #262632;
  --line: #2d2d3a;
  --text: #ececf2;
  --muted: #9b9bad;
  --faint: #6c6c80;
  --accent: #9a6bff;
  --accent-strong: #7c4dff;
  --ok: #3ddc97;
  --warn: #ffb547;
  --err: #ff5c6c;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
code, kbd {
  font: 12px/1 ui-monospace, "Cascadia Mono", Consolas, monospace;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 5px;
}
a { color: var(--accent); }
.muted { color: var(--muted); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.spacer { flex: 1; }

button, .btnlink {
  font: inherit;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .btnlink:hover { border-color: #44445a; background: #2d2d3b; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent-strong); border-color: var(--accent-strong); font-weight: 600; }
button.primary:hover { background: var(--accent); }
button.ghost, .btnlink.ghost { background: transparent; }
button.small, .btnlink.small { padding: 4px 9px; font-size: 12.5px; }
button.wide { width: 100%; padding: 10px; margin-top: 6px; }
button.danger { color: var(--err); }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent-strong); outline-offset: -1px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent-strong); width: 15px; height: 15px; margin: 0; }
input[type=range] { accent-color: var(--accent-strong); padding: 0; width: 100%; background: none; border: 0; }
input.num { width: 70px; }

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: .2px;
  color: inherit; text-decoration: none; }
.brand:hover span { text-decoration: underline; text-underline-offset: 3px; }
.brand img { width: 24px; height: 24px; }
#sessionSelect { max-width: 320px; }
.tabs { display: flex; gap: 4px; background: var(--panel-2); border-radius: 9px; padding: 3px; }
.tabs button { border: 0; background: transparent; padding: 5px 14px; border-radius: 7px; color: var(--muted); }
.tabs button.active { background: var(--panel-3); color: var(--text); }
.guestbar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 7px 16px;
  background: rgba(255, 181, 71, .1); border-bottom: 1px solid rgba(255, 181, 71, .35); color: var(--muted); font-size: 13px; }
.guestbar b { color: var(--warn); }
.userbox { display: flex; align-items: center; gap: 8px; max-width: 280px; min-width: 0; color: var(--muted); font-size: 13px; }
.userbox img { width: 24px; height: 24px; border-radius: 50%; background: var(--panel-3); flex: none; }

main { flex: 1; min-height: 0; overflow: auto; }

/* ---- home ---- */
/* Wide screens: the search and recent sessions in the middle (where the page always was), starting to tag in a
   column on its left and who it's for on its right, both level with the search bar */
.home { margin: 0 auto; padding: 48px 16px 64px; display: grid; align-items: start; column-gap: 28px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 860px) minmax(0, 1fr); grid-template-rows: auto auto 1fr;
  grid-template-areas: ". head ." "start find pitch" "start recent pitch"; }
.home-head { grid-area: head; }
.home > .find { grid-area: find; justify-self: center; width: min(100%, 460px); } /* shorter than the rows below */
.home > .start-cards { grid-area: start; justify-self: end; width: 100%; max-width: 280px; grid-template-columns: 1fr;
  margin-top: 18px; }
.home-recent { grid-area: recent; min-width: 0; }
.home > .pitch { grid-area: pitch; justify-self: start; width: 100%; max-width: 280px; display: flex; flex-direction: column;
  margin-top: 18px; }
@media (max-width: 1440px) { /* not enough room beside it: one column, search, starting to tag, recent, who it's for */
  .home { max-width: 892px; grid-template-columns: minmax(0, 1fr); grid-template-rows: none;
    grid-template-areas: "head" "find" "start" "recent" "pitch"; }
  .home > .start-cards { max-width: none; justify-self: stretch; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    margin-top: 14px; }
  .home > .pitch { display: grid; max-width: none; justify-self: stretch; margin-top: 34px; }
}
.home h1 { font-size: 30px; line-height: 1.2; }
.home h1 span { color: var(--muted); font-weight: 500; }
.lede { color: var(--muted); max-width: 680px; margin: 14px 0 28px; font-size: 15px; }
/* Who it's for: the streamer who gets the recap, and the viewers who build it */
.pitch { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.pitch > div { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 10px 14px; }
.pitch b { font-size: 14px; }
.pitch p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.start-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card > button { margin-top: auto; } /* cards in a row line their buttons up */
.card-note { margin: 0; color: var(--muted); font-size: 13px; }
.section-title { margin: 34px 0 10px; color: var(--muted); font-weight: 600; }
.recent { display: flex; flex-direction: column; gap: 6px; }
.recent-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
  cursor: pointer; text-align: left;
}
.recent-row:hover { border-color: #44445a; }
.recent-row .when { color: var(--faint); font-size: 12.5px; margin-left: auto; }
.pill { font-size: 11.5px; padding: 2px 7px; border-radius: 99px; background: var(--panel-3); color: var(--muted); }
.pill.live { background: rgba(255, 92, 108, .15); color: var(--err); }
.pill.coll { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

/* ---- collections: parts of the plan view only a collection has, and parts it hasn't ---- */
body:not(.in-coll) .coll-only, body.in-coll .plain-only { display: none !important; }
.coll-head { display: flex; align-items: center; gap: 14px; }
.coll-title {
  font-size: 20px; font-weight: 650; line-height: 1.2; color: var(--text);
  background: transparent; border-color: transparent; padding: 4px 8px; margin-left: -8px; width: min(420px, 45%);
}
.coll-title:hover { border-color: var(--line); }
#collSummary { flex: 1; }
.coll-sources { display: flex; flex-direction: column; gap: 6px; }
.cs-row { display: flex; align-items: center; gap: 8px; font-size: 13px; background: var(--panel-2); border-radius: 8px; padding: 6px 9px; }
.cs-row b { white-space: nowrap; }
.cs-row .muted { flex: 1; }
.cs-row.missing { background: rgba(255, 181, 71, .08); }
.cs-row.missing .muted { color: #ffd79a; }
.cf-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; }
.cf-streams, .cf-filters { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cf-dates { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.cf-dates input { padding: 5px 8px; }
.cf-presets { display: flex; gap: 4px; }
.cf-list { display: flex; flex-direction: column; gap: 4px; max-height: min(330px, 40vh); overflow: auto; }
.cf-row {
  display: grid; grid-template-columns: auto 50px minmax(0, auto) minmax(0, 1fr) auto auto; align-items: center; gap: 8px;
  padding: 6px 9px; border-radius: 8px; background: var(--panel-2); border: 1px solid transparent; cursor: pointer; font-size: 13px;
}
.cf-row:hover { border-color: var(--line); }
.cf-row.on { background: color-mix(in srgb, var(--accent) 12%, var(--panel-2)); }
.cf-day { color: var(--muted); font-variant-numeric: tabular-nums; }
.cf-n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.cf-warn { color: var(--warn); font-size: 12px; }
.cf-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
.cf-chip {
  --c: var(--accent);
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; cursor: pointer; font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); color: var(--muted);
}
.cf-chip.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--text); }
.cf-chip.none { opacity: .5; }
.cf-chip input { accent-color: var(--c); }
.cf-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
@media (max-width: 760px) { .cf-grid { grid-template-columns: 1fr; } .coll-head { flex-wrap: wrap; } .coll-title { width: 100%; } }

/* ---- watch ---- */
.watch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  padding: 14px 16px;
  min-height: 100%;
}
.stage { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
/* Twitch's embed rules: a player is at least 400×300 (narrower than 16:9 on small screens: Twitch letterboxes it).
   Players are as wide as their column, said outright: left to the 16:9 shape, Safari's engine (every iPhone
   browser's) widens a player held at 300 tall to 533, past a phone's edge or under the buttons beside it */
.player-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 260px);
  min-height: 300px;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}
#player, #player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-hidden {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 6px; padding: 24px; text-align: center; background: var(--panel); color: var(--muted);
}
.player-hidden b { color: var(--text); }
.player-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); padding: 20px; text-align: center; }

.banner {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 9px 12px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.banner.warn { background: rgba(255, 181, 71, .08); border-color: rgba(255, 181, 71, .35); color: #ffd79a; }

.streambar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 12px;
}
.sb-main { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 220px; }
.sb-stats { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; color: var(--muted); }
.sb-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
#wClock { font-size: 22px; line-height: 1; }
.sb-actions { display: flex; gap: 6px; align-items: center; }
.srcswitch { display: inline-flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--panel-2); }
.srcswitch button { border: 0; background: transparent; color: var(--muted); padding: 3px 11px; }
.srcswitch button.on { background: var(--panel-3); color: var(--text); }
.vod-ask { display: flex; gap: 6px; width: min(460px, 100%); margin: 4px 0; }
.vod-ask input { flex: 1; min-width: 0; }
.game { display: flex; align-items: center; gap: 6px; }
.game input { width: 150px; padding: 4px 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.live { background: var(--err); box-shadow: 0 0 0 3px rgba(255, 92, 108, .2); }
.dot.vod { background: var(--accent); }

.mini { position: relative; height: 34px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }

.pad, .pad-buttons, .pad-tags { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.tagpad { display: flex; flex-direction: column; gap: 6px; }
.tp-row {
  --c: var(--accent);
  display: flex; align-items: stretch; gap: 5px;
  padding: 5px; border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  background: color-mix(in srgb, var(--c) 10%, var(--panel));
}
.tp-label { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 2px 6px; line-height: 1.25; }
.tp-label .name { font-weight: 650; font-size: 14.5px; }
.tp-label .count { color: var(--muted); font-size: 11.5px; }
.tp-opt {
  width: 66px; padding: 7px 4px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  background: color-mix(in srgb, var(--c) 18%, var(--panel-2));
  font-weight: 650; font-variant-numeric: tabular-nums;
}
.tp-opt:hover { background: color-mix(in srgb, var(--c) 32%, var(--panel-2)); border-color: var(--c); }
.tp-opt kbd { font-size: 10.5px; padding: 1px 4px; font-weight: 400; }
.tp-opt.flash { animation: flash .45s ease-out; }
@keyframes flash { from { background: var(--c); color: #111; } }
.keep {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 12px; border-radius: 10px; border-style: dashed;
}
.keep.on { border-style: solid; border-color: var(--ok); background: rgba(61, 220, 151, .12); color: var(--ok); }
.hint { margin: 0; color: var(--faint); font-size: 12.5px; }
.pad-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.taglist {
  position: relative; /* its rows' offsetTop are within it: a new tag scrolls the list, never the page (renderTagList) */
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px;
  overflow: auto; max-height: calc(100vh - 470px); min-height: 120px;
}
.tagrow {
  flex: none;
  display: grid; grid-template-columns: 4px 74px 1fr auto auto; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 5px 6px 5px 0;
  overflow: hidden;
}
.tagrow .bar { align-self: stretch; background: var(--c); }
.tagrow .meta { display: flex; flex-direction: column; line-height: 1.2; }
.tagrow .meta b { font-size: 12.5px; }
.tagrow .meta span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tagrow .clip { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tagrow.fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh { from { background: color-mix(in srgb, var(--c) 30%, var(--panel)); } }
.tagrow input { padding: 4px 7px; font-size: 12.5px; background: transparent; border-color: transparent; }
.tagrow input:hover, .tagrow input:focus { border-color: var(--line); background: var(--panel-2); }
.tagrow .x { border: 0; background: transparent; color: var(--faint); padding: 2px 6px; }
.tagrow .x:hover { color: var(--err); }
.tagrow .pen, .tagrow .note-text { display: none; } /* a phone's: the note box doesn't fit, ✎ asks for the note */
.empty { color: var(--faint); padding: 14px 4px; text-align: center; font-size: 13px; }

/* ---- timeline (shared by the mini strip and the plan view) ---- */
.timeline {
  position: relative; overflow-x: auto; overflow-y: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); height: 92px;
}
.tl-inner { position: relative; height: 100%; min-width: 100%; }
.tl-tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid #23232e; font-size: 10.5px; color: var(--faint); padding: 2px 4px; }
.tl-seg {
  position: absolute; top: 26px; bottom: 16px; min-width: 3px; border-radius: 4px;
  background: color-mix(in srgb, var(--c) 45%, transparent); border: 1px solid var(--c); cursor: pointer;
}
.tl-seg:hover, .tl-seg.sel { background: color-mix(in srgb, var(--c) 70%, transparent); }
.tl-seg.pending { background: repeating-linear-gradient(90deg, color-mix(in srgb, var(--c) 35%, transparent) 0 5px, transparent 5px 9px); }
.tl-seg.ghost { --c: #55556a; border-style: dashed; background: transparent; }
.tl-tag { position: absolute; bottom: 4px; width: 2px; height: 10px; border-radius: 1px; margin-left: -1px; }
.tl-src { /* a collection's timeline: where each stream's clips begin */
  position: absolute; top: 0; bottom: 0; border-left: 1px solid #4a4a60; padding: 2px 5px;
  font-size: 10.5px; color: var(--muted); white-space: nowrap; pointer-events: none;
}
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--err); }
.tl-now::after { content: "LIVE"; position: absolute; top: 2px; left: 4px; font-size: 9.5px; color: var(--err); font-weight: 700; }
.mini .tl-tick { display: none; }
.mini .tl-seg { top: 7px; bottom: 13px; }
.mini .tl-tag { bottom: 3px; height: 7px; }
.mini .tl-now::after { content: none; }

/* ---- plan ---- */
.plan { padding: 14px 16px 40px; display: flex; flex-direction: column; gap: 12px; }
.plan-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.stats { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); flex: 1; }
.stats b { color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; }
.inline { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.inline input[type=range] { width: 140px; }
.plan-body { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.seglist { display: flex; flex-direction: column; gap: 8px; }
.seg {
  --c: var(--accent);
  display: grid; grid-template-columns: 46px 1fr; gap: 4px 12px;
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c);
  border-radius: 9px; padding: 10px 12px;
}
.seg.sel { border-color: var(--c); }
.seg.pending { opacity: .75; }
.seg.ghost { --c: #55556a; opacity: .7; }
.seg .num { grid-row: span 4; font-size: 20px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.seg > :not(.num) { grid-column: 2; }
.seg .line1 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.seg .range { font-weight: 600; font-variant-numeric: tabular-nums; }
.seg .from { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--panel-3); color: var(--muted); }
.seg .dur { color: var(--muted); font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: color-mix(in srgb, var(--c) 18%, transparent); color: color-mix(in srgb, var(--c) 80%, white); }
.chip.wait { --c: var(--warn); }
.notes { color: var(--muted); font-size: 13px; font-style: italic; }
.seg .actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.seg .actions .grp { display: inline-flex; align-items: center; gap: 4px; color: var(--faint); font-size: 12px; margin-right: 6px; }
.subhead { margin: 14px 0 2px; color: var(--muted); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 10px; }

.plan-side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.slider { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.slider output { color: var(--text); font-weight: 600; margin-left: 4px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }
.offsetrow { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.offsetrow b { min-width: 34px; text-align: center; color: var(--text); }
.field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.field.inline { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; }
.help { margin: -4px 0 0; color: var(--faint); font-size: 12px; }

/* ---- dialogs ---- */
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
  padding: 0; width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 40px);
}
dialog.wide { width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlg { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg p { margin: 0; color: var(--muted); }
.dlg-title { display: flex; justify-content: space-between; align-items: center; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.preview-box { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 300px; background: #000; border-radius: 9px; overflow: hidden; }
.preview-box > div, .preview-box iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.preview-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pv-ads { margin: 8px 0 0; font-size: 11.5px; color: var(--faint); }
/* The recap window's foot: the note on ads and, for the channel's owner alone, a small </> that copies the code for
   their agent, with a ? that says what it is on hover (a tap, on a touch screen). Kept quiet on purpose. */
.pv-foot { display: flex; align-items: flex-end; gap: 12px; }
.pv-foot .pv-ads { flex: 1; }
.pv-agent { display: flex; align-items: center; gap: 6px; flex: none; }
.pv-agent .pv-agent-btn { padding: 0 5px; font: 600 10.5px/16px ui-monospace, Consolas, monospace; color: var(--faint); }
.pv-agent .pv-agent-btn:hover { color: var(--muted); }
.pv-agent-info { position: relative; display: grid; place-items: center; width: 15px; height: 15px; border: 1px solid var(--line);
  border-radius: 50%; font-size: 10px; font-weight: 700; line-height: 1; color: var(--faint); cursor: help; }
.pv-agent-info:hover, .pv-agent-info:focus-visible { color: var(--muted); }
.pv-agent-pop { display: none; position: absolute; right: -4px; bottom: calc(100% + 8px); z-index: 5; width: min(340px, 78vw);
  padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5); font-size: 12.5px; font-weight: 400; line-height: 1.5; color: var(--muted);
  text-align: left; cursor: auto; }
.pv-agent-info:is(:hover, :focus, .open) .pv-agent-pop { display: block; }
.pv-agent-pop b { display: block; margin-bottom: 6px; color: var(--text); }
.pv-agent-pop p { margin: 0 0 6px; color: var(--muted); }
.pv-agent-pop p:last-child { margin-bottom: 0; }
.copy-text { width: 100%; height: min(320px, 50vh); resize: vertical; font: 12px/1.45 ui-monospace, Consolas, monospace; white-space: pre; }
#previewTitle { font-variant-numeric: tabular-nums; }
.pv-dur { color: var(--muted); font-weight: 500; margin-left: 6px; }
.pv-trim { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 6px 10px; }
.pv-trim > button { justify-self: start; }
.pv-label { color: var(--muted); font-size: 13px; }
.pv-steps { display: flex; flex-wrap: wrap; gap: 4px; }
.pv-gap { width: 6px; }
#pvNote { font-size: 13px; }
#previewDialog:not(.comp) .pv-comp { display: none; }
.pv-comp { display: flex; flex-direction: column; gap: 8px; }
/* Zoomed in (#cpZoom), the bar is wider than the window and scrolls inside .cp-scroll */
.cp-scroll { overflow-x: auto; overflow-y: hidden; border-radius: 5px; scrollbar-width: thin; }
.cp-bar { position: relative; display: flex; height: 18px; min-width: 100%; border-radius: 5px; overflow: hidden; background: var(--panel-2); cursor: pointer; }
.cb-seg { --c: var(--accent); min-width: 0; background: color-mix(in srgb, var(--c) 40%, transparent); box-shadow: inset -1px 0 var(--panel); }
.cb-seg.on { background: color-mix(in srgb, var(--c) 85%, transparent); }
.cb-head { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text); pointer-events: none; }
.cp-row { display: flex; align-items: center; gap: 8px; }
.cp-now { flex: 1; font-variant-numeric: tabular-nums; }
.cp-time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.cp-zoom input[type=range] { width: 90px; }
.cp-games { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cp-games button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, transparent); }
/* The compilation gets a bigger window than a segment's preview, its controls scaled up to match (--cz), and only
   as wide as keeps the 16:9 player and everything under it on screen (224px: the controls' height unscaled, with
   room for the bar's scrollbar when it's zoomed in). */
#previewDialog.comp {
  --cz: 1.4;
  width: min(calc(100vw - 24px), max(860px, 48vw), calc((100vh - 124px - var(--cz) * 224px) * 16 / 9 + 40px));
}
#previewDialog.comp :is(.dlg-title, .pv-comp, .pv-trim, .preview-actions) { zoom: var(--cz); }
@media (max-height: 1050px) { #previewDialog.comp { --cz: 1.15; } }
@media (max-height: 800px) { #previewDialog.comp { --cz: 1; } }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 26px; }
.settings section { display: flex; flex-direction: column; gap: 9px; }
.settings section:first-child { grid-column: span 2; }
.account-actions { display: flex; gap: 8px; flex-wrap: wrap; }
table.types { border-collapse: collapse; width: 100%; }
table.types th { text-align: left; font-weight: 500; color: var(--faint); font-size: 12px; padding: 0 6px 4px 0; }
table.types td { padding: 3px 6px 3px 0; }
table.types input { width: 100%; padding: 5px 7px; }
table.types input[type=color] { padding: 2px; height: 31px; width: 44px; }
table.types th:nth-child(2), table.types .c { width: 56px; }
.types-wrap { overflow-x: auto; }
table.types td:first-child input { min-width: 100px; }
.optf { display: flex; align-items: center; gap: 4px; }
.optf label { display: flex; align-items: center; gap: 2px; color: var(--faint); }
table.types .optf input { width: 46px; padding: 5px 6px; }
table.types .optf .ok { width: 36px; text-transform: uppercase; }
table.types.keys .optf { gap: 8px; }
table.types.keys .win { color: var(--muted); font-size: 12.5px; min-width: 48px; font-variant-numeric: tabular-nums; }
.ct-actions { display: flex; gap: 8px; margin: 8px 0 4px; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--panel-3); border: 1px solid var(--line); color: var(--text);
  padding: 9px 16px; border-radius: 9px; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); z-index: 50; max-width: calc(100vw - 32px);
}
.toast.err { border-color: var(--err); color: #ffc2c8; }
.toast button { margin-left: 8px; }

/* ---- privacy and terms ---- */
.doc { max-width: 760px; margin: 0 auto; padding: 28px 16px 48px; line-height: 1.6; }
.doc h1 { margin: 0 0 8px; font-size: 28px; }
.doc h2 { margin: 26px 0 6px; font-size: 17px; }
.doc ul { padding-left: 20px; margin: 6px 0; }
.doc li { margin: 4px 0; }
.doc code { font-size: 12.5px; background: var(--panel-3); padding: 1px 5px; border-radius: 5px; }
.doc .lede { color: var(--muted); }
.sitefoot { text-align: center; padding: 18px 16px 26px; font-size: 12.5px; }
.sitefoot a { color: var(--faint); }
.sitefoot a:hover { color: var(--muted); }

/* ---- a channel's community page ---- */
.find { display: flex; gap: 8px; margin: 18px 0 6px; }
.find input { flex: 1; }
/* The calendar on the left, level with the leaderboard on the right: the name and its buttons sit above them both */
.community { max-width: 1480px; margin: 0 auto; padding: 24px 16px 48px; display: grid; align-items: start;
  grid-template-columns: 250px minmax(0, 1fr); grid-template-areas: ". head" "cal body"; column-gap: 24px; }
.community > .cm-head { grid-area: head; }
.community > .cm-cal { grid-area: cal; }
.community > .cm-body { grid-area: body; }
/* The channel's broadcasts by day: pick a day, then one of its broadcasts */
.cm-cal { position: sticky; top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.cal-head button { padding: 2px 10px; font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { font-size: 11px; color: var(--faint); text-align: center; padding: 2px 0 4px; }
.cal-day { position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; padding: 0;
  border-radius: 8px; border: 1px solid transparent; font-size: 13px; color: var(--faint); font-variant-numeric: tabular-nums; }
button.cal-day { color: var(--text); background: var(--panel-2); cursor: pointer; }
button.cal-day:hover { border-color: #44445a; }
.cal-day.today { border-color: var(--muted); font-weight: 700; }
.cal-day.sel, button.cal-day.sel:hover { background: var(--accent-strong); border-color: var(--accent); color: #fff; }
.cm-day { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
/* The broadcast on show, live or its VOD: Twitch's player, at least 400×300 and never covered */
.cm-player { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 300px; max-height: 62vh; margin: 2px 0 12px;
  background: #000; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
#cmPlayer, #cmPlayer iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.cm-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.cm-head h1 { margin: 0 0 4px; font-size: 28px; }
.cm-head p { margin: 0; }
.cm-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cm-types { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; font-size: 12.5px; }
.cm-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 22px; align-items: start; }
.cm-bc { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.cm-bc select { max-width: 460px; }
.heat { position: relative; height: 58px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.heat-cell { position: absolute; top: 16px; bottom: 12px; background: #ff7a45; }
.heat-hot { position: absolute; top: 16px; bottom: 12px; border: 2px solid #ffd166; border-radius: 3px; box-sizing: border-box; }
.heat-pick { position: absolute; bottom: 3px; height: 5px; background: var(--accent); border-radius: 3px; }
.heat-tick { position: absolute; top: 1px; font-size: 10.5px; color: var(--faint); transform: translateX(-50%); pointer-events: none; }
.cm-legend { font-size: 12px; margin: 6px 0 18px; }
.cm-main h3, .cm-side h3 { margin: 0 0 10px; }
.cm-recap-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.cm-recap-head h3 { margin: 0; }
/* A community recap in the preview window is watch-only: no trimming, splitting, removing or undo. */
#previewDialog.readonly .pv-steps, #previewDialog.readonly .pv-trim .pv-label, #previewDialog.readonly #pvSplit,
#previewDialog.readonly #pvSkip, #previewDialog.readonly #pvUndo, #previewDialog.readonly #pvShiftWrap { display: none; }
.cm-recap { display: flex; flex-direction: column; gap: 6px; }
.chip.refined { --c: #3ddc97; }
.board-row img, .board-row .noavatar { width: 22px; height: 22px; border-radius: 50%; background: var(--panel-3); flex: none; }
/* The recap's contributors, right under its heading: names only, A to Z, as a paragraph. Past a few lines the
   names scroll, and roll by themselves, slowly, like a film's credits; the edges fade, so names glide in and out */
.cm-credits-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cm-credits-head { text-align: center; padding-top: 12px; }
.cm-credits-about { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.cm-credits-names { max-height: 176px; overflow-y: auto; padding: 8px 18px 12px; text-align: center; font-size: 14.5px; line-height: 1.95;
  -webkit-mask-image: linear-gradient(transparent, #000 12px, #000 calc(100% - 12px), transparent);
  mask-image: linear-gradient(transparent, #000 12px, #000 calc(100% - 12px), transparent); }
.cm-credits-names .cr-name { white-space: nowrap; font-weight: 600; }
.cm-credits-names .cr-name.you { color: var(--accent); font-weight: 800; }
.cm-credits-names .cr-sep { color: var(--faint); }
/* Who made the recap clip playing in the preview window: their name big and bold, so the credit is easy to see */
.by-label { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.pv-credit { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; }
.pv-credit-who { display: flex; align-items: center; gap: 10px; }
.pv-credit img, .pv-credit .noavatar { width: 34px; height: 34px; border-radius: 50%; background: var(--panel-3); flex: none;
  display: grid; place-items: center; font-size: 15px; font-weight: 700; color: var(--muted); }
.pv-credit b { color: var(--text); font-weight: 800; font-size: 22px; }
.cm-side { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
/* Its heading: which board is on show (all time, this broadcast, the last 7 days), and the arrows that switch */
.cm-board-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cm-side .cm-board-head h3 { margin: 0 0 2px; }
.cm-board-name { color: var(--accent); }
.cm-board-arrows { display: flex; gap: 4px; flex: none; }
.cm-board-arrows button { padding: 2px 10px; font-size: 16px; }
.board { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.board-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px; }
.board-row.you { background: var(--panel-3); }
.board-row .rank { width: 22px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.board-row .name { flex: 1; }
.board-row .score { font-weight: 700; font-variant-numeric: tabular-nums; }
/* The streamer's tools: picked taggers shown on their own, the tagger search, tick boxes and thumbs */
.cm-pickbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 12px;
  margin-bottom: 10px; font-size: 13px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.heat.lanes .lane-seg { position: absolute; height: 8px; border-radius: 3px; }
.lane-key { display: inline-flex; align-items: center; gap: 5px; margin-right: 12px; }
.lane-key i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cm-find { margin-bottom: 10px; }
.cm-find input { width: 100%; margin-bottom: 4px; }
.cm-find .board { margin-bottom: 0; }
.board-row input[type=checkbox] { flex: none; }
.board-row.picked { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.board-row .votes { display: flex; gap: 2px; }
.board-row .vote { padding: 1px 5px; font-size: 13px; background: transparent; border-color: transparent; opacity: .45; }
.board-row .vote:hover { opacity: .8; }
.board-row .vote.on { opacity: 1; border-color: var(--line); background: var(--panel-3); }
@media (max-width: 860px) { .cm-body { grid-template-columns: 1fr; } }
/* Narrower screens: one column. The channel's name with Tag this broadcast on its right, its tag types under it;
   then the broadcast (its menu, the player, the heat map under it, the recap); then the calendar; then the board. */
@media (max-width: 1100px) {
  .community { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "main" "cal" "side"; row-gap: 22px; }
  .community > .cm-body { display: contents; }
  .cm-main { grid-area: main; min-width: 0; }
  .cm-side { grid-area: side; }
  .cm-cal { position: static; max-width: 360px; }
  .cm-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; margin-bottom: 0;
    grid-template-areas: "name actions" "chips chips"; }
  .cm-who { display: contents; }
  .cm-head h1 { grid-area: name; }
  #cmTypeChips { grid-area: chips; }
  .cm-head-actions { grid-area: actions; }
  .cm-bc label.inline { display: flex; align-items: center; gap: 8px; flex: 1 1 100%; min-width: 0; }
  .cm-bc select { flex: 1 1 auto; min-width: 0; max-width: 100%; } /* a long stream title stays on the screen */
}

@media (max-width: 980px) {
  .watch, .plan-body { grid-template-columns: 1fr; }
  .plan-side { position: static; }
  .taglist { max-height: 340px; }
  .settings { grid-template-columns: 1fr; }
  .settings section:first-child { grid-column: auto; }
}
/* Watch & tag in one column: right under the player, the tag buttons with the tags made beside them (as tall as
   the buttons, scrolling), then the stream's details and the timeline (the stage's parts laid out around the pad) */
@media (max-width: 980px) and (min-height: 501px) {
  .watch { display: flex; flex-direction: column; gap: 10px; }
  .watch > .stage { display: contents; }
  .watch .player-box { order: 1; }
  .watch .banner { order: 2; }
  .watch > .pad { order: 3; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .watch .pad-tags { contain: size; } /* the buttons set the row's height; the list fills it and scrolls */
  .watch .taglist { flex: 1; max-height: none; min-height: 0; }
  .watch .streambar { order: 4; }
  .watch .mini { order: 5; }
}
/* A phone on its side: the buttons beside the player, both on screen at once (296: Twitch's player gets its 400
   inside the box's border on a common phone) */
@media (max-width: 980px) and (max-height: 500px) {
  .watch { grid-template-columns: minmax(0, 1fr) 296px; }
}
/* Phones, upright or on their side: the page scrolls as a whole (the browser's own bars can tuck away as it does),
   and the top bar is compact: the logo, the menu of pages, your picture and Settings in a row, the tabs under them.
   Sign out is in Settings. */
@media (max-width: 700px), (max-height: 500px) {
  html, body { height: auto; }
  body { display: block; }
  main { overflow: visible; }
  .wide-only { display: none; }
  .topbar { gap: 8px; padding: 6px 10px; }
  .brand span, .topbar .spacer, #userName, #signOutBtn { display: none; }
  #sessionSelect { flex: 1 1 0; max-width: none; padding: 5px 8px; font-size: 13px; }
  .tabs button { padding: 5px 10px; }
  #settingsBtn, #signInBtn { padding: 5px 9px; font-size: 13px; }
  .guestbar { gap: 8px; padding: 5px 10px; font-size: 12px; }
  .watch { padding: 10px; }
}
@media (max-width: 700px) { /* upright: the tabs get a row of their own (on its side, a phone has room in the top one) */
  .tabs { order: 10; flex: 1 1 100%; }
  .tabs button { flex: 1; padding: 5px 8px; }
}
/* Touch screens: no keyboard, so no key hints; buttons big enough for a thumb */
@media (hover: none) and (pointer: coarse) {
  .tp-opt kbd, .keep kbd, #padHint { display: none; }
  .tp-opt { min-height: 44px; justify-content: center; }
}
/* An upright phone: the buttons and the tags made each get half the width. A tag type's name sits over its three
   buttons; a tag is its type and time (and note), ✎ to write the note, × to delete it */
@media (max-width: 700px) and (min-height: 501px) {
  .tagpad { gap: 5px; }
  .tp-row { flex-wrap: wrap; gap: 4px; padding: 4px; }
  .tp-label { flex: 1 1 100%; flex-direction: row; align-items: baseline; gap: 6px; padding: 0 3px; }
  .tp-label .name { font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tp-label .count { flex: none; margin-left: auto; font-size: 11px; }
  .tp-opt { flex: 1 1 0; width: auto; min-width: 0; min-height: 40px; padding: 5px 2px; font-size: 13px; justify-content: center; }
  .keep { padding: 8px 10px; font-size: 13px; }
  .pad-head h3 { font-size: 13px; }
  .tagrow { grid-template-columns: 3px minmax(0, 1fr) auto auto; gap: 4px; padding: 3px 0; border-radius: 7px; }
  .tagrow input, .tagrow .clip { display: none; }
  .tagrow .pen { display: block; }
  .tagrow .meta b { font-size: 12px; }
  .tagrow .meta span { font-size: 11px; }
  .tagrow .note-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: italic; }
  .tagrow .x, .tagrow .pen { border: 0; background: transparent; color: var(--faint); padding: 6px 5px; font-size: 14px; }
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.player-box, .cm-player { min-height: calc(300px + 2px * var(--fit, 1)); } /* the frame inside the border: 300 */
/* A phone held upright is laid out 559 to 570 pixels wide (the script in index.html sets --fit), so Twitch's players
   can be a true 16:9 of at least 534×300 at the screen's width. Everything else is drawn --fit times larger, so it
   looks as it would at the phone's own width; the players stay at the page's own scale (their zoom undoes body's),
   and the messages shown in a player's place are drawn larger like everything else. Only at this layout width, so a
   phone showing the desktop site (which ignores the viewport tag) isn't zoomed; in a narrow window --fit is 1. */
@media (min-width: 540px) and (max-width: 700px) {
  body { zoom: var(--fit, 1); }
  .player-box, .preview-box, .cm-player { zoom: calc(1 / var(--fit, 1)); }
  .player-box, .cm-player { border-width: calc(1px * var(--fit, 1)); }
  .player-box { border-radius: calc(var(--radius) * var(--fit, 1)); }
  .cm-player { border-radius: calc(10px * var(--fit, 1)); }
  .preview-box { border-radius: calc(9px * var(--fit, 1)); }
  .player-box > .player-hidden, .player-box .player-msg { zoom: var(--fit, 1); }
  .player-box:has(> .player-hidden:not([hidden])) { min-height: calc(300px * var(--fit, 1)); }
  /* the community page's and the preview's players as wide as Watch & tag's */
  .cm-player { margin-inline: calc(-6px * var(--fit, 1)); width: calc(100% + 12px * var(--fit, 1)); }
  dialog.wide, #previewDialog.comp { width: 100%; max-width: 100%; --cz: 1; }
  .preview-box { margin-inline: calc(-20px * var(--fit, 1)); width: calc(100% + 40px * var(--fit, 1)); }
}
