/* ============================================================================
   AI Videos — shared stylesheet (industrial-cockpit theme)
   Warm charcoal + amber. Space Grotesk display / IBM Plex Sans body / Plex Mono.
   Class names are kept stable so every page (Queue / Generate / Styles /
   Messages) shares one source of truth — restyle here, all pages follow.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  /* warm charcoal neutrals — tinted toward the amber accent, never pure black */
  --bg: #14110d;
  --panel: #1b1712;
  --panel-2: #241e16;
  --panel-3: #2c2419;
  --border: #342a1d;
  --border-hi: #4c3c28;
  --text: #ece4d6;
  --muted: #a2978a;

  /* one confident accent: amber. --accent = highlight; --accent-2 = button fill */
  --accent: #f6a821;
  --accent-2: #e0901a;
  --accent-soft: rgba(246, 168, 33, 0.14);
  --accent-ink: #1a1206;

  /* semantic status — all tuned warm so they sit in the same world as amber */
  --ok: #86c34a;
  --ok-soft: rgba(134, 195, 74, 0.16);
  --err: #ef6a45;
  --err-soft: rgba(239, 106, 69, 0.15);
  --err-line: rgba(239, 106, 69, 0.42);
  --warn: #e8a93a;
  --warn-soft: rgba(232, 169, 58, 0.16);
  --queued: #a89b88;

  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --display: 'Space Grotesk', system-ui, sans-serif;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 0 rgba(0,0,0,0.4), 0 8px 24px -16px rgba(0,0,0,0.8);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body { min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }

::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Header & nav ---------------------------------------------------------- */
header {
  padding: 16px clamp(16px, 3vw, 28px) 0; border-bottom: 1px solid var(--border);
  display: flex; align-items: baseline; column-gap: 14px; row-gap: 8px; flex-wrap: wrap;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(246,168,33,0.05), transparent 60%),
    var(--panel);
}
header h1 {
  margin: 0; font-family: var(--display); font-weight: 700;
  font-size: clamp(19px, 0.6vw + 16px, 24px); letter-spacing: -0.01em;
}
header h1::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 9px;
  border-radius: 2px; background: var(--accent); transform: translateY(-2px);
  box-shadow: 0 0 12px var(--accent-soft);
}
/* The description always sits on its OWN full-width line below the title + nav,
   so a long sub (e.g. the API-keys page) can't push the nav links around.
   order:1 + flex-basis:100% drops it to the next flex row regardless of length. */
header .sub { color: var(--muted); font-size: 13px; margin: 0 0 12px; line-height: 1.45; order: 1; flex-basis: 100%; }

nav.tabs { display: flex; gap: 2px; align-self: flex-end; }
nav.tabs button, nav.tabs a {
  background: transparent; border: none; color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent;
  font-family: inherit; text-decoration: none; display: inline-flex; align-items: center;
  transition: color 120ms ease, border-color 120ms ease;
}
nav.tabs button:hover, nav.tabs a:hover { color: var(--text); }
nav.tabs button.active, nav.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

.userbar {
  margin-left: auto; display: flex; align-items: center; gap: 8px; align-self: flex-end;
  padding-bottom: 9px; font-size: 13px; color: var(--muted);
}
.userbar .who { color: var(--text); font-weight: 600; }
.userbar button {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-size: 12px; padding: 4px 10px; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit;
  transition: color 120ms, border-color 120ms;
}
.userbar button:hover { border-color: var(--accent); color: var(--accent); }
.userbar .ub-link {
  color: var(--muted); text-decoration: none; font-size: 12px; padding: 4px 8px;
  border-radius: var(--radius-sm); transition: color 120ms, background 120ms;
}
.userbar .ub-link:hover { color: var(--accent); background: var(--accent-soft); }
.userbar .role-tag {
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); padding: 2px 7px; border-radius: 999px;
}

/* Disabled radio options (key-gated engines/voices) — dim + not-allowed. */
label.opt-disabled { opacity: 0.45; cursor: not-allowed; }
label.opt-disabled input { cursor: not-allowed; }

