/* ░░░░░ Vidlytic — clip.opus.pro-inspired dashboard ░░░░░ */
:root {
  --bg:        #0a0a0b;
  --bg-2:      #0d0d0f;
  --panel:     #151517;
  --panel-2:   #1b1b1e;
  --panel-3:   #232327;
  --border:    rgba(255,255,255,.07);
  --border-2:  rgba(255,255,255,.13);
  --text:      #f4f4f5;
  --muted:     #a1a1a8;            /* secondary text — lifted for legibility on dark panels */
  --muted-2:   #71717a;            /* tertiary text / placeholders */
  --accent:    #d4f96a;            /* lime, used sparingly */
  --accent-dim: rgba(212,249,106,.14);
  --warn:      #f6a623;
  --radius:    16px;
  --radius-sm: 11px;
  --rail-w:    60px;
  --shadow:    0 20px 50px -20px rgba(0,0,0,.75);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5; letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
/* Global heading reset — single source of truth for color/weight/rhythm.
   <dialog> sits in the top layer and does NOT inherit body's color, so without
   this its headings render as the UA default (near-black on our dark panels). */
h1, h2, h3, h4, h5 { margin: 0; color: var(--text); font-weight: 700; line-height: 1.25; letter-spacing: -.015em; }
.muted { color: var(--muted); }
button { font-family: inherit; cursor: pointer; letter-spacing: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a2a2e; border-radius: 8px; border: 2px solid var(--bg); }

/* ░░ App shell ░░ */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Left rail ── */
.rail {
  width: var(--rail-w); flex-shrink: 0; background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0; gap: 8px;
}
.rail__top { margin-bottom: 6px; }
.rail__logo { width: 40px; height: 40px; display: grid; place-items: center; background: none; border: none; padding: 0; border-radius: 11px; transition: .15s; }
.rail__logo:hover { background: var(--panel-2); }

/* Brand mark — lime lens + play triangle + AI spark (video understanding) */
.brand-mark { display: block; flex-shrink: 0; filter: drop-shadow(0 0 9px rgba(212,249,106,.4)); }
.rail__logo .brand-mark { width: 28px; height: 28px; }
.topbar__brand .brand-mark { width: 52px; height: 52px; }
.authcard__brand .brand-mark { width: 22px; height: 22px; }
.logo-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px rgba(212,249,106,.6); }
.rail__bottom { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.rail__btn {
  width: 40px; height: 40px; border-radius: 11px; border: none;
  background: transparent; color: var(--muted); display: grid; place-items: center; transition: .15s;
}
.rail__btn svg { width: 21px; height: 21px; }
.rail__btn:hover { background: var(--panel-2); color: var(--text); }
.rail__btn.is-active { background: var(--panel-3); color: var(--text); }
/* hover label pill to the right of rail icons */
.rail__btn[data-tip], .rail__logo[data-tip] { position: relative; }
.rail__btn[data-tip]::after, .rail__logo[data-tip]::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--text); color: #0a0a0b; padding: 7px 14px; border-radius: 11px; font-size: 14px; font-weight: 700;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 60; box-shadow: var(--shadow);
}
.rail__btn[data-tip]:hover::after, .rail__logo[data-tip]:hover::after { opacity: 1; }

/* ── Main column ── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 72px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.topbar__brand { display: flex; align-items: center; gap: 13px; }
.topbar__brand .logo-word { font-size: 30px; }
/* Wordmark: tight, heavy, two-tone — "vid" in ink, "lytic" in the brand lime
   gradient (echoing both the mark and ana-LYTIC). */
.logo-word { font-weight: 800; font-size: 24px; letter-spacing: -.035em; line-height: 1; }
.logo-word .lw-accent {
  background: linear-gradient(96deg, var(--accent), #a4e64d);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.topbar__right { display: flex; align-items: center; gap: 10px; }
.pill { font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
.pill--soft { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); cursor: pointer; }
.pill--soft:hover { color: var(--text); border-color: var(--border-2); }
.pill--ghost { background: transparent; color: var(--muted-2); border: 1px solid var(--border); }

.scroll { flex: 1; overflow-y: auto; }
.view { width: 100%; margin: 0; padding: 0 28px 60px; }
@media (min-width: 1500px) { .view { padding-left: 40px; padding-right: 40px; } }
/* high-res / wide screens: fill width with more columns so cards stay reasonable */
@media (min-width: 1600px) {
  .vid-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (min-width: 2000px) {
  .vid-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* ░░ Hero / uploader ░░ */
.hero { position: relative; padding: 84px 0 40px; }
.hero__wm {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  font-size: clamp(120px, 23vw, 360px); font-weight: 800; letter-spacing: -.05em;
  color: #fff; opacity: .04; pointer-events: none; user-select: none; white-space: nowrap;
}
.uploader {
  position: relative; width: min(640px, 100%); margin: 0 auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); transition: border-color .2s, box-shadow .2s;
}
.uploader.dragover { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-dim); }
.uploader__link {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 6px 0 14px; transition: border-color .15s;
}
.uploader__link:focus-within { border-color: var(--border-2); }
.uploader__linkicon { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.uploader__link input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--text); font-size: 15px; padding: 16px 0; }
.uploader__link input::placeholder { color: var(--muted-2); }
.uploader__row { display: flex; gap: 8px; justify-content: center; margin: 12px 0; }
.uploader__src {
  display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--muted);
  background: transparent; border: none; padding: 9px 14px; border-radius: 9px; transition: .15s;
}
.uploader__src svg { width: 18px; height: 18px; }
.uploader__src:hover { background: var(--panel-2); color: var(--text); }
.uploader__go {
  flex-shrink: 0; display: grid; place-items: center; width: 46px; height: 46px;
  border: none; border-radius: 12px; background: var(--accent); color: #0a0f08; transition: filter .12s, transform .05s;
}
.uploader__go svg { width: 21px; height: 21px; }
.uploader__go:hover { filter: brightness(1.06); }
.uploader__go:active { transform: translateY(1px); }

