:root {
  --bg: #0e0f11;
  --panel: #16181b;
  --panel-2: #1c1f23;
  --line: #2a2e34;
  --text: #e8e9eb;
  --muted: #9aa0a8;
  --dim: #6b7178;
  --accent: #e0a43a;
  --accent-ink: #1a1408;
  --ok: #57b67c;
  --warn: #e0a43a;
  --bad: #e06a5a;
  --info: #6aa5e0;
  --radius: 8px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.hidden { display: none !important; }
.mt { margin-top: 16px; }

/* ---------- buttons and fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  height: 38px; padding: 0 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font: 600 14px var(--sans); cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: #3a4048; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; font-weight: 550; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 9px 11px; font: 15px var(--sans);
}
textarea { resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type=file] { color: var(--muted); font-size: 13px; max-width: 100%; }
.field { margin-bottom: 16px; }
.row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.hint { font-size: 12.5px; color: var(--dim); margin-top: 5px; }
.error-msg { color: var(--bad); font-size: 14px; min-height: 1.4em; }

/* ---------- landing ---------- */
.site-head { border-bottom: 1px solid var(--line); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { font-weight: 750; font-size: 18px; color: var(--text); letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.hero { padding: 88px 0 56px; }
.hero h1 { font-size: clamp(32px, 5vw, 52px); max-width: 15ch; }
.hero p { font-size: 18px; color: var(--muted); max-width: 58ch; }
.hero .actions { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.section { padding: 48px 0; border-top: 1px solid var(--line); }
.section h2 { font-size: 24px; margin-bottom: 20px; }
.grid4 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h3 { font-size: 16px; margin-bottom: 4px; }
.card .tag { font: 12px var(--mono); color: var(--accent); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.card p { color: var(--muted); font-size: 14px; margin: 0; }
.steps { counter-reset: s; display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.steps .card::before { counter-increment: s; content: counter(s, decimal-leading-zero); font: 600 13px var(--mono); color: var(--accent); display: block; margin-bottom: 10px; }
.site-foot { border-top: 1px solid var(--line); padding: 28px 0; color: var(--dim); font-size: 13px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; }
.login .brand { display: block; margin-bottom: 28px; font-size: 22px; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 0 10px 18px; }
.nav { display: flex; align-items: center; justify-content: space-between; padding: 9px 10px; border-radius: 6px; color: var(--muted); font-weight: 550; cursor: pointer; border: 0; background: none; font-size: 14.5px; text-align: left; width: 100%; }
.nav:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav.active { background: var(--panel-2); color: var(--text); }
.nav .count { font: 12px var(--mono); color: var(--dim); }
.side .spacer { flex: 1; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; padding: 0 28px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.topbar h1 { font-size: 18px; margin: 0; }
.content { padding: 28px; max-width: 1160px; }

.pill { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; font-weight: 600; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.s-stopped .dot { background: var(--dim); }
.s-starting .dot, .s-stopping .dot { background: var(--warn); animation: blink 1s infinite; }
.s-ready .dot { background: var(--ok); }
@keyframes blink { 50% { opacity: .3; } }
.sim { font: 11px var(--mono); color: var(--accent); border: 1px solid #5a4520; border-radius: 4px; padding: 2px 6px; letter-spacing: .05em; }

.panels { display: grid; gap: 16px; grid-template-columns: repeat(12, 1fr); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.panel h2 { font-size: 15px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; }

.card-state { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.card-state .big { font-size: 28px; font-weight: 700; text-transform: capitalize; }
.card-state .sub { color: var(--muted); font-size: 14px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px 20px; margin: 0 0 18px; }
.kv div span { display: block; font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.kv div b { font: 600 16px var(--mono); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.route { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.route:last-child { border-bottom: 0; }
.route .name { font-weight: 600; }
.route .what { font-size: 13px; color: var(--muted); }

.events { list-style: none; margin: 0; padding: 0; font-size: 13px; max-height: 320px; overflow: auto; }
.events li { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.events li:last-child { border-bottom: 0; }
.events time { font-family: var(--mono); color: var(--dim); }
.events .lv-error, .events .lv-alert { color: var(--bad); }
.events .lv-warn { color: var(--warn); }

/* ---------- model picker ---------- */
.models { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 20px; }
.model { position: relative; display: block; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; margin: 0; color: var(--text); }
.model input { position: absolute; opacity: 0; }
.model b { display: block; font-size: 15px; margin-bottom: 3px; }
.model small { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; font-weight: 400; }
.model.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.model:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.form-foot .est { font-size: 13px; color: var(--muted); }

/* ---------- jobs ---------- */
.jobs { display: flex; flex-direction: column; gap: 12px; }
.job { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.job-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.job-title { font-weight: 600; }
.job-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.job-prompt { font-size: 14px; color: var(--muted); margin: 10px 0 0; overflow-wrap: anywhere; }
.status { white-space: nowrap; font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .05em; padding: 3px 8px; border-radius: 4px; border: 1px solid var(--line); }
.st-done { color: var(--ok); border-color: #2c5a3e; }
.st-failed { color: var(--bad); border-color: #6a3029; }
.st-running, .st-waiting_gpu { color: var(--warn); border-color: #5a4520; }
.st-queued, .st-cancelled { color: var(--muted); }
.bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 12px; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.outputs { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-top: 14px; }
.outputs img, .outputs video { width: 100%; border-radius: 6px; border: 1px solid var(--line); display: block; background: #000; }
.outputs audio { width: 100%; grid-column: 1 / -1; }
.outputs .wide { grid-column: 1 / -1; max-width: 640px; }
.out-actions { margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.empty { color: var(--dim); text-align: center; padding: 40px 0; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: var(--radius); max-width: 360px; font-size: 14px; z-index: 50; }
.toast.err { border-left-color: var(--bad); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; gap: 4px; }
  .side .brand { width: 100%; padding: 0 0 8px; }
  .side .spacer { display: none; }
  .nav { width: auto; }
  .topbar { padding: 0 16px; top: 0; }
  .content { padding: 16px; }
  .panels > * { grid-column: span 12 !important; }
}
