/* Studio — premium dark design system */
:root {
  color-scheme: dark;
  --bg: #070709;
  --bg-2: #0c0c10;
  --surface: rgba(255, 255, 255, 0.028);
  --surface-2: rgba(255, 255, 255, 0.05);
  --surface-3: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.075);
  --line-2: rgba(255, 255, 255, 0.13);
  --line-3: rgba(255, 255, 255, 0.22);
  --text: #f5f3ef;
  --muted: #a7a3ad;
  --faint: #6f6b78;
  --accent: #ff7a3d;
  --accent-2: #ffb547;
  --accent-ink: #1a0b03;
  --grad: linear-gradient(135deg, #ff6a3d 0%, #ff8f3d 45%, #ffbe5c 100%);
  --grad-soft: linear-gradient(135deg, rgba(255, 106, 61, 0.16), rgba(255, 190, 92, 0.08));
  --mint: #4fe0a3;
  --amber: #ffc55c;
  --danger: #ff8f8f;
  --r-xs: 8px;
  --r-sm: 11px;
  --r: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 30px 80px -30px rgba(0, 0, 0, 0.8);
  --glow: 0 10px 40px -10px rgba(255, 122, 61, 0.55);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sans: "Inter Tight", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Instrument Serif", ui-serif, Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-family: var(--sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

body.lightbox-lock { overflow: hidden; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  cursor: pointer;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

button:disabled { cursor: not-allowed; }

a { color: inherit; }

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

::selection { background: rgba(255, 122, 61, 0.35); }

.ico {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- ambient background ---------- */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1100px 600px at 85% -15%, rgba(255, 122, 61, 0.11), transparent 60%),
    radial-gradient(900px 500px at 20% 110%, rgba(120, 90, 255, 0.07), transparent 60%),
    radial-gradient(600px 400px at 50% 40%, rgba(255, 255, 255, 0.015), transparent 70%);
}

.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- shell ---------- */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 14px 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14, 14, 19, 0.85), rgba(8, 8, 11, 0.85));
  backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--grad);
  box-shadow: var(--glow);
}

.brand-mark svg { width: 17px; height: 17px; fill: var(--accent-ink); }

.brand-word {
  font-family: var(--serif);
  font-size: 1.65rem;
  letter-spacing: -0.01em;
  line-height: 1;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav-group {
  margin: 14px 12px 6px;
  color: var(--faint);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.nav-group:first-child { margin-top: 4px; }

.nav button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 0.93rem;
  font-weight: 500;
  text-align: left;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.nav button:hover { background: var(--surface-2); color: var(--text); }

.nav button[aria-current] {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--line) inset;
}

.nav button[aria-current]::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--grad);
}

.nav button[aria-current] .ico { color: var(--accent-2); }

.nav-tag {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--grad-soft);
  color: var(--accent-2);
  font-size: 0.66rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.rail-foot { display: grid; gap: 8px; }

.wallet {
  position: relative;
  padding: 14px 14px 12px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--grad-soft), var(--surface);
  overflow: hidden;
}

.wallet-label {
  color: var(--faint);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.wallet-value {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 2rem;
  line-height: 1.1;
}

.mode {
  position: absolute;
  top: 12px;
  right: 12px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mode::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 10px var(--mint);
}

.logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--faint);
  font-size: 0.9rem;
}

.logout:hover { color: var(--text); background: var(--surface-2); }

/* ---------- stage ---------- */
.stage {
  min-width: 0;
  padding: 44px clamp(20px, 4vw, 56px) 80px;
}

.studio {
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  gap: 28px;
  animation: rise 0.5s var(--ease);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.page-head { display: grid; gap: 8px; max-width: 760px; }

.eyebrow {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.page-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.4rem, 4.6vw, 3.6rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
}

.page-head h1 i {
  font-style: italic;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-right: 0.06em;
}

.lede { margin: 4px 0 0; color: var(--muted); font-size: 1rem; max-width: 620px; }

/* ---------- workspace (composer + output) ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.composer,
.panel,
.step {
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015));
  box-shadow: var(--shadow);
}

.composer {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 18px;
  padding: 22px;
}

.label,
.field > span,
.slot-name,
.url-line > .label {
  color: var(--faint);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.field { display: grid; gap: 9px; align-content: start; min-width: 0; }

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.prompt { position: relative; display: grid; gap: 9px; }

textarea,
input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="number"],
.token-line input {
  width: 100%;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: rgba(0, 0, 0, 0.35);
  padding: 12px 14px;
  color: var(--text);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s;
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.55;
  font-size: 1rem;
}

.prompt textarea { padding: 16px 16px 34px; }

textarea::placeholder,
input::placeholder { color: #55525d; }

textarea:hover,
input:hover { border-color: var(--line-3); }

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: rgba(255, 150, 80, 0.6);
  box-shadow: 0 0 0 4px rgba(255, 122, 61, 0.12);
  background: rgba(0, 0, 0, 0.45);
}

.kbd-hint {
  position: absolute;
  right: 12px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--faint);
  font-size: 0.72rem;
  pointer-events: none;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  font-family: var(--sans);
  font-size: 0.72rem;
}

select {
  width: 100%;
  min-height: 46px;
  padding: 11px 38px 11px 14px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: rgba(0, 0, 0, 0.35) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23a7a3ad' stroke-width='1.6'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center;
  appearance: none;
  cursor: pointer;
}

select option { background: #141418; color: var(--text); }
select option:disabled { color: #5f5c66; }

.meta,
.hint {
  margin: 0;
  color: var(--faint);
  font-size: 0.84rem;
}

.meta { font-family: var(--mono); font-size: 0.74rem; letter-spacing: -0.01em; }

.error {
  margin: 0;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255, 143, 143, 0.25);
  background: rgba(255, 90, 90, 0.07);
  color: var(--danger);
  font-size: 0.9rem;
}

/* ---------- chips (segmented) ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  width: fit-content;
  max-width: 100%;
}

.chips:empty { display: none; }

.chip {
  padding: 7px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s;
}

.chip:hover { color: var(--text); background: var(--surface-2); }

.chip.on {
  background: var(--text);
  color: #0b0b0e;
  box-shadow: 0 4px 14px -6px rgba(255, 255, 255, 0.5);
}

/* ---------- model picker ---------- */
.model-slot { position: relative; min-width: 0; }

.model-native {
  position: absolute !important;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.model-picker { position: relative; }

.model-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 10px 14px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: rgba(0, 0, 0, 0.35);
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
}

.model-trigger:hover { border-color: var(--line-3); background: rgba(0, 0, 0, 0.45); }
.model-picker.is-open .model-trigger { border-color: rgba(255, 150, 80, 0.6); box-shadow: 0 0 0 4px rgba(255, 122, 61, 0.12); }

.model-face { display: grid; gap: 4px; flex: 1; min-width: 0; }

.model-name {
  font-weight: 600;
  font-size: 0.97rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.model-tier,
.model-status,
.model-cost {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.model-tier { background: var(--surface-3); color: var(--muted); }
.model-tier.is-v2 { background: rgba(140, 120, 255, 0.16); color: #c3b8ff; }
.model-status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.model-status.is-live { color: var(--mint); background: rgba(79, 224, 163, 0.1); }
.model-status.is-paused { color: var(--amber); background: rgba(255, 197, 92, 0.1); }
.model-status.is-off { color: var(--faint); background: var(--surface-2); }
.model-cost { color: var(--accent-2); background: rgba(255, 150, 70, 0.1); font-family: var(--mono); }

.model-chevron {
  width: 10px;
  height: 10px;
  border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: translateY(-3px) rotate(45deg);
  transition: transform 0.25s var(--ease);
}

.model-picker.is-open .model-chevron { transform: translateY(2px) rotate(225deg); }

.model-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(380px, 60vh);
  overflow-y: auto;
  padding: 6px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: rgba(18, 18, 23, 0.97);
  backdrop-filter: blur(24px);
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top center;
  transition: opacity 0.18s var(--ease), transform 0.22s var(--ease);
}

.model-picker.is-open .model-menu { opacity: 1; transform: none; }

.model-option {
  display: flex;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  text-align: left;
  transition: background 0.15s;
}

.model-option:hover,
.model-option:focus { background: var(--surface-3); outline: none; }
.model-option[aria-selected="true"] { background: var(--grad-soft); box-shadow: 0 0 0 1px rgba(255, 150, 80, 0.25) inset; }
.model-option[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; }

/* ---------- upload slots ---------- */
.slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.slots-one { grid-template-columns: minmax(0, 1fr); }

.slot {
  position: relative;
  display: grid;
  align-content: end;
  justify-items: start;
  gap: 2px;
  min-height: 104px;
  padding: 12px;
  border-radius: var(--r);
  border: 1px dashed var(--line-3);
  background: rgba(255, 255, 255, 0.015);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s, transform 0.2s var(--ease);
}

.slot:hover { border-color: rgba(255, 170, 100, 0.55); background: rgba(255, 140, 70, 0.04); }
.slot input { display: none; }
.slot-tall { min-height: 200px; }

.slot-ico {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--faint);
  z-index: 1;
}

.slot .slot-name { position: relative; z-index: 1; color: var(--text); letter-spacing: 0.08em; }

.slot-hint {
  position: relative;
  z-index: 1;
  color: var(--faint);
  font-size: 0.8rem;
}

.slot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slot.has-file { border-style: solid; border-color: rgba(255, 170, 100, 0.5); }

.slot.has-file::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(0, 0, 0, 0.8));
}

