/* Shotbox — "Darkroom": a dark editing-suite look. Near-black warm greys, one red "record" accent for
   live activity and selection, light primary buttons, monospace for technical values. */
:root {
  --bg: #0b0b0c;
  --surface: #111113;
  --surface-2: #17171a;
  --surface-3: #1e1e22;
  --hover: #222227;
  --border: #242428;
  --border-strong: #34343a;
  --text: #ecebe7;
  --muted: #8d8b86;
  --faint: #5f5d59;
  --accent: #e5484d;          /* record red: live, selected, focus */
  --accent-soft: rgba(229, 72, 77, .14);
  --accent-text: #ffffff;
  --primary: #ecebe7;         /* primary buttons */
  --primary-text: #0b0b0c;
  --ok: #4cc38a;
  --warn: #e2a336;
  --bad: #ff6b5e;
  --video: #d9a35f;
  --radius: 6px;
  --top: 48px;
  --side: 216px;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.error { color: var(--bad); min-height: 0; margin: 0; font-size: 12px; }
.error:empty { display: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 16px; }
h2 { font-size: 14px; }
h3 { font-size: 13px; }
a { color: var(--text); }
i.ti { font-size: 16px; line-height: 1; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid var(--bg); }

/* ---------- controls ---------- */
.btn {
  appearance: none; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  border-radius: var(--radius); padding: 0 12px; height: 32px; font: inherit; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); border-color: #44444b; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.btn.primary:hover { background: #fff; border-color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger:hover { color: var(--bad); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn.primary.wide { height: 38px; font-size: 13px; }
.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--muted); width: 30px; height: 30px; border-radius: var(--radius);
  display: inline-grid; place-items: center; cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.link-btn {
  appearance: none; border: 0; background: none; padding: 0; font: inherit; font-size: 12px; color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.link-btn i.ti { font-size: 14px; color: var(--accent); }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-btn.muted, .link-btn.muted i.ti { color: var(--muted); }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 6px 9px; min-height: 32px;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
select {
  appearance: none; padding-right: 28px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238d8b86' stroke-width='2'%3E%3Cpath d='M8 9l4-4 4 4M16 15l-4 4-4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: #44444b; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible, .seg:focus-visible, .chip:focus-visible, .media:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input[type=range] { width: 100%; accent-color: var(--text); height: 18px; margin: 2px 0 0; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

/* switch (styled checkbox) */
.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span:first-of-type {
  width: 28px; height: 16px; border-radius: 9px; background: var(--border-strong); position: relative; flex: none; transition: background .15s;
}
.switch > span:first-of-type::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #d6d4cf; transition: transform .15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(12px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch.small { font-size: 12px; color: var(--muted); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; }
.rec { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; flex: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top); display: flex; align-items: center; gap: 14px;
  padding: 0 12px 0 14px; padding-top: env(safe-area-inset-top);
  background: rgba(11, 11, 12, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
#nav-toggle { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); min-width: 0; padding-left: 14px; border-left: 1px solid var(--border); height: 20px; }
.crumbs i.ti { font-size: 12px; color: var(--faint); }
#crumb-page { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.chip-btn {
  appearance: none; display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px; font: inherit; font-size: 12px;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.chip-btn:hover { border-color: var(--border-strong); color: var(--text); }
.chip-btn i.ti { font-size: 14px; }
#queue-chip.live { color: var(--text); border-color: rgba(229, 72, 77, .45); }
#queue-chip.live #queue-count { color: var(--accent); }
.led { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: inline-block; flex: none; }
.led.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(76, 195, 138, .14); }
.led.warn { background: var(--warn); }
.led.bad { background: var(--bad); }
.led.neutral { background: var(--muted); }
.status-wrap { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 6px); width: 270px; padding: 10px 12px; z-index: 40;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}
.pop-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0; font-size: 12px; }
.pop-row > span:first-child { display: flex; align-items: center; gap: 8px; }
.pop-row .mono { color: var(--muted); }
.meter { height: 4px; border-radius: 2px; background: var(--border); margin: 6px 0 8px; overflow: hidden; }
.meter > div { height: 100%; background: var(--text); width: 0; }
.pop-foot { color: var(--faint); font-size: 11px; }