/* ---- Auth (login) --------------------------------------------------------- */
.auth-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-card {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 26px 24px;
}
.auth-card h1 {
  font-family: var(--display); font-size: 22px; margin: 0 0 4px; color: var(--text);
}
.auth-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.auth-card label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
.auth-card input {
  width: 100%; box-sizing: border-box; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.auth-card input:focus { outline: none; border-color: var(--accent); }
.auth-card button {
  width: 100%; margin-top: 20px; background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 11px;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; transition: background 120ms, color 120ms;
}
.auth-card button:hover { background: var(--accent); color: var(--accent-ink); }
.auth-card button:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-card .err { color: var(--err); font-size: 12px; margin-top: 12px; min-height: 16px; }

/* ---- Generic content panel (account / admin pages) ------------------------ */
.panel-wrap { padding: 22px; max-width: 980px; width: 100%; margin: 0 auto; overflow: auto; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px;
}
.card h2 { font-family: var(--display); font-size: 16px; margin: 0 0 4px; color: var(--text); }
.card .hint { color: var(--muted); font-size: 12px; margin: 0 0 14px; line-height: 1.5; }
.card label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
.card input, .card select {
  width: 100%; box-sizing: border-box; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); padding: 9px 11px; font-size: 13px; font-family: inherit;
}
.card input:focus, .card select:focus { outline: none; border-color: var(--accent); }
.btn {
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent);
  border-radius: var(--radius-sm); padding: 9px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background 120ms, color 120ms;
}
.btn:hover { background: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: transparent; }
.btn-danger { background: var(--err-soft); color: var(--err); border-color: var(--err-line); }
.btn-danger:hover { background: var(--err); color: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* Data table (admin users + jobs) */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.data-table th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table td .who { font-weight: 600; color: var(--text); }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.pill.yes { color: var(--ok); border-color: var(--ok-soft); background: var(--ok-soft); }
.pill.no { color: var(--muted); }
.pill.admin { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.pill.off { color: var(--err); border-color: var(--err-line); background: var(--err-soft); }

/* ---- Layout shells -------------------------------------------------------- */
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view { flex: 1; min-height: 0; display: grid; grid-template-columns: clamp(360px, 32vw, 440px) 1fr; }
.view.hidden { display: none; }
@media (max-width: 900px) { .view { grid-template-columns: 1fr; } }

section.left { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
section.right { display: flex; flex-direction: column; min-height: 0; }

/* Desktop: lock the layout to the viewport so the job list (left) and the job
   details (right) each scroll INDEPENDENTLY — clicking a job no longer requires
   scrolling the whole page back up. Mobile keeps normal page scrolling. */
@media (min-width: 901px) {
  html, body { height: 100%; }
  body { overflow: hidden; }
  /* The WHOLE left column scrolls as one (form + toolbar + list together), and
     the right details column scrolls on its own — so clicking a job down the
     list keeps its data in view without scrolling the page. */
  section.left { overflow-y: auto; }
  section.left .joblist { flex: 0 0 auto; overflow: visible; }
  section.right { overflow-y: auto; }
  .panel-wrap { flex: 1; min-height: 0; }
}

/* ---- Forms ---------------------------------------------------------------- */
.form { padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.form .row { display: flex; gap: 8px; }
.form input, .form select, .form textarea {
  flex: 1; min-width: 0; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); font-size: 14px; outline: none;
  font-family: inherit; transition: border-color 120ms, box-shadow 120ms;
}
.form textarea { width: 100%; min-height: 110px; line-height: 1.5; resize: vertical; box-sizing: border-box; }
.form select { width: 100%; padding: 9px 11px; font-size: 13px; cursor: pointer; }
/* Checkboxes must stay native (the rule above styles them as text-field bars,
   hiding the tick). Reset size/box styling and use the accent color. */
.form input[type="checkbox"] {
  flex: none; width: 16px; height: 16px; min-width: 0; padding: 0;
  border: 0; background: none; border-radius: 0; accent-color: var(--accent); cursor: pointer;
}
.form input:focus, .form select:focus, .form textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.form .field { margin-top: 12px; }
.form .num { width: 90px; flex: 0 0 auto; }
.form button {
  padding: 10px 18px; background: var(--accent-2); color: var(--accent-ink); border: none;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background 120ms, transform 80ms;
}
.form button:hover { background: var(--accent); }
.form button:active { transform: translateY(1px); }
.form button:disabled { background: var(--panel-3); color: var(--muted); cursor: not-allowed; transform: none; }
.form .err { color: var(--err); font-size: 12px; margin-top: 8px; min-height: 16px; }

/* provider disclosure (distilled dropdown): a <details> summary that shows the
   current pick, expanding to the grouped <select> only when the user wants it. */
.provider { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel-2); }
.provider > summary {
  list-style: none; cursor: pointer; padding: 9px 12px; display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text);
}
.provider > summary::-webkit-details-marker { display: none; }
.provider > summary .plabel { color: var(--muted); font-size: 12px; }
.provider > summary .pcurrent { font-weight: 600; }
.provider > summary .chev { margin-left: auto; color: var(--muted); transition: transform 160ms ease; }
.provider[open] > summary .chev { transform: rotate(180deg); }
.provider .pbody { padding: 0 12px 12px; }
.provider select { width: 100%; }

/* voice radio chips + mode toggle */
.voice-group { margin-top: 12px; }
.voice-group > .glabel { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 6px; }
.radio-row label {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 10px; cursor: pointer; margin: 0; transition: border-color 120ms, background 120ms;
}
.radio-row label:hover { border-color: var(--border-hi); }
.radio-row input { accent-color: var(--accent); margin: 0; }
.radio-row label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-row .flag {
  width: 20px; height: 15px; border-radius: 2px; display: inline-block;
  object-fit: cover; box-shadow: 0 0 0 1px rgba(0,0,0,0.3);
}
/* TTS engine / voice / model dropdowns. color-scheme:dark keeps the native option
   popup dark to match the rest of the UI. Full width inside the .radio-row holder. */
.radio-row > .tts-select { flex: 1 1 100%; }
.tts-select {
  width: 100%; padding: 9px 11px; font-size: 13px; cursor: pointer; min-height: 38px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); font-family: inherit; color-scheme: dark;
  transition: border-color 120ms, box-shadow 120ms;
}
.tts-select:hover { border-color: var(--border-hi); }
.tts-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tts-select option:disabled { color: var(--muted); }
.mode-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.mode-tabs button {
  flex: 1; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit;
}
.mode-tabs button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---- Queue toolbar -------------------------------------------------------- */
.queue-toolbar {
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--panel);
}
.queue-toolbar .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.queue-toolbar .actions { display: flex; gap: 6px; }
.queue-toolbar button {
  background: transparent; border: 1px solid var(--err-line); color: var(--err);
  font-size: 12px; padding: 5px 10px; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit;
  transition: background 120ms;
}
.queue-toolbar button:hover:not(:disabled) { background: var(--err-soft); }
.queue-toolbar button:disabled { opacity: 0.4; cursor: not-allowed; }
.queue-toolbar button.muted { border-color: var(--border); color: var(--muted); }
.queue-toolbar button.muted:hover:not(:disabled) { background: var(--panel-2); }