.slot.has-file .slot-name,
.slot.has-file .slot-hint { z-index: 2; }
.slot.has-file .slot-hint { color: rgba(255, 255, 255, 0.75); }
.slot.has-file .slot-ico { display: none; }

.url-line { display: grid; gap: 8px; }

/* ---------- buttons ---------- */
.cta { display: grid; gap: 10px; }

.go {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 54px;
  padding: 0 22px;
  border-radius: var(--r);
  background: var(--grad);
  color: var(--accent-ink);
  font-weight: 650;
  font-size: 1rem;
  letter-spacing: -0.01em;
  box-shadow: var(--glow), 0 1px 0 rgba(255, 255, 255, 0.4) inset;
  overflow: hidden;
  transition: transform 0.2s var(--ease), box-shadow 0.25s var(--ease), filter 0.2s;
}

.go::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.7s var(--ease);
}

.go:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 16px 50px -12px rgba(255, 122, 61, 0.75), 0 1px 0 rgba(255, 255, 255, 0.4) inset; }
.go:hover:not(:disabled)::after { transform: translateX(120%); }
.go:active:not(:disabled) { transform: translateY(0) scale(0.99); }
.go:disabled { filter: grayscale(0.85) brightness(0.55); box-shadow: none; }
.go-inline { height: 46px; }

.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s;
}

.ghost:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-3); }
.ghost:disabled { opacity: 0.4; }
.ghost.sm { height: 34px; padding: 0 12px; font-size: 0.84rem; border-radius: 10px; }
.ghost.strong { background: var(--text); color: #0b0b0e; border-color: transparent; }
.ghost.strong:hover:not(:disabled) { background: #fff; }
.ghost.danger { color: var(--danger); }

.download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 7px 13px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
}

.download::before {
  content: "";
  width: 12px;
  height: 12px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v12M7 11l5 5 5-5M4 20h16'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v12M7 11l5 5 5-5M4 20h16'/%3E%3C/svg%3E") center / contain no-repeat;
}

button.download::before { display: none; }
.download:hover { background: var(--surface-3); border-color: var(--line-3); }
.download.mini { padding: 5px 10px; font-size: 0.78rem; border-radius: 8px; }

/* ---------- output column ---------- */
.output { display: grid; gap: 16px; min-width: 0; }

.output-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 14px;
  padding: 0 4px;
}

.output-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.7rem;
  letter-spacing: -0.01em;
}

.output-sub { margin: 0; color: var(--faint); font-size: 0.85rem; }
.output-tools { margin-left: auto; display: flex; gap: 8px; }

.jobs { display: grid; gap: 14px; }

.grid-jobs,
.pick-grid {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.jobs-empty {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  gap: 6px;
  margin: 0;
  padding: 56px 20px;
  border-radius: var(--r-xl);
  border: 1px dashed var(--line-2);
  background: radial-gradient(400px 200px at 50% 0%, rgba(255, 140, 70, 0.05), transparent 70%);
  color: var(--faint);
  text-align: center;
}

.jobs-empty strong { color: var(--text); font-weight: 600; font-size: 1rem; }
.jobs-empty span { font-size: 0.88rem; }

.empty-ico {
  width: 40px;
  height: 40px;
  padding: 10px;
  margin-bottom: 6px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--accent-2);
  stroke-width: 1.5;
}

/* ---------- job card ---------- */
.job {
  position: relative;
  display: grid;
  grid-template-columns: minmax(130px, 210px) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 12px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  animation: rise 0.45s var(--ease);
  transition: border-color 0.25s, background 0.25s;
}

.job:hover { border-color: var(--line-2); }

.grid-jobs .job,
.pick-grid .job {
  grid-template-columns: 1fr;
  align-items: start;
  gap: 10px;
  padding: 8px 8px 12px;
}

.grid-jobs .job-copy,
.pick-grid .job-copy { padding: 0 4px; }

.job-frame {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: #0f0f13;
  aspect-ratio: 9 / 16;
  max-height: 380px;
  width: 100%;
}