/* ---------- shell ---------- */
.shell { display: flex; align-items: flex-start; min-height: calc(100vh - var(--top)); }
.sidebar {
  position: sticky; top: var(--top); width: var(--side); flex: none; height: calc(100vh - var(--top)); overflow-y: auto;
  border-right: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; padding: 8px 8px 6px;
}
.nav { flex: 1; }
.nav-group { margin-bottom: 10px; }
.nav-title { font-size: 10.5px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); padding: 8px 10px 4px; }
.nav-item {
  appearance: none; width: 100%; display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 10px; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--muted); font: inherit; cursor: pointer; text-align: left; position: relative; white-space: nowrap;
}
.nav-item span { overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 500; }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 2px; border-radius: 2px; background: var(--accent); }
.nav-item[aria-current="page"] i.ti { color: var(--accent); }
.nav-collapse {
  appearance: none; display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 10px; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--faint); font: inherit; font-size: 12px; cursor: pointer; border-top: 1px solid var(--border); margin-top: 6px;
}
.nav-collapse:hover { color: var(--text); background: var(--surface-2); }
body.nav-rail { --side: 56px; }
body.nav-rail .nav-item span, body.nav-rail .nav-title, body.nav-rail .nav-collapse span { display: none; }
body.nav-rail .nav-item, body.nav-rail .nav-collapse { justify-content: center; padding: 0; }
body.nav-rail .nav-group { margin-bottom: 4px; border-top: 1px solid var(--border); padding-top: 4px; }
body.nav-rail .nav-group:first-child { border-top: 0; }
body.nav-rail .nav-collapse i.ti { transform: scaleX(-1); }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 34; }
.workspace { flex: 1; min-width: 0; }

