:root {
  --ground: #0B0B0D;
  --surface: #131317;
  --surface-2: #17171C;
  --surface-3: #1C1C22;
  --ink: #F4F4F2;
  --ink-2: #B9B9C2;
  --ink-3: #8E8EA0;
  --ink-4: #5A5A68;
  --line: rgba(244, 244, 242, 0.08);
  --line-2: rgba(244, 244, 242, 0.16);
  --wash: rgba(244, 244, 242, 0.08);
  --accent: #C8F04D;
  --display: 'Space Grotesk', 'Helvetica Neue', system-ui, sans-serif;
  --body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --right: env(safe-area-inset-right, 0px);
  --rail-w: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--body); -webkit-font-smoothing: antialiased; }
body { overscroll-behavior: none; }
button, select { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--ink); }
a:hover { color: #fff; }
button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 18px; height: 18px; flex-shrink: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; flex-shrink: 0; }
.dot.dim { background: var(--ink-4); }

/* ---- shared controls ------------------------------------------------------ */

.chip {
  height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2);
  background: transparent; color: var(--ink); font-size: 13px; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.chip.on { background: var(--ink); color: var(--ground); border-color: var(--ink); font-weight: 500; }
.chip .n { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.chip.on .n { color: rgba(11, 11, 13, 0.6); }
.chip-select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; max-width: 240px; text-overflow: ellipsis;
  background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230B0B0D' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 14px;
  color: var(--ground); border-color: var(--ink); font-weight: 500;
}
.chip-select option { color: var(--ink); background: var(--surface); }
.round {
  width: 48px; height: 48px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.round:disabled { opacity: 0.3; cursor: default; }
.card { padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; font-size: 13px; }
.card h2 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 14px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kv > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv span:first-child { color: var(--ink-3); }
.kv span:last-child { font-family: var(--mono); overflow-wrap: anywhere; }
.note { color: var(--ink-2); line-height: 1.45; overflow-wrap: anywhere; }
.rows { display: flex; flex-direction: column; gap: 10px; }
.rows > div { display: flex; justify-content: space-between; gap: 12px; }
.rows span:first-child { color: var(--ink-3); }
.rows span:last-child { font-family: var(--mono); }

/* ---- feed: phone first ---------------------------------------------------- */

.feed { position: fixed; inset: 0; background: var(--ground); }
.topbar, .side, .nav-btn { display: none; }
.stage-row { position: absolute; inset: 0; }
.stage { position: absolute; inset: 0; overflow: hidden; background: var(--surface); touch-action: none; user-select: none; -webkit-user-select: none; }

.slot { position: absolute; inset: 0; will-change: transform; background: var(--surface); }
.slot.anim { transition: transform 280ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.slot video, .slot img.poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.slot img.poster { filter: brightness(0.9); }
.slot.cover video, .slot.cover img.poster { object-fit: cover; }
.slot video { opacity: 0; transition: opacity 120ms; }
.slot video.ready { opacity: 1; }
.slot.end { display: flex; align-items: center; justify-content: center; padding: 32px; text-align: center; }
.end-msg { display: flex; flex-direction: column; gap: 14px; align-items: center; max-width: 280px; }
.end-msg h2 { margin: 0; font-family: var(--display); font-size: 24px; }
.end-msg p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }

.shade-top, .shade-bottom { position: absolute; left: 0; right: 0; pointer-events: none; }
.shade-top { top: 0; height: 180px; background: linear-gradient(rgba(11, 11, 13, 0.75), rgba(11, 11, 13, 0)); }
.shade-bottom { bottom: 0; height: 340px; background: linear-gradient(rgba(11, 11, 13, 0), rgba(11, 11, 13, 0.9)); }

.over-top { position: absolute; left: 16px; right: 16px; top: calc(16px + var(--top)); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 8px 12px; border-radius: 999px; border: none;
  background: rgba(244, 244, 242, 0.1); font-family: var(--mono); font-size: 12px; color: var(--ink); max-width: 70%; min-width: 0;
}
.pill.marked { background: rgba(244, 244, 242, 0.18); }
.pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.over-top .right { display: flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.icon-btn { width: 44px; height: 44px; border-radius: 999px; border: none; background: transparent; display: flex; align-items: center; justify-content: center; color: var(--ink); }

.over-bottom { position: absolute; left: 20px; right: 20px; bottom: calc(28px + var(--bottom)); display: flex; flex-direction: column; gap: 14px; }
.over-bottom h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1.15; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.over-bottom .head { display: flex; flex-direction: column; gap: 6px; padding-right: calc(var(--rail-w) + 4px); }
.meta-line { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.btn {
  height: 52px; border-radius: 999px; border: 1px solid rgba(244, 244, 242, 0.18); background: rgba(244, 244, 242, 0.08);
  color: var(--ink); font-size: 15px; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-skip { flex: 1; }
.btn-keep { flex: 1.4; border: none; background: rgba(244, 244, 242, 0.92); color: var(--ground); }
.btn-keep.on { background: var(--accent); }
.btn-skip.on { background: rgba(244, 244, 242, 0.16); border-color: rgba(244, 244, 242, 0.5); }
.btn kbd { font-family: var(--mono); font-size: 11px; color: var(--ink-3); display: none; }
.btn-keep kbd { color: rgba(11, 11, 13, 0.6); }
/* Action rail: right edge, centred in the lower half, ending above the progress bar. The column itself lets taps
   through to the video; only the buttons catch them (and the stage ignores pointerdowns on buttons). */
.rail {
  position: absolute; right: calc(6px + var(--right)); top: 50%; bottom: calc(76px + var(--bottom)); width: var(--rail-w);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; pointer-events: none;
}
.rail-btn {
  pointer-events: auto; width: var(--rail-w); padding: 2px 0; border: none; background: none; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 4px; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.rail-btn .ic {
  position: relative; width: 50px; height: 50px; border-radius: 999px; display: flex; align-items: center; justify-content: center;
  background: rgba(11, 11, 13, 0.42); border: 1px solid rgba(244, 244, 242, 0.16); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: background 120ms, transform 120ms, border-color 120ms;
}
.rail-btn .ic svg.i { width: 22px; height: 22px; }
.rail-btn .lab { font-size: 11px; font-weight: 500; line-height: 1; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); }
.rail-btn:active .ic { transform: scale(0.92); }
.rail-btn:focus-visible { outline: none; }
.rail-btn:focus-visible .ic { outline: 2px solid var(--accent); outline-offset: 2px; }
.rail-btn.r-keep.on .ic { background: var(--accent); border-color: var(--accent); color: var(--ground); }
.rail-btn.r-keep.on .lab { color: var(--accent); }
.rail-btn.r-drop.on .ic { background: rgba(244, 244, 242, 0.9); border-color: var(--ink); color: var(--ground); }
.rail-btn.r-note.on .ic { background: rgba(200, 240, 77, 0.16); border-color: var(--accent); color: var(--accent); }
.rail-btn.r-note.on .lab { color: var(--accent); }
.rail-btn.r-note.open .ic { background: var(--ink); border-color: var(--ink); color: var(--ground); }
.badge-count {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: var(--ground); font-family: var(--mono); font-size: 10px; font-weight: 500; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px rgba(11, 11, 13, 0.7);
}

/* Note popover: a tooltip beside the rail's Note button; JS places it (fixed, visual-viewport coordinates) and sets
   --ay, the arrow's height on its right edge. */
.notepop {
  position: fixed; z-index: 20; padding: 10px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line-2);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55); display: flex; flex-direction: column; gap: 8px;
}
.notepop::after {
  content: ''; position: absolute; right: -7px; top: var(--ay, 50%); width: 12px; height: 12px; margin-top: -6px;
  background: var(--surface-2); border: 1px solid var(--line-2); border-left: none; border-bottom: none; transform: rotate(45deg); border-radius: 0 3px 0 0;
}
.notepop.no-arrow::after { display: none; }
.note-input {
  display: block; width: 100%; resize: none; border-radius: 12px; border: 1px solid var(--line-2); background: var(--ground);
  color: var(--ink); font: 15px/1.4 var(--body); padding: 9px 11px; overflow-y: auto;
}
.note-input::placeholder { color: var(--ink-4); }
.note-input:focus { outline: none; border-color: rgba(244, 244, 242, 0.4); }
.note-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.note-hint { font-family: var(--mono); font-size: 11px; color: var(--ink-3); min-width: 0; }
.note-save {
  height: 36px; padding: 0 18px; border-radius: 999px; border: none; background: var(--accent); color: var(--ground);
  font-size: 14px; font-weight: 500; margin-left: auto;
}
.note-save:disabled { background: var(--wash); color: var(--ink-4); cursor: default; }

.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.notes li { padding: 10px 12px; border-radius: 12px; background: var(--surface-3); display: flex; flex-direction: column; gap: 4px; }
.notes p { margin: 0; color: var(--ink); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.note-foot time { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.note-del { width: 36px; height: 36px; margin: -8px -8px -8px 0; border: none; border-radius: 999px; background: transparent; color: var(--ink-3); display: flex; align-items: center; justify-content: center; }
.note-del:hover { color: var(--ink); background: var(--wash); }
.note-del svg.i { width: 16px; height: 16px; }
.notes-empty { margin: 0; color: var(--ink-3); line-height: 1.45; }
.sheet-notes { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; border-top: 1px solid var(--line); }
.sheet-notes-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; }
.sheet-notes-head h3 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 14px; }
.sheet-notes-head .chip { height: 32px; padding: 0 12px; }
.sheet-notes-head .chip svg.i { width: 15px; height: 15px; }

/* Seekable progress bar: a 3px line at the foot of a 32px hit area that reaches up, not down (negative margins keep
   the layout). The line stays 28px above the safe area in both modes so a drag never starts in the home-indicator zone. */
.bar { position: relative; height: 32px; padding-bottom: 15px; margin: -14px 0 -15px; display: flex; align-items: flex-end; cursor: pointer; touch-action: none; }
.bar .track { width: 100%; height: 3px; border-radius: 2px; background: rgba(244, 244, 242, 0.18); overflow: hidden; transition: height 120ms, border-radius 120ms; }
.bar .fill { height: 100%; width: var(--p, 0%); background: var(--accent); }
.bar .thumb { position: absolute; bottom: 8.5px; left: var(--p, 0%); width: 16px; height: 16px; margin: 0 0 0 -8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(11, 11, 13, 0.6); opacity: 0; transform: scale(0.5); transition: opacity 120ms, transform 120ms; pointer-events: none; }
.bar .time { position: absolute; bottom: 30px; left: clamp(48px, var(--p, 0%), calc(100% - 48px)); transform: translateX(-50%); padding: 3px 7px; border-radius: 6px; background: rgba(11, 11, 13, 0.85); font-size: 11px; color: var(--ink); white-space: nowrap; display: none; pointer-events: none; }
.bar.scrub .track { height: 8px; border-radius: 4px; }
.bar.scrub .thumb { opacity: 1; transform: none; bottom: 11px; }
.bar.scrub .time { display: block; }

/* Hidden UI: only the eye button and the thin progress line remain. */
.ui-hidden .over-bottom .head, .ui-hidden .rail, .ui-hidden .notepop, .ui-hidden .over-top .pill, .ui-hidden .over-top .pos, .ui-hidden .over-top .icon-btn:not(.hide-btn),
.ui-hidden .sound-hint, .ui-hidden .shade-top, .ui-hidden .shade-bottom, .ui-hidden .nav-btn { display: none !important; }
.ui-hidden .over-top { justify-content: flex-end; }
.ui-hidden .hide-btn { opacity: 0.55; }
.ui-hidden .hide-btn:hover, .ui-hidden .hide-btn:focus-visible { opacity: 1; }
.ui-hidden .hide-btn svg.i { width: 16px; height: 16px; }
.ui-hidden .over-bottom { left: 0; right: 0; }
.ui-hidden .bar:not(.scrub) .track { height: 2px; border-radius: 0; }

.flash { position: absolute; left: 50%; top: 42%; width: 88px; height: 88px; margin: -44px 0 0 -44px; border-radius: 999px; display: flex; align-items: center; justify-content: center; pointer-events: none; opacity: 0; transform: scale(0.8); background: rgba(11, 11, 13, 0.55); }
.flash svg { width: 40px; height: 40px; }
.flash.keep { color: var(--accent); }
.flash.go { animation: flash 520ms ease-out; }
@keyframes flash { 0% { opacity: 0; transform: scale(0.8); } 25% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.1); } }
.paused-mark { position: absolute; left: 50%; top: 50%; width: 72px; height: 72px; margin: -36px 0 0 -36px; border-radius: 999px; background: rgba(11, 11, 13, 0.55); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.paused-mark svg { width: 30px; height: 30px; }
.sound-hint { position: absolute; left: 50%; top: calc(72px + var(--top)); transform: translateX(-50%); border: none; border-radius: 999px; padding: 8px 14px; min-height: 36px; background: rgba(11, 11, 13, 0.7); font-size: 13px; display: flex; gap: 8px; align-items: center; }

/* Mark toast with Undo: top centre, under the top row. */
.toast {
  position: absolute; left: 50%; top: calc(68px + var(--top)); transform: translateX(-50%); z-index: 5; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; min-height: 44px; border-radius: 999px;
  background: rgba(11, 11, 13, 0.85); border: 1px solid var(--line-2); font-size: 13px; white-space: nowrap; animation: toast-in 160ms ease-out;
}
.toast-ic { display: flex; }
.toast-ic svg.i { width: 16px; height: 16px; }
.toast.keep .toast-ic, .toast.change .toast-ic { color: var(--accent); }
.toast > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; }
.toast-undo { height: 32px; padding: 0 14px; border-radius: 999px; border: none; background: var(--ink); color: var(--ground); font-size: 13px; font-weight: 500; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -6px); } }
.toast:not([hidden]) ~ .sound-hint, .sound-hint:has(~ .toast:not([hidden])) { display: none; }
.flash.change { color: var(--accent); }
.note-unmark { height: 36px; margin-left: auto; }
.note-unmark + .note-save { margin-left: 0; }