.job-frame[data-aspect="1:1"] { aspect-ratio: 1; }
.job-frame[data-aspect="9:16"] { aspect-ratio: 9 / 16; }
.job-frame[data-aspect="16:9"] { aspect-ratio: 16 / 9; }
.job-frame[data-aspect="4:3"] { aspect-ratio: 4 / 3; }
.job-frame[data-aspect="3:4"] { aspect-ratio: 3 / 4; }
.job-frame[data-aspect="21:9"] { aspect-ratio: 21 / 9; }
.job-frame[data-aspect="2:3"] { aspect-ratio: 2 / 3; }
.job-frame[data-aspect="3:2"] { aspect-ratio: 3 / 2; }
.job-frame[data-aspect="4:5"] { aspect-ratio: 4 / 5; }

.job-frame img,
.job-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.job-frame video { object-fit: contain; }

.shimmer {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 60% at 50% 120%, rgba(255, 122, 61, 0.22), transparent 60%),
    linear-gradient(115deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.07) 50%, rgba(255, 255, 255, 0) 70%) 0 0 / 250% 100%,
    #101015;
  animation: sweep 1.8s linear infinite;
}

@keyframes sweep { to { background-position: 0 0, -250% 0, 0 0; } }

.job-veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  padding: 14px;
  text-align: center;
}

.job-veil strong { font-weight: 600; font-size: 0.95rem; }
.job-veil em { color: var(--muted); font-style: normal; font-size: 0.8rem; }

.pulse {
  width: 10px;
  height: 10px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 0 rgba(255, 181, 71, 0.6);
  animation: ping 1.6s var(--ease) infinite;
}

@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(255, 181, 71, 0.55); }
  80%, 100% { box-shadow: 0 0 0 14px rgba(255, 181, 71, 0); }
}

[data-state="queued"] .pulse { background: var(--faint); animation-duration: 2.4s; }
[data-state="failed"] .pulse { background: var(--danger); animation: none; }
[data-state="failed"] .shimmer { animation: none; background: rgba(255, 80, 80, 0.06); }
.job[data-state="done"] .shimmer,
.job[data-state="done"] .job-veil { display: none; }

.job-copy { display: grid; gap: 6px; min-width: 0; align-content: start; }

.job-prompt {
  margin: 0;
  font-size: 0.97rem;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.job-sub { margin: 0; color: var(--faint); font-family: var(--mono); font-size: 0.72rem; }
.job-error { margin: 0; color: var(--danger); font-size: 0.85rem; }

.job.can-pick { cursor: pointer; }
.job.can-pick:hover { border-color: rgba(255, 170, 100, 0.5); transform: translateY(-2px); transition: transform 0.25s var(--ease), border-color 0.2s; }

.job.is-selected {
  border-color: transparent;
  background: var(--grad-soft), var(--surface);
  box-shadow: 0 0 0 2px var(--accent), var(--glow);
}

.job.is-selected::after {
  content: "Start frame";
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--grad);
  color: var(--accent-ink);
  font-size: 0.72rem;
  font-weight: 700;
}

/* ---------- chain: steps ---------- */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 18px;
  counter-reset: step;
}

.step {
  position: relative;
  display: grid;
  gap: 20px;
  padding: 24px;
}

.step-head { display: flex; align-items: center; gap: 14px; }

.step-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.65rem;
  line-height: 1.05;
}

.step-head p { margin: 2px 0 0; color: var(--faint); font-size: 0.88rem; }

.step-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  font-family: var(--mono);
  font-weight: 500;
}

.step:has(.choice.on) .step-num,
.step[data-step="2"] .step-num { background: var(--grad); color: var(--accent-ink); border-color: transparent; box-shadow: var(--glow); }

.step-body { display: grid; gap: 18px; }

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choice {
  display: grid;
  justify-items: start;
  gap: 4px;
  padding: 18px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-2);
  background: rgba(0, 0, 0, 0.25);
  text-align: left;
  transition: border-color 0.2s, background 0.2s, transform 0.25s var(--ease);
}

.choice .ico { width: 22px; height: 22px; margin-bottom: 8px; color: var(--accent-2); }
.choice strong { font-weight: 600; font-size: 1rem; }
.choice span { color: var(--faint); font-size: 0.86rem; }
.choice:hover { border-color: var(--line-3); transform: translateY(-1px); }

.choice.on {
  border-color: transparent;
  background: var(--grad-soft), rgba(0, 0, 0, 0.25);
  box-shadow: 0 0 0 1.5px rgba(255, 150, 80, 0.7);
}

.ref-row {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
}

.row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.picked {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--mint);
  font-weight: 500;
}

.picked::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--mint) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23062016' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12 4 4 8-8'/%3E%3C/svg%3E") center / 12px no-repeat;
}

.board-settings {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) repeat(3, auto);
  gap: 18px;
  align-items: start;
}

/* prompt lists (scene options) */
.prompt-list { display: grid; gap: 10px; }

.prompt-row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.row-index {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-top: 6px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.prompt-row textarea { min-height: 76px; font-size: 0.95rem; }

.row-remove {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-top: 6px;
  border-radius: 10px;
  color: var(--faint);
  font-size: 1.2rem;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
}

.row-remove:hover:not(:disabled) { background: rgba(255, 90, 90, 0.12); color: var(--danger); }
.row-remove:disabled { opacity: 0.25; }

/* storyboard cards */
.storyboard {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.storyboard .prompt-row {
  grid-template-columns: 1fr;
  gap: 0;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-2);
  background: rgba(0, 0, 0, 0.3);
  overflow: visible;
  transition: border-color 0.2s, box-shadow 0.2s;
  animation: rise 0.4s var(--ease);
}

.storyboard .prompt-row:focus-within { border-color: rgba(255, 150, 80, 0.55); box-shadow: 0 0 0 4px rgba(255, 122, 61, 0.1); }

.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 14px;
  border-bottom: 1px solid var(--line);
}

.storyboard .row-index {
  display: inline-flex;
  align-items: baseline;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.storyboard .row-index b {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--faint);
  margin-right: 6px;
  vertical-align: 3px;
}

.card-top select {
  width: auto;
  min-height: 32px;
  margin-left: auto;
  padding: 4px 28px 4px 10px;
  border-radius: 9px;
  font-size: 0.82rem;
  font-family: var(--mono);
  background-position: right 9px center;
}

.storyboard .row-remove { margin: 0; width: 30px; height: 30px; }

.storyboard textarea {
  min-height: 132px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none !important;
  padding: 14px;
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.74rem;
}

.card-foot .ico { width: 13px; height: 13px; color: var(--accent-2); }