/* ---------- tool view: inspector + gallery ---------- */
.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); align-items: start; }
.panel.inspector {
  position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow: hidden;
  border-right: 1px solid var(--border); background: var(--surface);
}
#job-form { display: flex; flex-direction: column; height: 100%; }
.feature-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--border); }
.feature-head p { margin: 4px 0 0; font-size: 12px; line-height: 1.45; }
.inspector-body { flex: 1; overflow-y: auto; padding: 14px 16px 6px; }
.inspector-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: grid; gap: 8px; background: var(--surface); }
.field { margin-bottom: 16px; min-width: 0; }
.field > label, .field .label, .label-row > label {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.label-row > label, .label-row > .label { margin-bottom: 0; }
.label-row output { font-size: 12px; color: var(--text); }
.label-tools { display: flex; gap: 12px; }
.opt { font-size: 10.5px; letter-spacing: .04em; color: var(--faint); text-transform: none; font-weight: 400; }
.field .hint, .hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.input-row { display: flex; gap: 6px; align-items: center; }
.prompt-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.range-row { display: flex; gap: 10px; align-items: center; }
.range-row output { min-width: 3.5em; text-align: right; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
.advanced { margin: 4px 0 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.advanced summary, details > summary { cursor: pointer; color: var(--muted); font-size: 12px; list-style: none; display: flex; align-items: center; gap: 6px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; flex: none; }
details[open] > summary::before { transform: rotate(45deg); }
.advanced[open] summary { margin-bottom: 12px; }

/* media drop zone */
.drop {
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
  min-height: 112px; display: grid; place-items: center; text-align: center; cursor: pointer;
  position: relative; overflow: hidden; color: var(--muted); font-size: 12px; padding: 10px; transition: border-color .12s, background .12s;
}
.drop:hover, .drop.drag { border-color: var(--accent); background: #1a1517; }
.drop.filled { border-style: solid; padding: 6px; background: #000; }
.drop-empty { display: grid; justify-items: center; gap: 4px; }
.drop-empty i.ti { font-size: 20px; color: var(--text); margin-bottom: 2px; }
.drop img, .drop video { max-width: 100%; max-height: 240px; border-radius: 4px; display: block; }
.drop .clear { position: absolute; top: 6px; right: 6px; background: rgba(0, 0, 0, .7); color: #fff; }
.drop input { display: none; }
.drop.busy::after {
  content: "Uploading…"; position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--mono);
  background: rgba(11, 11, 12, .82); color: var(--text);
}

/* segmented control */
.seg-group, .segmented { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.segmented { display: flex; margin-bottom: 16px; }
.seg {
  appearance: none; border: 0; background: transparent; color: var(--muted); height: 24px; padding: 0 10px; border-radius: 5px;
  font: inherit; font-size: 12px; cursor: pointer; flex: 1; white-space: nowrap;
}
.seg:hover { color: var(--text); }
.seg.on { background: var(--surface-3); color: var(--text); font-weight: 500; box-shadow: inset 0 0 0 1px var(--border-strong); }

/* results gallery */
.panel.gallery { padding: 14px 16px 24px; min-width: 0; }
.results-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.results-head h2 { font-size: 13px; }
.results-head .seg-group { margin-left: auto; }
.jobs { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.jobs[data-filter="image"] .job:not([data-media="image"]):not([data-media="pending"]),
.jobs[data-filter="video"] .job:not([data-media="video"]):not([data-media="pending"]) { display: none; }
.job { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.job .media {
  appearance: none; border: 0; padding: 0; width: 100%; aspect-ratio: 1 / 1; border-radius: var(--radius); background: var(--surface-2);
  display: grid; place-items: center; cursor: pointer; position: relative; overflow: hidden; outline: 1px solid var(--border); outline-offset: -1px;
}
.job .media img, .job .media video { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.job .media:hover img, .job .media:hover video { transform: scale(1.03); }
.job.selected .media { outline: 2px solid var(--accent); outline-offset: -2px; }
.job .placeholder { color: var(--muted); font-size: 12px; text-align: center; padding: 12px; display: grid; gap: 8px; justify-items: center; }
.job .placeholder i.ti { font-size: 20px; }
.job.running .placeholder i.ti, .details-preview .placeholder i.ti-loader-2, .link-btn .ti-loader-2 { animation: spin 1s linear infinite; }
.job.error .placeholder { color: var(--bad); }
.job .count { position: absolute; bottom: 6px; right: 6px; background: rgba(0, 0, 0, .72); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.tag {
  position: absolute; top: 6px; left: 6px; display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 500;
  letter-spacing: .04em; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; background: rgba(11, 11, 12, .78); color: var(--text);
  backdrop-filter: blur(4px);
}
.tag.video { color: var(--video); }
.tag.bad { color: var(--bad); }
.tag.live { color: #fff; }
.tag .rec { width: 6px; height: 6px; box-shadow: none; animation: blink 1.2s ease-in-out infinite; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .08); }
.bar > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.caption { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; padding: 0 2px; }
.cap-name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 72px 16px; text-align: center; grid-column: 1 / -1; display: grid; justify-items: center; gap: 6px; border: 1px dashed var(--border); border-radius: 8px; }
.empty i.ti { font-size: 24px; color: var(--faint); }
.empty-title { font-weight: 500; }
#more { margin-top: 14px; }
.badge { font-size: 10.5px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 4px; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.badge.running, .badge.queued { color: var(--warn); }
.badge.done { color: var(--ok); }
.badge.error, .badge.cancelled { color: var(--bad); }

/* details panel */
.details {
  position: sticky; top: var(--top); width: 360px; flex: none; height: calc(100vh - var(--top)); overflow-y: auto;
  border-left: 1px solid var(--border); background: var(--surface); padding: 14px 16px 20px; display: grid; gap: 14px; align-content: start;
}
.details-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.details-title { font-weight: 600; font-size: 14px; }
.details-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.details-status.done .led { background: var(--ok); }
.details-status.running .led, .details-status.queued .led { background: var(--accent); animation: blink 1.2s ease-in-out infinite; }
.details-status.error .led, .details-status.cancelled .led { background: var(--bad); }
.details-preview { display: grid; gap: 6px; }
.preview-btn { appearance: none; border: 0; padding: 0; background: #000; border-radius: var(--radius); overflow: hidden; cursor: zoom-in; display: block; width: 100%; }
.preview-btn img, .preview-btn video { width: 100%; max-height: 420px; object-fit: contain; display: block; }
.details-preview .placeholder { aspect-ratio: 4 / 3; border-radius: var(--radius); background: var(--surface-2); display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); }
.details-strip { display: flex; gap: 6px; overflow-x: auto; }
.strip-item { appearance: none; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); border-radius: 4px; width: 48px; height: 48px; padding: 0; overflow: hidden; cursor: pointer; flex: none; }
.strip-item img { width: 100%; height: 100%; object-fit: cover; }
.kv-list { border-top: 1px solid var(--border); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.kv > span:first-child { color: var(--muted); }
.kv > span:last-child { text-align: right; overflow-wrap: anywhere; }
.details-prompt p { margin: 0; font-size: 12.5px; line-height: 1.55; color: #cfcdc8; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow-y: auto; }
.details-prompt .label { font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.details-error { display: flex; gap: 8px; align-items: flex-start; color: var(--bad); font-size: 12px; background: rgba(255, 107, 94, .08); border: 1px solid rgba(255, 107, 94, .25); border-radius: var(--radius); padding: 8px 10px; overflow-wrap: anywhere; }
.details-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.details-actions .use-in, .viewer-actions .use-in { width: auto; height: 28px; min-height: 28px; font-size: 12px; padding: 0 28px 0 10px; }
.details-actions .danger { margin-left: auto; }

/* live workflow view */
.pipeline-wrap { border-top: 1px solid var(--border); padding-top: 10px; font-size: 12px; }
.pipeline-wrap > summary { justify-content: flex-start; }
.pipeline-wrap > summary .mono { margin-left: auto; }
.pipeline-head { font-weight: 500; margin-bottom: 6px; }
.pipeline { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 1px; }
.stage { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 8px; padding: 3px 0; position: relative; }
.stage .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage .time, .node .time { color: var(--muted); white-space: nowrap; }
.dot {
  width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; line-height: 1;
  border: 1.5px solid var(--border-strong); color: var(--muted); box-sizing: border-box;
}
.stage:not(:last-child)::after { content: ""; position: absolute; left: 7.25px; top: calc(50% + 9px); height: calc(100% - 16px); width: 1.5px; background: var(--border); }
.stage.pending, .stage.skipped { color: var(--faint); }
.stage.done .dot, .node.done .dot { background: var(--text); border-color: var(--text); color: var(--bg); }
.stage.cached .dot, .node.cached .dot { border-color: var(--muted); color: var(--muted); }
.stage.error .dot { background: var(--bad); border-color: var(--bad); color: #fff; }
.stage.running { font-weight: 500; }
.stage.running .dot, .node.running .dot { border-color: var(--accent); border-top-color: transparent; animation: spin .9s linear infinite; }
.stage.running .time { color: var(--accent); }
.nodes { margin-top: 8px; }
.node-group { margin-top: 6px; }
.node-group-title { font-weight: 500; margin-bottom: 2px; }
.node { display: grid; grid-template-columns: 16px auto 1fr auto; align-items: center; gap: 6px; padding: 1px 0 1px 4px; }
.node .dot { width: 12px; height: 12px; font-size: 7px; }
.node code { font-family: var(--mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node.pending, .node.skipped { color: var(--faint); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  .stage.running .dot, .node.running .dot, .tag .rec, .details-status .led, .ti-loader-2 { animation: none !important; }
}

/* full-size viewer */
.viewer {
  border: 1px solid var(--border-strong); padding: 0; background: #000; color: var(--text); border-radius: 10px;
  max-width: min(96vw, 1400px); max-height: 94vh; width: auto;
}
.viewer::backdrop { background: rgba(0, 0, 0, .86); }
#viewer-body { display: grid; gap: 8px; padding: 12px; max-height: 84vh; overflow: auto; }
#viewer-body img, #viewer-body video { max-width: 100%; max-height: 78vh; display: block; margin: 0 auto; border-radius: 4px; }
.viewer .close { position: absolute; top: 8px; right: 8px; z-index: 2; background: rgba(0, 0, 0, .6); color: #fff; }
.viewer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 12px 12px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(16px);
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); padding: 9px 14px; border-radius: 8px; font-size: 12.5px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5); opacity: 0; pointer-events: none; transition: all .18s; max-width: calc(100vw - 32px); z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- shared panels used by Story, Remake, Prompt from reference ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; min-width: 0; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: 10px; }
.story-view { padding: 20px 24px 40px; max-width: 1240px; margin: 0 auto; }
.story-home { display: grid; gap: 16px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.story-home textarea { min-height: 200px; margin: 10px 0; }
.row-end { display: flex; justify-content: flex-end; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.row-gap.tight { margin-top: 0; }
.row-split { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.story-list { display: grid; gap: 6px; margin-top: 10px; }
.story-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; cursor: pointer;
}
.story-item:hover { border-color: var(--border-strong); background: var(--hover); }
.story-item.on { border-color: var(--accent); }
.story-item-title { font-weight: 500; }
.story-item .muted { grid-column: 1 / -1; font-size: 12px; }
.story-item .badge { align-self: start; }

.story-wrap { display: grid; gap: 14px; }
.story-head { display: grid; gap: 14px; }
.story-head-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.story-title, .story-title-input { font-size: 16px; font-weight: 600; flex: 1; min-width: 160px; }
.story-title-input { background: transparent; border-color: transparent; padding-left: 4px; }
.story-title-input:hover, .story-title-input:focus { border-color: var(--border-strong); }
/* Steps as a timeline: each step is a track segment that lights up as the film progresses. */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.steps li { padding: 0; background: none; color: var(--muted); }
.steps li button {
  width: 100%; display: flex; align-items: center; gap: 8px; font: inherit; font-size: 12px; color: inherit; text-align: left;
  padding: 10px 10px 8px; border-radius: 0; background: transparent; border: 0; border-top: 3px solid var(--border-strong); cursor: pointer;
}
.steps li button:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.steps li button:disabled { cursor: not-allowed; opacity: .5; }
.steps li button span { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.steps li.done button { border-top-color: var(--text); color: var(--text); }
.steps li.current button { border-top-color: var(--accent); color: var(--text); }
.steps li.current button span { color: var(--accent); }
.steps li.shown button { background: var(--surface-2); font-weight: 600; color: var(--text); }
.story-alert { padding: 9px 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; overflow-wrap: anywhere; }
.story-alert.error { color: var(--bad); border-color: rgba(255, 107, 94, .3); background: rgba(255, 107, 94, .06); }
.story-body { display: grid; gap: 14px; }
.story-body h3 { margin: 0 0 12px; font-size: 13px; }
.story-working { text-align: center; padding: 48px 16px; }
.story-working h2 { margin-top: 16px; }
.spinner { width: 30px; height: 30px; margin: 0 auto; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .9s linear infinite; }
.summary { font-size: 12.5px; color: var(--muted); }
.summary strong { color: var(--text); }
.action-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; position: sticky; bottom: 10px; z-index: 5;
  background: rgba(17, 17, 19, .94); backdrop-filter: blur(8px); box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.action-bar .muted { flex: 1; min-width: 160px; font-size: 12px; }

.sf { display: grid; gap: 4px; margin-bottom: 10px; min-width: 0; }
.sf-label { font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.char-row { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
.char-row:first-of-type { border-top: none; padding-top: 0; }

.shot-list { display: grid; gap: 12px; }
.shot-card { border-left: 3px solid var(--border-strong); }
.shot-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.shot-num {
  min-width: 28px; height: 22px; padding: 0 6px; border-radius: 4px; background: var(--surface-3); color: var(--text);
  display: grid; place-items: center; font-family: var(--mono); font-size: 11px; flex: none;
}
.shot-title { flex: 1; min-width: 140px; font-weight: 500; }
.shot-tools { display: flex; gap: 2px; margin-left: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border-strong); background: transparent; color: var(--muted); border-radius: var(--radius); padding: 0 10px; height: 26px;
  font: inherit; font-size: 12px; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: #44444b; }
.chip.on { background: var(--accent-soft); border-color: rgba(229, 72, 77, .6); color: var(--text); }
.prompts { margin: 4px 0 12px; }
.prompts > summary { margin-bottom: 8px; }
.audio-panel { display: grid; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-top: 4px; }
.audio-row { display: grid; grid-template-columns: 190px 1fr; gap: 10px; align-items: start; }
.audio-row > .check { padding-top: 6px; }
.audio-fields { display: grid; gap: 6px; grid-template-columns: 1fr; }

.kf-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.kf-grid.portraits { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.kf { margin: 0; display: grid; gap: 6px; min-width: 0; }
.kf img { width: 100%; border-radius: var(--radius); display: block; cursor: zoom-in; background: var(--surface-2); outline: 1px solid var(--border); outline-offset: -1px; }
.kf figcaption { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; }
.kf-placeholder { aspect-ratio: 16 / 9; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.kf-placeholder.running { border: 1px dashed var(--accent); color: var(--text); }
.kf-placeholder.error { color: var(--bad); }

.prod-head { display: grid; gap: 14px; }
.shot-tiles { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile {
  display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 4px; background: var(--surface-2);
  border: 1px solid var(--border); border-top: 3px solid var(--border-strong); font-size: 12px;
}
.tile-num { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tile-text { display: grid; gap: 2px; min-width: 0; }
.tile-eta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.tile.done { border-top-color: var(--text); }
.tile.failed { border-top-color: var(--bad); }
.tile.voice, .tile.video, .tile.sfx, .tile.mixing, .tile.keyframe { border-top-color: var(--accent); }
.live-job .pipeline-wrap { margin: 8px 0 0; }
.review-list { display: grid; gap: 12px; }
.review-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.review-grid video, .review-grid img { width: 100%; border-radius: var(--radius); background: #000; display: block; }
.tracks { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; font-size: 12px; }
.tracks audio { display: block; width: 100%; height: 32px; margin-top: 4px; min-width: 0; }
.tracks .line-item { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tracks .line-item audio { flex-basis: 100%; }
.final { text-align: center; }
.final-video { width: 100%; max-height: 70vh; border-radius: 8px; background: #000; margin: 10px 0; }
.final .row-gap { justify-content: center; }
.story-wrap > *, .story-body > *, .review-grid > *, .tracks li, .audio-row > *, .kf { min-width: 0; }
.story-view audio, .story-view video, .story-view img { max-width: 100%; }
.story-view .err { overflow-wrap: anywhere; color: var(--bad); }
audio { filter: invert(.88) hue-rotate(180deg); height: 32px; }
fieldset.readonly { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 14px; }
.picker { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.picker.has-file audio { flex: 1; min-width: 160px; height: 32px; }
.lang-row { display: flex; gap: 8px; }
.lang-row select { flex: 1; }
.line-meta { display: grid; grid-template-columns: 130px 1fr; gap: 8px; align-items: center; }
.inline-field { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); white-space: nowrap; }
.inline-field select, .inline-field input { width: auto; color: var(--text); }
input.num { width: 80px; }
.length-picker { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.length-picker select { width: auto; }
.lines-panel { display: grid; gap: 8px; margin: 6px 0 12px; padding: 10px; border-radius: var(--radius); border: 1px dashed var(--border-strong); }
.line-row { display: grid; gap: 6px; padding: 10px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.line-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.line-top select { width: auto; min-width: 130px; }
.line-num { min-width: 22px; height: 20px; border-radius: 4px; display: grid; place-items: center; font-family: var(--mono); font-size: 11px; background: var(--surface-3); flex: none; }

/* Video Remake */
.remake-preview { width: 100%; max-height: 300px; border-radius: var(--radius); background: #000; margin-top: 10px; }
.mode-pick { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.upload-bar { width: 100%; height: 6px; margin-top: 10px; accent-color: var(--accent); }
.source-row { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 16px; align-items: start; }
.source-row video { width: 100%; border-radius: var(--radius); background: #000; }
.source-info p { margin: 0 0 8px; }
.ref-row { display: grid; grid-template-columns: 220px 1fr; gap: 12px; align-items: start; margin-bottom: 12px; }
.ref-row video { width: 100%; border-radius: 4px; background: #000; aspect-ratio: 16 / 9; object-fit: contain; }

/* Prompt from Reference */
.refprompt-home { align-items: start; }
.refprompt-col { display: grid; gap: 16px; min-width: 0; }
.ref-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.ref-thumb { position: relative; margin: 0; width: 132px; }
.ref-thumb img, .ref-thumb video { width: 132px; height: 99px; object-fit: cover; border-radius: 4px; background: #000; display: block; }
.ref-thumb figcaption { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 3px; }
.ref-thumb button { position: absolute; top: 4px; right: 4px; height: 22px; padding: 0 7px; }
.ref-main { width: 100%; max-height: 320px; border-radius: var(--radius); background: #000; margin: 10px 0; }
.prompt-block { margin: 14px 0; }
.prompt-block textarea { width: 100%; }
.shot-prompt { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.small-working { padding: 16px 0; }

/* Angles & poses (Image edit) */
.angle-set { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.angle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 8px; }
.angle-item { margin: 0; }
.angle-item img, .angle-item .kf-placeholder { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: zoom-in; }
.angle-item figcaption { display: flex; justify-content: space-between; align-items: center; gap: 4px; font-size: 11px; margin-top: 4px; }
.angle-item figcaption .btn { height: 22px; padding: 0 6px; font-size: 11px; }
.exact-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.exact-row .num { width: 72px; }
.exact-row select { flex: 1; min-width: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  /* The details panel slides over the gallery instead of squeezing it. */
  .details { position: fixed; right: 0; top: var(--top); bottom: 0; height: auto; z-index: 25; box-shadow: -16px 0 40px rgba(0, 0, 0, .45); }
}
@media (max-width: 1080px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr); }
  .story-home { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  #nav-toggle { display: inline-grid; margin-left: -6px; }
  .crumbs { display: none; }
  .sidebar { position: fixed; left: 0; top: var(--top); bottom: 0; height: auto; z-index: 35; transform: translateX(-100%); transition: transform .2s; width: 248px; }
  .sidebar.open { transform: none; box-shadow: 16px 0 40px rgba(0, 0, 0, .5); }
  body.nav-rail { --side: 216px; }
  body.nav-rail .nav-item span, body.nav-rail .nav-title { display: revert; }
  .nav-collapse { display: none; }
  .layout { grid-template-columns: 1fr; }
  .panel.inspector { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .inspector-body { overflow: visible; }
  .inspector-foot { position: sticky; bottom: 0; z-index: 4; }
  .details { left: 0; width: auto; border-left: 0; }
  .story-view { padding: 14px 12px 32px; }
  .grid3, .grid4 { grid-template-columns: 1fr 1fr; }
  .audio-row { grid-template-columns: 1fr; }
  .review-grid, .source-row, .ref-row { grid-template-columns: 1fr; }
  .action-bar { position: static; }
}
@media (max-width: 560px) {
  .hide-sm { display: none; }
  .topbar { gap: 8px; }
  .brand { letter-spacing: .1em; font-size: 11px; }
  .jobs { grid-template-columns: 1fr 1fr; gap: 8px; }
  .results-head .seg-group { margin-left: 0; order: 3; width: 100%; }
  .results-head .seg-group .seg { flex: 1; }
  .steps { grid-template-columns: 1fr 1fr; }
  .grid3, .grid4 { grid-template-columns: 1fr; }
  .line-meta { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
}

/* Switches and checkboxes inside a field keep normal text (the field label style is uppercase). */
.field > label.switch, .field > label.check {
  justify-content: flex-start; text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 400; color: var(--text); margin-bottom: 0;
}
/* Small notes inside a field label stay quiet lowercase. */
.field > label .muted, .field .label .muted, .field > label .small, .field .label .small {
  text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--faint); font-size: 11px;
}
.preview-btn.video { cursor: default; }
.tag .dur { letter-spacing: 0; text-transform: none; }
.results-head #result-scope { font-size: 12px; }

/* Replace object (Image edit) */
.segmented .seg { padding: 0 6px; }
.rp-stage { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; touch-action: none; user-select: none; cursor: crosshair; }
.rp-stage img { display: block; width: 100%; height: auto; pointer-events: none; }
.rp-box {
  appearance: none; position: absolute; padding: 0; background: rgba(0, 0, 0, .08); cursor: pointer;
  border: 1.5px solid rgba(255, 255, 255, .75); border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .45);
}
.rp-box:hover { border-color: #fff; background: rgba(255, 255, 255, .08); }
.rp-box.on { border: 2px solid var(--accent); background: var(--accent-soft); }
.rp-num {
  position: absolute; top: -1px; left: -1px; min-width: 16px; height: 16px; padding: 0 3px; font-size: 10px; line-height: 16px;
  background: rgba(0, 0, 0, .78); color: #fff; border-radius: 2px 0 3px 0;
}
.rp-box.on .rp-num { background: var(--accent); }
.rp-draw { position: absolute; border: 1.5px dashed var(--accent); background: var(--accent-soft); pointer-events: none; }
.rp-chips { margin: 8px 0; }
.rp-chips .chip { height: 24px; font-size: 11.5px; }
.field .hint .ti-loader-2 { animation: spin 1s linear infinite; display: inline-block; }

/* UI design > Full app (uiapp.js) */
.uiapp-modes { max-width: 420px; }
.uiapp-home { grid-template-columns: minmax(0, 4fr) minmax(0, 1.4fr); }
.uiapp-home textarea { min-height: 0; margin: 0; }
.uiapp-plan { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin: 12px 0; background: var(--surface-2); }
.uiapp-plan summary { cursor: pointer; font-weight: 500; }
.uiapp-plan[open] summary { margin-bottom: 10px; }
.uiapp-plan-page { display: grid; gap: 6px; padding: 10px 0; border-top: 1px solid var(--border); }
.uiapp-plan-page .input-row input { flex: 1; }
.uiapp-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-top: 14px; }
.uiapp-page { display: grid; gap: 8px; align-content: start; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.uiapp-page .input-row input { flex: 1; min-width: 0; }
.uiapp-page .bad { color: var(--bad); margin: 0; }
.uiapp-shot { position: relative; display: block; border-radius: 4px; overflow: hidden; background: #000; aspect-ratio: 16 / 10; }
.uiapp-shot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.uiapp-shot.empty { display: grid; place-items: center; }
.uiapp-veil { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .55); }
.uiapp-group-in { flex: 0 0 140px !important; }
.uiapp-actions { align-items: center; }
.uiapp-themebar { margin-top: 12px; }
.uiapp-themebar .segmented { margin-bottom: 0; width: 220px; }
.uiapp-group { margin-top: 16px; }
.uiapp-group > summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.uiapp-group > .uiapp-pages { margin-top: 12px; }
.segmented.mini { display: inline-flex; margin: 0; }
.segmented.mini .seg { height: 22px; padding: 0 8px; font-size: 11px; }
.uiapp-new { max-width: 820px; }
.uiapp-tabs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.uiapp-tab {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; max-width: 260px; cursor: pointer; user-select: none;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: 13px; list-style: none;
}
.uiapp-tab::-webkit-details-marker { display: none; }
.uiapp-tab:hover { border-color: var(--border-strong); color: var(--text); }
.uiapp-tab.on { border-color: var(--accent); color: var(--text); font-weight: 500; background: var(--surface-2); }
.uiapp-tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uiapp-tab-x { display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--muted); cursor: pointer; }
.uiapp-tab-x:hover { background: var(--hover); color: var(--text); }
.uiapp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.uiapp-spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .9s linear infinite; flex: none; }
.uiapp-all { position: relative; margin-left: auto; }
.uiapp-menu {
  position: absolute; right: 0; top: 38px; z-index: 30; width: 340px; max-height: 420px; overflow: auto; display: grid; gap: 6px;
  padding: 8px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: 0 12px 32px rgba(0, 0, 0, .4);
}
@media (max-width: 900px) { .uiapp-home { grid-template-columns: 1fr; } .uiapp-all { margin-left: 0; } .uiapp-menu { left: 0; right: auto; width: min(340px, 90vw); } }
.uiapp-project > .field { margin-top: 14px; }
.uiapp-all > summary::before { content: none; }
.uiapp-all > summary.uiapp-tab { font-size: 13px; color: var(--muted); }

/* Running list (top bar) and Cancel on result cards (v20) */
.running-wrap { position: relative; }
.running-pop { width: min(380px, calc(100vw - 24px)); max-height: 70vh; overflow: auto; }
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; min-height: 28px; }
.run-list { display: grid; gap: 2px; }
.run-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.run-text { flex: 1; min-width: 0; font-size: 12px; display: grid; gap: 2px; }
.run-what { font-weight: 500; color: var(--text); }
.run-title { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job { position: relative; }
.card-cancel {
  position: absolute; top: 6px; right: 6px; z-index: 2; display: grid; place-items: center; width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(0, 0, 0, .72); color: #fff; cursor: pointer; opacity: .85;
}
.card-cancel:hover { opacity: 1; background: var(--bad); }

/* Full-window image viewer (uikit.js) */
.lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(5, 5, 6, .97); color: var(--text); overflow: hidden; }
.lightbox::backdrop { background: rgba(0, 0, 0, .9); }
.lb-stage { position: absolute; inset: 52px 0 56px; overflow: hidden; cursor: zoom-in; touch-action: none; }
.lb-stage.zoomed { cursor: grab; }
.lb-stage.zoomed:active { cursor: grabbing; }
.lb-stage img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; user-select: none; image-rendering: auto; box-shadow: 0 8px 40px rgba(0, 0, 0, .6); }
.lb-top, .lb-bar { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: rgba(11, 11, 12, .9); }
.lb-top { top: 0; height: 52px; justify-content: space-between; border-bottom: 1px solid var(--border); }
.lb-bar { bottom: 0; height: 56px; justify-content: space-between; border-top: 1px solid var(--border); flex-wrap: wrap; }
.lb-name { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.lb-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-info { display: flex; align-items: center; gap: 12px; min-width: 0; overflow: hidden; }
.lb-info > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-acts { display: flex; gap: 8px; align-items: center; }
.lb-acts .use-in { width: auto; height: 28px; min-height: 28px; font-size: 12px; padding: 0 28px 0 10px; }
.lb-zoom { min-width: 44px; text-align: center; }
.lb-btn { color: #fff; }
.lb-prev, .lb-next { position: absolute; top: 50%; z-index: 2; width: 44px; height: 44px; margin-top: -22px; border-radius: 50%; background: rgba(0, 0, 0, .55); }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
.lb-prev:hover, .lb-next:hover { background: rgba(0, 0, 0, .85); }
.lb-prev i.ti, .lb-next i.ti { font-size: 22px; }
body.lb-open { overflow: hidden; }
@media (max-width: 640px) { .lb-bar { height: auto; padding: 8px 12px; } .lb-stage { bottom: 92px; } .lb-acts .btn span { display: none; } }

/* Size and colour controls (uikit.js) */
.size-row { margin-top: 8px; align-items: center; }
.size-row input { width: 96px; flex: none; }
.hint.warn { color: var(--warn); }
.palette .segmented.mini, .field > .segmented.mini { margin-top: 2px; }
.palette > input[type="text"] { margin-top: 8px; }
.presets { margin-top: 10px; }
.chip.preset { display: inline-flex; align-items: center; gap: 6px; }
.swatches { display: inline-flex; gap: 2px; vertical-align: middle; }
.swatches i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15); }
.palette-rows { display: grid; gap: 6px; margin-top: 10px; }
.palette-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) 92px auto; align-items: center; gap: 10px; }
.palette-row.off .palette-name, .palette-row.off input { opacity: .5; }
.palette-row input[type="color"] { width: 36px; height: 30px; padding: 2px; min-height: 0; cursor: pointer; }
.palette-row input[type="text"] { width: 92px; }
.palette-name { display: grid; min-width: 0; }
.palette-name .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Full app: reference image, look, fix texts (v20) */
.uiapp-refbox { position: relative; min-height: 84px; }
.uiapp-refbox img { max-height: 180px; margin: 0 auto; }
.uiapp-refbox + div .segmented { margin-top: 8px; }
button.uiapp-shot { padding: 0; border: 0; width: 100%; cursor: zoom-in; }
.uiapp-shot { aspect-ratio: auto; }
.uiapp-note { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uiapp-fix { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.uiapp-fix .input-row { align-items: center; }
.uiapp-fix .input-row input { flex: 1; min-width: 0; }
.uiapp-meta .swatches { margin-left: 4px; }
.btn.ghost.on { color: var(--text); background: var(--hover); }