/* optional upload trim range (start/end mm:ss) */
.uploader__trim { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 4px 0 2px; }
.uploader__trim-icon { width: 15px; height: 15px; color: var(--muted-2); }
.uploader__trim-label { font-size: 12px; color: var(--muted); }
.uploader__trim-in { width: 92px; padding: 6px 9px; font-size: 12.5px; font-family: ui-monospace, monospace; text-align: center; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); }
.uploader__trim-in:focus { outline: none; border-color: var(--accent); }
.uploader__trim-dash { color: var(--muted-2); }
.uploader__trim-hint { flex-basis: 100%; text-align: center; font-size: 11px; color: var(--muted-2); }
.uploader__state { margin-top: 14px; }
.uploading__row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 9px; }
.uploading__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uploading__row .spinner { flex-shrink: 0; }
#upPct { flex-shrink: 0; }
.progress { height: 6px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress__bar--indeterminate { width: 35%; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.banner-err { background: rgba(246,166,35,.1); border: 1px solid rgba(246,166,35,.32); color: #f7c46b; padding: 11px 13px; border-radius: var(--radius-sm); font-size: 13px; }
.banner-ok { background: rgba(212,249,106,.1); border: 1px solid rgba(212,249,106,.32); color: var(--accent); padding: 11px 13px; border-radius: var(--radius-sm); font-size: 13px; }
.banner-err__code { margin-top: 6px; font-size: 11px; font-family: ui-monospace, monospace; color: rgba(246,166,35,.65); letter-spacing: .04em; }

/* ░░ Capability row ░░ */
.caps {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  margin-top: 44px; position: relative;
}
.cap {
  position: relative;
  min-width: 112px; background: transparent; border: none; padding: 12px 14px; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 11px; transition: .15s;
}
.cap:hover { background: var(--panel); }
.cap.is-active { background: var(--panel-2); }
.cap__icon {
  width: 60px; height: 60px; border-radius: 17px; display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
}
.cap:hover .cap__icon { border-color: var(--border-2); }
.cap__icon svg { width: 28px; height: 28px; }
.cap__name { font-size: 13px; font-weight: 600; color: var(--muted); text-align: center; line-height: 1.25; white-space: nowrap; }
/* short tagline on hover (home capability tiles + workspace switcher pills) */
.cap[data-tip]::after, .wscap[data-tip]::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: #0a0a0b; padding: 6px 12px; border-radius: 10px; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 60; box-shadow: var(--shadow);
}
.cap[data-tip]:hover::after, .wscap[data-tip]:hover::after { opacity: 1; }
.cap:hover .cap__name { color: var(--text); }

/* ░░ Home recent feed (dashboard) ░░ */
.home-feed { margin-top: 40px; display: flex; flex-direction: column; gap: 32px; }
.home-sec__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.home-sec__head h3 { font-size: 16px; font-weight: 700; }
.home-sec__more { background: none; border: none; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.home-sec__more:hover { color: var(--accent); }
.home-empty { padding: 56px 0; }

/* ░░ Library ░░ */
.view--library { padding-top: 28px; }
.view--library .library { margin-top: 4px; }
.view__head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 22px; }
.view__title { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.view__sub { font-size: 13px; color: var(--muted); }
.library { margin-top: 46px; }
.library__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
/* library controls: task-type filter + name search */
.library__controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* custom task-type dropdown (themed, replaces the native <select>) */
.lib-filter { position: relative; }
.lib-filter__btn { display: inline-flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.lib-filter__btn:hover { border-color: var(--border-2); }
.lib-filter__btn.is-open { border-color: var(--accent); }
.lib-filter__label { min-width: 56px; text-align: left; }
.lib-filter__caret { width: 15px; height: 15px; color: var(--muted-2); transition: transform .15s; }
.lib-filter__btn.is-open .lib-filter__caret { transform: rotate(180deg); }
.lib-filter__menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 200; min-width: 100%; white-space: nowrap; background: var(--panel); border: 1px solid var(--border-2); border-radius: 10px; padding: 5px; box-shadow: var(--shadow); }
.lib-filter__item { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; text-align: left; padding: 8px 10px; font-size: 13px; font-weight: 500; color: var(--text); background: none; border: none; border-radius: 7px; cursor: pointer; }
.lib-filter__item:hover { background: var(--panel-2); }
.lib-filter__item.is-active { color: var(--accent); font-weight: 600; }
.lib-filter__check { width: 15px; height: 15px; opacity: 0; flex-shrink: 0; }
.lib-filter__item.is-active .lib-filter__check { opacity: 1; }
.lib-search { position: relative; display: flex; align-items: center; }
.lib-search > svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--muted-2); pointer-events: none; }
.lib-search input { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); font-size: 13px; padding: 8px 30px 8px 32px; border-radius: 10px; width: 240px; max-width: 60vw; }
.lib-search input:focus { border-color: var(--accent); outline: none; }
.lib-search__clear { position: absolute; right: 6px; width: 20px; height: 20px; display: grid; place-items: center; background: none; border: none; color: var(--muted-2); cursor: pointer; border-radius: 5px; }
.lib-search__clear:hover { color: var(--text); background: var(--border); }
.lib-search__clear svg { width: 12px; height: 12px; }
/* date / in-progress group headers (no icon) + infinite-scroll sentinel */
.task-group--runs .task-group__name { color: var(--accent); }
.lib-sentinel { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 18px 0; color: var(--muted); font-size: 13px; }
.lib-nomatch { color: var(--muted-2); }
.tabs { display: flex; gap: 4px; }
.tab { background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 600; padding: 6px 4px; }
.tab.is-active { color: var(--text); }
.tab span { color: var(--muted-2); font-weight: 500; }

/* minmax(0,1fr), not 1fr: a 1fr track has an implicit `auto` minimum, so a long
   unbreakable filename (nowrap) would force its column wider than the rest and
   make that card bigger. minmax(0,…) keeps every column exactly equal. */