.sheet-back { position: absolute; inset: 0; background: rgba(11, 11, 13, 0.4); }
.sheet {
  position: absolute; left: 12px; right: 12px; bottom: calc(12px + var(--bottom)); max-height: calc(100% - 96px - var(--top)); overflow: auto;
  padding: 20px; border-radius: 24px; background: var(--surface-2); border: 1px solid rgba(244, 244, 242, 0.1);
  display: flex; flex-direction: column; gap: 14px; font-size: 13px; touch-action: pan-y;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head h2 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 16px; }
.sheet-head .icon-btn { background: var(--wash); }
.sheet .chips { display: flex; gap: 8px; flex-wrap: wrap; }
.pipe-list { display: flex; flex-direction: column; gap: 2px; }
.pipe-list button { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 12px; border: none; background: transparent; text-align: left; font-family: var(--mono); font-size: 13px; }
.pipe-list button.on { background: var(--surface-3); }
.pipe-list button span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipe-list button span:last-child { color: var(--ink-3); }

/* ---- feed: desktop ---------------------------------------------------------- */

@media (min-width: 860px) {
  .feed { position: static; min-height: 100vh; min-height: 100dvh; padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 20px; }
  .topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
  .brand { display: flex; align-items: center; gap: 12px; }
  .brand b { font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
  .brand span { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
  .topbar .chips { display: flex; gap: 8px; flex-wrap: wrap; }

  .main { flex: 1; display: flex; flex-wrap: wrap; gap: 32px; align-items: center; justify-content: center; }
  .stage-row { position: static; display: flex; align-items: center; gap: 20px; flex: 1 1 520px; justify-content: center; min-width: 0; }
  .nav-btn { display: flex; }
  .stage { position: relative; inset: auto; width: min(414px, calc((100dvh - 120px) * 9 / 16)); min-width: 240px; aspect-ratio: 9 / 16; border-radius: 24px; flex-shrink: 1; }
  .over-top .pill, .over-top .pos, .meta-line, .rail, .notepop { display: none; }
  .over-bottom .head { padding-right: 0; }
  .over-top { justify-content: flex-end; top: 12px; right: 12px; }
  .shade-bottom { height: 160px; background: linear-gradient(rgba(11, 11, 13, 0), rgba(11, 11, 13, 0.85)); }
  .shade-top { height: 90px; }
  .over-bottom { bottom: 20px; gap: 10px; }
  .over-bottom h1 { font-size: 22px; }
  .sheet, .sheet-back, .sound-hint { display: none; }

  .side { display: flex; flex: 0 1 320px; min-width: 260px; flex-direction: column; gap: 20px; }
  .side .who { display: flex; flex-direction: column; gap: 8px; }
  .side .who .pill { align-self: flex-start; padding: 6px 10px; min-height: 0; background: var(--wash); max-width: 100%; }
  .topbar .seg { display: flex; gap: 6px; }
  .side .mark-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .side .mark-tag { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
  .side .mark-tag::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
  .side .mark-row.keep .mark-tag::before, .side .mark-row.change .mark-tag::before { background: var(--accent); }
  .side .mark-row.drop .mark-tag::before { background: var(--ink); }
  .side .mark-row .chip { height: 32px; }
  .side .who .sub { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
  .side .rate { display: flex; gap: 10px; }
  .side .btn { flex: 1; height: 48px; border-radius: 14px; font-size: 14px; }
  .side .btn-skip { background: transparent; border-color: var(--line-2); }
  .side .btn-skip.on { background: rgba(244, 244, 242, 0.16); border-color: rgba(244, 244, 242, 0.5); }
  .side .btn kbd { display: inline; }
  .notes-card h2 { display: flex; align-items: center; gap: 8px; }
  .notes-card h2 svg.i { width: 16px; height: 16px; color: var(--ink-3); }
  .notes-card h2 .count { margin-left: auto; font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--ink-3); }
  .notes-card .note-input { font-size: 14px; }
  .notes-card .note-save { height: 32px; padding: 0 14px; font-size: 13px; }
  .notes-card .notes { max-height: 260px; overflow-y: auto; }
  .notes-card .notes li { background: var(--surface-2); border: 1px solid var(--line); }
  .side .keys { display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

  /* The page is exactly one screen tall: the video stays put and the side panel scrolls inside itself. */
  .feed { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
  .main { min-height: 0; flex-wrap: nowrap; align-items: stretch; }
  .stage-row { min-height: 0; }
  .side { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 8px; margin-right: -8px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
  .side > * { flex-shrink: 0; }
  /* Long sidecar values and texts are clamped; click one to expand it. */
  .side .kv span:last-child, .side .card .note { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; cursor: pointer; }
  .side .kv span.open:last-child, .side .card .note.open { -webkit-line-clamp: unset; display: block; }
}

/* ---- library ----------------------------------------------------------------- */

.lib { min-height: 100vh; padding: calc(20px + var(--top)) 24px calc(40px + var(--bottom)); display: flex; flex-direction: column; gap: 28px; max-width: 1440px; margin: 0 auto; }
.lib-head { display: flex; justify-content: space-between; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 12px; font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.crumbs a { text-decoration: none; }
.crumbs .sep { color: var(--ink-4); }
.lib-head .totals { font-family: var(--mono); font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lib-head .totals button { height: 36px; }
.section { display: flex; flex-direction: column; gap: 14px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 14px; color: var(--ink-2); }
.section-head .chips { display: flex; gap: 8px; flex-wrap: wrap; }
.pipes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.pipe {
  text-align: left; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 12px; min-height: 44px;
}
.pipe.on { background: var(--surface-3); border-color: rgba(244, 244, 242, 0.3); }
.pipe .name { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; min-width: 0; }
.pipe .name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipe .big { display: flex; align-items: baseline; gap: 8px; }
.pipe .big b { font-family: var(--display); font-weight: 700; font-size: 28px; line-height: 1; }
.pipe .big span { font-size: 12px; color: var(--ink-3); }
.pipe .foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-3); }
.pipe .marks { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--ink-3); }
.pipe .marks .m { display: inline-flex; gap: 4px; align-items: baseline; }
.pipe .marks b { font-family: var(--mono); font-weight: 500; color: var(--ink); }
.pipe .marks .keep b, .pipe .marks .change b { color: var(--accent); }
.pipe .marks .zero b { color: var(--ink-4); }
.pipe .meter { height: 3px; border-radius: 2px; background: var(--wash); overflow: hidden; }
.pipe .meter div { height: 3px; background: var(--ink-3); }
.pipe.on .meter div { background: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { position: relative; display: block; aspect-ratio: 9 / 16; border-radius: 14px; overflow: hidden; background: var(--surface); text-decoration: none; color: var(--ink); }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile .fade { position: absolute; left: 0; right: 0; bottom: 0; height: 90px; background: linear-gradient(rgba(11, 11, 13, 0), rgba(11, 11, 13, 0.85)); }
.badge { position: absolute; left: 10px; top: 10px; padding: 4px 8px; border-radius: 999px; font-family: var(--mono); font-size: 11px; background: rgba(11, 11, 13, 0.8); color: var(--ink-2); }
.badge.keep { background: var(--accent); color: var(--ground); }
.badge.change { background: rgba(11, 11, 13, 0.8); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.badge.skip { background: rgba(11, 11, 13, 0.8); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(244, 244, 242, 0.35); }
.tile .txt { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 4px; }
.tile .txt div:first-child { font-size: 13px; font-weight: 500; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .txt div:last-child { font-family: var(--mono); font-size: 11px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .watched { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); opacity: 0.8; }
.empty { padding: 40px 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.empty code { font-family: var(--mono); font-size: 12px; color: var(--ink); overflow-wrap: anywhere; }

@media (max-width: 520px) {
  .lib { padding-left: 16px; padding-right: 16px; gap: 24px; }
  .pipes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pipe { padding: 14px; }
  .pipe .big b { font-size: 24px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tile { border-radius: 10px; }
  .tile .txt div:first-child { font-size: 12px; }
  .badge { left: 6px; top: 6px; font-size: 10px; padding: 3px 6px; }
  .tile .txt { left: 8px; right: 8px; bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .slot.anim { transition: none; }
  .flash.go { animation-duration: 1ms; }
}

/* ---- putclip additions ----------------------------------------------------------- */

/* EU AI Act disclosure: always visible on the video and in the side panel, for every viewer. */
.ai-label {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px;
  border: 1px solid rgba(200, 240, 77, 0.6); color: var(--accent); background: rgba(11, 11, 13, 0.45);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em; white-space: nowrap;
}
.who-ai:empty { display: none; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: -0.01em; text-decoration: none; }
.publish-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.publish-row .vis-tag { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.publish-row .vis-tag svg.i { width: 16px; height: 16px; color: var(--ink-3); }
.publish-btns { display: flex; gap: 8px; }
.publish-row .chip { height: 32px; }
.chip:disabled { opacity: 0.4; cursor: default; }
.links h3 { margin: 0 0 6px; font-family: var(--display); font-weight: 700; font-size: 13px; }
.links ul { margin: 0; padding: 0 0 0 16px; display: flex; flex-direction: column; gap: 4px; color: var(--ink-2); font-size: 12px; }
.links a { color: var(--ink-2); overflow-wrap: anywhere; }
.links a:hover { color: var(--ink); }
.note-reply { color: var(--accent) !important; font-size: 13px; }
.settings-card { max-width: 640px; }
.settings-card .note-row .note-input { flex: 1; }
.settings-card h2 { display: flex; align-items: center; gap: 8px; }
.key-once { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface-3); }
.key-once code { overflow-wrap: anywhere; font-size: 12px; }
.side .rate .share-label { flex: 0; }
