:root {
  --black: #000;
  --text: #e8e8e8;
  --dim: #8a8a8a;
  --faint: #4a4a4a;
  --rule: rgba(255, 255, 255, 0.14);
  --accent: #5fd9a3;
  --panel: rgba(10, 10, 10, 0.72);
  --sans: "Segoe UI", "Source Sans 3", system-ui, sans-serif;
  --mono: Consolas, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--black); color: var(--text); overflow: hidden; font-family: var(--sans); }
body.idle, body.idle * { cursor: none !important; }

#stage { position: fixed; inset: 0; background: var(--black); }
#stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: transparent; opacity: 0; z-index: 0; }
#stage video.on { opacity: 1; z-index: 2; }
#stage video.under { opacity: 1; z-index: 1; }   /* the outgoing clip, until the incoming one has painted */

/* Controls */
#hud {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 0 28px 18px;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
body.idle #hud { opacity: 0; transform: translateY(8px); pointer-events: none; }
#hud::before { content: ""; position: absolute; inset: -8px 0 0 0; background: var(--panel); backdrop-filter: blur(10px); z-index: -1; border-top: 1px solid var(--rule); }

#timeline { position: relative; padding-top: 14px; }
#labels { position: relative; height: 22px; }
#labels .leader { position: absolute; width: 1px; background: rgba(255, 255, 255, 0.22); pointer-events: none; }
#labels .leader[hidden] { display: none; }
/* Chapter labels: 13 px regular so Windows draws them crisp (lighter or smaller breaks up); clickable */
#labels .lab {
  position: absolute; top: 0; height: 22px; padding: 0 8px 0 1px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font: 400 13px/22px var(--sans); letter-spacing: 0.01em; color: #a6a6a6; cursor: pointer; transition: color 0.15s;
}
#labels .lab b { font: 400 11px var(--mono); color: #6a6a6a; margin-right: 6px; }
#labels .lab:hover, #labels .lab.hov { color: #f2f2f2; }
#labels .lab.cur { color: #f2f2f2; }
#labels .lab.cur b { color: var(--accent); }

#track { position: relative; height: 22px; cursor: pointer; touch-action: none; }
#blocks { position: absolute; inset: 7px 0; }
.blk { position: absolute; top: 0; bottom: 0; display: flex; padding-right: 2px; }
.blk i { display: block; height: 100%; background: rgba(255, 255, 255, 0.16); }
.blk i.intro { background: rgba(255, 255, 255, 0.07); }
.blk i .fill { display: block; height: 100%; width: 0; background: rgba(255, 255, 255, 0.62); }
.blk.cur i.body .fill { background: var(--accent); }
#head { position: absolute; top: 2px; bottom: 2px; width: 2px; margin-left: -1px; background: #fff; pointer-events: none; }

#tip {
  position: absolute; bottom: 52px; width: 196px; margin-left: -98px; padding: 6px; display: none;
  background: var(--panel); border: 1px solid var(--rule); backdrop-filter: blur(10px); pointer-events: none;
}
#tip.show { display: block; }
#tip img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #111; }
#tip div { display: flex; justify-content: space-between; gap: 8px; padding-top: 6px; font: 500 10px var(--sans); letter-spacing: 0.12em; text-transform: uppercase; }
#tipTime { font-family: var(--mono); color: var(--dim); letter-spacing: 0.02em; }

#bar { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 16px; }
.group { display: flex; align-items: center; gap: 6px; min-width: 0; }
button { all: unset; cursor: pointer; }
#bar > .group > button:not(.pill) { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 4px; }
#bar > .group > button:not(.pill):hover { background: rgba(255, 255, 255, 0.08); }
#bar button[hidden] { display: none !important; }
#bar svg { width: 18px; height: 18px; fill: var(--text); }
#bPlay svg { width: 22px; height: 22px; }
#bPlay .i-pause, body.playing #bPlay .i-play { display: none; }
body.playing #bPlay .i-pause { display: block; }