.storyboard .prompt-row:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -13px;
  width: 10px;
  height: 10px;
  border-top: 1.6px solid var(--accent-2);
  border-right: 1.6px solid var(--accent-2);
  transform: translateY(-50%) rotate(45deg);
  opacity: 0.6;
}

.add-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  border-radius: var(--r-lg);
  border: 1px dashed var(--line-3);
  color: var(--muted);
  font-weight: 500;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.add-card:hover { border-color: rgba(255, 170, 100, 0.6); color: var(--text); background: rgba(255, 140, 70, 0.04); }

.extras {
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}

.extras summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

.extras summary::-webkit-details-marker { display: none; }

.extras summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s var(--ease);
}

.extras[open] summary::before { transform: rotate(45deg); }
.extras .ref-row { padding: 0 16px 16px; }
.extras .slot { min-height: 96px; }

.build-bar {
  position: sticky;
  bottom: 16px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 12px 12px 12px 20px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-2);
  background: rgba(16, 16, 21, 0.88);
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.9);
}

.build-bar .go { margin-left: auto; min-width: 220px; }

.build-stats { display: flex; flex-wrap: wrap; gap: 22px; }

.stat { display: grid; gap: 0; }
.stat b { font-family: var(--serif); font-weight: 400; font-size: 1.6rem; line-height: 1.05; }
.stat span { color: var(--faint); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.13em; text-transform: uppercase; }

/* timeline strip in build bar */
.strip {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 120px;
  flex: 1;
  max-width: 340px;
  align-self: center;
}

.strip i {
  height: 8px;
  border-radius: 3px;
  background: var(--grad);
  opacity: 0.85;
}

.strip i:nth-child(even) { opacity: 0.55; }

/* ---------- chain render card ---------- */
.chain-card {
  position: relative;
  display: grid;
  gap: 18px;
  padding: 20px;
  border-radius: var(--r-xl);
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01));
  overflow: hidden;
  animation: rise 0.45s var(--ease);
}

.chain-shimmer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent) 0 0 / 50% 100% no-repeat;
  animation: slide 1.6s linear infinite;
}

@keyframes slide { from { background-position: -50% 0; } to { background-position: 150% 0; } }

.chain-card[data-state="done"] .chain-shimmer,
.chain-card[data-state="failed"] .chain-shimmer { display: none; }

.chain-head {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 4px 12px;
}

.chain-head .pulse { margin: 0; }
.chain-head strong { font-family: var(--serif); font-weight: 400; font-size: 1.6rem; line-height: 1; }
.chain-head em { color: var(--muted); font-style: normal; font-size: 0.9rem; }
.chain-head .job-sub { grid-column: 1 / -1; }
.chain-card[data-state="done"] .pulse { background: var(--mint); animation: none; box-shadow: 0 0 12px var(--mint); }

.chain-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.chain-progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--grad);
  transition: width 0.6s var(--ease);
}

.clip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.clip-row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: start;
  gap: 8px 10px;
  padding: 10px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  transition: border-color 0.3s;
}

.clip-thumb {
  grid-column: 1 / -1;
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 11px;
  overflow: hidden;
  background: #0f0f13;
}

.clip-thumb[data-aspect="9:16"] { aspect-ratio: 3 / 4; }

.clip-thumb video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.clip-thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.06) 50%, transparent 70%) 0 0 / 250% 100%;
  animation: sweep 1.8s linear infinite;
}

.clip-row[data-state="done"] .clip-thumb::before,
.clip-row[data-state="failed"] .clip-thumb::before,
.clip-row[data-state="queued"] .clip-thumb::before { display: none; }

.clip-index {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--surface-3);
  font-family: var(--mono);
  font-size: 0.74rem;
}

