:root {
  --bg: #0b0d10;
  --bg-elev: #14181d;
  --bg-elev-2: #1b2027;
  --border: #242a33;
  --text: #e6edf3;
  --text-dim: #8b96a5;
  --accent: #5ad1ff;
  --accent-dim: #2f8fb2;
  --ok: #6bd47b;
  --warn: #e2b24a;
  --err: #ff6b6b;
  --purple: #c78dff;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-family: var(--mono);
}
.topbar-spacer { flex: 1; }
.cookie-btn {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s, background 0.1s;
}
.cookie-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--text-dim);
}
.cookie-btn:disabled { opacity: 0.6; cursor: progress; }
.cookie-btn-ok      { border-color: rgba(107, 212, 123, 0.4); color: var(--ok); }
.cookie-btn-stale   { border-color: rgba(226, 178, 74, 0.4); color: var(--warn); }
.cookie-status {
  font-size: 11px;
  opacity: 0.8;
  margin-left: 4px;
}
.cookie-toggle {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cookie-toggle:hover { color: var(--text); border-color: var(--text-dim); }
.cookie-toggle input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}
.cookie-toggle.cookie-toggle-on {
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* --- layout: sidebar + main --- */
.app-layout {
  display: flex;
  min-height: calc(100vh - 53px);
}
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;
}
.sidebar-title {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.sidebar-empty {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
  padding: 16px 0;
}

/* task cards in sidebar */
.task-card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}
.task-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.task-char {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.task-url {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-card .stage-bar {
  min-width: unset;
  margin-bottom: 4px;
}
.task-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

main {
  flex: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 24px 80px;
  /* Keep every direct section inside main the same width so the top
     cards (tabs, char-bar, submit-card) align with the jobs table. */
  width: 100%;
  box-sizing: border-box;
}

/* --- tabs --- */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tab {
  background: var(--bg-elev);
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 13px;
  text-decoration: none;
}
.tab.active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--bg-elev-2);
}
.tab-add {
  border-style: dashed;
  color: var(--accent-dim);
}
.tab-add:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.tab[draggable="true"] { cursor: grab; }
.tab[draggable="true"]:active { cursor: grabbing; }
.tab.tab-dragging { opacity: 0.4; }

.saved-batch-bar {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg-elev-2);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 200;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}
.saved-batch-bar[hidden] { display: none; }
.saved-batch-label { color: var(--accent); }
.saved-batch-bar button {
  font-family: var(--mono);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
}
.saved-batch-bar button:hover { border-color: var(--accent); color: var(--accent); }
.saved-batch-bar #saved-batch-go {
  background: var(--accent-dim);
  color: var(--bg);
  border-color: var(--accent);
}
.saved-batch-bar #saved-batch-go:hover { background: var(--accent); }

/* --- character bar --- */
.char-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  margin-bottom: 16px;
}
.char-thumb {
  width: 32px !important;
  height: 32px !important;
  max-width: 32px !important;
  max-height: 32px !important;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.char-bar-name {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

/* gear dropdown */
.gear-wrap {
  position: relative;
  flex-shrink: 0;
}
.gear-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
}
.gear-btn:hover { color: var(--accent); }
.gear-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 6px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 190px;
  padding: 4px 0;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.gear-wrap.open .gear-menu { display: block; }
.gear-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.gear-menu button:hover {
  background: var(--bg-elev);
  color: var(--accent);
}
/* Inline form inside the gear menu (for the delete action). Makes the
   submit button render identically to the other menu buttons. */
.gear-menu form {
  margin: 0;
  border-top: 1px solid var(--border);
}
.gear-menu button.gear-danger {
  color: var(--err);
}
.gear-menu button.gear-danger:hover {
  background: color-mix(in srgb, var(--err) 15%, var(--bg-elev));
  color: var(--err);
}

/* --- shared panel (add / edit character / outfit) --- */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--accent-dim);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.panel.hidden { display: none; }
.panel-title {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.panel-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.form-row {
  flex: 1;
  min-width: 180px;
}
.form-row label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-row input[type="text"] {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
}
.form-row input[type="text"]:focus { border-color: var(--accent-dim); }
.form-row input[type="file"] {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}
.optional {
  font-size: 10px;
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
}
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.form-actions button {
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.form-actions button[type="submit"] {
  background: var(--accent);
  color: #0b1116;
  border: none;
}
.form-actions button[type="submit"]:hover { filter: brightness(1.1); }
.btn-secondary {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text); border-color: var(--text-dim); }

/* --- mode selector --- */
.mode-select-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.mode-select {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid var(--border);
  width: fit-content;
  max-width: 100%;
}
.mode-option {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.mode-option input[type="radio"] {
  display: none;
}
.mode-option:has(input:checked) {
  background: var(--bg-elev-2);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
}
.mode-option:not(:has(input:checked)) {
  border: 1px solid transparent;
}
.mode-option:hover {
  color: var(--text);
}

/* --- outfit library --- */
.outfit-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.outfit-section-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.outfit-add-btn {
  background: transparent;
  border: 1px dashed var(--accent-dim);
  color: var(--accent-dim);
  padding: 4px 12px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
}
.outfit-add-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.outfit-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
/* Wrapper that holds the card + a floating delete button. Hover the card
   to reveal the button so it doesn't clutter the grid at rest. */
.outfit-card-wrap {
  position: relative;
  display: inline-block;
}
.card-delete-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 2;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: border-color 0.1s, color 0.1s, background 0.1s, opacity 0.12s;
}
.outfit-card-wrap:hover .card-delete-btn,
.outfit-card-wrap:focus-within .card-delete-btn {
  opacity: 1;
  pointer-events: auto;
}
.card-delete-btn:hover {
  border-color: var(--err);
  color: var(--err);
  background: color-mix(in srgb, var(--err) 15%, var(--bg-elev-2));
}
.outfit-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg);
  width: 80px;
}
.outfit-card:has(input:checked) {
  border-color: var(--purple);
  background: var(--bg-elev-2);
}
.outfit-card:hover {
  border-color: var(--text-dim);
}
.outfit-card input[type="radio"] {
  display: none;
}
.outfit-thumb {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
}
.outfit-label {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.2;
  color: var(--text-dim);
  text-align: center;
  width: 100%;
  /* Allow the label to wrap onto multiple lines and break mid-word so
     long names like "black_bikini" stay inside the card instead of
     extending past it. */
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}
.outfit-card:has(input:checked) .outfit-label {
  color: var(--purple);
}
/* Folder badge on a foldered ref-image card (FolderedLibrary). */
.outfit-folder-badge {
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  padding: 1px 4px;
  margin-top: 2px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.outfit-empty {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  margin: 0 0 12px;
}

/* Drop-zone "+" tile that lives at the end of every outfit-grid. Same
   footprint as .outfit-card so the row keeps a single mental model. Click
   opens the matching add-panel; drop-an-image populates the panel's file
   input and prefills the name. */
.outfit-card-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
  color: var(--text-dim);
  width: 80px;
  min-height: 92px;
  box-sizing: border-box;
  user-select: none;
}
.outfit-card-add:hover,
.outfit-card-add:focus-visible {
  border-color: var(--accent);
  border-style: solid;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  outline: none;
}
.outfit-card-add.is-dragover {
  border-color: var(--accent);
  border-style: solid;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}
.outfit-card-add .add-plus {
  font-family: var(--mono);
  font-size: 28px;
  line-height: 1;
}
.outfit-card-add .add-label {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

/* --- submit --- */
.submit-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 24px;
}
.submit-card label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.submit-card textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 13px;
  resize: vertical;
  outline: none;
}
.submit-card textarea:focus {
  border-color: var(--accent-dim);
}
.submit-card button[type="submit"] {
  margin-top: 10px;
  background: var(--accent);
  color: #0b1116;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 600;
  font-family: var(--mono);
  cursor: pointer;
}
.submit-card button[type="submit"]:hover { filter: brightness(1.1); }

/* Video-generation and image-generation share one form; their mode
   tab-groups sit side by side inside a flex row so image gen reads as a
   secondary panel to the right of video gen. */
