/* AI Reels — "Rail Terminal" (v1.2). IBM Plex Mono bundled locally; no external requests. */

@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-mono-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-mono-latin-700-normal.woff2) format('woff2'); }

:root {
  --bg: #1c1c1e;
  --panel: #232325;
  --raised: #2a2a2d;
  --hover: #313134;
  --line: #3d3d41;
  --line-soft: #303033;
  --text: #f0f0f0;
  --muted: #8c8c8c;
  --faint: #5a5a5a;
  --soft-text: #bdbdbd;
  --gen: #e8b34b;
  --review: #5ccfe6;
  --ok: #7bd88f;
  --bad: #ff6b6b;
  --gen-soft: rgba(232, 179, 75, .14);
  --review-soft: rgba(92, 207, 230, .13);
  --ok-soft: rgba(123, 216, 143, .13);
  --bad-soft: rgba(255, 107, 107, .13);
  --accent-soft: rgba(255, 255, 255, .07);
  --stripes: repeating-linear-gradient(135deg, #19191b 0 8px, #212124 8px 16px);
  --stripes-sm: repeating-linear-gradient(135deg, #19191b 0 6px, #212124 6px 12px);
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 12.5px/1.5 var(--mono);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
::selection { background: var(--text); color: var(--bg); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--text); }
a:hover { color: #fff; }
code { font-family: var(--mono); font-size: .92em; background: var(--raised); padding: 1px 5px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--text); color: var(--bg); padding: 6px 10px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 1px solid var(--text); outline-offset: 2px; }
input:focus, textarea:focus, select:focus { border-color: var(--text) !important; outline: none; box-shadow: none; }
input[type=checkbox] { accent-color: var(--text); width: 16px; height: 16px; margin: 0; cursor: pointer; }
input[type=checkbox]:disabled { cursor: default; opacity: .4; }
.grow { flex: 1; min-width: 0; }
.push { margin-left: auto; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-gen { color: var(--gen); }

@keyframes blink { 50% { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: 0;
  border: 1px solid var(--line); background: var(--raised); color: var(--text);
  font-weight: 550; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--hover); color: var(--text); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:disabled:hover { background: var(--raised); }
.btn-primary { border-color: var(--text); background: var(--text); color: var(--bg); }
.btn-primary:hover { background: #fff; color: var(--bg); }
.btn-primary:disabled:hover { background: var(--text); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--raised); color: var(--text); }
.btn-ghost:disabled:hover { background: transparent; }
.btn-danger { border-color: var(--soft-text); background: var(--soft-text); color: var(--bg); }
.btn-danger:hover { background: #fff; color: var(--bg); }
.btn-ink { border-color: var(--bg); background: var(--bg); color: var(--text); }
.btn-ink:hover { background: #000; color: var(--text); }
.btn-small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 42px; padding: 0 22px; font-size: 15px; }
.btn-icon { width: 30px; height: 30px; padding: 0; }
.btn-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.link { color: var(--text); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; display: inline-block; background: currentColor; }
.dot-gen { background: var(--gen); }
.dot-review { background: var(--review); }
.dot-ok { background: var(--ok); }
.dot-bad { background: var(--bad); }
.dot-faint { background: var(--faint); }
.dot-muted { background: var(--muted); }
.spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; flex: none; display: inline-block; }

.bar { height: 4px; background: var(--line); overflow: hidden; position: relative; }
.bar > i { display: block; height: 100%; width: 0; background: var(--text); transition: width .4s; }
.bar-gen > i { background: var(--gen); }
.bar-ok > i { background: var(--ok); }
.bar-indet > i { width: 40% !important; animation: indet 1.2s ease-in-out infinite; transition: none; }

/* ----------------------------------------------------------------- header */
.topbar {
  position: sticky; top: 0; z-index: 30; height: 56px;
  display: flex; align-items: center; gap: 20px; padding: 0 16px 0 20px;
  background: var(--bg); border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 176px; flex: none; white-space: nowrap; }
.brand-badge { padding: 3px 8px; background: var(--text); color: var(--bg); font-weight: 700; letter-spacing: .16em; }
.brand-ver { color: var(--faint); }
.cursor { animation: blink 1s steps(1) infinite; font-weight: 700; }
.badge-mock { font-size: 11px; font-weight: 650; padding: 2px 7px; background: var(--raised); color: var(--text); border: 1px solid #555; }
.live { flex: 1; display: flex; gap: 18px; color: var(--muted); font-size: 13px; min-width: 0; overflow: hidden; }
.live-item { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; flex: none; }
.live-item b { color: var(--text); font-weight: 600; }
.live-item .dot { width: 8px; height: 8px; }
.live-item.is-bad { color: var(--bad); }
.balance { flex: none; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--muted); font-size: 13px; }
.balance b { color: var(--text); font-weight: 600; }
.btn-quit svg { width: 16px; height: 16px; }

.banner {
  position: sticky; top: 56px; z-index: 29; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--text); color: var(--bg); border-bottom: 1px solid var(--text); font-size: 13.5px;
}

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 196px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.rail {
  position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 2px;
  border-right: 1px solid var(--line-soft); background: var(--bg);
}
.nav {
  display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 12px;
  text-decoration: none; font-weight: 550; color: var(--muted);
}
.nav:hover { color: var(--text); }
.nav[aria-current=page] { color: var(--text); background: var(--raised); }
.nav svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-count { margin-left: auto; font-size: 12px; color: var(--faint); font-weight: 600; }
.nav-count-hot:not(:empty) { color: var(--bg); background: var(--review); padding: 0 7px; line-height: 19px; }
main { padding: 28px 32px 40px; min-width: 0; outline: none; }
.main-inner { max-width: 1680px; }

.view-head { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 6px 24px; margin-bottom: 22px; }
.view-head h1 { font-weight: 700; font-size: 20px; line-height: 1.2; letter-spacing: .12em; }
.view-head > .view-sub { margin: 0 0 3px; color: var(--muted); flex-basis: 100%; order: 2; }
.view-head-row { justify-content: space-between; align-items: flex-start; }
.view-head-row .view-sub { color: var(--muted); margin-top: 6px; }
.view-head-row > .chips, .view-head-row > .head-action { margin-left: auto; }
.section-title { font-size: 15px; font-weight: 650; }

.panel { background: var(--panel); border: 1px solid var(--line-soft); }
.tile { background: var(--panel); border: 1px solid var(--line-soft); padding: 14px 16px 16px; }
.tile-label { color: var(--muted); font-size: 13px; }
.tile-big { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.big-num { font-size: 30px; font-weight: 600; line-height: 1.1; }
.big-unit { font-size: 13px; color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; }
.warn { color: var(--bad); font-size: 12.5px; margin: 0 0 8px; }
.field-label { font-weight: 600; font-size: 13px; }
.row-end { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.empty { border: 1px dashed var(--line); padding: 40px 24px; text-align: center; color: var(--muted); }
.empty p { margin: 4px 0; }
.empty-title { color: var(--text); font-weight: 600; font-size: 15px; }
.panel-empty { color: var(--muted); margin: 8px 0 12px; font-size: 13px; }

input[type=text], input[type=password], input[type=number], textarea, select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 0; padding: 8px 10px; width: 100%;
}
textarea { line-height: 1.5; resize: vertical; }
select { height: 36px; padding: 0 10px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; cursor: pointer;
  font-weight: 550; font-size: 13px; background: transparent; color: var(--muted); border: 1px solid var(--line);
}
.chip:hover { color: var(--text); }
.chip[aria-checked=true] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip-n { font-size: 12px; opacity: .75; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* ------------------------------------------------------------------ pills */
.pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600;
  padding: 3px 10px 3px 8px; white-space: nowrap; color: var(--muted); background: var(--raised);
}
.pill-ready, .pill-approved, .pill-done { color: var(--ok); background: var(--ok-soft); }
.pill-downloading, .pill-generating, .pill-running { color: var(--gen); background: var(--gen-soft); }
.pill-error, .pill-failed, .pill-rejected { color: var(--bad); background: var(--bad-soft); }
.pill-pending_review { color: var(--review); background: var(--review-soft); }

/* --------------------------------------------------------------- overview */
.ov-tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.ov-tile { display: flex; flex-direction: column; gap: 10px; }
.ov-actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.ov-foot { margin-top: auto; font-size: 13px; color: var(--muted); }
.ov-foot b { color: var(--text); font-weight: 600; }
.ov-foot-bar { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.ov-media-head { display: flex; align-items: center; gap: 8px; }
.ov-media-state { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ok); }
.ov-media-state.is-off { color: var(--bad); }
.ov-media-state.is-low { color: var(--gen); }
.ov-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.ov-cols > .panel { padding: 4px 18px 10px; }
.panel-head { display: flex; align-items: center; margin: 14px 0 6px; }
.panel-head h2 { font-size: 15px; font-weight: 650; }
.panel-head a { margin-left: auto; font-size: 13px; }
.gen-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) 120px 48px; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.gen-file { font-weight: 550; }
.gen-sub { color: var(--muted); font-size: 12.5px; }
.gen-dots { display: flex; gap: 3px; }
.gen-dots span { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.gen-dots span.is-done { background: var(--gen); }
.gen-dots span.is-run { background: var(--gen-soft); box-shadow: inset 0 0 0 1px rgba(232,179,75,.35); }
.gen-pct { font-size: 14px; font-weight: 700; color: var(--gen); text-align: right; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: #38383c; color: var(--text); flex: none; object-fit: cover; overflow: hidden; }
.avatar-sm { width: 18px; height: 18px; font-size: 9px; }
.ev-row { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-top: 1px solid var(--line-soft); font-size: 13px; }
.ev-time { font-size: 12px; color: var(--faint); padding-top: 1px; }
.ev-text { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.ev-text .dot { transform: translateY(-1px); }

/* event badge tones */
.tone-accent { color: var(--text); background: var(--accent-soft); }
.tone-ok { color: var(--ok); background: var(--ok-soft); }
.tone-bad { color: var(--bad); background: var(--bad-soft); }
.tone-gen { color: var(--gen); background: var(--gen-soft); }
.tone-review { color: var(--review); background: var(--review-soft); }
.tone-faint { color: var(--muted); background: var(--raised); }

/* ------------------------------------------------------------------ queue */
.add-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 28px; }
.add-links { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.add-links textarea { font-size: 12.5px; min-height: 80px; flex: 1; }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px;
  padding: 16px; border: 1.5px dashed var(--line); background: var(--panel); transition: border-color .15s, background .15s;
}
.drop.is-over { border-color: var(--text); background: var(--accent-soft); }
.drop > svg { width: 38px; height: 38px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.drop-hint { margin-top: 4px; max-width: 40ch; }
.uploads { width: 100%; display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.upload { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; font-size: 12.5px; text-align: left; }
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-pct { color: var(--muted); }
.upload .bar { grid-column: 1 / -1; }

.queue-head { display: flex; align-items: center; gap: 16px; padding: 0 4px 10px; border-bottom: 1px solid var(--line-soft); }
.queue-head .hint { margin-left: auto; }
.queue-list { list-style: none; margin: 0; padding: 0; }
.qrow {
  display: grid; grid-template-columns: 22px 48px minmax(0, 1fr) 70px 80px 150px 36px; align-items: center; gap: 14px;
  padding: 10px 4px; border-bottom: 1px solid var(--line-soft); min-height: 82px;
}
.qrow.is-selected { background: linear-gradient(90deg, var(--accent-soft), transparent 60%); }
.thumb { width: 48px; height: 64px; border: 1px solid var(--line-soft); display: grid; place-items: center; background: var(--stripes-sm); overflow: hidden; color: var(--faint); }
.thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb svg { width: 20px; height: 20px; fill: none; stroke: var(--faint); stroke-width: 1.6; }
.qname { min-width: 0; }
.qname-main { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qname-sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qname-sub a { color: var(--muted); text-decoration: none; }
.qname-sub a:hover { color: var(--text); text-decoration: underline; }
.qname-err { color: var(--soft-text); font-size: 12.5px; }
.qname-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.dur { font-size: 13px; font-weight: 500; }
.chunk { font-size: 12px; color: var(--text); background: var(--raised); padding: 2px 8px; white-space: nowrap; }
.qstatus { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.qstatus .bar { width: 120px; }

.genbar {
  position: sticky; bottom: 16px; z-index: 10; margin-top: 24px; display: flex; align-items: center; gap: 20px;
  padding: 12px 12px 12px 14px; background: rgba(28, 28, 30, .96); border: 1px solid var(--line);
}
.genbar-creator { position: relative; flex: none; }
.genbar-est { flex: 1; color: var(--muted); min-width: 0; }
.genbar-est b { color: var(--text); font-weight: 600; }
.genbar-est .est-cost { font-weight: 700; color: var(--text); }
.picker-btn {
  display: flex; align-items: center; gap: 10px; height: 42px; min-width: 230px; padding: 0 12px 0 5px;
  background: var(--bg); border: 1px solid var(--line); cursor: pointer; text-align: left;
}
.picker-btn:hover { border-color: var(--faint); }
.picker-btn > span:not(.avatar) { font-weight: 600; }
.picker-placeholder { color: var(--muted); padding-left: 7px; font-weight: 550 !important; }
.chev { margin-left: auto; width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.picker-list {
  position: absolute; bottom: calc(100% + 8px); left: 0; min-width: 100%; max-height: 320px; overflow: auto; padding: 6px;
  background: var(--raised); border: 1px solid var(--line); z-index: 20; list-style: none; margin: 0; outline: none;
}
.picker-opt { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; cursor: pointer; }
.picker-opt:hover, .picker-opt.is-active { background: var(--hover); }
.picker-opt[aria-selected=true] { background: var(--accent-soft); }
.picker-opt[aria-selected=true].is-active { background: var(--hover); }
.picker-opt > span:nth-child(2) { font-weight: 550; }
.picker-n { margin-left: auto; color: var(--faint); font-size: 12px; padding-left: 16px; }
.no-creators { color: var(--muted); display: flex; gap: 8px; align-items: center; height: 42px; padding: 0 6px; }

/* ---------------------------------------------------------------- backlog */
.ov-backlog {
  display: flex; align-items: center; gap: 14px; margin-top: 12px; padding: 11px 16px;
  text-decoration: none; color: var(--muted); font-size: 13px;
}
.ov-backlog:hover { border-color: var(--line); color: var(--text); }
.ov-backlog-label { color: var(--text); font-weight: 650; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; }
.ov-backlog-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-backlog-link { color: var(--text); white-space: nowrap; }
.ov-backlog:hover .ov-backlog-link { text-decoration: underline; text-underline-offset: 2px; }

.bl-dl {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: -12px 0 18px;
  background: var(--panel); border: 1px solid var(--line-soft); border-left: 2px solid var(--gen); color: var(--muted);
}
.bl-dl b { color: var(--text); font-weight: 600; }
.bl-dl.is-paused { border-left-color: var(--bad); color: var(--text); }
.bl-dl-n { color: var(--muted); }
.bl-dl .btn { flex: none; }

.bl-tools { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 14px; }
.bl-search { position: relative; flex: 1 1 260px; max-width: 420px; display: flex; }
.bl-search svg { position: absolute; left: 10px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; pointer-events: none; }
.bl-search input { height: 32px; padding: 0 10px 0 32px; background: var(--bg); border: 1px solid var(--line); border-radius: 0; width: 100%; }
.bl-search input:focus { border-color: var(--text); outline: none; }
.bl-search input::-webkit-search-cancel-button { filter: invert(.6); }
.bl-notfor { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.bl-notfor select { height: 32px; min-width: 160px; }
.bl-head { margin-top: 4px; }

.blrow {
  grid-template-columns: 22px 48px minmax(0, 1fr) minmax(120px, 210px) 64px 74px 130px 36px;
  grid-template-areas: "cb thumb name used dur parts status del";
}
.blrow > .bl-cb { grid-area: cb; }
.blrow > .thumb { grid-area: thumb; }
.blrow > .qname { grid-area: name; }
.blrow > .bl-used { grid-area: used; }
.blrow > .dur { grid-area: dur; }
.blrow > .chunk-slot { grid-area: parts; }
.blrow > .qstatus { grid-area: status; }
.blrow > .bl-del { grid-area: del; }
.bl-used { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.bl-chip { font-size: 12px; padding: 1px 7px; background: var(--raised); color: var(--soft-text); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.bl-chip.is-hot { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--faint); }
.bl-unused { font-size: 12px; color: var(--faint); }
.pill-waiting { color: var(--muted); background: var(--raised); }
.bl-more { display: flex; justify-content: center; padding: 14px 0 4px; }
.bl-again { color: var(--gen); }
.linkbtn { background: none; border: 0; padding: 0 0 0 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.linkbtn:hover { color: var(--text); }
.bl-bar .btn-lg { flex: none; }
#view-backlog .empty { margin-top: 12px; }
/* keep toasts clear of the sticky action bar */
body[data-view=queue] .toasts, body[data-view=backlog] .toasts { bottom: 96px; }
@media (max-width: 1100px) {
  .bl-bar { flex-wrap: wrap; gap: 10px 12px; }
  .bl-bar .genbar-est { order: 3; flex-basis: 100%; }
  .bl-bar .genbar-creator { margin-right: auto; }
}

/* ----------------------------------------------------------------- review */
.review-filters { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-left: auto; }
.review-filters select { min-width: 160px; height: 32px; }
.keys { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: -8px 0 16px; color: var(--faint); font-size: 12px; }
.keys > span { display: inline-flex; gap: 4px; align-items: center; }
kbd { font-family: var(--mono); font-size: 11px; min-width: 20px; text-align: center; padding: 1px 5px; background: var(--raised); border: 1px solid var(--line); border-bottom-width: 2px; }

.reel-grid { display: grid; gap: 12px; align-items: start; grid-template-columns: repeat(auto-fill, minmax(175px, 190px)); padding-bottom: 56px; }
.card {
  background: var(--panel); display: flex; flex-direction: column; min-width: 0; position: relative;
  border: 1px solid var(--line-soft); transition: border-color .15s, box-shadow .15s; outline: none;
}
.card.is-focused, .card:focus-visible { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.card.is-compare { grid-column: span 2; }
.card.is-busy { opacity: .7; }
.card-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px; min-height: 32px; }
.card-creator { font-weight: 650; font-size: 11px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { margin-left: auto; flex: none; font-size: 9.5px; font-weight: 600; padding: 0 4px; white-space: nowrap; color: var(--muted); background: var(--raised); }
.tag-pending_review { color: var(--review); background: var(--review-soft); }
.tag-generating { color: var(--gen); background: var(--gen-soft); }
.tag-approved { color: var(--ok); background: var(--ok-soft); }
.tag-rejected, .tag-failed { color: var(--bad); background: var(--bad-soft); }
.stage { display: grid; gap: 2px; padding: 0 2px; grid-template-columns: 1fr; }
.card.is-compare .stage { grid-template-columns: 1fr 1fr; }
.frame { position: relative; aspect-ratio: 9 / 16; overflow: hidden; display: grid; place-items: center; background: var(--stripes); }
.frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.frame-tag { position: absolute; top: 4px; left: 4px; z-index: 2; font-size: 10px; font-weight: 600; padding: 0 4px; background: var(--text); color: var(--bg); pointer-events: none; }
.frame-sound {
  position: absolute; top: 4px; right: 4px; z-index: 2; width: 24px; height: 24px; padding: 0; display: grid; place-items: center;
  background: rgba(28, 28, 30, .7); border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
.frame-sound svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.frame-state { padding: 8px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; font-size: 10px; }
.frame-state .big { font-size: 18px; font-weight: 700; color: var(--gen); line-height: 1; }
.frame-state .bar { width: 70%; }
.frame-state.is-failed .big { font-size: 14px; color: var(--soft-text); }
.frame-state.is-gone .big { font-size: 12px; color: var(--muted); }
.frame-state .err { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.card-meta { padding: 6px 8px 0; min-width: 0; }
.card-file { display: flex; gap: 6px; align-items: baseline; }
.card-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; min-width: 0; }
.card-file-name a { color: var(--muted); text-decoration: none; }
.card-file-name a:hover { color: var(--text); text-decoration: underline; }
.card-file .dur { font-size: 11px; margin-left: auto; flex: none; font-weight: 400; }
.approved-name { margin-top: 4px; font-size: 10px; color: var(--ok); overflow-wrap: anywhere; display: flex; gap: 4px; align-items: center; }
.approved-name svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; flex: none; }
.vtabs { display: flex; gap: 3px; padding: 6px 8px 0; align-items: center; }
.vtablist { display: flex; gap: 3px; flex: 1; min-width: 0; }
.vtab {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 3px 5px; min-width: 0; cursor: pointer;
  text-align: left; background: var(--bg); border: 1px solid var(--line-soft);
}
.vtab[aria-selected=true] { background: var(--accent-soft); border-color: var(--text); }
.vtab-top { display: flex; align-items: center; gap: 4px; width: 100%; font-size: 11px; font-weight: 650; }
.vtab-top .dot { margin-left: auto; }
.vtab-star { color: var(--ok); }
.vtab .bar { width: 100%; height: 3px; }
.vtab-sub { font-size: 9.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.compare-btn { flex: none; width: 24px; height: 24px; padding: 0; display: grid; place-items: center; cursor: pointer; color: var(--text); background: var(--raised); border: 1px solid var(--line); }
.compare-btn svg { width: 16px; height: 16px; }
.compare-btn[aria-pressed=true] { border-color: var(--text); background: var(--accent-soft); }
.card-actions { display: flex; gap: 3px; padding: 8px; margin-top: auto; }
.card-actions .act {
  flex: 1; height: 26px; padding: 0; font-size: 12px; border: 1px solid var(--line); background: var(--raised);
  font-weight: 550; cursor: pointer; display: grid; place-items: center; color: var(--text);
}
.card-actions .act:hover:not(:disabled) { background: var(--hover); }
.card-actions .act:disabled { opacity: .4; cursor: default; }
.card-actions .act-ok { background: var(--ok); color: var(--bg); font-weight: 700; }
.card-actions .act-ok:hover:not(:disabled) { background: #97e3a8; }
.card-actions .act-bad { color: var(--bad); }
.card-actions .act-bad:hover:not(:disabled) { border-color: var(--soft-text); }
.card-actions .act svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.card-note { padding: 8px; color: var(--faint); font-size: 10px; margin-top: auto; }
.card-actions-em { align-items: center; }
.card-actions-em .card-note-in { color: var(--faint); font-size: 10px; flex: none; padding-right: 4px; }
.card-actions .act-em { font-size: 11px; padding: 0 6px; white-space: nowrap; }
.card-cb { flex: none; margin: 0 2px 0 0; width: 14px; height: 14px; accent-color: var(--ok); cursor: pointer; }
.card.is-picked { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.rv-head { margin-bottom: 12px; }
.rv-bar .btn-lg { flex: none; }
@media (max-width: 640px) {
  .rv-head .hint { display: none; }
  .rv-bar { flex-wrap: wrap; gap: 8px; }
  .rv-bar .genbar-est { flex-basis: 100%; }
  .rv-bar .btn-lg { flex: 1; }
}

/* --------------------------------------------------------------- creators */
.creator-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.ccard { background: var(--panel); border: 1px solid var(--line-soft); overflow: hidden; display: flex; flex-direction: column; }
.ccard-photo { aspect-ratio: 4 / 5; width: 100%; display: block; object-fit: cover; background: var(--stripes); }
.ccard-body { display: flex; align-items: center; gap: 4px; padding: 10px 8px 10px 14px; }
.ccard-text { margin-right: auto; min-width: 0; }
.ccard-name { font-size: 16px; font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.ccard-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* --------------------------------------------------------------- activity */
.act-panel { padding: 4px 18px; max-width: 900px; }
.act-day { font-size: 12px; font-weight: 650; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 16px 0 6px; }
.act-row { display: grid; grid-template-columns: 52px 96px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line-soft); font-size: 13.5px; }
.act-time, .act-ago { font-size: 12px; color: var(--faint); }
.act-kind { justify-self: start; font-size: 12px; font-weight: 600; padding: 2px 9px; }
.act-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-more { display: flex; justify-content: center; padding: 12px 0 14px; border-top: 1px solid var(--line-soft); }
.act-panel > .panel-empty { margin: 16px 0; }

/* ------------------------------------------------------------------ stats */
.stat-tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat-tiles .tile-big { margin-top: 10px; }
.stat-tiles .big-unit { font-weight: 500; margin-left: -2px; }
.tile-counts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 28px; align-items: baseline; }
.count { display: flex; align-items: center; gap: 8px; }
.count .dot { width: 8px; height: 8px; }
.count b { font-size: 20px; font-weight: 700; line-height: 1; }
.count span:last-child { color: var(--muted); font-size: 13px; }
#view-stats > .section-title { margin: 32px 0 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); background: var(--panel); }
.stat-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.stat-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.stat-table td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.stat-table tr:last-child td { border-bottom: 0; }
.stat-table .num { text-align: right; }
.stat-table td.name { font-weight: 600; }
.rate { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.rate .bar { flex: 1; max-width: 110px; height: 6px; }
.rate .bar > i { background: var(--ok); }

/* --------------------------------------------------------------- settings */
.settings-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 28px; align-items: start; max-width: 1040px; }
.settings-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.settings-form { padding: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-toggle .check { align-self: flex-start; }
.key-row { display: flex; gap: 8px; align-items: stretch; }
.key-row input { flex: 1; min-width: 0; }
.key-row .btn { height: auto; padding: 0 10px; font-size: 13px; }
.key-test { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.is-ok { color: var(--ok) !important; }
.is-bad { color: var(--bad) !important; }
.ig-panel { padding: 20px; }
.ig-panel .section-title { margin-bottom: 6px; }
.ig-lead { margin-bottom: 16px; }
.ig-login-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ig-result:not(:empty) { margin-top: 10px; }
.ig-advanced { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.ig-advanced summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; margin-bottom: 12px; }
.ig-file-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ig-tips { margin: 0 0 8px; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.ig-foot { margin-top: 14px; }
.status-card { padding: 4px 18px 10px; }
.status-card .section-title { margin: 14px 0 8px; }
.kv { display: grid; grid-template-columns: 1fr auto; margin: 0; }
.kv dt { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line-soft); color: var(--muted); }
.kv dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line-soft); text-align: right; font-weight: 600; }
.media-line { margin-bottom: 8px; word-break: break-word; }
.storage-note { margin: 10px 0 4px; }
.storage-actions { margin: 8px 0 6px; }
.media-move { margin: 14px 0 8px; padding-top: 12px; border-top: 1px solid var(--line-soft); }

/* ----------------------------------------------------------------- modals */
.modal {
  width: min(620px, calc(100vw - 32px)); border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 0; border-radius: 0;
}
.modal-sm { width: min(440px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(20, 20, 22, .72); }
.modal-body { padding: 22px 22px 18px; }
.modal h2 { margin: 0 0 16px; font-size: 18px; font-weight: 650; }
.modal-sm p { color: var(--muted); margin: 0 0 18px; }
.creator-edit { display: grid; grid-template-columns: 180px 1fr; gap: 20px; }
.photo-pick {
  aspect-ratio: 4 / 5; overflow: hidden; border: 1.5px dashed var(--line); display: grid; place-items: center; cursor: pointer;
  position: relative; background: var(--stripes);
}
.photo-pick:hover { border-color: var(--text); }
.photo-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.photo-empty svg { width: 40px; height: 40px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.form-error { color: var(--soft-text); background: #29292c; padding: 8px 10px; font-size: 13px; margin: 14px 0; border-left: 2px solid var(--bad); }
.modal .row-end { margin-top: 8px; }

/* ----------------------------------------------------------------- toasts */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: min(560px, calc(100vw - 32px));
  padding: 10px 12px 10px 14px; font-weight: 520; animation: toastin .22s cubic-bezier(.2, .7, .2, 1);
  background: var(--text); color: var(--bg);
}
.toast-error { background: var(--raised); color: var(--text); border: 1px solid var(--line); border-left: 2px solid var(--bad); }
.toast .btn { height: 26px; font-size: 12.5px; padding: 0 10px; border-color: var(--line); background: var(--raised); color: var(--text); }
.toast-x { background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; }
.toast-x:hover { opacity: 1; }

.stopped { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center; text-align: center; padding: 24px; }
.stopped svg { width: 44px; height: 44px; margin-bottom: 14px; }
.stopped h1 { font-size: 46px; margin: 0 0 10px; line-height: 1; }
.stopped p { color: var(--muted); max-width: 46ch; margin: 0 auto 18px; }

/* -------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .ov-cols { grid-template-columns: minmax(0, 1fr); }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1240px) {
  .blrow {
    grid-template-columns: 22px 48px minmax(0, 1fr) 56px 74px 120px 36px;
    grid-template-areas: "cb thumb name dur parts status del" "cb thumb used used used used del";
    row-gap: 6px;
  }
  .blrow > .bl-used:empty { display: none; }
  .blrow > .thumb { align-self: start; }
}
@media (max-width: 1000px) {
  .qrow { grid-template-columns: 22px 48px minmax(0, 1fr) 56px 120px 36px; }
  .qrow .chunk-slot { display: none; }
  .blrow { grid-template-columns: 22px 48px minmax(0, 1fr) 56px 110px 36px; grid-template-areas: "cb thumb name dur status del" "cb thumb used used parts del"; }
  .blrow .chunk-slot { display: block; }
  .live .live-item:nth-child(n+3) { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 60px minmax(0, 1fr); }
  .rail { padding: 14px 6px; }
  .nav { padding: 0; justify-content: center; position: relative; }
  .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .nav-count { position: absolute; top: 2px; right: 2px; font-size: 10px; }
  .nav-count-hot:not(:empty) { padding: 0 4px; line-height: 15px; }
  main { padding: 22px 18px 32px; }
  .brand { min-width: 0; }
  .topbar { gap: 12px; }
  .creator-edit { grid-template-columns: 1fr; }
  .photo-pick { max-width: 200px; }
  .field-row { grid-template-columns: 1fr; }
  .genbar { flex-wrap: wrap; gap: 10px 16px; }
  .picker-btn { min-width: 180px; }
  .bl-notfor { margin-left: 0; }
  .bl-bar .btn-lg { height: 38px; padding: 0 14px; font-size: 13.5px; }
}

/* EM Reels tab: embedded local app */

/* v1.5 Review → Spoof */
.card-actions-em { flex-wrap: wrap; gap: 4px; }
.spoof-badge { flex: none; font: inherit; font-size: 10px; padding: 2px 6px; border: 1px solid var(--line); background: transparent; color: var(--faint); cursor: pointer; white-space: nowrap; }
.spoof-badge:hover { color: var(--text); border-color: var(--soft-text); }
.spoof-badge.is-spoofed { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.spoof-badge.is-running { color: var(--gen); border-color: var(--gen); }
.card-actions .act-spoof { font-weight: 650; }
.spoof-pick { -webkit-appearance: none; appearance: none; text-align: center; text-align-last: center; flex: none; width: 28px; min-width: 0; height: 28px; padding: 0 2px; font-size: 11px; background: var(--raised); color: var(--text); border: 1px solid var(--line); cursor: pointer; }
.spoof-pick:disabled { opacity: .4; cursor: default; }
.rv-head .rv-notspoofed { margin-left: auto; }
.rv-notspoofed.is-on { background: var(--text); color: var(--bg); border-color: var(--text); }
.rv-spoof-group { display: inline-flex; align-items: stretch; gap: 0; flex: none; }
.rv-spoof-group .btn { border-right: 0; }
.rv-spoof-group select { height: 100%; min-height: 40px; max-width: 180px; }
@media (max-width: 640px) {
  .rv-bar { flex-wrap: wrap; }
  .rv-bar .genbar-est { flex-basis: 100%; }
  .rv-spoof-group { flex: 1; }
  .rv-spoof-group select { flex: 1; max-width: none; }
}
.em-auto-panel { padding: 20px; }
.em-auto-panel .section-title { margin-bottom: 10px; }
.em-auto-panel select { width: 100%; }

/* v1.6 server mode: sign-in / invite pages, user chip, users panel */
.auth-page { min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; display: grid; gap: 14px; padding: 24px; }
.auth-title { font-size: 15px; letter-spacing: .08em; margin: 4px 0 0; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; }
.user-role { color: var(--muted); text-transform: uppercase; font-size: 10px; letter-spacing: .08em; }
.by-line { color: var(--muted); font-size: 11px; }
.users-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.users-table th, .users-table td { text-align: left; padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.users-table td .btn { margin: 0 4px 4px 0; }
.users-table .inactive { opacity: .5; }
.once-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.once-box code { word-break: break-all; }
.access-list { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.users-table select { min-width: 6.5em; }