.clip-status {
  align-self: center;
  justify-self: end;
  grid-column: 2;
  grid-row: 2;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.clip-index { grid-row: 2; }

.clip-prompt {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.clip-actions,
.clip-resume { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.clip-resume > div { display: grid; gap: 8px; width: 100%; }
.clip-resume textarea { min-height: 90px; font-size: 0.9rem; }
.clip-resume .go { height: 44px; }

.clip-row[data-state="generating"] { border-color: rgba(255, 181, 71, 0.45); box-shadow: 0 0 0 3px rgba(255, 181, 71, 0.06); }
.clip-row[data-state="generating"] .clip-status { color: var(--amber); border-color: rgba(255, 197, 92, 0.4); }
.clip-row[data-state="done"] .clip-status { color: var(--mint); border-color: rgba(79, 224, 163, 0.35); }
.clip-row[data-state="done"] .clip-index { background: rgba(79, 224, 163, 0.14); color: var(--mint); }
.clip-row[data-state="failed"] { border-color: rgba(255, 143, 143, 0.4); }
.clip-row[data-state="failed"] .clip-status { color: var(--danger); border-color: rgba(255, 143, 143, 0.35); }

.chain-final { display: grid; gap: 12px; justify-items: start; }

.chain-final video {
  width: 100%;
  max-height: 72vh;
  border-radius: var(--r-lg);
  background: #000;
  border: 1px solid var(--line-2);
  box-shadow: 0 40px 100px -40px rgba(255, 122, 61, 0.35);
}

.chain-final .download {
  padding: 11px 18px;
  font-size: 0.92rem;
  background: var(--text);
  color: #0b0b0e;
  border-color: transparent;
}

.chain-again { height: 46px; }

/* ---------- transcribe ---------- */
.tx-drop {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 34px 18px;
  border-radius: var(--r-lg);
  border: 1.5px dashed var(--line-3);
  background: radial-gradient(300px 160px at 50% 0%, rgba(255, 140, 70, 0.08), transparent 70%), rgba(0, 0, 0, 0.25);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.25s var(--ease);
}

.tx-drop input { display: none; }
.tx-drop strong { font-weight: 600; font-size: 1.02rem; }
.tx-drop span { color: var(--faint); font-size: 0.84rem; }
.tx-drop:hover,
.tx-drop.over { border-color: var(--accent-2); background-color: rgba(255, 140, 70, 0.05); transform: translateY(-1px); }

.drop-ico {
  width: 46px;
  height: 46px;
  padding: 12px;
  margin-bottom: 6px;
  border-radius: 15px;
  background: var(--grad);
  color: var(--accent-ink);
  box-shadow: var(--glow);
  stroke-width: 2;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.toggle input { position: absolute; opacity: 0; pointer-events: none; }

.switch {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  transition: background 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.25s var(--ease), background 0.2s;
}

.toggle input:checked + .switch { background: var(--grad); border-color: transparent; }
.toggle input:checked + .switch::after { transform: translateX(16px); background: #fff; }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.tx-file {
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  animation: rise 0.35s var(--ease);
}

.tx-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 15px 18px;
  text-align: left;
}

.tx-head:hover { background: var(--surface-2); }
.tx-chev { color: var(--faint); font-size: 0.62rem; transition: transform 0.2s var(--ease); }
.tx-file.open .tx-chev { transform: rotate(90deg); }
.tx-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

.tx-badge {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
}

.tx-badge.done { color: var(--mint); border-color: rgba(79, 224, 163, 0.35); }
.tx-badge.run { color: var(--amber); border-color: rgba(255, 197, 92, 0.4); }
.tx-badge.err { color: var(--danger); border-color: rgba(255, 143, 143, 0.35); }

.tx-bar { height: 2px; background: var(--surface-2); }
.tx-bar i { display: block; height: 100%; background: var(--grad); transition: width 0.4s var(--ease); }
.tx-body { display: none; padding: 16px 18px 18px; gap: 4px; }
.tx-file.open .tx-body { display: grid; }
.tx-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tx-actions .chip { border: 1px solid var(--line-2); font-size: 0.8rem; padding: 6px 11px; }

.tx-seg {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  line-height: 1.55;
}

.tx-seg:hover { background: var(--surface-2); }
.tx-seg span:first-child { color: var(--accent-2); font-family: var(--mono); font-size: 0.76rem; padding-top: 3px; }

/* ---------- history ---------- */
.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.history-day {
  grid-column: 1 / -1;
  margin: 18px 0 2px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.45rem;
  color: var(--muted);
}

.history-day:first-of-type { margin-top: 0; }

.history-row {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 132px;
  padding: 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.2s, transform 0.25s var(--ease), background 0.2s;
}

.history-row:hover { border-color: var(--line-3); transform: translateY(-2px); background: var(--surface-2); }
.history-row.is-open { border-color: rgba(255, 150, 80, 0.6); box-shadow: 0 0 0 3px rgba(255, 122, 61, 0.12); }

.history-top { display: flex; align-items: center; gap: 8px; }

.history-badge {
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--surface-3);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.history-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.74rem;
}

.history-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.history-row[data-status="done"] .history-chip::before { background: var(--mint); }
.history-row[data-status="error"] .history-chip::before { background: var(--danger); }
.history-row[data-status="running"] .history-chip::before { background: var(--amber); animation: ping 1.6s infinite; }

.history-time { margin-left: auto; color: var(--faint); font-family: var(--mono); font-size: 0.72rem; }

.history-prompt {
  font-weight: 500;
  font-size: 0.97rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-owner { color: var(--faint); font-size: 0.78rem; }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 3, 5, 0.78);
  backdrop-filter: blur(14px);
  opacity: 0;
  transition: opacity 0.24s var(--ease);
}

.lightbox-sheet {
  position: relative;
  width: min(880px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 28px;
  border-radius: var(--r-xl);
  border: 1px solid var(--line-2);
  background: #101015;
  box-shadow: 0 50px 120px -30px rgba(0, 0, 0, 0.95);
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  transition: opacity 0.24s var(--ease), transform 0.3s var(--ease);
}

.lightbox.is-open .lightbox-backdrop,
.lightbox.is-open .lightbox-sheet { opacity: 1; transform: none; }

.lightbox-x {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 1.3rem;
}

.lightbox-x:hover { background: var(--surface-3); color: var(--text); }

#lightbox-body { display: grid; gap: 16px; }

.lightbox-kicker {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lightbox-title {
  margin: 0;
  padding-right: 40px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.8rem;
  line-height: 1.15;
}

.lightbox-clip { display: grid; gap: 8px; }
.lightbox-clip p { margin: 0; color: var(--muted); font-size: 0.88rem; }

.lightbox-frame {
  display: grid;
  place-items: center;
  width: 100%;
  padding: 0;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #000;
}

.lightbox-frame img,
.lightbox-frame video { display: block; max-width: 100%; max-height: 64vh; }

.lightbox-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.lightbox-close {
  margin-left: auto;
  height: 36px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  color: var(--muted);
}

/* ---------- users / account ---------- */
.panel { padding: 22px; }

.user-form {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(120px, 0.6fr) auto;
  gap: 14px;
  align-items: end;
}

.user-form label,
.token-line { display: grid; gap: 8px; }
.user-form .go { height: 46px; }

.user-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.user-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
}

.user-row > span { flex: 1 1 320px; min-width: 0; color: var(--muted); font-size: 0.9rem; }
.user-row .ghost { height: 34px; padding: 0 12px; font-size: 0.84rem; }

.credit-form { display: flex; gap: 6px; }
.credit-form input { width: 92px; height: 34px; padding: 6px 10px; border-radius: 10px; font-family: var(--mono); }

.account-panel { display: grid; gap: 16px; max-width: 820px; }
.token-line input { font-family: var(--mono); font-size: 0.86rem; }
.token-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.token-config {
  margin: 0;
  padding: 18px;
  overflow-x: auto;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.45);
  color: #e3dccf;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.6;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 200;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(20, 20, 26, 0.95);
  backdrop-filter: blur(16px);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.3s var(--ease);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- auth pages ---------- */
body.gate { min-height: 100vh; }

.auth-wrap {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  display: grid;
  gap: 18px;
  width: min(420px, 100%);
  padding: 34px 30px 30px;
  border-radius: var(--r-xl);
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  box-shadow: 0 50px 120px -40px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  backdrop-filter: blur(20px);
  animation: rise 0.6s var(--ease);
}

.auth-card .brand { padding: 0; margin-bottom: 6px; }

.auth-card h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2.6rem;
  line-height: 1;
}

.auth-card h1 i {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-card label {
  display: grid;
  gap: 8px;
  color: var(--faint);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.auth-card input { text-transform: none; letter-spacing: 0; font-size: 0.97rem; font-weight: 400; color: var(--text); }
.gate-go { width: 100%; margin-top: 4px; }
.auth-foot { margin: 0; color: var(--faint); font-size: 0.8rem; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .board-settings { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .board-settings .field-model { grid-column: 1 / -1; }
}

@media (max-width: 1020px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .composer { position: static; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .rail {
    position: sticky;
    top: 0;
    z-index: 50;
    height: auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px 12px;
    padding: 12px 14px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(9, 9, 12, 0.88);
  }

  .brand { padding: 0; }
  .brand-mark { width: 28px; height: 28px; border-radius: 9px; }
  .brand-word { font-size: 1.4rem; }

  .nav {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    margin: 0 -14px;
    padding: 2px 14px;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar { display: none; }
  .nav-group { display: none; }

  .nav button {
    width: auto;
    flex: none;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.86rem;
    white-space: nowrap;
  }

  .nav button[aria-current]::before { display: none; }
  .nav-tag { display: none; }

  .rail-foot {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .wallet {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px 5px 12px;
    border-radius: 999px;
  }

  .wallet-label { display: none; }
  .wallet-value { margin: 0; font-family: var(--mono); font-size: 0.86rem; }
  .mode { position: static; padding: 2px 8px; font-size: 0.62rem; }
  .logout { padding: 8px; }
  .logout span { display: none; }

  .stage { padding: 26px 16px 70px; }
  .page-head h1 { font-size: 2.4rem; }
  .step { padding: 18px; }
  .user-form { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .choices { grid-template-columns: minmax(0, 1fr); }
  .ref-row { grid-template-columns: minmax(0, 1fr); }
  .board-settings { grid-template-columns: minmax(0, 1fr); }
  .job { grid-template-columns: minmax(0, 1fr); }
  .job-frame { max-height: 60vh; }
  .storyboard { grid-template-columns: minmax(0, 1fr); }
  .storyboard .prompt-row:not(:last-child)::after {
    top: auto;
    bottom: -13px;
    right: 50%;
    transform: translateX(50%) rotate(135deg);
  }
  .build-bar { padding: 12px; }
  .build-bar .go { width: 100%; min-width: 0; }
  .strip { display: none; }
  .output-tools { margin-left: 0; }
  .composer { padding: 18px; }
  .lightbox { padding: 10px; }
  .lightbox-sheet { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.mode[data-mode="dry"]::before { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.mode[data-mode="off"]::before { background: var(--danger); box-shadow: none; }

/* ---------- account ---------- */
.acct-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.6fr);
  gap: 18px;
  align-items: stretch;
}

.acct-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 18px;
}

.card-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.7rem;
  line-height: 1.05;
}

.card-head p { margin: 4px 0 0; color: var(--faint); font-size: 0.88rem; }

code {
  font-family: var(--mono);
  font-size: 0.84em;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-3);
  color: #f0e6d8;
}

pre code { padding: 0; background: none; }

.profile-card {
  display: grid;
  align-content: space-between;
  gap: 22px;
  background: radial-gradient(420px 220px at 0% 0%, rgba(255, 122, 61, 0.14), transparent 70%), linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015));
}

.avatar {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--grad);
  color: var(--accent-ink);
  font-family: var(--serif);
  font-size: 1.9rem;
  box-shadow: var(--glow);
}

.profile-who { display: grid; gap: 8px; justify-items: start; min-width: 0; }
.profile-who strong { font-size: 1.05rem; font-weight: 600; overflow-wrap: anywhere; }

.role-badge {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.role-badge[data-role="admin"] { color: var(--accent-2); border-color: rgba(255, 181, 71, 0.4); background: rgba(255, 150, 70, 0.08); }

.profile-credits { display: grid; gap: 2px; padding-top: 16px; border-top: 1px solid var(--line); }
.profile-credits b { font-family: var(--serif); font-weight: 400; font-size: 2.6rem; line-height: 1; }

.key-card { display: grid; align-content: start; gap: 14px; }
.key-card .card-head { margin-bottom: 4px; }

.key-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--faint);
  font-size: 0.76rem;
  font-weight: 600;
}

.key-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.key-status[data-on="1"] { color: var(--mint); border-color: rgba(79, 224, 163, 0.35); background: rgba(79, 224, 163, 0.06); }
.key-status[data-on="1"]::before { background: var(--mint); box-shadow: 0 0 10px var(--mint); }

.key-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: rgba(0, 0, 0, 0.45);
}

.key-box:focus-within { border-color: rgba(255, 150, 80, 0.6); box-shadow: 0 0 0 4px rgba(255, 122, 61, 0.12); }
.key-box > .ico { color: var(--accent-2); }

.key-box input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 4px;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.key-box input[type="password"] { letter-spacing: 0.18em; }

.icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}

.icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.icon-btn:disabled { opacity: 0.3; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.sm .ico { width: 15px; height: 15px; }

.key-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.key-go { height: 50px; padding: 0 24px; }
.key-go .ico { width: 17px; height: 17px; stroke-width: 2; }
.key-go[data-armed="1"],
.ghost[data-armed="1"] { animation: nudge 0.35s var(--ease); }
.key-go[data-armed="1"] { background: linear-gradient(135deg, #ff5a3d, #ff8a3d); }
.ghost.danger[data-armed="1"] { background: rgba(255, 90, 90, 0.14); border-color: rgba(255, 143, 143, 0.5); }

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
}

.endpoint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  max-width: 100%;
}

.endpoint code { background: none; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
}

.tab {
  padding: 9px 16px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--text); color: #0b0b0e; }

.tab-pane { display: grid; gap: 16px; animation: rise 0.3s var(--ease); }

.howto {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: how;
  display: grid;
  gap: 10px;
}

.howto li {
  counter-increment: how;
  position: relative;
  min-height: 26px;
  padding: 3px 0 0 38px;
  color: var(--muted);
}

.howto li::before {
  content: counter(how);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.howto b { color: var(--text); font-weight: 600; }

.code-block { position: relative; }
.code-block .token-config { padding-top: 40px; }

.code-lang {
  position: absolute;
  top: 12px;
  left: 18px;
  color: var(--faint);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.code-copy { position: absolute; top: 8px; right: 8px; }

.doc-links { display: grid; gap: 10px; }

.doc-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, transform 0.25s var(--ease);
}

.doc-link:hover { border-color: rgba(255, 170, 100, 0.5); background: rgba(255, 140, 70, 0.05); transform: translateY(-1px); }
.doc-link > .ico:first-child { width: 36px; height: 36px; padding: 8px; border-radius: 11px; background: var(--grad-soft); color: var(--accent-2); }
.doc-link span { display: grid; gap: 2px; flex: 1; min-width: 0; }
.doc-link strong { font-weight: 600; }
.doc-link em { color: var(--faint); font-style: normal; font-size: 0.84rem; }
.doc-link .arrow { color: var(--faint); transition: transform 0.25s var(--ease), color 0.2s; }
.doc-link:hover .arrow { color: var(--accent-2); transform: translate(2px, -2px); }

.tool-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.tool-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 9px 10px;
  border-radius: 10px;
}

.tool-list li:hover { background: var(--surface-2); }
.tool-list code { color: var(--accent-2); background: rgba(255, 150, 70, 0.08); }
.tool-list span { color: var(--muted); font-size: 0.88rem; }

@media (max-width: 1020px) {
  .acct-grid,
  .acct-grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- API quickstart page ---------- */
.docs-page { max-width: 860px; margin: 0 auto; padding: 48px 20px 96px; position: relative; z-index: 1; }
.docs-page h1 { margin: 6px 0 10px; font-family: var(--serif); font-weight: 400; font-size: clamp(2.4rem, 5vw, 3.4rem); line-height: 1; }
.docs-page h1 i { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.docs-page h2 { margin: 40px 0 12px; font-family: var(--serif); font-weight: 400; font-size: 1.8rem; }
.docs-page p, .docs-page li { color: var(--muted); line-height: 1.65; }
.docs-page a { color: var(--accent-2); }
.docs-page ul { padding-left: 20px; display: grid; gap: 6px; }
.docs-page .token-config { margin: 12px 0; white-space: pre-wrap; word-break: break-all; }
.docs-back { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 26px; color: var(--muted) !important; text-decoration: none; font-size: 0.9rem; }
.docs-back:hover { color: var(--text) !important; }
.key-box input::placeholder { letter-spacing: 0; font-family: var(--sans); font-size: 0.92rem; }
.studio { grid-template-columns: minmax(0, 1fr); }
.studio > *, .acct-grid > *, .panel, .tab-pane, .code-block { min-width: 0; }
.token-config { max-width: 100%; }

/* ---------- users & credits ---------- */
.page-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  max-width: none;
}

.page-head-row > div { display: grid; gap: 8px; max-width: 760px; }
.page-head-row .go .ico { stroke-width: 2.2; }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.kpi {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
  padding: 18px 20px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
}

.kpi b { font-family: var(--serif); font-weight: 400; font-size: 2.5rem; line-height: 1.05; letter-spacing: -0.01em; }
.kpi em { color: var(--faint); font-style: normal; font-size: 0.8rem; }

.spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 44px;
  margin: 8px 0 4px;
}

.spark i {
  flex: 1;
  min-height: 3px;
  border-radius: 3px 3px 1px 1px;
  background: var(--grad);
  opacity: 0.9;
  transition: height 0.5s var(--ease);
}

.spark i.zero { background: var(--surface-3); opacity: 1; }

.table-panel { padding: 0; overflow: hidden; }

.table-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.table-panel > .error { margin: 12px 18px 0; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 240px;
  max-width: 360px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: rgba(0, 0, 0, 0.35);
}

.search:focus-within { border-color: rgba(255, 150, 80, 0.6); box-shadow: 0 0 0 4px rgba(255, 122, 61, 0.12); }
.search .ico { color: var(--faint); width: 16px; height: 16px; }
.search input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 10px 0; }