.mode-select-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.mode-group {
  display: flex;
  flex-direction: column;
}
.mode-group .mode-select { margin-bottom: 0; }
#image-inputs input[type="file"],
.reel-upload-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  margin-bottom: 10px;
  box-sizing: border-box;
  cursor: pointer;
}
#image-inputs input[type="file"]::file-selector-button,
.reel-upload-input::file-selector-button {
  margin-right: 10px;
  padding: 4px 10px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
}
#image-inputs input[type="file"]:hover::file-selector-button,
.reel-upload-input:hover::file-selector-button {
  border-color: var(--accent-dim);
  color: var(--accent);
}
.reel-upload-label {
  /* Softer "or" label — visually distinct from the primary URLs label. */
  opacity: 0.75;
  font-size: 12px;
  margin-top: 4px;
}

/* --- jobs --- */
.jobs-section { margin-top: 4px; }
.jobs-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.jobs-header h2 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}
.jobs-header .hint {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.empty {
  color: var(--text-dim);
  text-align: center;
  padding: 32px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  font-family: var(--mono);
  font-size: 13px;
}
.submit-error {
  margin-bottom: 12px;
  padding: 10px 14px;
  border: 1px solid var(--err);
  border-radius: 8px;
  color: var(--err);
  font-family: var(--mono);
  font-size: 12px;
  background: color-mix(in srgb, var(--err) 8%, transparent);
}

/* --- download cell + artifacts dropdown --- */
.dl-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}
.artifacts-menu {
  position: relative;
  font-family: var(--mono);
  font-size: 11px;
}

/* Disclosure marker: hide defaults on all engines, render our own caret. */
.artifacts-menu > summary {
  list-style: none;
  list-style-type: none;
}
.artifacts-menu > summary::-webkit-details-marker { display: none; }
.artifacts-menu > summary::marker { content: ""; font-size: 0; }

.artifacts-menu > summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  background: transparent;
  user-select: none;
  white-space: nowrap;
  transition: border-color 0.1s, color 0.1s, background 0.1s;
}
.artifacts-menu > summary::after {
  content: "▾";
  font-size: 9px;
  opacity: 0.7;
  transition: transform 0.15s;
  display: inline-block;
}
.artifacts-menu[open] > summary::after { transform: rotate(180deg); }