.mono { font: 13px var(--mono); letter-spacing: 0.02em; }
.dim { color: var(--dim); }
#tc { margin-left: 12px; color: var(--text); }
.tech { font: 500 11px var(--sans); letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chapName { margin-left: 18px; color: var(--text); }
#status { margin-left: 12px; color: var(--accent); }
#status.warn { color: #e0b25f; }

.seg { display: flex; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; margin-right: 8px; }
.seg button { padding: 7px 12px; font: 500 11px var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.seg button:hover { color: var(--text); }
.seg button.on { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.seg button[data-mode="present"].on { color: var(--accent); }

.pill { display: inline-flex; align-items: center; white-space: nowrap; padding: 7px 12px; margin-right: 8px; border: 1px solid var(--rule); border-radius: 4px; font: 500 11px var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text); }
.pill:hover { background: rgba(255, 255, 255, 0.08); }
.pill[hidden] { display: none; }
.pill span { margin-left: 8px; font-family: var(--mono); letter-spacing: 0; color: var(--accent); }

/* Compare: live before / after. Before on the left, after on the right. */
body.comparing #hud { display: none; }
#compare { position: fixed; inset: 0; background: var(--black); opacity: 0; transition: opacity 0.3s ease; }
#compare[hidden] { display: none; }
#compare.show { opacity: var(--blackout, 1); }
#cmpView { position: absolute; inset: 0; overflow: hidden; cursor: ew-resize; touch-action: none; transition: opacity 0.2s ease; }
#cmpView.swap { opacity: 0; }
#cmpView .layer { position: absolute; inset: 0; }
#cmpView img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; }
#cmpLine { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 6px rgba(0, 0, 0, 0.55); pointer-events: none; }
#cmpLine .ring {
  position: absolute; top: 50%; left: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(0, 0, 0, 0.28); box-shadow: 0 0 8px rgba(0, 0, 0, 0.5); display: grid; place-items: center;
}
#cmpLine svg { width: 22px; height: 22px; fill: #fff; }
.tag {
  position: absolute; top: 24px; padding: 6px 10px; background: rgba(0, 0, 0, 0.55); border-radius: 3px;
  font: 500 10px var(--sans); letter-spacing: 0.18em; text-transform: uppercase; color: var(--text); transition: opacity 0.2s ease; pointer-events: none;
}
#tagA { left: 24px; }
#tagB { right: 24px; }
.tag.off { opacity: 0; }

#cmpBar {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 28px 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  background: var(--panel); backdrop-filter: blur(10px); border-top: 1px solid var(--rule); transition: opacity 0.35s ease, transform 0.35s ease;
}
body.idle #cmpBar { opacity: 0; transform: translateY(8px); pointer-events: none; }
#cmpPairs { display: flex; gap: 10px; min-width: 0; overflow-x: auto; }
#cmpPairs button { display: block; width: 150px; flex: none; }
#cmpPairs img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; opacity: 0.55; outline: 1px solid var(--rule); transition: opacity 0.2s; }
#cmpPairs button:hover img { opacity: 0.85; }
#cmpPairs button.on img { opacity: 1; outline: 2px solid var(--accent); }
#cmpPairs span { display: block; padding-top: 6px; font: 500 10px var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cmpPairs button.on span { color: var(--text); }
.cmpInfo { display: flex; align-items: center; gap: 14px; flex: none; }
.cmpInfo .tech { color: var(--dim); }
#cmpClose { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 4px; }
#cmpClose:hover { background: rgba(255, 255, 255, 0.08); }
#cmpClose svg { width: 18px; height: 18px; fill: var(--text); }

/* Help */
#help { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.6); }
#help[hidden] { display: none; }
#help .panel { width: min(520px, calc(100vw - 32px)); padding: 28px 32px; background: #0b0b0b; border: 1px solid var(--rule); }
#help h2 { margin: 0 0 18px; font: 300 26px var(--sans); }
#help dl { display: grid; grid-template-columns: auto 1fr; gap: 9px 24px; margin: 0; }
#help dt { font: 12px var(--mono); color: var(--accent); white-space: nowrap; }
#help dd { margin: 0; font-size: 13px; color: var(--text); }
#help p { margin: 20px 0 0; font-size: 12px; line-height: 1.5; color: var(--dim); }
#help h3 { margin: 22px 0 12px; font: 500 10px var(--sans); letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim); }
#help .panel { max-height: calc(100vh - 32px); overflow-y: auto; }

#message { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; font: 14px var(--mono); color: var(--dim); }
#message[hidden] { display: none; }

@media (max-width: 720px) {
  #hud { padding: 0 16px 12px; }
  #chapName, #status, #tcTotal, #tcTotal + span, .dim { display: none; }
  #labels { display: none; }
  .cmpInfo .tech { display: none; }
  #cmpPairs button { width: 110px; }
}

/* Locked picture. With spare room below it (.band) the picture sits at the top and the bar lives in
   the black band; without it (.full) nothing shows over the picture unless C pins the bar. */
body.band #stage { bottom: auto; height: var(--pic-h); }
body.band #hud { height: var(--band-h); padding: 0 28px; display: flex; flex-direction: column; justify-content: center; }
body.band #hud::before { inset: 0; background: var(--black); backdrop-filter: none; border-top: 0; }
body.band #tip { display: none; }
body.full:not(.pinned):not(.client) #hud { opacity: 0; transform: none; pointer-events: none; }

/* A thin band: one row (transport, timeline, the rest) */
body.band-tight #hud { flex-direction: row; align-items: center; gap: 16px; }
body.band-tight #bar { display: contents; }
body.band-tight #bar > .group:first-child { order: 1; flex: none; }
body.band-tight #timeline { order: 2; flex: 1; min-width: 120px; padding: 0 0 22px; }   /* labels above; track lines up with the buttons */
body.band-tight #bar > .group:last-child { order: 3; flex: none; }
body.band-tight #chapName, body.band-tight #tcTotal, body.band-tight #tc + .dim { display: none; }
body.band-tight #status { flex: none; width: 210px; }   /* fixed: the timeline beside it never resizes */
body.band-tight #tc { flex: none; width: 76px; }