.table-wrap { overflow-x: auto; }

.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.user-table th {
  padding: 12px 18px;
  text-align: left;
  color: var(--faint);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.user-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}

.user-table tbody tr { transition: background 0.15s; }
.user-table tbody tr:hover { background: var(--surface); }
.user-table tbody tr:last-child td { border-bottom: 0; }
.user-table .num { text-align: right; font-family: var(--mono); font-size: 0.86rem; }
.user-table .muted { color: var(--muted); }
.user-table .act { text-align: right; }
.user-table .act > * { vertical-align: middle; }
.user-table .act .ghost { margin-right: 4px; }
.user-table tr.is-disabled td:not(.act) { opacity: 0.45; }

.who { display: flex; align-items: center; gap: 12px; }
.who > div { display: grid; gap: 4px; }
.who strong { font-weight: 600; }
.who-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.who-tags em { color: var(--faint); font-style: normal; font-size: 0.76rem; }

.avatar.sm { width: 34px; height: 34px; border-radius: 11px; font-size: 1.15rem; box-shadow: none; }

.tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
}

.tag-off { color: var(--danger); background: rgba(255, 90, 90, 0.1); }
.user-table .role-badge { padding: 1px 8px; font-size: 0.66rem; }

.credit-cell {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}

.credit-cell b { font-family: var(--serif); font-weight: 400; font-size: 1.45rem; line-height: 1; }
.credit-cell span { color: var(--faint); font-family: var(--mono); font-size: 0.7rem; }
.credit-cell:hover { background: var(--surface-2); border-color: var(--line-2); }
.credit-cell.low b { color: var(--amber); }
.credit-cell.low::after { content: "low"; margin-left: 2px; padding: 0 6px; border-radius: 999px; background: rgba(255, 197, 92, 0.12); color: var(--amber); font-family: var(--sans); font-size: 0.64rem; font-weight: 700; }

.key-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--faint);
  font-size: 0.8rem;
}

.key-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.key-pill[data-on="1"] { color: var(--mint); }
.key-pill[data-on="1"]::before { background: var(--mint); box-shadow: 0 0 8px var(--mint); }

.table-empty { margin: 0; padding: 36px; text-align: center; color: var(--faint); }

.row-menu {
  position: fixed;
  z-index: 150;
  width: 210px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--line-2);
  background: rgba(20, 20, 26, 0.98);
  backdrop-filter: blur(20px);
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.95);
  animation: rise 0.18s var(--ease);
}

.row-menu button {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  text-align: left;
  font-size: 0.9rem;
  color: var(--text);
}

.row-menu button:hover,
.row-menu button:focus { background: var(--surface-3); outline: none; }
.row-menu button.danger { color: var(--danger); }
.row-menu hr { margin: 5px 4px; border: 0; border-top: 1px solid var(--line); }

/* ledger */
.ledger { list-style: none; margin: 0; padding: 0; display: grid; }

.ledger-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
}

.ledger-row:last-child { border-bottom: 0; }

.ledger-dot {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--surface-3) center / 14px no-repeat;
}

