:root {
  --bg: #0a0a0c;
  --bg-2: #101014;
  --surface: #16161b;
  --surface-2: #1e1e25;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f4f4f6;
  --muted: #9b9ba8;
  --faint: #6b6b78;
  --accent: #ffd60a;
  --accent-ink: #0a0a0c;
  --accent-soft: rgba(255, 214, 10, 0.14);
  --danger: #ff5c5c;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  --font: "Heebo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(255, 214, 10, 0.07), transparent 60%),
    radial-gradient(700px 400px at 0% 0%, rgba(120, 120, 255, 0.05), transparent 60%);
  pointer-events: none;
  z-index: -1;
}
button, input, select { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 720px) 1fr;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: rgba(10, 10, 12, 0.78);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
body.searching .topbar { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--accent);
  display: grid; align-content: center; gap: 5px; padding: 0 7px;
  box-shadow: 0 6px 22px -6px rgba(255, 214, 10, 0.55);
}
.brand-mark i { display: block; height: 3.5px; border-radius: 3px; background: var(--accent-ink); }
.brand-mark i:first-child { width: 62%; }
.brand-name { font-weight: 900; font-size: 22px; letter-spacing: -0.02em; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  height: 52px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding-inline: 18px 6px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.search:focus-within { border-color: rgba(255, 214, 10, 0.6); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface-2); }
.search-icon { color: var(--muted); width: 20px; height: 20px; }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none;
  font-size: 17px; font-weight: 500; padding-inline: 12px;
}
.search input::placeholder { color: var(--faint); font-weight: 400; }
.search input::-webkit-search-cancel-button { display: none; }
.kbd-hint {
  font-family: var(--mono); font-size: 12px; color: var(--faint); border: 1px solid var(--line-2);
  border-radius: 6px; padding: 1px 7px; margin-inline-end: 8px;
}
.search:focus-within .kbd-hint { display: none; }
.search-go {
  height: 40px; padding: 0 20px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 800;
  transition: transform 0.1s, filter 0.15s;
}
.search-go:hover { filter: brightness(1.08); }
.search-go:active { transform: scale(0.97); }