/* ---- Job list ------------------------------------------------------------- */
.joblist { flex: 1; overflow-y: auto; padding: 10px; }
.joblist .empty { color: var(--muted); text-align: center; padding: 52px 16px; font-size: 13px; line-height: 1.6; }
.joblist .empty strong { color: var(--text); display: block; font-size: 14px; margin-bottom: 4px; }
.job {
  padding: 12px; margin-bottom: 8px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; transition: border-color 120ms, transform 80ms, box-shadow 120ms;
}
.job:hover { border-color: var(--border-hi); }
.job.selected { border-color: var(--accent); background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.job .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.job .id { font-family: var(--mono); font-size: 10px; color: var(--muted); }
/* Publish badges: named text chips — greyed when not posted, lit (coloured)
   when published, pulsing while uploading, red on failure. */
.pub-badges { display: inline-flex; gap: 5px; margin-left: auto; }
.pub { font-size: 9px; font-weight: 600; letter-spacing: .02em; padding: 2px 6px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap; line-height: 1.4; }
.pub.off { opacity: .55; }
.pub.on { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.pub.pending { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); animation: pubpulse 1s ease-in-out infinite; }
.pub.fail { color: var(--err); border-color: var(--err-line); background: var(--err-soft); }
@keyframes pubpulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.job .label { font-size: 14px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; margin-bottom: 4px; word-break: break-word; }
.job .label .rename { background: transparent; border: none; color: var(--muted); font-size: 13px; cursor: pointer; padding: 2px 4px; line-height: 1; border-radius: 4px; }
.job .label .rename:hover { color: var(--accent); background: var(--panel-3); }
.job .status {
  font-size: 11px; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; white-space: nowrap;
}
.status-queued    { background: var(--panel-3); color: var(--queued); }
.status-running   { background: var(--accent-soft); color: var(--accent); }
.status-done      { background: var(--ok-soft); color: var(--ok); }
.status-failed    { background: var(--err-soft); color: var(--err); }
.status-cancelled, .status-cancelling { background: var(--warn-soft); color: var(--warn); }
.job .url { font-size: 13px; color: var(--muted); word-break: break-all; line-height: 1.35; }
.job .meta { color: var(--muted); font-size: 11px; margin-top: 6px; }
.job .body { display: flex; gap: 10px; align-items: flex-start; }
.job .body > .main { flex: 1; min-width: 0; }
.job .thumb {
  width: 50px; height: 88px; flex-shrink: 0; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border); background: var(--panel-2); position: relative;
}
.job .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.job .thumb .badge {
  position: absolute; bottom: 2px; right: 2px; font-size: 9px; padding: 1px 5px;
  background: rgba(0,0,0,0.72); color: #fff; border-radius: 3px; font-family: var(--mono);
}
.job .actions { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.job .actions a, .job .actions button {
  font-size: 12px; padding: 5px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: transparent; color: var(--text); text-decoration: none; cursor: pointer; font-family: inherit;
  transition: background 120ms, border-color 120ms;
}
.job .actions a:hover, .job .actions button:hover { background: var(--panel-2); border-color: var(--border-hi); }
.job .actions .danger { color: var(--err); border-color: var(--err-line); }
.job .actions .primary { color: var(--accent); border-color: rgba(246,168,33,0.4); }

/* ---- Right pane: logs header + mobile back -------------------------------- */
.logs-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--panel);
}
.logs-header .title { font-size: 15px; font-weight: 600; font-family: var(--display); }
.logs-header .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.mobile-back {
  display: none; background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-size: 12px; padding: 6px 11px; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit; flex-shrink: 0;
}
.mobile-back:hover { color: var(--accent); border-color: var(--accent); }
@media (max-width: 900px) { .mobile-back { display: inline-flex; } }