.ledger-row[data-kind="grant"] .ledger-dot,
.ledger-row[data-kind="refund"] .ledger-dot { background-color: rgba(79, 224, 163, 0.12); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234fe0a3' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
.ledger-row[data-kind="spend"] .ledger-dot,
.ledger-row[data-kind="deduct"] .ledger-dot { background-color: rgba(255, 150, 70, 0.12); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffb547' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E"); }
.ledger-row[data-kind="set"] .ledger-dot { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a7a3ad' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M5 9h14M5 15h14'/%3E%3C/svg%3E"); }

.ledger-main { display: grid; gap: 2px; min-width: 0; }
.ledger-main strong { font-weight: 500; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-main em { color: var(--faint); font-style: normal; font-size: 0.76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-amt { display: grid; justify-items: end; gap: 1px; }
.ledger-amt b { font-family: var(--mono); font-weight: 500; font-size: 0.9rem; }
.ledger-amt b.pos { color: var(--mint); }
.ledger-amt b.neg { color: var(--accent-2); }
.ledger-amt em { color: var(--faint); font-style: normal; font-family: var(--mono); font-size: 0.7rem; }
.ledger-empty { padding: 26px 4px; color: var(--faint); text-align: center; font-size: 0.9rem; }
.ledger.compact .ledger-row { padding: 8px 2px; }
.ledger.compact .ledger-dot { width: 24px; height: 24px; border-radius: 8px; background-size: 11px; }

/* dialogs */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 3, 5, 0.72);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.dialog-sheet {
  position: relative;
  display: grid;
  gap: 16px;
  width: min(460px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 24px;
  border-radius: var(--r-xl);
  border: 1px solid var(--line-2);
  background: #111116;
  box-shadow: 0 50px 120px -30px rgba(0, 0, 0, 0.95);
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.2s var(--ease), transform 0.28s var(--ease);
}

.dialog.is-open .dialog-backdrop,
.dialog.is-open .dialog-sheet { opacity: 1; transform: none; }

.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 2px 0 0; font-family: var(--serif); font-weight: 400; font-size: 1.8rem; line-height: 1.05; overflow-wrap: anywhere; }
.dialog-head .lightbox-x { position: static; flex: none; }
.dialog-sheet label { display: grid; gap: 8px; }
.dialog-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pw-line { display: flex; gap: 8px; }
.pw-line input { font-family: var(--mono); font-size: 0.9rem; }
.pw-line .ghost { height: auto; }

.balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--grad-soft), rgba(0, 0, 0, 0.25);
}

.balance-row > div { display: grid; gap: 2px; }
.balance-row > div:last-child { text-align: right; }
.balance-row b { font-family: var(--serif); font-weight: 400; font-size: 2.3rem; line-height: 1; transition: color 0.2s; }
.balance-row b.up { color: var(--mint); }
.balance-row b.down { color: var(--accent-2); }
.balance-row b.neg { color: var(--danger); }
.balance-arrow { color: var(--faint); width: 22px; height: 22px; }

.credit-modes { width: 100%; }
.credit-modes .chip { flex: 1; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick .chip { border: 1px solid var(--line-2); font-family: var(--mono); font-size: 0.8rem; padding: 6px 12px; }
.sheet-ledger { display: grid; gap: 6px; padding-top: 14px; border-top: 1px solid var(--line); }

.confirm-sheet { width: min(400px, 100%); }
.confirm-sheet h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 1.7rem; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* account credits */
.acct-grid-credits { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}

.mini-stats > div {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
}

.mini-stats b { font-family: var(--serif); font-weight: 400; font-size: 1.8rem; line-height: 1.05; }
#my-ledger { max-height: 420px; overflow-y: auto; }

.rates { display: grid; gap: 2px; }
.rates-head { margin: 10px 0 4px; color: var(--faint); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.13em; text-transform: uppercase; }
.rates-head:first-child { margin-top: 0; }

.rate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name cost" "per cost";
  gap: 0 12px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 10px;
}

.rate-row:hover { background: var(--surface-2); }
.rate-row.off { opacity: 0.4; }
.rate-name { grid-area: name; font-weight: 500; font-size: 0.92rem; }
.rate-name em { margin-left: 6px; color: #c3b8ff; font-style: normal; font-size: 0.68rem; font-weight: 700; }
.rate-per { grid-area: per; color: var(--faint); font-size: 0.76rem; }
.rate-cost { grid-area: cost; font-family: var(--mono); font-weight: 500; color: var(--accent-2); font-size: 0.92rem; }
.rate-cost small { margin-left: 3px; color: var(--faint); font-size: 0.7rem; }

/* wallet & buttons when credits run low */
.wallet[data-low="1"] { border-color: rgba(255, 197, 92, 0.45); }
.wallet[data-low="1"] .wallet-value { color: var(--amber); }
.wallet[data-low="1"]::after {
  content: "Low balance · ask an admin to top up";
  display: block;
  margin-top: 6px;
  color: var(--amber);
  font-size: 0.72rem;
}

.go.is-short { filter: none; background: var(--surface-3); color: var(--amber); box-shadow: 0 0 0 1px rgba(255, 197, 92, 0.35) inset; }

@media (max-width: 1020px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .acct-grid-credits { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .wallet[data-low="1"]::after { display: none; }
}

@media (max-width: 600px) {
  .kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi b { font-size: 2rem; }
  .dialog-row { grid-template-columns: minmax(0, 1fr); }
  .mini-stats b { font-size: 1.4rem; }
  .dialog { padding: 10px; align-items: end; }
}
.user-table th.num { font-family: var(--sans); font-size: 0.68rem; text-align: right; }
@media (max-width: 1360px) { .user-table .col-key { display: none; } }
@media (max-width: 1180px) { .user-table .col-jobs { display: none; } }
@media (max-width: 760px) {
  .user-table .col-last, .user-table .col-spent { display: none; }
  .user-table td, .user-table th { padding: 12px 10px; }
  .user-table .act .credit-btn { display: none; }
  .who-tags em { display: none; }
}
.user-table .act .icon-btn { display: inline-grid; }

/* ---------- failure reasons ---------- */
.history-error {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255, 90, 90, 0.07);
  border: 1px solid rgba(255, 143, 143, 0.18);
  color: var(--danger);
  font-size: 0.8rem;
  line-height: 1.4;
}

.fail-box {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  border: 1px solid rgba(255, 143, 143, 0.28);
  background: radial-gradient(400px 160px at 0% 0%, rgba(255, 90, 90, 0.1), transparent 70%), rgba(255, 90, 90, 0.035);
}

.fail-head { display: flex; align-items: center; gap: 12px; }
.fail-head > div { display: grid; gap: 1px; }
.fail-head strong { font-family: var(--serif); font-weight: 400; font-size: 1.35rem; line-height: 1.1; }
.fail-head span:not(.fail-icon) { color: var(--muted); font-size: 0.84rem; }

.fail-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255, 90, 90, 0.16);
  color: var(--danger);
  font-weight: 700;
}

.fail-hint { margin: 0; color: var(--text); line-height: 1.5; }

.fail-raw {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  color: #f3c4c4;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.fail-facts { margin: 0; color: var(--mint); font-size: 0.82rem; }

.fail-fix {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 143, 143, 0.18);
}

.fail-fix textarea { min-height: 84px; font-size: 0.92rem; }
.fail-fix .go { justify-self: start; }

.clip-status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.clip-status-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
}

.csl-num { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; background: var(--surface-3); font-family: var(--mono); font-size: 0.72rem; }
.csl-text { color: var(--muted); font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csl-state { font-size: 0.72rem; font-weight: 600; color: var(--faint); }
.clip-status-list li[data-state="done"] .csl-state { color: var(--mint); }
.clip-status-list li[data-state="done"] .csl-num { background: rgba(79, 224, 163, 0.14); color: var(--mint); }
.clip-status-list li[data-state="failed"] { border-color: rgba(255, 143, 143, 0.35); }
.clip-status-list li[data-state="failed"] .csl-state,
.clip-status-list li[data-state="failed"] .csl-num { color: var(--danger); }
.clip-status-list li[data-state="running"] .csl-state { color: var(--amber); }
.clip-status-list li[data-state="skipped"] { opacity: 0.55; }