.vid-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .vid-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px)  { .vid-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.empty {
  grid-column: 1 / -1; text-align: center; color: var(--muted-2); padding: 70px 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty p { margin: 6px 0 0; color: var(--muted); font-weight: 600; font-size: 15px; }
.empty span { font-size: 13px; }

.vcard { cursor: pointer; animation: pop .25s ease; }
.vcard__media {
  position: relative; aspect-ratio: 16/9; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--border); transition: .15s;
}
.vcard:hover .vcard__media { border-color: var(--border-2); }
.vcard.is-active .vcard__media { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
/* Absolutely positioned so the media stays a fixed 16/9 regardless of the
   video's own aspect ratio (portrait clips otherwise stretch the card taller).
   contain (not cover) keeps portrait / non-16:9 thumbnails whole — they
   letterbox on the card background instead of being center-cropped. */
.vcard__media video, .vcard__media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.vcard__ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted-2); }
.vcard__ph svg { width: 30px; height: 30px; }
.vcard__badge {
  position: absolute; left: 8px; bottom: 8px; font-size: 11px; font-weight: 600;
  background: rgba(0,0,0,.6); color: #d8d8da; padding: 3px 8px; border-radius: 6px; backdrop-filter: blur(4px);
}
.vcard__active {
  position: absolute; left: 8px; top: 8px; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  background: var(--accent); color: #0a0a0b; padding: 3px 8px; border-radius: 999px;
}
.vcard__title { margin-top: 10px; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vcard__sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* per-type group header inside the Tasks grid (spans the full grid width so
   cards keep flowing under it). Organizes history by capability type. */
.task-group {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 8px;
  margin: 10px 0 -4px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.task-group:first-child { margin-top: 0; }
.task-group__icon { display: inline-flex; width: 18px; height: 18px; }
.task-group__icon svg { width: 18px; height: 18px; }
.task-group__name { font-size: 14px; font-weight: 700; color: var(--text); }
.task-group__count { font-size: 12px; color: var(--muted-2); font-weight: 500; }

/* bulk-select checkbox on library cards — hidden until the grid is selecting */
.vcard__check { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 7px; display: none; place-items: center; background: rgba(0,0,0,.55); border: 1.5px solid rgba(255,255,255,.5); color: transparent; backdrop-filter: blur(4px); z-index: 2; }
.vcard__check svg { width: 15px; height: 15px; }
.vid-grid.selecting .vcard__check { display: grid; }
.vid-grid.selecting .vcard { cursor: pointer; }
.vid-grid.selecting .vcard__del { display: none; }
.vcard.is-selected .vcard__check { background: var(--accent); border-color: var(--accent); color: #0a0a0b; }
.vcard.is-selected .vcard__media { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* library toolbar: Select / batch-delete bar */
.library__meta { display: flex; align-items: center; gap: 8px; }
.lib-tool { padding: 6px 12px; font-size: 12.5px; }
.lib-selbar { display: flex; align-items: center; gap: 8px; }
.lib-selbar__count { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.lib-tool--danger:not(:disabled) { color: #ff8a7a; border-color: rgba(255,138,122,.4); }
.lib-tool--danger:not(:disabled):hover { background: #ff4d4d; color: #fff; border-color: #ff4d4d; }
.lib-tool:disabled { opacity: .5; cursor: default; }

/* ░░ Workspace ░░ */
.view--workspace { padding-top: 22px; }
.backlink { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 600; padding: 6px 0; margin-bottom: 16px; }
.backlink:hover { color: var(--text); }
/* Workspace capability switcher — compact pills (icon + name) */
.ws-caps { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.wscap {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  padding: 9px 15px; border-radius: 999px; font-size: 13px; font-weight: 600; transition: .15s;
}
.wscap:hover { color: var(--text); border-color: var(--border-2); }
.wscap.is-active { color: var(--text); border-color: var(--accent); background: var(--panel-2); }
/* Incompatible with the loaded media: greyed, non-interactive. The native title
   carries the reason; suppress the hover tagline so it isn't misleading. */
.wscap.is-disabled { opacity: .4; cursor: not-allowed; }
.wscap.is-disabled:hover { color: var(--muted); border-color: var(--border); background: transparent; }
.wscap.is-disabled[data-tip]:hover::after { opacity: 0; }
.wscap__icon { display: inline-grid; place-items: center; width: 17px; height: 17px; flex-shrink: 0; }
.wscap__icon svg { width: 17px; height: 17px; }

/* Stacked: config panel on top, results full-width below. */
.ws-grid { display: flex; flex-direction: column; gap: 18px; }
.ws-panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
/* config row: video left, form/actions right; wraps on narrow screens */
.ws-config { display: flex; gap: 22px; align-items: flex-start; }
.ws-config__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ws-config .ws-video { flex: 0 0 380px; max-width: 380px; margin-bottom: 0; }
.ws-config .ws-form { margin-bottom: 16px; }
.ws-config .ws-actions { margin-top: auto; }
@media (max-width: 760px) { .ws-config { flex-direction: column; } .ws-config .ws-video { flex-basis: auto; max-width: none; width: 100%; } }
/* detail view (replaying a saved task / run): no form, so center a larger video
   instead of a small box with empty space beside it */
.ws-config--detail { flex-direction: column; align-items: stretch; }
.ws-config--detail .ws-video { flex: none; max-width: 760px; width: 100%; margin: 0 auto; }
.ws-config--detail .ws-video__name { text-align: center; }
.ws-config--detail .ws-actions { justify-content: center; margin-top: 12px; }
.ws-config--detail .ws-status { flex: none; text-align: center; }

/* Summary / Screenplay split: video left, results scroll on the right */
.ws-grid--split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.ws-grid--split .ws-panel { position: sticky; top: 8px; align-self: start; }
.ws-grid--split .ws-config, .ws-grid--split .ws-config__main { display: block; }
.ws-grid--split .ws-config .ws-video { margin-bottom: 12px; max-width: none; }
.ws-grid--split .ws-config__main .ws-actions { margin-top: 0; }
.ws-grid--split .ws-video video { max-height: calc(100vh - 240px); width: 100%; object-fit: contain; background: #000; }
.ws-grid--split .ws-config--detail .ws-video__name,
.ws-grid--split .ws-config--detail .ws-actions { text-align: left; justify-content: flex-start; }
.ws-grid--split .ws-results { max-height: calc(100vh - 120px); overflow-y: auto; min-height: 0; }

/* Detail (replay) split: give both columns the same height and let the video
   fill the left one (letterboxed) so the bottom edges line up. */
.ws-grid--split:has(.ws-config--detail) .ws-panel,
.ws-grid--split:has(.ws-config--detail) .ws-results { height: calc(100vh - 120px); max-height: none; }
.ws-grid--split:has(.ws-config--detail) .ws-panel { display: flex; flex-direction: column; }
.ws-grid--split:has(.ws-config--detail) .ws-config { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ws-grid--split:has(.ws-config--detail) .ws-config__main { flex: 0 0 auto; }
.ws-grid--split:has(.ws-config--detail) .ws-video { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-bottom: 8px; }
.ws-grid--split:has(.ws-config--detail) .ws-video video { flex: 1; min-height: 0; height: auto; max-height: none; }

@media (max-width: 900px) {
  .ws-grid--split { grid-template-columns: 1fr; }
  .ws-grid--split .ws-panel { position: static; }
  .ws-grid--split .ws-results { max-height: none; }
  .ws-grid--split:has(.ws-config--detail) .ws-panel,
  .ws-grid--split:has(.ws-config--detail) .ws-results { height: auto; }
  .ws-grid--split:has(.ws-config--detail) .ws-video { display: block; }
  .ws-grid--split:has(.ws-config--detail) .ws-video video { height: auto; }
}
.ws-head { display: flex; gap: 12px; margin-bottom: 16px; min-width: 0; }
.ws-head__icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); flex-shrink: 0; }
.ws-head__icon svg { width: 22px; height: 22px; }
.ws-head > div { min-width: 0; flex: 1; }
.ws-head h3 { margin: 0; font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-head p { margin: 3px 0 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

.ws-video { margin-bottom: 16px; }
.ws-video video { width: 100%; border-radius: var(--radius-sm); background: #000; border: 1px solid var(--border); display: block; }
.ws-video__name { font-size: 12px; color: var(--muted); margin-top: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ws-form { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field__label { font-size: 13px; font-weight: 600; }
.field__hint { font-size: 11px; color: var(--muted); }
.ws-form input[type=text], .ws-form input[type=number], .ws-form select, .ws-form textarea, .dialog__body input {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; color: var(--text);
  padding: 10px 12px; font-size: 14px; font-family: inherit; outline: none; transition: border-color .15s;
}
.ws-form input:focus, .ws-form select:focus, .ws-form textarea:focus, .dialog__body input:focus { border-color: var(--border-2); }
/* Themed file picker — the native control otherwise renders an unstyled
   OS button that clashes with the rest of the form. */
.ws-form input[type=file] {
  padding: 9px 12px; font-size: 13px; color: var(--muted);
  border-style: dashed; border-color: var(--border-2); cursor: pointer;
}
.ws-form input[type=file]::file-selector-button {
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 8px; margin-right: 12px; transition: border-color .15s;
}
.ws-form input[type=file]::file-selector-button:hover { border-color: var(--border-2); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; min-width: 60px; background: var(--bg-2); border: 1px solid var(--border); color: var(--muted); padding: 8px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; transition: .15s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent-dim); color: var(--accent); border-color: rgba(212,249,106,.4); }

/* themed select (custom dropdown) — replaces the native <select> everywhere */
.fsel { position: relative; }
.fsel__btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; color: var(--text);
  padding: 10px 12px; font-size: 14px; font-family: inherit; font-weight: 500; cursor: pointer; transition: border-color .15s;
}
.fsel__btn:hover { border-color: var(--border-2); }
.fsel__btn.is-open { border-color: var(--accent); }
.fsel__label { text-align: left; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsel__caret { width: 16px; height: 16px; color: var(--muted-2); flex-shrink: 0; transition: transform .15s; }
.fsel__btn.is-open .fsel__caret { transform: rotate(180deg); }
.fsel__menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 200; max-height: 280px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 10px; padding: 5px; box-shadow: var(--shadow);
}
.fsel__item {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; text-align: left;
  padding: 9px 10px; font-size: 13.5px; font-weight: 500; color: var(--text); background: none; border: none; border-radius: 7px; cursor: pointer;
}
.fsel__item:hover { background: var(--panel-2); }
.fsel__item.is-active { color: var(--accent); font-weight: 600; }
.fsel__check { width: 15px; height: 15px; opacity: 0; flex-shrink: 0; }
.fsel__item.is-active .fsel__check { opacity: 1; }

/* min/max integer-range field (e.g. scene count) */
.intrange { display: flex; align-items: center; gap: 10px; }
.intrange input { flex: 1; min-width: 0; }
.intrange__sep { color: var(--muted-2); font-weight: 600; flex-shrink: 0; }
.checkrow { flex-direction: row; align-items: center; gap: 10px; }
.checkrow input { width: 17px; height: 17px; accent-color: var(--accent); }
.checkrow label { font-size: 13px; }

.ws-actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.btn-cta { background: #fff; color: #0a0a0b; border: none; padding: 11px 22px; border-radius: 10px; font-size: 14px; font-weight: 700; transition: .12s; }
.btn-cta:hover { background: #e9e9ea; }
.btn-line { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 10px 18px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.btn-line:hover { border-color: var(--border-2); }
.ws-status { font-size: 13px; color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-status.err { color: var(--warn); }
.run-warn { display: flex; align-items: flex-start; gap: 7px; margin-top: 12px; font-size: 12px; line-height: 1.4; color: var(--warn); background: rgba(246,166,35,.1); border: 1px solid rgba(246,166,35,.3); border-radius: var(--radius-sm); padding: 9px 11px; }
.run-warn svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }

/* ░░ Results ░░ */
.ws-results { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; min-height: 360px; }
.results__empty { color: var(--muted-2); text-align: center; padding: 110px 0; font-size: 14px; }
.res-section { margin-bottom: 22px; }
.res-section h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 12px; }

.clip { display: flex; gap: 13px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px; margin-bottom: 10px; animation: pop .25s ease; }
.clip__time { font-family: ui-monospace, monospace; font-size: 12px; color: var(--accent); background: var(--accent-dim); padding: 4px 8px; border-radius: 7px; white-space: nowrap; height: fit-content; }
.clip__body { flex: 1; min-width: 0; }
.clip__title { font-weight: 600; font-size: 14px; }
.clip__desc { color: var(--muted); font-size: 13px; margin-top: 4px; line-height: 1.45; }
.clip__transcript { color: var(--muted-2); font-size: 12px; margin-top: 6px; font-style: italic; }
.clip__score { font-size: 12px; color: var(--muted); margin-top: 6px; }
.clip__jump { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; white-space: nowrap; height: fit-content; }
.clip__jump:hover { border-color: var(--accent); color: var(--accent); }

/* clip card grid */
.clips-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.clips-head h4 { margin: 0; }
.clips-count { color: var(--muted-2); font-weight: 500; text-transform: none; letter-spacing: 0; }
.clips-actions { display: flex; gap: 8px; align-items: center; }
.clips-actions .btn-line, .clips-actions .btn-cta { padding: 7px 14px; font-size: 13px; }
/* clip sort toggle (by score / by time) */
.clip-sort { display: inline-flex; align-items: center; gap: 4px; padding: 3px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; }
.clip-sort__label { font-size: 11.5px; color: var(--muted-2); padding: 0 4px 0 6px; }
.clip-sort__btn { font-size: 12px; font-weight: 600; color: var(--muted); background: none; border: none; padding: 5px 10px; border-radius: 7px; cursor: pointer; }
.clip-sort__btn:hover { color: var(--text); }
.clip-sort__btn.on { color: #0a0a0b; background: var(--accent); }
.clip-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1400px) { .clip-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .clip-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px)  { .clip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px)  { .clip-grid { grid-template-columns: 1fr; } }
.clipcard { animation: pop .25s ease; border-radius: var(--radius-sm); }
.clipcard--flash { animation: pop .25s ease, clipFlash 1.1s ease; }
@keyframes clipFlash { 0%, 100% { box-shadow: none; } 20% { box-shadow: 0 0 0 2px var(--accent); } }
.clipcard__media { position: relative; aspect-ratio: 16/9; border-radius: var(--radius-sm); overflow: hidden; background: #000; border: 1px solid var(--border); cursor: pointer; }
.clipcard__media:hover { border-color: var(--border-2); }
/* contain (not cover) so portrait / non-16:9 clips letterbox on the black card
   instead of being center-cropped — this same <video> also goes native
   fullscreen, so cover would crop there too. */
.clipcard__media video { width: 100%; height: 100%; object-fit: contain; display: block; }
.clipcard__dur { position: absolute; top: 8px; right: 8px; font-family: ui-monospace, monospace; font-size: 11px; background: rgba(0,0,0,.65); color: #fff; padding: 2px 7px; border-radius: 6px; backdrop-filter: blur(4px); }
.clipcard__play { position: absolute; inset: 0; margin: auto; width: 44px; height: 44px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; font-size: 14px; pointer-events: none; transition: .15s; backdrop-filter: blur(4px); }
.clipcard__media:hover .clipcard__play { background: rgba(0,0,0,.72); }
.clipcard__media.playing .clipcard__play { opacity: 0; }
/* bulk-select checkbox — hidden until the results pane is in selecting mode */
.clipcard__check { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 7px; display: none; place-items: center; background: rgba(0,0,0,.55); border: 1.5px solid rgba(255,255,255,.5); color: transparent; backdrop-filter: blur(4px); }
.ws-results.selecting .clipcard__check { display: grid; }
.ws-results.selecting .clipcard__media { cursor: pointer; }
.ws-results.selecting .clipcard__play { display: none; }
.clipcard.selected .clipcard__check { background: var(--accent); border-color: var(--accent); color: #0a0a0b; }
.clipcard.selected .clipcard__media { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.clipcard__row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; min-height: 28px; }
.clipcard__score { font-size: 17px; font-weight: 800; color: var(--accent); }
.clipcard__actions { display: flex; align-items: center; gap: 5px; }
.clipcard__btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.clipcard__btn:hover { border-color: var(--accent); color: var(--accent); }
.clipcard__btn:disabled { opacity: .6; cursor: default; }
.clipcard__title { font-size: 12.5px; font-weight: 600; margin-top: 5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.clipcard__title:hover { color: var(--accent); }
.clipcard__desc { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.clipcard__desc:hover { color: var(--text); }

/* clip transcript / description tabs (音频转写 / 视频描述) — used inside the modal */
.clip-tabs { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel-2); overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.clip-tabs__nav { display: flex; gap: 2px; padding: 4px 4px 0; border-bottom: 1px solid var(--border); }
.clip-tab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px; font-size: 11.5px; font-weight: 600; color: var(--muted); background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; }
.clip-tab svg { width: 13px; height: 13px; }
.clip-tab:hover { color: var(--text); }
.clip-tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.clip-tabs__body { max-height: 124px; overflow-y: auto; padding: 8px 10px; }
.clip-tabs__pane { display: none; }
.clip-tabs__pane.on { display: block; }
.clip-trans__line { display: flex; gap: 9px; font-size: 12px; line-height: 1.5; margin-bottom: 6px; }
.clip-trans__line:last-child { margin-bottom: 0; }
.clip-trans__t { flex: 0 0 auto; font-family: ui-monospace, monospace; font-size: 10.5px; color: var(--accent); padding-top: 1px; }
.clip-trans__x { color: var(--text); }
.clip-trans__desc { font-size: 13px; color: var(--text); line-height: 1.6; }
.clip-trans__empty { font-size: 12px; color: var(--muted-2); }

/* enlarged clip modal */
/* Height fits the content (video + transcript/desc) but is capped at 88vh; when
   a transcript overflows that cap the right pane scrolls internally. Avoids the
   tall empty band a fixed 88vh leaves on big screens with short content. */
.clip-modal { width: min(960px, 94vw); max-height: 88vh; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.clip-modal::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
.clip-modal__head { flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.clip-modal__title { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; line-height: 1.35; }
.clip-modal__n { color: var(--accent); font-family: ui-monospace, monospace; margin-right: 4px; }
.clip-modal__meta { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.clip-modal__score { font-size: 18px; font-weight: 800; color: var(--accent); }
.clip-modal__range { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); }
.clip-modal__close { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 14px; flex-shrink: 0; }
.clip-modal__close:hover { border-color: var(--accent); color: var(--accent); }
.clip-modal__body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1.5fr 1fr; grid-template-rows: minmax(0, 1fr); gap: 16px; padding: 16px; }
/* Center + fit the clip in both dimensions. Don't force width:100% — a portrait
   clip would then blow up to the column width and overflow the modal (looking
   cropped). max-height is viewport-relative so it caps reliably regardless of
   how the grid row resolves. */
.clip-modal__media { min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.clip-modal__stage { flex: 1; background: #000; border-radius: var(--radius-sm); overflow: hidden; min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; }
.clip-modal__stage video { max-width: 100%; max-height: 64vh; width: auto; height: auto; display: block; object-fit: contain; background: #000; }
.clip-modal__media .clipctl { flex-shrink: 0; margin-top: 0; }
.clip-modal__side { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: hidden; }
.clip-modal__side .clip-tabs { flex: 1; min-height: 0; }
.clip-modal__side .clip-tabs__body { max-height: none; flex: 1; min-height: 0; overflow-y: auto; }
.clip-modal__acts { flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.clip-modal__dl { display: inline-flex; align-items: center; gap: 7px; }
.clips-actions .btn-line { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 720px) { .clip-modal__body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow-y: auto; } .clip-modal__stage video { max-height: 40vh; } }

/* highlight timeline: full-duration bar with the picked clips marked on it */
.clip-timeline { margin: 2px 0 16px; }
.clip-timeline__bar { position: relative; height: 30px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); overflow: hidden; }
.clip-timeline__seg { position: absolute; top: 0; bottom: 0; min-width: 3px; background: linear-gradient(180deg, var(--accent), rgba(212,249,106,.55)); border-radius: 3px; cursor: pointer; opacity: .82; transition: opacity .12s, transform .12s; }
.clip-timeline__seg:hover, .clip-timeline__seg.on { opacity: 1; transform: scaleY(1.12); box-shadow: 0 0 0 1px rgba(212,249,106,.5); }
.clip-timeline__scale { display: flex; justify-content: space-between; margin-top: 5px; font-family: ui-monospace, monospace; font-size: 10.5px; color: var(--muted-2); }

/* clip in-window scrubber + boundary fine-tune */
.clipctl { margin-top: 8px; }
.clipctl__bar { display: flex; align-items: center; gap: 8px; }
.clipctl__play { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); display: grid; place-items: center; }
.clipctl__play:hover { border-color: var(--accent); color: var(--accent); }
.clipctl__track { position: relative; flex: 1; height: 6px; border-radius: 999px; background: var(--panel-3); cursor: pointer; touch-action: none; }
.clipctl__fill { position: absolute; left: 0; top: 0; height: 100%; width: 0; background: var(--accent); border-radius: 999px; }
.clipctl__handle { position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); transform: translate(-50%, -50%); box-shadow: 0 0 0 3px rgba(212,249,106,.2); pointer-events: none; }
.clipctl__time { flex-shrink: 0; font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); white-space: nowrap; }
.clipctl__adj { display: flex; gap: 8px; flex-wrap: nowrap; justify-content: space-between; margin-top: 8px; }
.clipctl__grp { display: flex; align-items: center; gap: 3px; min-width: 0; }
.clipctl__lbl { font-size: 11px; color: var(--muted); white-space: nowrap; }
.clipctl__step { flex-shrink: 0; width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 14px; line-height: 1; display: grid; place-items: center; }
.clipctl__step:hover { border-color: var(--accent); color: var(--accent); }
.clipctl__val { font-family: ui-monospace, monospace; font-size: 11px; color: var(--text); min-width: 32px; text-align: center; }

/* Summary chapter = timeline: range pill + per-bullet timestamps on a dashed rail */
.chapter { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 14px; }
/* chapter keyframe: representative still at the head of each chapter */
.chapter__keyframe { display: block; width: 100%; padding: 0; margin: -2px 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #000; cursor: pointer; line-height: 0; }
.chapter__keyframe img { width: 100%; max-height: 220px; object-fit: cover; display: block; transition: transform .25s; }
.chapter__keyframe:hover { border-color: var(--accent); }
.chapter__keyframe:hover img { transform: scale(1.02); }
.chapter__head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.chapter__range { display: inline-flex; align-items: center; gap: 6px; font-family: ui-monospace, monospace; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-dim); border: none; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.chapter__range:hover { filter: brightness(1.12); }
.chapter__copy { margin-left: auto; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); display: grid; place-items: center; flex-shrink: 0; }
.chapter__copy:hover { color: var(--accent); border-color: var(--accent); }
.chapter__copy svg { width: 15px; height: 15px; }
.chapter__title { font-weight: 700; font-size: 14px; margin-bottom: 12px; }
.chapter__timeline { display: flex; flex-direction: column; }
.tl-row { display: grid; grid-template-columns: 62px 20px 1fr; align-items: start; cursor: pointer; }
.tl-time { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); padding-top: 13px; white-space: nowrap; }
.tl-dotcol { position: relative; align-self: stretch; }
.tl-dotcol::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 1.5px dashed var(--border-2); }
.tl-row:last-child .tl-dotcol::before { bottom: auto; height: 18px; }
.tl-dot { position: absolute; left: 50%; top: 13px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); transform: translate(-50%, 0); box-shadow: 0 0 0 3px var(--bg-2); }
.tl-card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px; font-size: 13px; line-height: 1.55; margin-bottom: 12px; transition: border-color .12s; }
.tl-row:hover .tl-card { border-color: var(--border-2); }
.tl-row:hover .tl-dot { box-shadow: 0 0 0 3px var(--bg-2), 0 0 8px var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { font-size: 12px; padding: 5px 11px; border-radius: 999px; background: var(--accent-dim); color: var(--accent); }

.scene { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 15px; margin-bottom: 12px; animation: pop .25s ease; transition: border-color .15s, box-shadow .15s; }
/* script ↔ video sync: the scene playing in the source video is highlighted */
.scene--active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 16px rgba(212,249,106,.12); }
.scene__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.scene__seek { display: inline-flex; align-items: center; gap: 6px; font-family: ui-monospace, monospace; font-size: 11.5px; font-weight: 600; color: var(--accent); background: var(--accent-dim); border: none; padding: 5px 10px; border-radius: 999px; cursor: pointer; flex-shrink: 0; }
.scene__seek:hover { filter: brightness(1.12); }
.scene__slug { font-weight: 700; font-size: 13px; letter-spacing: .03em; color: var(--accent); flex: 1; min-width: 0; }
/* per-scene accuracy badge (task 3): match score of generated content vs source */
.scene__score { margin-left: auto; flex-shrink: 0; font-family: ui-monospace, monospace; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.score--hi { color: #9fe870; background: rgba(159,232,112,.14); }
.score--mid { color: #f6c453; background: rgba(246,196,83,.14); }
.score--lo { color: #ff8a7a; background: rgba(255,138,122,.16); }
.score--na { color: var(--muted-2); background: var(--panel-2); }
.el { position: relative; margin-bottom: 8px; font-size: 13px; line-height: 1.5; border-left: 2px solid transparent; padding-left: 10px; padding-right: 26px; }
/* per-line delete (×) — revealed on hover over the line */
.el__del { position: absolute; top: 0; right: 0; width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; background: none; border: none; color: var(--muted-2); opacity: 0; transition: .12s; cursor: pointer; }
.el:hover .el__del { opacity: 1; }
.el__del:hover { background: #ff4d4d; color: #fff; }
.el__del svg { width: 12px; height: 12px; }
/* thin hover-revealed inserter between lines — insert a new line at any position */
.el-insert { position: relative; height: 7px; margin-left: 10px; }
.el-insert__btn { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--border-2); color: var(--muted); opacity: 0; transition: .12s; cursor: pointer; z-index: 1; }
.el-insert__btn svg { width: 11px; height: 11px; display: block; }
.el-insert:hover .el-insert__btn { opacity: 1; }
.el-insert__btn:hover { color: var(--accent); border-color: var(--accent); }
.el-insert:hover::before { content: ''; position: absolute; left: 24px; right: 26px; top: 50%; height: 1px; background: var(--border-2); }
.el--action { color: var(--muted); }
.el--dialogue { padding-left: 12px; }
/* confidence color coding: low-confidence content is flagged for human review */
.el.conf--lo { border-left-color: #ff8a7a; background: rgba(255,138,122,.06); border-radius: 0 6px 6px 0; }
.el.conf--mid { border-left-color: rgba(246,196,83,.55); }
.el__speaker { font-weight: 700; color: var(--text); background: none; border: none; padding: 0; cursor: pointer; border-bottom: 1px dashed transparent; font: inherit; }
.el__speaker:hover { color: var(--accent); border-bottom-color: var(--accent); }
.el__text { font: inherit; }
.el__colon { color: var(--muted-2); }
/* inline-editable screenplay line (proofreading: typos / re-segmentation) */
.el__text--edit { font: inherit; outline: none; border-radius: 4px; padding: 0 3px; margin: 0 -3px; cursor: text; transition: background .12s, box-shadow .12s; white-space: pre-wrap; }
.el__text--edit:hover { background: var(--panel-2); }
.el__text--edit:focus { background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--accent); cursor: text; }
.script-edit-hint { font-size: 12px; color: var(--muted-2); margin: 2px 0 12px; padding: 7px 10px; background: var(--panel-2); border-radius: 8px; }
.el__paren { color: var(--muted-2); font-style: italic; }
.el__flag { margin-left: 6px; font-size: 11px; color: #ff8a7a; cursor: help; }

/* hover tooltip (scene score badge, low-confidence flag). A single shared
   popup positioned in JS so it clamps to the viewport instead of clipping, and
   never doubles up with the native title tooltip. */
.htip { cursor: help; }
.htip-pop {
  position: fixed; z-index: 200; max-width: 260px; white-space: normal; text-align: left;
  text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; line-height: 1.45;
  background: var(--panel); color: var(--text); border: 1px solid var(--border-2);
  border-radius: 8px; padding: 7px 10px; box-shadow: 0 10px 28px rgba(0,0,0,.45);
  pointer-events: none; display: none;
}

/* speaker reassign popup */
.spk-menu { position: fixed; z-index: 200; min-width: 180px; max-height: 280px; overflow-y: auto; background: var(--panel); border: 1px solid var(--border-2); border-radius: 10px; padding: 5px; box-shadow: 0 12px 32px rgba(0,0,0,.4); }
.spk-menu__item { display: block; width: 100%; text-align: left; padding: 7px 10px; font-size: 13px; color: var(--text); background: none; border: none; border-radius: 7px; cursor: pointer; }
.spk-menu__item:hover { background: var(--panel-2); }
.spk-menu__item.on { color: var(--accent); }
.spk-menu__new { color: var(--accent); border-top: 1px solid var(--border); border-radius: 0 0 7px 7px; margin-top: 4px; }

/* editable character roster */
.char-hint { font-size: 12px; color: var(--muted); margin: -4px 0 8px; line-height: 1.5; }
.char-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 10px; }
.char-count { font-size: 11.5px; color: var(--muted); }
.char-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); cursor: pointer; user-select: none; }
.char-toggle input { accent-color: var(--accent); cursor: pointer; margin: 0; }
.char-toggle:hover { color: var(--text); }
/* Responsive grid that caps its height and scrolls internally, so a long
   speaker roster never pushes the rest of the script off-screen. ~5 rows show
   before the list scrolls; the count label cues that there's more below. */
.char-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px;
  max-height: 340px; overflow-y: auto; padding: 2px 6px 2px 2px;
  overscroll-behavior: contain;
}
.char-list::-webkit-scrollbar { width: 8px; }
.char-list::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 999px; }
.char-list::-webkit-scrollbar-track { background: transparent; }
.character { display: flex; flex-direction: column; gap: 4px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.character:focus-within { border-color: var(--accent); }
.character__name { width: 100%; box-sizing: border-box; font-weight: 600; font-size: 14px; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; }
.character__name:focus { outline: none; border-color: var(--accent); }
.character__meta { font-size: 11px; color: var(--muted); padding-left: 2px; }
.char-add { width: 100%; box-sizing: border-box; margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--accent); background: var(--accent-dim); border: 1px dashed var(--accent); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.char-add:hover { filter: brightness(1.1); }

.res-img { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-top: 10px; }
.downloads { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.caption-img { display: block; max-width: 100%; max-height: 340px; width: auto; object-fit: contain; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 12px; background: #000; }
/* Pre-run thumbnail of the image to be captioned, shown inside the config form. */
.cap-preview { display: flex; align-items: center; gap: 10px; padding: 8px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; }
.cap-preview img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: #000; flex-shrink: 0; }
.cap-preview__name { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); word-break: break-all; }
.cap-preview__clear { flex-shrink: 0; width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; }
.cap-preview__clear:hover { color: var(--text); border-color: var(--border-2); }
.caption-out { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; font-size: 15px; line-height: 1.6; }
.log-line { font-size: 12px; color: var(--muted-2); font-family: ui-monospace, monospace; padding: 3px 0; }

.processing { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 13px; padding: 120px 0; text-align: center; }
.processing__title { font-size: 15px; font-weight: 600; color: var(--text); }
.processing__bar { width: 240px; height: 6px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.processing__fill { height: 100%; width: 5%; background: var(--accent); border-radius: 999px; transition: width .5s ease; }
.processing__sub { font-size: 13px; color: var(--muted); min-height: 1em; }
.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0; }
.spinner--lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ░░ Dialog ░░ */
.dialog { border: none; background: transparent; padding: 0; }
.dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.dialog__body { background: var(--panel); color: var(--text); border: 1px solid var(--border-2); border-radius: var(--radius); padding: 24px; width: min(440px, 90vw); box-shadow: var(--shadow); }
.dialog__body h3 { margin: 0 0 4px; font-size: 18px; }
.dialog__body > .muted { font-size: 13px; margin: 0 0 4px; }
.dialog__body input { width: 100%; margin-top: 12px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
/* section sub-heads inside dialogs (Change password / API endpoint / Create account) */
.dialog__body h4.userform__title { margin: 22px 0 2px; font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.dialog__body h4.userform__title:first-of-type { margin-top: 14px; }

/* ░░ Accounts / auth ░░ */
.pill--user { background: var(--accent-dim); color: var(--accent); border: 1px solid transparent; }

/* User menu (account center) */
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #0a0a0b; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex-shrink: 0; }
.avatar--lg { width: 38px; height: 38px; font-size: 16px; }
.usermenu-wrap { position: relative; }
.usermenu-trigger { display: inline-flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 5px 9px 5px 5px; border-radius: 999px; font-size: 13px; font-weight: 600; transition: border-color .15s; }
.usermenu-trigger:hover, .usermenu-trigger.is-open { border-color: var(--border-2); }
.usermenu-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-caret { width: 15px; height: 15px; color: var(--muted); }
.usermenu { position: absolute; right: 0; top: calc(100% + 8px); width: 250px; background: var(--panel); border: 1px solid var(--border-2); border-radius: 14px; box-shadow: var(--shadow); padding: 8px; z-index: 200; animation: pop .15s ease; }
.usermenu__head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.usermenu__name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.usermenu__role { font-size: 12px; color: var(--muted); margin-top: 1px; }
.usermenu__item { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none; color: var(--text); padding: 9px 8px; border-radius: 9px; font-size: 13px; font-weight: 500; text-align: left; }
.usermenu__item svg { width: 17px; height: 17px; color: var(--muted); flex-shrink: 0; }
.usermenu__item:hover { background: var(--panel-2); }
.usermenu__val { margin-left: auto; color: var(--muted); font-size: 12px; }
.usermenu__chev { width: 14px; height: 14px; margin-left: 6px; color: var(--muted); transition: transform .15s; }
.usermenu__item.is-open .usermenu__chev { transform: rotate(90deg); }
.usermenu__sep { height: 1px; background: var(--border); margin: 6px 4px; }
.usermenu__item--danger { color: #ff7a7a; }
.usermenu__item--danger svg { color: #ff7a7a; }
/* language submenu */
.usermenu__sub { padding-left: 34px; }
.usermenu__subitem { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none; color: var(--text); padding: 8px; border-radius: 8px; font-size: 13px; text-align: left; }
.usermenu__subitem:hover { background: var(--panel-2); }
.usermenu__check { width: 15px; height: 15px; margin-left: auto; color: var(--accent); opacity: 0; }
.usermenu__subitem.is-active { color: var(--accent); }
.usermenu__subitem.is-active .usermenu__check { opacity: 1; }
/* account id (read-only) in the account dialog */
.account-id { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; font-size: 13px; margin: 2px 0 6px; }
.account-id #accountId { font-weight: 700; }
.account-id__fixed { font-size: 12px; }

/* Login gate — full-screen overlay above everything */
.authgate {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #161618, var(--bg));
}
.authcard {
  width: min(380px, 90vw); background: var(--panel); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 30px 28px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.authcard__brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; letter-spacing: .2px; }
.authcard h2 { margin: 18px 0 4px; font-size: 22px; }
.authcard .muted { font-size: 13px; margin: 0 0 18px; }
.authcard__label { display: flex; flex-direction: column; gap: 7px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.authcard__label input {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 13px; border-radius: 10px; font-size: 14px; font-weight: 500;
}
.authcard__label input:focus { border-color: var(--border-2); outline: none; }
.authcard__go { margin-top: 6px; width: 100%; }

/* Accounts dialog */
.dialog__body--wide { width: min(560px, 92vw); }

/* Video picker dialog */
.pick-actions { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; flex-wrap: wrap; }
.pick-actions .btn-cta { flex-shrink: 0; }
.pick-url { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 6px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 0 6px 0 12px; }
.pick-url:focus-within { border-color: var(--border-2); }
.pick-url input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--text); font-size: 13px; padding: 10px 0; margin: 0; }
.pick-url input::placeholder { color: var(--muted-2); }
.pick-url__go { flex-shrink: 0; display: grid; place-items: center; width: 32px; height: 32px; border: none; border-radius: 8px; background: var(--accent); color: #0a0f08; }
.pick-url__go svg { width: 16px; height: 16px; }
.pick-url__go:hover { filter: brightness(1.06); }
.pick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-height: 320px; overflow: auto; margin-top: 12px; padding: 2px; }
.pick-grid .vcard__title { font-size: 12px; }
@media (max-width: 560px) { .pick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.userlist { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; max-height: 280px; overflow: auto; }
.userrow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; }
.userrow__name { font-weight: 600; font-size: 14px; }
.userrow__role { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--panel-3); color: var(--muted); }
.userrow__role.is-admin { background: var(--accent-dim); color: var(--accent); }
.userrow__spacer { margin-left: auto; }
.userrow__del { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; }
.userrow__del:hover:not(:disabled) { color: #ff6b6b; border-color: #ff6b6b55; }
.userrow__del:disabled { opacity: .4; cursor: not-allowed; }
.userform { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.userform input { width: auto; flex: 1 1 130px; margin-top: 0; }
.userform .fsel { flex: 1 1 120px; }
.userform .btn-cta { padding: 9px 16px; font-size: 13px; }

/* Saved-task cards reuse .vcard; add a capability tint + delete affordance */
.vcard { position: relative; }
.vcard__cap { position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
.vcard__cap svg { width: 15px; height: 15px; }
.vcard__del {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55);
  border: none; color: #fff; opacity: 0; transition: .12s;
}
.vcard:hover .vcard__del { opacity: 1; }
.vcard__del:hover { background: #ff4d4d; }
.vcard__del svg { width: 14px; height: 14px; }
.vcard__dl {
  position: absolute; top: 8px; right: 42px; width: 26px; height: 26px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55);
  border: none; color: #fff; opacity: 0; transition: .12s; cursor: pointer;
}
.vcard:hover .vcard__dl { opacity: 1; }
.vcard__dl:hover { background: var(--accent); color: #0a0a0b; }
.vcard__dl svg { width: 15px; height: 15px; }
.vid-grid.selecting .vcard__dl { display: none; }
.vcard__expiry { font-size: 11px; color: var(--muted-2); margin-top: 2px; }
/* in-progress / failed run badge on a Library card */
.vcard__run {
  position: absolute; left: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em; color: var(--accent);
  background: rgba(0,0,0,.6); padding: 4px 9px; border-radius: 999px; backdrop-filter: blur(4px);
}
.vcard__run--err { color: #ff7a7a; }
.vcard__run .spinner { width: 11px; height: 11px; border-width: 2px; }

/* Replay banner in the workspace */
.replay-note { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; margin-bottom: 12px; }
.replay-note .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex-shrink: 0; }