/* ---- Logs ----------------------------------------------------------------- */
.logs-wrap {
  flex: 1; overflow: auto; padding: 14px 18px; background: #100c08;
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; min-height: 0;
}
.logs-wrap.collapsed { display: none; }
.logs-wrap .ln { color: #cfc6b6; }
.logs-wrap .ln-err { color: var(--err); }
.logs-wrap .ln-srv { color: var(--accent); }
.logs-empty { color: var(--muted); }
.logs-toggle {
  padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--panel);
  display: flex; justify-content: space-between; align-items: center;
}
.logs-toggle button {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  font-size: 12px; padding: 5px 10px; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit;
}
.logs-toggle button:hover { border-color: var(--border-hi); background: var(--panel-2); }
.logs-toggle .count { color: var(--muted); font-size: 11px; font-family: var(--mono); }

/* ---- Progress ------------------------------------------------------------- */
.progress { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.progress.hidden { display: none; }
.progress .current {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 15px; margin-bottom: 14px;
}
.progress .current.ready { border-color: rgba(134,195,74,0.5); animation: readySweep 1100ms ease-out; }
.progress .current .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.progress .current .name { font-size: 15px; font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.progress .current .name.is-done { color: var(--ok); }
.progress .current .name.is-failed { color: var(--err); }
.progress .current .sub { font-size: 12px; color: var(--muted); font-family: var(--mono); word-break: break-word; }
.progress ul.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.progress ul.steps li {
  display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 7px 10px;
  border-radius: var(--radius-sm); background: transparent; color: var(--muted); transition: background 160ms, color 160ms;
}
.progress ul.steps li.is-running { background: var(--accent-soft); color: var(--text); }
.progress ul.steps li.is-done { color: var(--text); }
.progress ul.steps li.is-failed { color: var(--err); }
.progress ul.steps li .ico { width: 16px; text-align: center; font-size: 13px; }
.progress ul.steps li.is-running .ico { animation: spin 1.4s linear infinite; color: var(--accent); display: inline-block; }
.progress ul.steps li.is-done .ico { color: var(--ok); }
.progress ul.steps li.is-failed .ico { color: var(--err); }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes readySweep {
  0%   { box-shadow: 0 0 0 0 rgba(134,195,74,0); }
  30%  { box-shadow: 0 0 0 3px rgba(134,195,74,0.28); }
  100% { box-shadow: 0 0 0 0 rgba(134,195,74,0); }
}

/* ---- Metadata / Facebook sections ---------------------------------------- */
.meta-section { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.meta-section.hidden { display: none; }
.meta-section .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.meta-section .head .title { font-size: 13px; font-weight: 600; color: var(--text); }
.meta-section .head .gen-btns { display: flex; gap: 6px; }
.meta-section .head .gen-btn {
  background: var(--accent-2); border: none; color: var(--accent-ink); font-size: 12px; padding: 6px 12px;
  border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-family: inherit; transition: background 120ms;
}
.meta-section .head .gen-btn:hover:not(:disabled) { background: var(--accent); }
.meta-section .head .gen-btn:disabled { opacity: 0.5; cursor: progress; }
.meta-section .head .gen-btn.codex { background: transparent; border: 1px solid var(--accent-2); color: var(--accent); }
.meta-section .head .gen-btn.codex:hover:not(:disabled) { background: var(--accent-soft); }
.meta-lang { margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px dashed var(--border); }
.meta-lang:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.meta-lang.hidden { display: none; }
.meta-lang-title { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 10px; letter-spacing: 0.3px; }
.meta-row { margin-bottom: 12px; }
.meta-row:last-child { margin-bottom: 0; }
.meta-row label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.meta-row .field-row { display: flex; gap: 6px; align-items: stretch; }
.meta-row input, .meta-row textarea {
  flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13px;
  font-family: inherit; resize: vertical;
}
.meta-row textarea { line-height: 1.5; }
.meta-row .copy {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  font-size: 12px; padding: 0 10px; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit; flex-shrink: 0;
  transition: color 120ms, border-color 120ms;
}
.meta-row .copy:hover { border-color: var(--accent); color: var(--accent); }
.meta-row .copy.ok { color: var(--ok); border-color: var(--ok); }
.meta-status { font-size: 11px; color: var(--muted); margin-top: 6px; min-height: 14px; }
.meta-status.err { color: var(--err); }

/* ---- Generated-image gallery --------------------------------------------- */
.images-section { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.images-section.hidden { display: none; }
.images-section .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.images-section .head .title { font-size: 13px; font-weight: 600; color: var(--text); }
.images-section .head .count { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.images-grid a.slot {
  position: relative; display: block; aspect-ratio: 9 / 16; overflow: hidden;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel-2); text-decoration: none;
}
.images-grid a.slot:hover { border-color: var(--accent); }
.images-grid a.slot img,
.images-grid a.slot video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Little ▶ badge on video slots so they read as clips, not stills. */
.images-grid a.slot .vtag {
  position: absolute; top: 3px; right: 4px; font-size: 9px;
  color: #fff; background: var(--accent, rgba(0,0,0,0.7)); padding: 1px 5px; border-radius: 2px;
}
.images-grid a.slot .lbl {
  position: absolute; top: 3px; left: 4px; font-size: 9px; font-family: var(--mono);
  color: #fff; background: rgba(0,0,0,0.58); padding: 1px 5px; border-radius: 2px; letter-spacing: 0.3px;
}

/* ---- Styles page ---------------------------------------------------------- */
.styles-view { display: block; grid-template-columns: none; padding: clamp(16px, 3vw, 28px); overflow-y: auto; }
.styles-view .help { color: var(--muted); font-size: 13px; margin-bottom: 18px; max-width: 720px; line-height: 1.55; }
.styles-list { max-width: 880px; display: flex; flex-direction: column; gap: 12px; }
.style-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.style-card.active { border-color: var(--accent); background: var(--panel-2); }
.style-card .top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.style-card .name {
  flex: 1; background: transparent; border: none; color: var(--text); font-size: 15px; font-weight: 600;
  padding: 4px 0; font-family: inherit;
}
.style-card .name:focus { outline: 1px solid var(--accent); outline-offset: 2px; }
.style-card .name[readonly] { cursor: default; }
.style-card .badge {
  font-size: 10px; padding: 2px 8px; border-radius: 999px; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted); background: var(--panel-3);
}
.style-card .badge.active { background: var(--accent-soft); color: var(--accent); }
.style-card textarea {
  width: 100%; min-height: 90px; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: var(--radius-sm); font-size: 12px; line-height: 1.5; font-family: var(--mono);
  resize: vertical; box-sizing: border-box;
}
.style-card textarea[readonly] { color: var(--muted); cursor: default; }
.style-card .actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }
.style-card .actions button {
  background: transparent; border: 1px solid var(--border); color: var(--text); font-size: 12px;
  padding: 5px 12px; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit; transition: color 120ms, border-color 120ms;
}
.style-card .actions button:hover { border-color: var(--accent); color: var(--accent); }
.style-card .actions .activate { color: var(--accent); border-color: rgba(246,168,33,0.4); }
.style-card .actions .delete { color: var(--err); border-color: var(--err-line); }
.style-card .actions .save { color: var(--ok); border-color: rgba(134,195,74,0.45); }
.add-style { margin-top: 8px; max-width: 880px; }
.add-style button {
  background: transparent; border: 1px dashed var(--border); color: var(--muted); font-size: 13px;
  padding: 11px 16px; border-radius: var(--radius); cursor: pointer; width: 100%; font-family: inherit; transition: color 120ms, border-color 120ms;
}
.add-style button:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Generate page -------------------------------------------------------- */
.generate-view { display: block; grid-template-columns: none; padding: clamp(16px, 3vw, 28px); overflow-y: auto; }
.generate-view .gen-wrap { max-width: 640px; }
.generate-view .help { color: var(--muted); font-size: 13px; margin-bottom: 18px; line-height: 1.55; }
.badge-type {
  font-size: 9px; padding: 1px 6px; border-radius: 999px; letter-spacing: 0.4px;
  background: var(--panel-3); color: var(--muted); text-transform: uppercase; margin-left: 4px;
}
.badge-type.topic { background: var(--accent-soft); color: var(--accent); }
/* "this job carries an AI instruction" chip — glyph + text so it isn't color-only. */
.badge-ai {
  font-size: 9px; padding: 1px 6px; border-radius: 999px; letter-spacing: 0.4px; margin-left: 4px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent);
  text-transform: uppercase; cursor: help;
}

/* ---- Pagination ----------------------------------------------------------- */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 12px; border-top: 1px solid var(--border); background: var(--panel);
}
.pagination button {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  font-size: 12px; padding: 5px 12px; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit;
}
.pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .pageinfo { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ============================================================================
   Shared overlays: toast notifications + confirm/prompt dialog
   (replaces native alert()/confirm()/prompt() across all pages)
   ========================================================================== */
.toast-host {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 60; pointer-events: none;
}
.toast {
  background: var(--panel-2); border: 1px solid var(--border-hi); color: var(--text);
  padding: 11px 18px; border-radius: var(--radius); font-size: 13px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px); transition: opacity 220ms ease, transform 220ms cubic-bezier(0.2,0.7,0.2,1);
  max-width: min(440px, 92vw); pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { border-color: var(--err-line); }
.toast.err::before { content: "⚠ "; color: var(--err); }
.toast.ok::before { content: "✓ "; color: var(--ok); }

.dialog-host {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.dialog-host[hidden] { display: none; }
.dialog-backdrop { position: absolute; inset: 0; background: rgba(10,8,5,0.62); backdrop-filter: blur(2px); animation: fadeIn 140ms ease; }
.dialog {
  position: relative; width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border-hi);
  border-radius: 14px; padding: 22px; box-shadow: var(--shadow); animation: dialogIn 180ms cubic-bezier(0.2,0.7,0.2,1);
}
.dialog h2 { margin: 0 0 8px; font-family: var(--display); font-size: 17px; font-weight: 600; }
.dialog p { margin: 0 0 16px; font-size: 13px; line-height: 1.55; color: var(--muted); white-space: pre-wrap; }
.dialog input {
  width: 100%; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; outline: none; margin-bottom: 16px;
}
.dialog input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dialog textarea {
  width: 100%; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; line-height: 1.5; outline: none;
  min-height: 120px; resize: vertical; box-sizing: border-box; margin-bottom: 8px;
}
.dialog textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dialog .dialog-hint { margin: 0 0 16px; font-size: 12px; color: var(--muted); line-height: 1.5; white-space: normal; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.dialog-actions button {
  font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit;
  border: 1px solid var(--border); background: transparent; color: var(--text); transition: background 120ms, border-color 120ms;
}
.dialog-actions .btn-ghost:hover { border-color: var(--border-hi); background: var(--panel-2); }
.dialog-actions .btn-primary { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-ink); }
.dialog-actions .btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.dialog-actions .btn-primary.danger { background: var(--err); border-color: var(--err); color: #1a0805; }
.dialog-actions .btn-primary.danger:hover { background: #ff7e5b; border-color: #ff7e5b; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialogIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