.artifacts-menu > summary:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.artifacts-menu[open] > summary {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* Floating menu panel */
.artifacts-menu ul {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  margin: 0;
  padding: 6px;
  list-style: none;
  min-width: 320px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.artifacts-menu li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  margin: 0;
}
.artifacts-menu li + li { margin-top: 1px; }
/* Subtle separators between stage groups — any li whose label starts with
   a different leading digit than the previous. */
.artifacts-menu li:has(a[href*="keyframe"]) + li:not(:has(a[href*="keyframe"])),
.artifacts-menu li:has(a[href*="faceswap"]) + li:not(:has(a[href*="faceswap"])),
.artifacts-menu li:has(a[href*="outfit_swap/"]) + li:not(:has(a[href*="outfit_swap/"])),
.artifacts-menu li:has(a[href*="body_enhance/"]) + li:not(:has(a[href*="body_enhance/"])),
.artifacts-menu li:has(a[href*="kling_input_"]) + li:not(:has(a[href*="kling_input_"])) {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.artifacts-menu li .artifact-step-open {
  display: block;
  padding: 6px 10px;
  border-radius: 5px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artifacts-menu li .artifact-step-open:hover,
.artifacts-menu li .artifact-step-open:focus-visible {
  background: var(--bg-elev-2);
  color: var(--accent);
  outline: none;
}
.artifacts-menu li .artifact-step-download {
  padding: 5px 7px;
  border-radius: 5px;
  color: var(--accent);
  font-size: 10px;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.78;
}
.artifacts-menu li .artifact-step-download:hover,
.artifacts-menu li .artifact-step-download:focus-visible {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  opacity: 1;
  outline: none;
}

/* --- preview dropdown (inline video player for finished jobs) --- */
.preview-menu {
  position: relative;
  font-family: var(--mono);
  font-size: 11px;
}
/* Belt-and-suspenders: different engines use different mechanisms to
   render the default disclosure triangle. Kill all of them. */
.preview-menu > summary {
  list-style: none;
  list-style-type: none;
}
.preview-menu > summary::-webkit-details-marker { display: none; }
.preview-menu > summary::marker { content: ""; font-size: 0; }

.preview-menu > summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  background: transparent;
  user-select: none;
  white-space: nowrap;
  transition: border-color 0.1s, color 0.1s, background 0.1s;
}
.preview-menu > summary::after {
  content: "▾";
  font-size: 9px;
  opacity: 0.7;
  transition: transform 0.15s;
  display: inline-block;
}
.preview-menu[open] > summary::after { transform: rotate(180deg); }
.preview-menu > summary:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.preview-menu[open] > summary {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.preview-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  padding: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
/* Fixed compact 9:16 player — intentionally small so it never dominates
   the layout. Users who want full-size can download. Both width/height are
   hard-capped (not just max-*) so the browser can't fall back to intrinsic
   video dimensions (1080x1920) while loading metadata. */
.preview-panel video,
.preview-panel img {
  display: block;
  width: 200px;
  height: 356px;      /* 200 * 16/9, rounded */
  max-width: 80vw;
  max-height: 70vh;
  border-radius: 6px;
  background: #000;
  object-fit: contain;
}

/* --- toggle option (checkbox row in submit form) --- */
#body-options,
.core-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

/* --- extra-prompt section (shows when "extra prompting" is ticked) --- */
.extra-prompt-section {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.extra-prompt-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
/* Textarea picks up `.submit-card textarea` styling automatically; the
   block here just tightens the gap so the section reads as one unit. */
.extra-prompt-section textarea {
  margin-bottom: 0;
}
.extra-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

/* --- Custom-action model picker (Wan 2.7 vs Nano Banana Pro) --- */
.custom-model-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

/* --- Custom-action extra reference image slots (img_edit/custom) --- */
.custom-image-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.custom-image-slot {
  flex: 1 1 0;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.custom-image-slot-head {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.custom-image-lib {
  width: 100%;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 12px;
}
.custom-image-or-divider {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  position: relative;
}
.custom-image-or-divider::before,
.custom-image-or-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}
.custom-image-or-divider::before { left: 0; }
.custom-image-or-divider::after  { right: 0; }
.custom-image-upload-btn {
  display: block;
  text-align: center;
  padding: 8px 10px;
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}
.custom-image-upload-btn:hover {
  border-color: var(--accent-dim);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-elev));
}
.custom-image-upload-input {
  display: none;
}
.custom-image-upload-label {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Start hidden; JS flips to `display: flex` whenever core mode is active. */
.core-options { display: none; }
/* Override `.submit-card label { display: block }` from the generic form
   styling — we want the toggles laid out as inline pills on one row. */
.submit-card label.toggle-option,
.toggle-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin-bottom: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.1s, color 0.1s, background 0.1s;
  width: auto;
}
.toggle-option:hover {
  border-color: var(--accent-dim);
  color: var(--text);
}
.toggle-option:has(input:checked) {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.toggle-option input[type="checkbox"] {
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* --- cancel / pause controls --- */
.jobs-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.btn-cancel,
.btn-cancel-all,
.btn-pause,
.btn-pause-all,
.btn-resume,
.btn-resume-all,
.btn-rerun,
.btn-download-all {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s, background 0.1s;
  text-decoration: none;
  display: inline-block;
}
.btn-cancel:hover:not(:disabled),
.btn-cancel-all:hover {
  border-color: var(--err);
  color: var(--err);
  background: color-mix(in srgb, var(--err) 8%, transparent);
}
.btn-pause:hover,
.btn-pause-all:hover {
  border-color: var(--text);
  color: var(--text);
}
.btn-resume:hover,
.btn-resume-all:hover,
.btn-rerun:hover {
  border-color: var(--accent, var(--text));
  color: var(--accent, var(--text));
  background: color-mix(in srgb, var(--accent, var(--text)) 8%, transparent);
}
.btn-cancel:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}
.btn-cancel-all,
.btn-pause-all,
.btn-resume-all,
.btn-download-all {
  font-size: 12px;
  padding: 6px 14px;
}
.btn-download-all {
  border-color: var(--accent-dim);
  color: var(--accent);
}
.btn-download-all:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.status-cancelled {
  opacity: 0.75;
}

table.jobs {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  /* `visible` so the artifacts dropdown can escape the table bounds.
     Corner rounding is preserved via border-radius on the first/last
     th / td cells below. */
  overflow: visible;
  font-size: 13px;
}
table.jobs thead th:first-child { border-top-left-radius: 12px; }
table.jobs thead th:last-child  { border-top-right-radius: 12px; }
table.jobs tbody tr:last-child td:first-child { border-bottom-left-radius: 12px; }
table.jobs tbody tr:last-child td:last-child  { border-bottom-right-radius: 12px; }
table.jobs th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
}
table.jobs td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.jobs tr:last-child td { border-bottom: none; }
table.jobs td.id { font-family: var(--mono); color: var(--text-dim); width: 40px; }
table.jobs td.url a {
  color: var(--text);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 12px;
}
table.jobs td.url a:hover { color: var(--accent); }
table.jobs td.when { color: var(--text-dim); font-family: var(--mono); font-size: 11px; width: 80px; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pill-core           { background: #1d2d3a; color: var(--accent); }
.pill-body_enhance   { background: #2d2a1d; color: var(--warn); }
.pill-outfitswap     { background: #2d1d3a; color: var(--purple); }
.pill-experiment     { background: #1d3a2d; color: #7bdfb0; }
.pill-refimage       { background: #3a2a1d; color: #f0c087; }
.pill-transition     { background: #1d3a3a; color: #87f0d0; }
.pill-img_faceswap   { background: #1d3a3a; color: #7dd3c0; }
/* Mode pills now show readable labels with arrow glyphs — skip upper-casing
   and tighten padding a bit so the longer strings fit the mode column. */
.pill-core, .pill-body_enhance, .pill-outfitswap, .pill-experiment, .pill-refimage, .pill-img_faceswap, .pill-img_edit, .pill-transition, .pill-multi_transition, .pill-body_outfit_exp, .pill-talking {
  text-transform: none;
  letter-spacing: 0;
  padding: 3px 8px;
  white-space: nowrap;
}
.pill-mode-orientation .mode-orientation {
  margin-left: 2px;
  opacity: 0.72;
}
.pill-queued      { background: #2a3340; color: #a8b3c4; }
.pill-downloading { background: #3a1d1d; color: var(--err); }

/* Make the downloading state unmissable — tint the whole row red while
   yt-dlp is fetching the source. State is transient (flips to processing
   within seconds) so the row-level tint is easier to catch than the pill. */
table.jobs tr.row.status-downloading {
  background: rgba(255, 107, 107, 0.08);
}
table.jobs tr.row.status-downloading td {
  border-top-color: rgba(255, 107, 107, 0.25);
}

/* Download button turns red once the user has clicked it — tracked in
   localStorage so state survives the htmx auto-refresh. */
/* Match the visual weight of sibling action buttons (.btn-rerun etc.). */
.btn-download {
  padding: 4px 10px;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.4;
}
.btn-download.downloaded {
  color: var(--err);
  border-color: rgba(255, 107, 107, 0.5);
  background: rgba(255, 107, 107, 0.08);
}
.btn-download.downloaded:hover {
  background: rgba(255, 107, 107, 0.14);
}
.pill-processing  { background: #1d3a4a; color: #5ad1ff; }
.pill-provider_waiting { background: #2d2548; color: #c6a8ff; }
.pill-done        { background: #18371f; color: var(--ok); }
.pill-failed      { background: #3a1d1d; color: var(--err); }
.pill-cancelled   { background: #2d2a33; color: #b8a8c4; }
.stage-bar {
  position: relative;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
  min-width: 140px;
}
.stage-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.3s ease;
}
.stage-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}
.err { color: var(--err); font-family: var(--mono); font-size: 11px; }

.err-block {
  font-family: var(--mono);
  font-size: 11px;
  max-width: 320px;
  line-height: 1.35;
}
.err-title {
  color: var(--err);
  font-weight: 600;
}
.err-reason {
  color: var(--text-dim);
  margin-top: 2px;
}

/* --- Admin: system overseer (settings dialog) --- */
.overseer-section { background: var(--bg-elev-2); }
.overseer-badge {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  margin-left: 6px;
}
.overseer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.overseer-panel {
  background: var(--bg);
  border: 1px solid var(--bg-elev);
  border-radius: 6px;
  padding: 10px 12px;
  min-width: 0;
}
.overseer-panel-title {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.overseer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}
.overseer-empty {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  font-style: italic;
}
.overseer-row {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 0;
  border-bottom: 1px solid var(--bg-elev);
}
.overseer-row:last-child { border-bottom: none; }
.overseer-row-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  justify-content: space-between;
}
.overseer-row-meta {
  color: var(--text-dim);
  margin-top: 2px;
}
.overseer-email {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.overseer-pill {
  background: var(--bg-elev);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
}
.overseer-count {
  color: var(--accent);
  font-weight: 600;
}
.overseer-fail-title {
  color: var(--err);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.overseer-fail-reason {
  color: var(--text-dim);
  margin-top: 2px;
  font-size: 10px;
  line-height: 1.3;
}
.overseer-capacity {
  font-family: var(--mono);
  font-size: 11px;
}
.overseer-cap-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 6px;
}
.overseer-cap-num {
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
}
.overseer-cap-lbl { color: var(--text-dim); }
.overseer-cap-sep { color: var(--text-dim); margin: 0 4px; }
.overseer-cap-bar {
  height: 6px;
  background: var(--bg-elev);
  border-radius: 3px;
  overflow: hidden;
}
.overseer-cap-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.3s ease;
}
.overseer-cap-foot {
  color: var(--text-dim);
  margin-top: 4px;
  font-size: 10px;
}
@media (max-width: 720px) {
  .overseer-grid { grid-template-columns: 1fr; }
}

.btn {
  display: inline-block;
  background: var(--bg-elev-2);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: 5px 12px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn:hover { background: var(--accent-dim); color: #fff; }

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px;
    max-height: 180px;
  }
  main { padding: 16px 12px 80px; }
  .char-card { padding: 12px 14px; gap: 10px; }
  .char-ref { width: 44px; height: 44px; }
  .panel-grid { flex-direction: column; gap: 10px; }
  table.jobs { font-size: 12px; }
  table.jobs th, table.jobs td { padding: 8px 6px; }
  table.jobs td.when { display: none; }
  .topbar { padding: 12px 16px; }
  .outfit-grid { gap: 6px; }
  .outfit-card { width: 68px; }
  .outfit-card-add { width: 68px; min-height: 80px; }
  .outfit-thumb { width: 48px; height: 48px; }
}

/* --- Submit row: queue-up button + live cost estimate ------------------ */
.submit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.cost-estimate {
  font-size: 12px;
  color: var(--accent-dim);
  font-family: inherit;
  cursor: help;
  user-select: none;
}
.batch-summary {
  font-size: 12px;
  color: var(--text-dim);
}
.batch-summary.is-blocked {
  color: var(--err);
}
.submit-success {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  font-size: 12px;
}

/* Transition mode: label for each add-on block (pre / post / split). */
.addons-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-dim);
  align-self: center;
  margin-right: 4px;
}
.transition-ts-input {
  width: 140px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
}

/* Instagram carousel picker: URL input + load button, then a grid of
   checkbox-thumbnails that ride along on submit as hidden form values. */
.carousel-loader {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--accent-dim);
}
.carousel-loader-row {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.carousel-url-input {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  border-radius: 3px;
  font-family: inherit;
  font-size: 13px;
}
.carousel-load-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.carousel-load-btn:hover:not(:disabled) {
  background: rgba(90, 209, 255, 0.1);
}
.carousel-load-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.carousel-status {
  margin-top: 6px;
  font-size: 11px;
  color: var(--accent-dim);
  min-height: 14px;
}
.carousel-status.ok {
  color: var(--ok);
}
.carousel-status.err {
  color: var(--err);
}
.carousel-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.carousel-card {
  position: relative;
  width: 96px;
  height: 96px;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  background: #000;
}
.carousel-card input[type="checkbox"] {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  cursor: pointer;
}
.carousel-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.carousel-card-index {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 6px;
  font-size: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 8px;
}
.carousel-card:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(90, 209, 255, 0.25);
}

/* Faceswap image queue: chips showing each accumulated upload/paste,
   with individual × remove + a "clear all" reset. */
.image-paste-hint {
  margin: 4px 0 8px;
  font-size: 11px;
  color: var(--accent-dim);
}
.image-queue {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(90, 209, 255, 0.04);
  border: 1px solid rgba(90, 209, 255, 0.2);
  border-radius: 4px;
}
.image-queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.image-queue-count {
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.image-queue-clear {
  padding: 2px 8px;
  background: transparent;
  border: 1px solid var(--accent-dim);
  color: var(--accent-dim);
  border-radius: 3px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}
.image-queue-clear:hover {
  border-color: var(--err);
  color: var(--err);
}
.image-queue-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.image-queue-thumb {
  position: relative;
  width: 88px;
  background: var(--bg);
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.image-queue-thumb img {
  display: block;
  width: 88px;
  height: 88px;
  object-fit: cover;
  background: #000;
}
.image-queue-thumb-label {
  display: block;
  padding: 3px 5px;
  font-size: 10px;
  color: var(--accent-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 88px;
}
.image-queue-thumb-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  padding: 0;
  background: rgba(0, 0, 0, 0.65);
  border: none;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-queue-thumb-x:hover {
  background: var(--err);
  color: #fff;
}

/* Transition manual preview: scrub-the-video-to-find-the-cut UI. */
#transition-preview-wrap {
  margin: 12px 0;
  padding: 12px;
  background: rgba(135, 240, 208, 0.05);
  border: 1px solid rgba(135, 240, 208, 0.25);
  border-radius: 4px;
}
.transition-preview-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.transition-use-btn {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.transition-use-btn:hover {
  background: rgba(90, 209, 255, 0.1);
}
#transition-preview-video {
  display: none;
  width: 100%;
  max-height: 400px;
  background: #000;
  border-radius: 3px;
}
.transition-preview-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--accent-dim);
}

/* Before/after frame thumbnails — auto-update as the user scrubs the
   transition source video. Two canvases sit side by side; their content
   is drawn from hidden helper <video> elements seeked to currentTime ± Δ. */
.transition-frames-row {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  justify-content: center;
}
.transition-frame-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.transition-frame-label {
  font-size: 11px;
  color: var(--accent-dim);
  letter-spacing: 0.04em;
  text-transform: lowercase;
}
.transition-frame-delta {
  color: var(--accent);
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}
.transition-frame-canvas {
  width: 140px;
  height: 248px;
  background: #000;
  border: 1px solid rgba(135, 240, 208, 0.25);
  border-radius: 3px;
  object-fit: cover;
}
.transition-delta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
}
.transition-delta-label {
  color: var(--accent-dim);
}
.transition-delta-input {
  width: 70px;
  padding: 3px 6px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(135, 240, 208, 0.3);
  border-radius: 3px;
  color: inherit;
  font-family: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.transition-delta-unit {
  color: var(--accent-dim);
  font-size: 11px;
}

/* --- Compact three-option rerun picker --- */
.rerun-menu {
  display: inline-block;
  position: relative;
}
.rerun-menu summary {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 6px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  /* Re-uses .btn-rerun styling (set as a class on summary). */
}
.rerun-menu summary::-webkit-details-marker { display: none; }
.rerun-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: max-content;
  min-width: 210px;
  max-width: calc(100vw - 24px);
  padding: 4px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  z-index: 1000;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.rerun-opt {
  display: block;
  width: 100%;
  font-family: var(--mono);
  font-size: 11px;
  text-align: left;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}
.rerun-opt:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg-elev);
  border-color: var(--border);
}
.rerun-opt:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
/* Retained for other compact action menus that need a visual divider. */
.rerun-sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 4px 0;
  opacity: 0.6;
}
.rerun-cost-note {
  max-width: 230px;
  padding: 3px 7px 5px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.35;
}

/* --- Manual rerun modal: video + scrub + submit --- */
.rerun-manual-dialog {
  width: min(720px, 90vw);
  max-width: 90vw;
  padding: 18px 20px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.rerun-manual-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}
.rerun-manual-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}
#rerun-manual-video {
  width: 100%;
  max-height: 60vh;
  background: #000;
  border-radius: 6px;
  margin-bottom: 6px;
}
.rerun-manual-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.rerun-manual-actions button {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.rerun-manual-actions button.btn-primary {
  background: var(--accent);
  color: #0b1116;
  border-color: var(--accent);
  font-weight: 600;
}
.rerun-manual-actions button:hover { color: var(--text); }
.rerun-manual-actions button.btn-primary:hover { filter: brightness(1.1); color: #0b1116; }

/* --- Manual-split readout (live mm:ss.mmm) + proportional pre/post bar --- */
.transition-split-readout {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}
.transition-split-readout strong {
  color: var(--accent);
  font-weight: 600;
}
.transition-split-readout .readout-dim {
  color: var(--text-dim);
  margin-left: 4px;
}
.transition-split-bar {
  display: flex;
  width: 100%;
  height: 8px;
  margin-top: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
}
.split-bar-pre,
.split-bar-post {
  height: 100%;
  transition: flex-basis 60ms linear;
  min-width: 1px;
}
.split-bar-pre  { background: var(--accent); }
.split-bar-post { background: var(--purple, #c78dff); }

/* --- Top nav (home / active / library) --- */
.topnav {
  display: flex;
  gap: 4px;
  margin-left: 24px;
}
.topnav-link {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  border: 1px solid transparent;
}
.topnav-link:hover {
  color: var(--text);
  background: var(--bg-elev-2);
}
.topnav-link-active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--bg-elev-2);
}

/* --- Save / saved toggle on completed job rows --- */
.btn-save,
.btn-saved {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 6px;
  border: 1px solid var(--border, #2a3038);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.btn-save:hover {
  color: #ffd44d;
  border-color: #ffd44d;
}
.btn-saved {
  color: #ffd44d;
  border-color: #ffd44d;
  background: rgba(255, 212, 77, 0.08);
}
.btn-saved:hover {
  background: rgba(255, 212, 77, 0.16);
}

/* --- Library page --- */
.page-section {
  padding: 16px 24px 32px;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 16px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--text);
}
.page-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}
.active-count {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 16px;
}
.library-filter label {
  font-size: 12px;
  color: var(--text-dim);
  margin-right: 6px;
}
.library-filter select {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border, #2a3038);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
}
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.library-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border, #2a3038);
  border-radius: 10px;
  /* No overflow:hidden — it would clip the resubmit dropdown panel.
     The thumbnail rounds its own top corners instead. */
  position: relative;
}
.library-thumb {
  display: block;
  aspect-ratio: 9 / 16;
  background: var(--bg-elev-2);
  overflow: hidden;
  border-radius: 9px 9px 0 0;
}
.library-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.library-thumb img.thumb-missing {
  object-fit: contain;
  opacity: 0.3;
}
.library-meta {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.library-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.pill-character {
  background: rgba(90, 209, 255, 0.12);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
}
.pill-ts {
  background: rgba(199, 141, 255, 0.10);
  color: var(--purple, #c78dff);
  border: 1px solid var(--purple, #c78dff);
}
.library-url {
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  word-break: break-all;
}
.library-url:hover {
  color: var(--text);
}
.library-when {
  font-size: 11px;
  color: var(--text-dim);
}
.library-actions {
  padding: 8px 12px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.library-action-form {
  margin: 0;
  display: contents;
}
/* Anchor variant of .rerun-opt — used for the library "new options" link
   that sends you back to the home form with the URL pre-filled. */
a.rerun-opt {
  text-decoration: none;
  display: block;
}

/* Library multi-select: toolbar above the grid + a checkbox in the corner of
   each card. Selected cards get a coloured outline so the picked set is
   readable at a glance. */
.library-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--border, #2a3038);
  margin-bottom: 14px;
}
.library-select-all {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}
#library-batch-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.library-toolbar-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
}
.library-select {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  padding: 3px 5px;
  cursor: pointer;
}
.library-select-cb {
  cursor: pointer;
}
.library-card:has(.library-select-cb:checked) {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* Whole-card click: in default mode the cursor hints "this plays the
   video"; in select mode it hints "this toggles selection". */
.library-card { cursor: pointer; }
.library-grid.select-mode .library-card { cursor: pointer; }

/* "Open original" link as a small icon top-right of the thumbnail.
   Only visible for URL-based saves (the upload-based ones don't render
   the anchor at all). */
.library-open-original {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: var(--text);
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
}
.library-open-original:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Preview play button — only shown in select mode (where whole-card
   click toggles selection so the video preview needs its own affordance).
   In default mode the entire card is the preview trigger so the explicit
   button isn't necessary. */
.library-preview-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding-left: 3px; /* nudge the ▶ glyph optically centred */
}
.library-grid.select-mode .library-preview-btn {
  display: flex;
}
.library-preview-btn:hover {
  background: rgba(0, 0, 0, 0.85);
}

/* Preview dialog — fullscreen-ish modal centred on the page. The native
   <dialog> ::backdrop dims the rest of the page; clicking outside the
   .library-preview-content closes (handled in JS via event.target check). */
.library-preview-dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 92vw;
  max-height: 92vh;
}
.library-preview-dialog::backdrop {
  background: rgba(0, 0, 0, 0.85);
}
.library-preview-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.library-preview-media video,
.library-preview-media img {
  display: block;
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
  background: #000;
}
.library-preview-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
}
.library-preview-close:hover {
  background: var(--bg-elev-2);
}
.library-url-upload {
  display: inline-block;
  font-size: 12px;
  color: var(--text-dim);
  word-break: break-all;
}

/* "Staged from library" panel on the home tab — shows up when the user
   arrives via /?reuse_ids=... from the library multi-select. Each chip
   carries a hidden <input name="reuse_saved_id"> that the submit handler
   turns into one job per chip. */
.staged-section {
  background: var(--bg-elev);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.staged-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text);
}
.staged-hint {
  font-size: 11px;
  color: var(--text-dim);
}
.staged-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.staged-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border, #2a3038);
  border-radius: 6px;
  padding: 4px 6px 4px 4px;
  max-width: 320px;
}
.staged-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.staged-thumb.thumb-missing {
  opacity: 0.3;
  object-fit: contain;
}
.staged-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.staged-display {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.staged-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.staged-remove:hover {
  color: var(--text);
}

/* Char-scope toggle (this char / all chars) in the jobs header. */
.jobs-scope {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 11px;
  margin-left: 12px;
}
.jobs-scope-btn {
  background: var(--bg-elev);
  color: var(--text-dim);
  border: none;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.jobs-scope-btn + .jobs-scope-btn {
  border-left: 1px solid var(--border);
}
.jobs-scope-btn:hover:not(.active) {
  color: var(--text);
  background: var(--bg-elev-2);
}
.jobs-scope-btn.active {
  background: var(--accent-dim);
  color: var(--bg);
  font-weight: 600;
  cursor: default;
}

/* "show older / show fewer" history toggle under the jobs table. Subtle,
   centered, full-width row so it reads as a footer control, not a row. */
.jobs-more {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 4px;
}
.jobs-more-btn {
  background: var(--bg-elev);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 14px;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.jobs-more-btn:hover {
  color: var(--text);
  background: var(--bg-elev-2);
}

/* Settings gear: pinned in the topbar (rendered by base.html). */
.settings-gear-v1 {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.settings-gear-v1:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-elev));
}

/* Account chip — email + log-out icon pinned at the right of the topbar.
   Mirrors the settings-gear sizing so the controls line up. */
.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}
.account-email {
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.85;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logout-form {
  display: inline;
  margin: 0;
  padding: 0;
}
.logout-btn {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.logout-btn:hover {
  color: #ff8888;
  border-color: #ff8888;
  background: color-mix(in srgb, #ff8888 12%, var(--bg-elev));
}

/* Settings dialog. Native <dialog> + custom styling. Cookies cluster
   gets moved here from the topbar by JS on load. */
.settings-dialog {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 12px;
  padding: 0;
  max-width: 560px;
  width: 90vw;
  max-height: 88vh;
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
  /* Vertical scroll inside the dialog so sections that don't fit
     (e.g., the new "job history" block) stay reachable. The header
     scrolls with the rest — keep it simple, scroll the whole modal. */
  overflow-y: auto;
  overflow-x: hidden;
}
.settings-dialog::-webkit-scrollbar { width: 6px; }
.settings-dialog::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 3px;
}
.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.settings-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.settings-dialog-header h3 {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}
.settings-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.12s;
}
.settings-close:hover { color: var(--text); }
/* Back button on the standalone link-history dialog — same family as
   settings-close but on the left, with a textual arrow. */
.settings-back {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.settings-back:hover {
  color: var(--accent);
  border-color: var(--accent);
}
/* Three-column header (back · title · close) for the link-history dialog. */
#links-history-dialog .settings-dialog-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}
#links-history-dialog .settings-dialog-header h3 {
  text-align: center;
}
.settings-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-child { border-bottom: none; }
.settings-section-title {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-soon {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0.04em;
  font-weight: 400;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.settings-section-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin: 0 0 10px;
  line-height: 1.5;
}
.settings-section-desc code {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--bg);
  padding: 1px 4px;
  border-radius: 3px;
}
.settings-section-desc strong { color: rgb(220, 90, 90); }
#settings-cookies-host {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Cookie state badge — green chip when cookies file exists. */
.cookie-state-badge {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 400;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.cookie-state-badge.active {
  color: rgb(70, 200, 120);
  border-color: rgb(70, 200, 120);
  background: color-mix(in srgb, rgb(70, 200, 120) 12%, transparent);
}
.cookie-state-badge.inactive {
  color: var(--text-dim);
}

/* Settings section — generic button + danger button */
.settings-btn {
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.settings-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.settings-btn-danger:hover {
  color: rgb(220, 90, 90);
  border-color: rgb(220, 90, 90);
}
.settings-btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.settings-btn-primary:hover {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.settings-btn-disabled,
.settings-btn-disabled:hover {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--text-dim);
  border-color: var(--border);
  background: var(--bg);
}
.settings-token-fallback {
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.settings-token-fallback > summary {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.settings-token-fallback > summary:hover {
  color: var(--text);
}
.settings-empty {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
  padding: 6px 0;
}

/* API keys list */
.settings-keys-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.settings-key-row {
  display: grid;
  grid-template-columns: minmax(160px, auto) 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
}
.settings-key-name {
  color: var(--accent);
  font-weight: 600;
}
.settings-key-value {
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10.5px;
}
.settings-key-value.settings-key-unset {
  color: var(--text-dim);
  font-style: italic;
  opacity: 0.6;
}
.settings-key-del-spacer {
  width: 22px;
}
.settings-key-del {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
  transition: color 0.12s;
}
.settings-key-del:hover { color: rgb(220, 90, 90); }

.settings-keys-add {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 8px;
  align-items: center;
}
.settings-keys-add input,
.settings-keys-add select {
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 8px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.settings-motion-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.settings-motion-form select {
  min-width: 0;
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 8px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.settings-provider-subheading {
  margin-top: 12px;
  margin-bottom: 6px;
}
.settings-higgsfield {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.settings-higgsfield-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
}
.settings-higgsfield-oauth {
  min-width: 170px;
}
.settings-higgsfield-workspace {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin: 6px 0 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
}
.settings-higgsfield-workspace select {
  min-width: 0;
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 8px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.settings-higgsfield-manual {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
}
.settings-higgsfield-manual summary {
  cursor: pointer;
  color: var(--accent);
}
.settings-higgsfield-connect {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  margin-top: 8px;
}
.settings-higgsfield-connect label {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.settings-higgsfield-connect input[type="file"] {
  min-width: 0;
  width: 100%;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
}
@media (max-width: 620px) {
  .settings-motion-form,
  .settings-higgsfield-connect,
  .settings-higgsfield-workspace {
    grid-template-columns: 1fr;
  }
}

/* Instagram cookies upload */
.settings-cookies-upload {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.settings-cookies-upload input[type="file"] {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  flex: 1;
}
.settings-cookies-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
  padding: 4px 0;
}

/* Chrome extension token */
.settings-token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.settings-token-row a.settings-btn {
  text-decoration: none;
}
.settings-token-display {
  background: var(--bg);
  border: 1px dashed var(--accent);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-token-display[hidden] {
  display: none;
}
.settings-token-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
}
.settings-token-value {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 8px;
  border-radius: 4px;
  word-break: break-all;
  user-select: all;
}

/* Link history list */
.settings-links-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  padding: 6px;
}
.settings-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  border-radius: 4px;
}
.settings-link-row:hover { background: var(--bg-elev); }
.settings-link-url {
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.settings-link-url:hover { color: var(--accent); }
.settings-link-meta {
  color: var(--text-dim);
  font-size: 9.5px;
  flex-shrink: 0;
}

/* =====================================================================
   Library page — pretty cards, hover-play videos, folder sidebar.
   ===================================================================== */

/* --- header: title + char filter ---------------------------------- */
.library-page .library-page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.library-page .library-page-header h2 {
  margin: 0;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  font-size: 18px;
  color: var(--text);
}
.library-page .library-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}
.library-page .library-filter select {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}

/* --- two-column body: sidebar + main ------------------------------ */
.library-page-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 800px) {
  .library-page-body {
    grid-template-columns: 1fr;
  }
}

/* --- LEFT: folder sidebar ---------------------------------------- */
.library-folders {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.library-folders-title {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.folder-row-wrap {
  display: flex;
  align-items: stretch;
  gap: 4px;
}
.folder-row-wrap .folder-row { flex: 1; }
.folder-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, outline 0.12s;
}
/* Drop target highlight when a card is being dragged over the row. */
.folder-row.drop-hover {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--accent) 25%, var(--bg-elev));
  color: var(--accent);
}
.folder-kebab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 0 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s, border-color 0.12s, background 0.12s;
}
.folder-row-wrap:hover .folder-kebab { opacity: 1; }
.folder-kebab:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-elev-2);
}
.folder-row:hover {
  background: var(--bg-elev-2);
  color: var(--text);
}
.folder-row.active {
  background: color-mix(in srgb, var(--accent) 20%, var(--bg-elev));
  color: var(--accent);
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}
.folder-icon {
  flex: 0 0 16px;
  font-size: 13px;
  text-align: center;
}
.folder-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-count {
  flex: 0 0 auto;
  font-size: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  color: var(--text-dim);
}
.folder-row.active .folder-count {
  border-color: var(--accent);
  color: var(--accent);
}
.library-folders-foot {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.library-folders-foot input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 10px;
  box-sizing: border-box;
}
.library-folders-hint {
  font-size: 10px;
  color: var(--text-dim);
  margin: 8px 0 0;
  line-height: 1.4;
  opacity: 0.7;
}

/* --- RIGHT: toolbar + grid -------------------------------------- */
.library-page-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
}
.library-page-toolbar-spacer { flex: 1; }
.library-stage-limit {
  max-width: 280px;
  color: var(--danger, #ff6b6b);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.3;
}
.library-select-all {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
}
.library-sort-form {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}
.library-sort-form select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
}
.library-sort-form select:hover { border-color: var(--accent); }
.library-page-btn {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.library-page-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}
.library-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.library-page-btn.primary {
  background: var(--accent-dim);
  color: var(--bg);
  border-color: var(--accent);
}
.library-page-btn.primary:hover:not(:disabled) {
  background: var(--accent);
}

/* --- card grid ---------------------------------------------------- */
.library-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.lib-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
  position: relative;
}
.lib-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.lib-card:has(.lib-card-select-cb:checked) {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* Visual feedback while a card is being dragged. */
.lib-card[draggable="true"] { cursor: grab; }
.lib-card.lib-card-dragging {
  opacity: 0.4;
  cursor: grabbing;
}

/* media area: 9:16 with hover-play video */
.lib-card-media {
  position: relative;
  aspect-ratio: 9 / 16;
  background: var(--bg);
  overflow: hidden;
}
.lib-card-media video,
.lib-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lib-card-media .lib-card-hover-video {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.lib-card-media.thumb-missing {
  background:
    repeating-linear-gradient(45deg,
      var(--bg-elev) 0 6px,
      var(--bg) 6px 12px);
}
.lib-card-media.thumb-missing::after {
  content: "no preview";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* select checkbox top-left */
.lib-card-select {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.15s;
}
.lib-card:hover .lib-card-select,
.lib-card:has(.lib-card-select-cb:checked) .lib-card-select {
  opacity: 1;
}
.lib-card-select input {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

/* corner link top-right (open original) */
.lib-card-corner {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  display: grid;
  place-items: center;
  text-decoration: none;
  font-size: 11px;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.15s, color 0.12s;
}
.lib-card:hover .lib-card-corner { opacity: 1; }
.lib-card-corner:hover { color: var(--accent); }

/* center play button (overlays media on hover) */
.lib-card-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: var(--text);
  border: 2px solid rgba(255, 255, 255, 0.3);
  display: grid;
  place-items: center;
  font-size: 18px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s, background 0.12s, border-color 0.12s;
  z-index: 4;
  padding: 0;
  padding-left: 4px;  /* visual centering of ▶ glyph */
}
.lib-card:hover .lib-card-play {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.lib-card-play:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--bg);
}

/* folder chip bottom-left of media */
.lib-card-folder-chip {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid var(--accent-dim);
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 4;
  pointer-events: none;
}

/* meta footer */
.lib-card-foot {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg);
}
.lib-card-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.lib-card-row-secondary { gap: 4px; }
.lib-card-row-bottom {
  justify-content: space-between;
  margin-top: 2px;
}
.lib-chip {
  font-family: var(--mono);
  font-size: 9.5px;
  padding: 2px 7px;
  border-radius: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.lib-chip.outfit { color: var(--accent); border-color: var(--accent-dim); }
.lib-chip.addon  { color: var(--warn); border-color: rgba(180, 140, 60, 0.4); }
.lib-card-url {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.lib-card-url:hover { color: var(--accent); }
.lib-card-url.upload { color: var(--text-dim); cursor: default; }
.lib-card-when {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0.7;
  flex: 0 0 auto;
}

/* hover-revealed action bar overlaying the bottom of the media area.
   Lives INSIDE .lib-card-media (which is position:relative) so this
   absolute positioning is relative to the media region only — leaves
   the meta footer untouched. */
/* Folder corner button — bottom-right of media (reuses .lib-card-corner
   positioning + reveal-on-hover behavior). The default .lib-card-corner
   sits at top-right; this override moves it to bottom-right so it
   doesn't collide with the existing ↗ external-link corner. */
.lib-card-corner-folder {
  top: auto;
  bottom: 8px;
  right: 8px;
  cursor: pointer;
  border: none;
  font-size: 12px;
}

/* --- hover-revealed action bars (replace meta pills on hover) -------
   At rest: meta pills/url/when are visible, bars are hidden.
   On hover: meta rows hide, bars stack into the foot area in priority
   order — rerun, rerun w/ options, download, unsave. The folder action
   lives separately as a corner overlay (above) so the bar list can
   stay focused on the 4 primary actions. */
.lib-card-bars {
  display: none;
  flex-direction: column;
  gap: 4px;
}
.lib-card:hover .lib-card-foot .lib-card-row,
.lib-card:hover .lib-card-foot .lib-card-row-secondary,
.lib-card:hover .lib-card-foot .lib-card-row-bottom {
  display: none;
}
.lib-card:hover .lib-card-bars {
  display: flex;
}
.lib-bar-form { margin: 0; width: 100%; }
.lib-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.lib-bar:hover {
  background: var(--bg-elev-2);
  border-color: var(--accent);
  color: var(--accent);
}
.lib-bar-icon {
  font-size: 14px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}
.lib-bar-label {
  flex: 1;
  letter-spacing: 0.02em;
}
/* rerun is the primary action — accent fill so it's the obvious pick */
.lib-bar-rerun {
  background: var(--accent-dim);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}
.lib-bar-rerun:hover {
  background: var(--accent);
  color: var(--bg);
}
/* unsave is destructive — red on hover */
.lib-bar-unsave {
  color: var(--err);
}
.lib-bar-unsave:hover {
  background: var(--err);
  color: var(--bg);
  border-color: var(--err);
}

/* --- library rerun dropdown ------------------------------------------- */
/* `<details>` keeps the three rerun intents tucked beneath one action bar. */
.lib-bar-rerun-menu {
  width: 100%;
}
.lib-bar-rerun-menu > summary {
  /* Inherit .lib-bar-rerun look — the class is also on the <summary>. */
  list-style: none;  /* Firefox */
  position: relative;
}
.lib-bar-rerun-menu > summary::-webkit-details-marker {
  display: none;  /* Safari/Chrome default arrow */
}
.lib-bar-caret {
  font-size: 10px;
  margin-left: auto;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.lib-bar-rerun-menu[open] > summary .lib-bar-caret {
  transform: rotate(180deg);
}
.lib-bar-menu-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  padding-left: 12px;
  border-left: 2px solid var(--accent-dim);
}
.lib-rerun-cost {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.3;
  padding: 1px 4px;
}
.lib-bar-menu-item {
  /* Visually subordinate to the parent rerun button — neutral fill,
     not the accent. Hovers to the accent the way other lib-bars do. */
  background: var(--bg-elev);
  color: var(--text);
  border-color: var(--border);
  font-weight: 400;
  padding: 6px 10px;
  font-size: 11.5px;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}
.lib-bar-menu-item:hover {
  background: var(--bg-elev-2);
  color: var(--accent);
  border-color: var(--accent);
}

/* --- folder picker dialog ---------------------------------------- */
.folder-picker-dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elev);
  color: var(--text);
  padding: 0;
  width: min(420px, 90vw);
  max-width: 90vw;
}
.folder-picker-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
}
.folder-picker-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.folder-picker-content h3 {
  margin: 0;
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.04em;
}
.folder-picker-target {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}
.folder-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.folder-picker-empty {
  margin: 0;
  padding: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}
.folder-pick-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  border-radius: 4px;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.folder-pick-btn:hover {
  background: var(--bg-elev-2);
  color: var(--accent);
  border-color: var(--accent-dim);
}
.folder-picker-new {
  display: flex;
  gap: 8px;
}
.folder-picker-new input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 10px;
}
.folder-picker-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ============================================================
   Provider balances + motion-provider quick switch
   ============================================================ */
.motion-provider-quick {
  margin-left: auto;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  min-width: 250px;
}
.provider-balances {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}
.provider-balance {
  appearance: none;
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: normal;
  letter-spacing: 0.04em;
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 28%, transparent);
  white-space: nowrap;
  user-select: none;
  transition: opacity 0.2s;
  cursor: default;
}
.provider-balance-label {
  margin-right: 6px;
  color: var(--text-dim);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ws-balance-symbol {
  opacity: 0.65;
  margin-right: 2px;
}
.provider-balance-value {
  font-weight: 600;
}
.provider-balance-unit {
  margin-left: 4px;
  color: var(--text-dim);
  font-size: 9px;
  letter-spacing: 0.02em;
}
.provider-balance.stale {
  opacity: 0.4;
  box-shadow: none;
}
.provider-balance.reconnect {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, var(--bg));
  border-color: color-mix(in srgb, var(--warn) 45%, var(--border));
  box-shadow: 0 0 8px color-mix(in srgb, var(--warn) 30%, transparent);
  cursor: pointer;
}
.provider-balance.reconnect:hover {
  border-color: var(--warn);
}
.ws-balance.low {
  color: var(--err);
  background: color-mix(in srgb, var(--err) 10%, var(--bg));
  border-color: color-mix(in srgb, var(--err) 45%, var(--border));
  box-shadow: 0 0 8px color-mix(in srgb, var(--err) 35%, transparent);
}
.motion-provider-quick select {
  width: 100%;
  min-width: 0;
  padding: 5px 24px 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  cursor: pointer;
}
.motion-provider-quick select:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent);
}
.motion-provider-quick select:disabled {
  cursor: wait;
  opacity: 0.65;
}
@media (max-width: 760px) {
  .motion-provider-quick {
    width: 100%;
    min-width: 0;
    margin-left: 0;
  }
  .provider-balances {
    justify-content: flex-start;
  }
}

/* When the no-cookies toggle is on, the cookies-snapshot button gets
   this class to clearly read as "currently not in use" — overrides
   the green "ok/fresh" treatment with a muted gray and removes the
   border-color cue. The browser's :disabled opacity:0.6 on its own
   was too subtle and read as "still active, just not clickable." */
.cookie-btn.cookie-btn-suppressed {
  color: var(--text-dim) !important;
  border-color: var(--border) !important;
  background: transparent !important;
  opacity: 0.5;
  text-decoration: line-through;
}
.cookie-btn.cookie-btn-suppressed .cookie-status {
  text-decoration: none;
  font-style: italic;
}

/* Inline error message inside the transition rerun modal when the
   source video can't load (file was retention-cleared). Surfaces the
   reason instead of silently showing an empty video player. */
.readout-error {
  color: var(--err);
  font-family: var(--mono);
  font-size: 11px;
  display: inline-block;
  padding: 4px 8px;
  background: color-mix(in srgb, var(--err) 8%, transparent);
  border-left: 2px solid var(--err);
  border-radius: 0 4px 4px 0;
}

/* Local-only badge — bottom-right corner, monospace, very subtle.
   At-a-glance proof you're on Reel Pipeline (not Sniper Bot or any
   other localhost project). pointer-events: none so it never blocks
   clicks on whatever's underneath. */
#local-badge {
  position: fixed;
  bottom: 6px;
  right: 8px;
  z-index: 1;
  pointer-events: none;
  user-select: none;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  opacity: 0.45;
  padding: 2px 6px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}

