:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e8eaef;
  --muted: #9aa1ae;
  --accent: #7c9cff;
  --accent-ink: #0b1020;
  --ok: #4fc08d;
  --warn: #e6b450;
  --bad: #ef6b73;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }
h2 { font-size: 20px; } h3 { font-size: 16px; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.error { color: var(--bad); }
.hint { color: var(--muted); font-size: 13px; }
.msg { min-height: 1.5em; font-size: 14px; color: var(--muted); }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; flex-wrap: wrap; }
.row.space { justify-content: space-between; gap: 12px; }

input, textarea, select {
  width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; font: inherit;
}
textarea { resize: vertical; font-size: 14px; line-height: 1.45; }
input:focus-visible, textarea:focus-visible, button:focus-visible, .drop:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
label, legend { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
fieldset { border: 0; padding: 0; margin: 0; }
.field { margin-bottom: 16px; }

button, .button {
  font: inherit; border-radius: 8px; padding: 8px 14px; cursor: pointer; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); text-decoration: none; display: inline-block;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.primary.big { width: 100%; padding: 12px; font-size: 16px; }
.ghost { background: transparent; }
.ghost:hover, .choice:hover { border-color: #3a4150; }
.danger { color: var(--bad); }
.link { background: none; border: 0; color: var(--muted); padding: 4px; text-decoration: underline; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; }
.login-card input { margin-bottom: 14px; }
.login-card button { width: 100%; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 20px; background: rgba(15, 17, 21, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .2px; }
.tabs { display: flex; gap: 4px; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 8px; }
.tabs button[aria-selected=true] { color: var(--text); background: var(--panel-2); }
.status { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line);
  white-space: nowrap; }
.pill[data-state=ok]::before, .pill[data-state=busy]::before, .pill[data-state=warn]::before, .pill[data-state=off]::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.pill[data-state=ok]::before { background: var(--ok); }
.pill[data-state=busy]::before { background: var(--accent); }
.pill[data-state=warn]::before { background: var(--warn); }
.pill[data-state=off]::before { background: var(--bad); }
.banner { background: #3a2f12; color: #f3d98b; border-bottom: 1px solid #5a4818; padding: 10px 20px; font-size: 14px; }

main { padding: 24px 20px 60px; max-width: 1280px; margin: 0 auto; }

/* create */
.create { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.side { position: sticky; top: 76px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.part textarea { min-height: 190px; }
.choices { display: grid; gap: 6px; }
.choices.small { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.choice { text-align: left; }
.choices.small .choice { text-align: center; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; }
.choice small { color: var(--muted); font-size: 9.5px; letter-spacing: -.2px; }
.choices.small .choice span { font-size: 14px; }
.choice[aria-pressed=true] { border-color: var(--accent); background: rgba(124, 156, 255, .12); }
.drop { position: relative; border: 1px dashed #3a4150; border-radius: var(--radius); padding: 14px; text-align: center;
  color: var(--muted); font-size: 13px; cursor: pointer; min-height: 64px; display: grid; place-items: center; }
.drop.over { border-color: var(--accent); background: rgba(124, 156, 255, .08); }
.drop.filled { padding: 6px; }
.drop img { max-width: 100%; max-height: 180px; border-radius: 6px; display: block; }
.drop .clear { position: absolute; top: 6px; right: 6px; font-size: 12px; padding: 3px 8px; }
.estimate { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }

/* library */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.job { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.media { background: #000; display: grid; place-items: center; overflow: hidden; }
.media video { width: 100%; height: 100%; object-fit: contain; display: block; }
.poster { position: relative; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 0; background: #000;
  display: grid; place-items: center; cursor: pointer; }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.play-icon { position: absolute; width: 64px; height: 64px; border-radius: 50%; background: rgba(0, 0, 0, .55);
  border: 2px solid rgba(255, 255, 255, .85); }
.play-icon::after { content: ""; position: absolute; left: 25px; top: 19px; border-style: solid;
  border-width: 12px 0 12px 19px; border-color: transparent transparent transparent #fff; }
.poster:hover .play-icon { background: rgba(124, 156, 255, .75); }
.placeholder { color: var(--muted); text-transform: capitalize; font-size: 14px; }
.job .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; }
.j-prompt { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.j-meta, .j-stage { font-size: 12px; margin: 0; }
.j-error:empty { display: none; }
.badge { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); }
.badge[data-status=done] { color: var(--ok); }
.badge[data-status=running] { color: var(--accent); }
.badge[data-status=failed] { color: var(--bad); }
.badge[data-status=queued], .badge[data-status=cancelled] { color: var(--muted); }
.bar { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin: 4px 0; }
.bar div { height: 100%; background: var(--accent); transition: width .4s ease; }
.actions { margin-top: 6px; }
.actions button, .actions .button { font-size: 13px; padding: 5px 10px; }

/* instance */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.card input { margin-bottom: 10px; }
dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; margin: 0 0 14px; font-size: 14px; }
dt { color: var(--muted); }
dd { margin: 0; word-break: break-word; }
ol { padding-left: 20px; margin: 0 0 12px; }

@media (max-width: 860px) {
  .create { grid-template-columns: 1fr; }
  .side { position: static; }
  .status { margin-left: 0; }
  .topbar { padding: 10px 14px; }
  main { padding: 18px 14px 50px; }
}
@media (prefers-reduced-motion: reduce) { .bar div { transition: none; } }