.status { justify-self: end; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.15); }
.status .dot.running { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- hero ---------- */
.hero { max-width: 880px; margin: 0 auto; padding: 12vh 24px 60px; text-align: center; }
.hero h1 { font-size: clamp(38px, 6.4vw, 76px); line-height: 1.02; font-weight: 900; letter-spacing: -0.035em; margin: 0 0 20px; }
.hero h1 .hl { color: var(--accent); }
.hero-sub { color: var(--muted); font-size: 18px; margin: 0 auto 36px; max-width: 560px; }
.try { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 44px; min-height: 40px; }
.chip {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 7px 15px;
  font-size: 14px; color: var(--text); cursor: pointer; transition: all 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.hero-stats { display: flex; justify-content: center; gap: 36px; flex-wrap: wrap; }
.stat b { display: block; font-size: 28px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
body.searching .hero { display: none; }

/* ---------- filters ---------- */
.results-wrap { padding: 18px 28px 80px; max-width: 1680px; margin: 0 auto; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 22px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--muted); transition: all 0.15s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--text); color: var(--bg); font-weight: 700; }
.seg.small button { padding: 5px 12px; font-size: 13px; }
.select {
  display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 6px 0 14px; height: 38px; font-size: 13px; color: var(--muted);
}
.select select { background: transparent; border: 0; outline: none; font-size: 14px; color: var(--text); max-width: 220px; cursor: pointer; padding: 6px 4px; }
.select select option { background: var(--surface-2); }
.count { margin-inline-start: auto; color: var(--muted); font-size: 14px; }
.count b { color: var(--text); }

/* ---------- grid / cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px 18px; }
.card {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  animation: rise 0.35s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  border: 0; padding: 0; cursor: pointer; color: inherit;
  background: linear-gradient(110deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 300% 100%; animation: shimmer 1.6s linear infinite;
  box-shadow: 0 0 0 1px var(--line);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
@keyframes shimmer { to { background-position: -150% 0; } }
.thumb:hover, .thumb:focus-visible { transform: translateY(-3px); box-shadow: 0 0 0 2px var(--accent), var(--shadow); outline: none; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.35s, filter 0.35s; }
.thumb img.ready { opacity: 1; }
/* YouTube's generic thumbnail is only a blurred placeholder until the real frame of the moment arrives */
.thumb img.base { filter: blur(14px) brightness(0.5); transform: scale(1.15); }
.thumb img.exact { z-index: 1; }
.thumb.has-frame { animation: none; }
.grabbing {
  position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; gap: 9px;
  font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, 0.85); text-shadow: 0 1px 3px #000;
}
.grabbing i {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.thumb.has-frame .grabbing, .thumb.no-frame .grabbing { display: none; }
.retry-frame {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 4; display: none;
  padding: 8px 14px; border-radius: 999px; background: rgba(0, 0, 0, 0.75); border: 1px solid var(--line-2);
  font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.retry-frame:hover { border-color: var(--accent); color: var(--accent); }
.thumb.no-frame .retry-frame { display: block; }
.thumb.no-frame .play { display: none; }
mark { background: transparent; color: var(--accent); }
.thumb .time {
  position: absolute; top: 10px; right: 10px; z-index: 2; font-family: var(--mono); font-size: 12px; font-weight: 600;
  background: rgba(0, 0, 0, 0.72); padding: 3px 8px; border-radius: 6px; direction: ltr;
  backdrop-filter: blur(6px);
}
.thumb .play {
  position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; opacity: 0; transition: opacity 0.2s;
  background: rgba(0, 0, 0, 0.25);
}
.thumb .play > span {
  width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; transform: scale(0.85); transition: transform 0.2s; box-shadow: var(--shadow);
}
.thumb .play svg { width: 24px; height: 24px; fill: currentColor; stroke: none; margin-inline-end: -3px; }
.thumb:hover .play, .thumb:focus-visible .play { opacity: 1; }
.thumb:hover .play > span { transform: scale(1); }
.thumb .src {
  position: absolute; top: 10px; left: 10px; z-index: 2; font-size: 11px; font-weight: 700;
  background: rgba(0, 0, 0, 0.72); padding: 3px 8px; border-radius: 6px; backdrop-filter: blur(6px);
}
.thumb .src.local { background: var(--accent); color: var(--accent-ink); }
.thumb.noimg { animation: none; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, #2a2a33, var(--surface)); }
.thumb.noimg::after { content: "🎞"; font-size: 34px; opacity: 0.35; }

.quote {
  margin: 2px 0 0; padding-inline: 2px; font-weight: 700; font-size: 16px; line-height: 1.4; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-actions { display: flex; gap: 8px; margin-top: 2px; }
.mini {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 700; text-decoration: none; cursor: pointer; transition: all 0.15s;
}
.mini svg { width: 15px; height: 15px; }
.mini:hover { border-color: rgba(255, 255, 255, 0.3); background: var(--surface-2); }
.mini.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.mini.primary:hover { filter: brightness(1.07); background: var(--accent); }

.info { display: flex; flex-direction: column; gap: 3px; padding-inline: 2px; min-width: 0; }
.info .series { font-weight: 800; font-size: 15.5px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.info .series > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag {
  flex: none; font-size: 11.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft);
  padding: 1px 7px; border-radius: 5px; white-space: nowrap;
}
.info .title { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sentinel { height: 1px; }
.empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 24px; margin: 0 0 8px; }
.skeleton .thumb { animation-duration: 1.2s; }
.skeleton .info i { display: block; height: 12px; border-radius: 4px; background: var(--surface); margin-top: 6px; }
.skeleton .info i:first-child { width: 55%; height: 15px; }
.skeleton .info i:nth-child(2) { width: 80%; }
.skeleton .info i:last-child { width: 40%; height: 30px; border-radius: 999px; margin-top: 10px; }

/* ---------- viewer ---------- */
dialog { border: 0; padding: 0; color: var(--text); background: transparent; max-width: none; max-height: none; }
dialog::backdrop { background: rgba(4, 4, 6, 0.82); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
dialog[open] { animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(8px); } }
.viewer { width: min(1320px, 96vw); }
.viewer-inner {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 360px;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow);
  max-height: 92vh;
}
.viewer-main { display: flex; flex-direction: column; min-width: 0; }
.player { aspect-ratio: 16 / 9; background: #000; position: relative; }
.player iframe, .player video, .player > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--line); }
.nav { margin-inline-start: auto; display: flex; gap: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line-2); font-weight: 600; font-size: 14px; transition: all 0.15s;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.3); background: #26262e; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 800; }
.btn.primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn[disabled] { opacity: 0.5; cursor: progress; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line-2); transition: all 0.15s;
}
.icon-btn:hover { background: #2a2a33; }
.close { position: absolute; top: 12px; inset-inline-end: 12px; z-index: 5; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(8px); }

.viewer-side { border-inline-start: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.v-meta { padding: 22px 22px 16px; border-bottom: 1px solid var(--line); }
.v-meta .kicker { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: 0.02em; margin-bottom: 4px; }
.v-meta h2 { margin: 0 0 6px; font-size: 22px; line-height: 1.2; font-weight: 900; letter-spacing: -0.01em; padding-inline-end: 36px; }
.v-meta .vt { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; }
.fact span { display: block; font-size: 11.5px; color: var(--muted); }
.fact b { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.fact b.ltr { direction: ltr; display: inline-block; font-family: var(--mono); font-size: 15px; }
.v-meta .path { margin-top: 10px; font-family: var(--mono); font-size: 11.5px; color: var(--faint); direction: ltr; text-align: left; word-break: break-all; }
.side-title { margin: 0; padding: 14px 22px 6px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }
.transcript { list-style: none; margin: 0; padding: 0 10px 16px; overflow-y: auto; flex: 1; scroll-behavior: smooth; }
.transcript li {
  display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14.5px; color: #c9c9d2; transition: background 0.12s;
}
.transcript li:hover { background: var(--surface); }
.transcript li .t { font-family: var(--mono); font-size: 12px; color: var(--faint); padding-top: 2px; direction: ltr; text-align: right; }
.transcript li.hit { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.transcript li.hit .t { color: var(--accent); }
.transcript li.now { box-shadow: inset -3px 0 0 var(--accent); color: var(--text); }

/* ---------- meme editor ---------- */
.meme { width: min(1100px, 96vw); }
.meme-inner {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 320px; background: var(--bg-2);
  border: 1px solid var(--line-2); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow);
}
.meme-stage { background: #000; display: grid; place-items: center; position: relative; min-height: 300px; }
.meme-stage canvas { max-width: 100%; max-height: 80vh; width: auto; height: auto; display: block; }
.meme-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: #000; }
.meme-loading[hidden] { display: none; }
.meme-controls { padding: 24px 22px; display: flex; flex-direction: column; gap: 14px; }
.meme-controls h3 { margin: 0 0 4px; font-size: 20px; font-weight: 900; }
.meme-controls label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.meme-controls input {
  height: 42px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface);
  padding: 0 12px; font-size: 15px; outline: none;
}
.meme-controls input:focus { border-color: var(--accent); }
.meme-buttons { display: flex; gap: 8px; margin-top: 6px; }
.meme-buttons .btn { flex: 1; justify-content: center; }
.hint { color: var(--faint); font-size: 12.5px; margin: auto 0 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); font-weight: 700; padding: 11px 20px; border-radius: 999px;
  transition: all 0.25s; z-index: 100; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .viewer-inner, .meme-inner { grid-template-columns: 1fr; overflow-y: auto; }
  .viewer-side { border-inline-start: 0; border-top: 1px solid var(--line); max-height: none; overflow: visible; }
  .transcript { max-height: 320px; }
}
@media (max-width: 720px) {
  .topbar { grid-template-columns: auto 1fr; gap: 12px; padding: 10px 16px; }
  .status { display: none; }
  .brand-name { display: none; }
  .search { height: 46px; padding-inline: 14px 4px; }
  .search input { font-size: 16px; }
  .search-go { height: 38px; padding: 0 14px; }
  .kbd-hint { display: none; }
  .hero { padding-top: 8vh; }
  .hero-sub { font-size: 16px; }
  .results-wrap { padding: 14px 16px 60px; }
  .grid { grid-template-columns: 1fr; }
  .count { width: 100%; margin: 0; }
  .filters { gap: 8px; }
  .seg { width: 100%; justify-content: space-between; }
  .select { flex: 1 1 40%; min-width: 0; }
  .select select { max-width: none; width: 100%; }
  .viewer, .meme { width: 100vw; }
  .viewer-inner, .meme-inner { border-radius: 0; max-height: 100vh; height: 100vh; }
  .actions .btn { flex: 1 1 calc(50% - 8px); justify-content: center; padding: 0 10px; }
  .nav { width: 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- clip trimmer ---------- */
.viewer-main { overflow-y: auto; }
.btn.active { border-color: var(--accent); color: var(--accent); }
.trim { border-top: 1px solid var(--line); padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.trim[hidden] { display: none; }
.trim-top { display: flex; align-items: center; gap: 12px; }
.trim-top h3 { margin: 0; font-size: 16px; font-weight: 900; }
.trim-dur { font-size: 13px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 9px; border-radius: 6px; }
.trim-dur.warn { color: #ffb3b3; background: rgba(255, 92, 92, 0.14); }
.icon-btn.small { width: 32px; height: 32px; margin-inline-start: auto; }
.icon-btn.small svg { width: 15px; height: 15px; }

/* the timeline reads left-to-right like every video player, even on an RTL page */
.trim-track {
  position: relative; height: 46px; direction: ltr; border-radius: 9px; cursor: pointer; touch-action: none;
  background: var(--surface); border: 1px solid var(--line-2);
}
.trim-lines { position: absolute; inset: 0; }
.trim-lines i { position: absolute; top: 50%; height: 10px; transform: translateY(-50%); border-radius: 3px; background: rgba(255, 255, 255, 0.16); }
.trim-sel {
  position: absolute; top: -1px; bottom: -1px; border: 2px solid var(--accent); border-radius: 9px;
  background: rgba(255, 214, 10, 0.12); pointer-events: none;
}
.trim-now { position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; background: #fff; border-radius: 2px; pointer-events: none; box-shadow: 0 0 6px rgba(0, 0, 0, 0.8); }
.trim-now[hidden] { display: none; }
/* inputs overhang by half a handle so each handle's centre sits exactly on its time */
.trim-track input[type="range"] {
  position: absolute; top: 0; left: -7px; width: calc(100% + 14px); height: 100%; margin: 0; background: none;
  -webkit-appearance: none; appearance: none; pointer-events: none;
}
.trim-track input[type="range"]::-webkit-slider-runnable-track { background: none; height: 100%; }
.trim-track input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; cursor: ew-resize; width: 14px; height: 46px; margin-top: 0;
  border-radius: 5px; background: var(--accent); box-shadow: 0 0 0 2px var(--bg-2);
}
.trim-track input[type="range"]::-moz-range-track { background: none; }
.trim-track input[type="range"]::-moz-range-thumb {
  pointer-events: auto; cursor: ew-resize; width: 14px; height: 46px; border: 0; border-radius: 5px;
  background: var(--accent); box-shadow: 0 0 0 2px var(--bg-2);
}
.trim-track input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid #fff; }
.trim-scale { display: flex; justify-content: space-between; direction: ltr; font-family: var(--mono); font-size: 11.5px; color: var(--faint); margin-top: -6px; }

.trim-edges { display: flex; flex-wrap: wrap; gap: 10px 24px; }
.edge { display: flex; align-items: center; gap: 6px; }
.edge-label { font-size: 13px; color: var(--muted); min-width: 42px; }
.edge-time { font-family: var(--mono); font-size: 15px; direction: ltr; min-width: 64px; text-align: center; }
.nudge {
  width: 34px; height: 30px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface);
  font-size: 13px; font-weight: 700; cursor: pointer; direction: ltr;
}
.nudge:hover { background: var(--surface-2); }
.edge .mini { height: 30px; padding: 0 11px; margin-inline-start: 4px; }
.trim-text { margin: 0; font-size: 14px; color: #c9c9d2; line-height: 1.45; }
.trim-text:empty { display: none; }
.trim-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.trim-actions .btn.primary { margin-inline-start: auto; }

@media (max-width: 720px) {
  .trim-actions .btn, .trim-actions .seg { flex: 1 1 100%; justify-content: center; }
  .trim-actions .btn.primary { margin: 0; }
  .edge { width: 100%; }
}

@media (max-width: 980px) {
  .viewer-main { overflow: visible; }
}

/* ---------- series picker ---------- */
.picker { position: relative; }
.picker-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 14px; max-width: 260px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 600; transition: border-color 0.15s;
}
.picker-btn:hover { border-color: var(--line-2); }
.picker-btn.active { border-color: var(--accent); color: var(--accent); }
.picker-btn > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-btn svg { width: 16px; height: 16px; }
.picker-btn .chev { color: var(--muted); transition: transform 0.15s; }
.picker-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.picker-panel {
  position: absolute; top: calc(100% + 8px); inset-inline-start: 0; z-index: 30; width: 360px;
  display: flex; flex-direction: column; max-height: min(520px, 70vh);
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow);
  animation: pop 0.15s ease;
}
.picker-panel[hidden] { display: none; }
.picker-search { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.picker-search svg { color: var(--muted); }
.picker-search input { flex: 1; min-width: 0; height: 36px; border: 0; background: transparent; outline: none; font-size: 15px; }
.picker-search input::-webkit-search-cancel-button { display: none; }
.picker-list { overflow-y: auto; padding: 6px; flex: 1; }
.pick {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; font-size: 14.5px;
}
.pick:hover { background: var(--surface); }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick .box {
  flex: none; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-2); display: grid; place-items: center;
  transition: all 0.12s;
}
.pick .box svg { width: 14px; height: 14px; stroke-width: 3; opacity: 0; color: var(--accent-ink); }
.pick.on .box { background: var(--accent); border-color: var(--accent); }
.pick.on .box svg { opacity: 1; }
.pick input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick.on .pick-name { font-weight: 700; }
.pick-n { color: var(--faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tag.news { color: #9ecbff; background: rgba(120, 170, 255, 0.14); }
.picker-empty { color: var(--muted); font-size: 14px; padding: 16px 12px; margin: 0; }
.picker-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.picker-foot > span { flex: 1; font-size: 13px; color: var(--muted); }

/* ---------- news switch ---------- */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line-2); transition: background 0.15s, border-color 0.15s;
}
.switch-track i {
  position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--muted); transition: all 0.15s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track i { inset-inline-start: 18px; background: var(--accent-ink); }
.switch input:checked ~ span:last-child { color: var(--text); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- chosen series ---------- */
.chosen { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 20px; }
.chosen[hidden] { display: none; }
.chosen-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 13px; border-radius: 999px; cursor: pointer;
  background: var(--accent-soft); border: 1px solid rgba(255, 214, 10, 0.35); color: var(--accent); font-size: 13.5px; font-weight: 700;
}
.chosen-chip svg { width: 13px; height: 13px; stroke-width: 2.6; }
.chosen-chip:hover { background: rgba(255, 214, 10, 0.22); }
.chosen-clear { border: 0; background: none; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; }

@media (max-width: 720px) {
  .picker { flex: 1 1 100%; }
  .picker-btn { width: 100%; max-width: none; }
  .picker-btn > span { flex: 1; text-align: start; }
  /* on a phone the picker becomes a bottom sheet */
  .picker-panel { position: fixed; inset: auto 0 0 0; width: auto; max-height: 75vh; border-radius: 18px 18px 0 0; }
  .switch { flex: 1 1 100%; }
}