/* === multi_transition (per-clip splice detector) ============================
   Phase 1 = .multi-upload-row (file / url / threshold / detect button) at the
   top of #multi-transition-section. Phase 2 = a horizontal strip of
   .clip-config tiles rendered by _multi_clip_blocks.html, each with a start
   frame preview, per-clip toggles, and an outfit picker. */

/* Phase-1 upload row: file picker + URL textbox + threshold + button on one
   wrapping line. The dedicated upload widget here replaces the standard
   #video-inputs block (toggleOutfit() hides that one for multi_transition). */
.multi-upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.multi-detect-field {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}
.multi-detect-url { flex: 1 1 220px; min-width: 200px; }
#multi-detect-spinner {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent-dim);
}

/* Phase-2 summary banner: "N clips detected · duration ... · cuts at ..." */
.multi-clip-summary {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 8px 12px;
  margin: 4px 0 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.multi-clip-summary strong { color: var(--accent); }

.multi-clip-error {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--err);
  padding: 10px 12px;
  background: color-mix(in srgb, var(--err) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--err) 60%, var(--border));
  border-radius: 8px;
  margin-bottom: 10px;
}
.multi-clip-error strong { color: var(--err); margin-right: 4px; }

/* Horizontal strip of per-clip cards. Up to six clips sit in one line on
   wide screens; narrower viewports wrap into stable, readable tracks. */
.multi-clip-list {
  display: grid;
  grid-template-columns: repeat(var(--clip-columns, 1), minmax(0, 1fr));
  gap: 10px;
  align-items: start;
  margin-bottom: 10px;
}
@media (max-width: 1180px) {
  .multi-clip-list {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }
}
@media (max-width: 520px) {
  .multi-clip-list {
    grid-template-columns: 1fr;
  }
}

/* One clip tile. */
.clip-config {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.12s;
  overflow: hidden;
  min-width: 0;
}
.clip-config:hover,
.clip-config:focus-within {
  border-color: var(--accent-dim);
}

.clip-preview-frame {
  position: relative;
  height: 220px;
  background: #05070a;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.clip-preview-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.clip-preview-empty {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
}
.clip-preview-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(5, 7, 10, 0.72);
  border: 1px solid color-mix(in srgb, var(--accent-dim) 55%, transparent);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
}

.clip-config-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 9px 10px 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  user-select: none;
}
.clip-num   { font-weight: 600; color: var(--accent); }
.clip-range {
  grid-column: 1 / -1;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}
.clip-dur {
  color: var(--text-dim);
  white-space: nowrap;
}

.clip-config-body {
  padding: 9px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.clip-addon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.clip-config .toggle-option {
  flex: 1 1 72px;
  justify-content: center;
  padding-inline: 9px;
}

/* Per-clip outfit picker — compact so the horizontal strip stays scannable. */
.clip-outfit-picker {
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.clip-outfit-picker .outfit-section-label {
  display: block;
  margin-bottom: 6px;
  font-size: 10px;
}
.clip-outfit-picker .outfit-grid {
  margin-bottom: 0;
  max-height: 228px;
  overflow-y: auto;
  padding-right: 2px;
}
.clip-outfit-picker .outfit-card {
  width: 72px;
}
.clip-outfit-picker .outfit-thumb {
  width: 54px;
  height: 54px;
}
.clip-outfit-empty {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- library: pinned outfit folders + outfit grid ------------
   No background override on .folder-row — let the shared rules at
   line ~6194 (hover) and line ~6198 (active) shine through so pinned
   rows pick up the same accent-color highlight + left border as user
   folders. Only the divider below distinguishes the pinned group. */
.library-folder-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 4px;
  opacity: 0.5;
}
.library-page-title {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.library-toolbar-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}
.outfit-upload-form {
  display: flex;
  align-items: center;
  gap: 6px;
}
.outfit-upload-form input[type="text"] {
  width: 130px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}
.outfit-upload-form input[type="file"] {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  max-width: 180px;
}
.library-outfits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 4px 0 16px;
}
.library-outfit-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.08s;
  text-align: left;
  font: inherit;
  color: inherit;
}
.library-outfit-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.library-outfit-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #111;
  display: block;
}
.library-outfit-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px 8px;
  font-family: var(--mono);
  font-size: 12px;
}
.library-outfit-name {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-outfit-char {
  color: var(--text-dim);
  font-size: 11px;
}

/* Step-artifact lightbox — reuses .library-preview-dialog. The content
   stacks the media above a caption + download bar (the shared
   .library-preview-content centres a single child, so override here). */
.artifact-preview-content {
  flex-direction: column;
  gap: 8px;
}
.artifact-preview-content .library-preview-media video,
.artifact-preview-content .library-preview-media img {
  max-height: calc(92vh - 52px);
}
.artifact-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
  padding-right: 28px;
  font-family: var(--mono);
  font-size: 12px;
}
.artifact-preview-label {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.artifact-preview-dl {
  color: var(--accent);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-elev);
  white-space: nowrap;
}
.artifact-preview-dl:hover {
  background: var(--bg-elev-2);
  border-color: var(--accent-dim);
}

/* QC "continue" panel — reuses .rerun-menu / .rerun-panel / .rerun-opt
   for the dropdown shell; only the candidate-row layout is new. */
.continue-panel {
  min-width: 248px;
}
.continue-hint {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  margin: 2px 4px 4px;
  line-height: 1.4;
}
.continue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.continue-cand {
  flex: 1;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.continue-multi-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.continue-group {
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 4px;
  padding: 4px 8px;
  margin: 0;
}
.continue-group legend {
  padding: 0 4px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.continue-row-radio {
  cursor: pointer;
}
.continue-row-radio input[type="radio"] {
  flex: 0 0 auto;
}
.continue-multi-submit[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.continue-cand:hover {
  background: var(--bg-elev);
  text-decoration: underline;
}
.continue-opt {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Admin: user accounts list (settings → user accounts section) */
.settings-input {
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 8px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
  box-sizing: border-box;
}
.settings-input:focus {
  outline: none;
  border-color: var(--accent);
}
.settings-users-search {
  margin: 10px 0 6px;
}
.settings-users-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}
.settings-user-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
}
.settings-user-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.settings-user-email {
  color: var(--accent);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
.settings-user-created {
  color: var(--text-dim);
  font-size: 10px;
  font-style: italic;
  margin-left: auto;
}
.settings-user-flag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.settings-user-flag.flag-admin {
  color: var(--accent);
  border-color: var(--accent);
}
.settings-user-flag.flag-inactive {
  color: rgb(220, 90, 90);
  border-color: rgb(120, 60, 60);
}
.settings-user-flag.flag-pw-change {
  color: rgb(220, 180, 90);
  border-color: rgb(120, 100, 60);
}
.settings-user-flag.flag-2fa {
  color: rgb(120, 200, 120);
  border-color: rgb(60, 120, 70);
}
.settings-user-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.settings-user-actions .settings-btn {
  font-size: 10px;
  padding: 3px 8px;
}

/* --- ported from debug: staged-from-library + carousel/extension polish --- */

/* Pill marking a staged job that belongs to a different character than the
   active tab (cross-character motion reuse). */
.pill-cross-char     { background: #3a1d33; color: #f0a0d8; text-transform: none; letter-spacing: 0; padding: 3px 8px; white-space: nowrap; }

/* "⏸ pipeline paused" status banner in the jobs actions bar. */
.paused-banner {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-right: auto;
}

/* Chrome-extension staged-frames section: label + small refresh button. */
.staged-frames-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.staged-frames-refresh {
  background: transparent;
  border: 1px solid var(--border, #2a323d);
  color: var(--muted, #8aa0b0);
  border-radius: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.staged-frames-refresh:hover { color: var(--text, #d8dee4); }

/* Carousel picker heading: label + "reload to load extension images" hint. */
.carousel-loader-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.carousel-loader-heading span {
  font-size: 12px;
  color: var(--text-dim);
}
/* ============================================================
   Mix & Match page
   ============================================================ */
.mm-page {
  padding: 0 24px 40px;
  max-width: 1200px;
}
.mm-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 12px;
}
@media (max-width: 900px) {
  .mm-panels { grid-template-columns: 1fr; }
}
.mm-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.mm-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.mm-panel-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}
.mm-mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 4px 9px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
}
.mm-mini-btn:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}
.mm-folder-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.mm-chip {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  cursor: pointer;
}
.mm-chip:hover { color: var(--text); }
.mm-chip.active {
  background: var(--accent-dim);
  color: var(--bg);
  border-color: var(--accent-dim);
}
.mm-asset-grid {
  max-height: 320px;
  overflow-y: auto;
}
.mm-empty {
  color: var(--text-dim);
  font-size: 13px;
  padding: 14px 4px;
}
.mm-addons {
  margin-top: 18px;
}

/* combination grid */
.mm-combine { margin-top: 18px; }
.mm-grid-wrap {
  overflow: auto;
  max-height: 460px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--bg-elev);
}
table.mm-grid {
  border-collapse: separate;
  border-spacing: 4px;
}
table.mm-grid th {
  padding: 0;
  position: sticky;
  background: var(--bg-elev);
  z-index: 1;
}
table.mm-grid thead th { top: 0; }
table.mm-grid tbody th { left: 0; }
.mm-axis-thumb {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--border);
  display: block;
}
.mm-cell {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--accent-dim);
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  cursor: pointer;
  padding: 0;
  transition: background 0.1s, border-color 0.1s;
}
.mm-cell:hover { border-color: var(--accent); }
.mm-cell.deselected {
  background: transparent;
  border-color: var(--border);
  border-style: dashed;
}
.mm-cell.deselected::after {
  content: "×";
  color: var(--text-dim);
  font-size: 14px;
}

/* submit bar */
.mm-submit-card { margin-top: 18px; }
.mm-submit-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.mm-count {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.mm-submit-bar #mm-cost { font-size: 13px; }
.mm-submit-bar #mm-submit {
  margin-left: auto;
  padding: 9px 22px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.mm-submit-bar #mm-submit:hover { filter: brightness(1.08); }
.mm-submit-bar #mm-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.mm-confirm { color: var(--warn); }
.mm-msg {
  margin-top: 10px;
  font-size: 13px;
  min-height: 18px;
}
.mm-msg.ok { color: var(--ok); }
.mm-msg.err { color: var(--err); }
.mm-msg a { color: var(--accent); }

/* toast */
.mm-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  z-index: 1000;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
}
.mm-toast.err { border-color: var(--err); color: var(--err); }
