*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #060608;
  --surface: rgba(255,255,255,0.04);
  --surface2: rgba(255,255,255,0.06);
  --border: rgba(255,255,255,0.08);
  --border-bright: rgba(255,255,255,0.14);
  --accent: #7c3aed;
  --accent2: #a855f7;
  --accent3: #c084fc;
  --cyan: #06b6d4;
  --pink: #ec4899;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --text: #f0f0f5;
  --text-muted: #6b6b80;
  --text-dim: #9090a8;
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ── Star canvas ──────────────────────────────────────────────────────────────── */
#star-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ── Animated Background ──────────────────────────────────────────────────── */
.bg-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.3;
  animation: orbFloat 12s ease-in-out infinite;
}

.orb1 {
  width: 700px; height: 700px;
  background: radial-gradient(circle, #7c3aed, transparent 70%);
  top: -250px; left: -250px;
  animation-delay: 0s;
}
.orb2 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #06b6d4, transparent 70%);
  bottom: -200px; right: -200px;
  animation-delay: -4s;
}
.orb3 {
  width: 450px; height: 450px;
  background: radial-gradient(circle, #ec4899, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -8s;
  opacity: 0.12;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(40px, -50px) scale(1.07); }
  66%       { transform: translate(-25px, 35px) scale(0.93); }
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 40%, transparent 100%);
}

/* ── App layout ───────────────────────────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 2rem 1.5rem 6rem;
}

/* ── Glass Card ───────────────────────────────────────────────────────────── */
.glass-card {
  background: rgba(10,10,16,0.8);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 3.5rem 1rem 2.5rem;
  animation: fadeUp 0.6s ease both;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(124,58,237,0.12);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 99px;
  padding: 0.4rem 1.1rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--accent3);
  margin-bottom: 1.75rem;
  text-transform: uppercase;
}

.pulse-dot {
  width: 7px; height: 7px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.6); }
  70%  { box-shadow: 0 0 0 9px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

.hero-title {
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -2px;
  margin-bottom: 1.1rem;
}

.gradient-text {
  background: linear-gradient(135deg, #c084fc 0%, #7c3aed 40%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 40px rgba(124,58,237,0.4));
}

.hero-sub {
  color: var(--text-dim);
  font-weight: 300;
  font-size: 0.75em;
  letter-spacing: 3px;
  text-transform: uppercase;
  display: block;
  margin-top: 0.3rem;
}

.hero-desc {
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto;
  font-size: 1rem;
  line-height: 1.75;
}

/* ── API Key bar ──────────────────────────────────────────────────────────── */
.apikey-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.35rem;
  margin-bottom: 1.5rem;
  animation: fadeUp 0.6s 0.1s ease both;
  transition: border-color 0.3s;
}
.apikey-bar.connected {
  border-color: rgba(34,197,94,0.3);
}

.apikey-icon { font-size: 1.1rem; flex-shrink: 0; }

.apikey-bar input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.9rem;
  outline: none;
  letter-spacing: 2px;
  min-width: 0;
}
.apikey-bar input::placeholder { letter-spacing: 0; color: var(--text-muted); font-family: var(--font); }

.btn-pill {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 99px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.48rem 1.3rem;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-pill:hover { opacity: 0.85; box-shadow: 0 0 20px rgba(124,58,237,0.4); }
.btn-pill:active { transform: scale(0.96); }

.apikey-status {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.apikey-status.ok    { color: var(--green); }
.apikey-status.error { color: var(--red); }

/* ── Layout grid ──────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 1fr 430px;
  gap: 1.25rem;
  align-items: start;
  animation: fadeUp 0.6s 0.15s ease both;
}
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }

/* ── Panel ────────────────────────────────────────────────────────────────── */
.panel { padding: 1.75rem; }

/* ── Section titles ───────────────────────────────────────────────────────── */
.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 1.5rem 0 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.section-title:first-child { margin-top: 0; }
.section-icon { color: var(--accent3); font-size: 0.9rem; }

.section-title.collapsible { cursor: pointer; user-select: none; transition: color 0.15s; }
.section-title.collapsible:hover { color: var(--text-dim); }

.chevron { margin-left: auto; transition: transform 0.25s; font-size: 0.85rem; }
.section-title.collapsed .chevron { transform: rotate(-90deg); }

.collapsible-body {
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease;
  max-height: 2000px;
  opacity: 1;
}
.collapsible-body.collapsed { max-height: 0; opacity: 0; }

/* ── Prompt Examples ──────────────────────────────────────────────────────── */
.example-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  padding-bottom: 0.5rem;
}

.example-btn {
  background: rgba(124,58,237,0.06);
  border: 1px solid rgba(124,58,237,0.18);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  transition: all 0.18s;
  text-align: left;
  line-height: 1.4;
}
.example-btn:hover {
  background: rgba(124,58,237,0.15);
  border-color: rgba(124,58,237,0.4);
  color: var(--accent3);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(124,58,237,0.2);
}
.example-btn:active { transform: translateY(0); }

/* ── Fields ───────────────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
  position: relative;
}
.field label { font-size: 0.78rem; font-weight: 500; color: var(--text-muted); letter-spacing: 0.3px; }
.unit { font-weight: 400; color: var(--text-muted); opacity: 0.6; }
.range-hint { font-size: 0.7rem; color: var(--text-muted); opacity: 0.5; }

input[type="number"],
input[type="text"],
input[type="password"],
textarea,
select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.6rem 0.85rem;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  width: 100%;
  -webkit-appearance: none;
}
textarea { resize: vertical; }
select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6b80' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.2rem;
  appearance: none;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(124,58,237,0.07);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.16);
}

.char-count {
  position: absolute;
  right: 0.6rem;
  bottom: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* ── Grids ────────────────────────────────────────────────────────────────── */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
@media (max-width: 600px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ── Turbo Mode Toggle ────────────────────────────────────────────────────── */
.turbo-toggle-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.turbo-option {
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  cursor: pointer;
  background: rgba(255,255,255,0.04);
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
  user-select: none;
  position: relative;
}

.turbo-option::after {
  content: '';
  position: absolute;
  top: 0.55rem;
  right: 0.65rem;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  transition: all 0.18s;
}

.turbo-option.turbo-active::after {
  background: var(--accent2);
  border-color: var(--accent2);
  box-shadow: 0 0 6px rgba(168,85,247,0.6);
}

.turbo-option:hover {
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.07);
}

.turbo-option.turbo-active {
  border-color: var(--accent2);
  background: rgba(168, 85, 247, 0.12);
  box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.3), inset 0 0 20px rgba(168,85,247,0.05);
}

.turbo-option-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.3rem;
}

.turbo-icon {
  font-size: 0.9rem;
}

.turbo-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  flex: 1;
}

.turbo-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  letter-spacing: 0.02em;
}

.turbo-badge-fast {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.turbo-badge-slow {
  background: rgba(245, 158, 11, 0.12);
  color: var(--yellow);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.turbo-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.turbo-option.turbo-active .turbo-desc {
  color: var(--text-dim);
}

/* ── Queue position banner ────────────────────────────────────────────────── */
.queue-pos-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  font-size: 0.8rem;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.queue-pos-wrap strong {
  color: var(--yellow);
  font-size: 1rem;
}

.queue-pos-icon {
  font-size: 1rem;
}

.queue-pos-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  width: 100%;
  margin-top: 0.1rem;
}

/* ── Models note ──────────────────────────────────────────────────────────── */
.models-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding: 0.4rem 0.7rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ── Presets ──────────────────────────────────────────────────────────────── */
.presets {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.preset-label { font-size: 0.74rem; color: var(--text-muted); margin-right: 0.2rem; }
.preset-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}
.preset-btn:hover {
  background: rgba(124,58,237,0.12);
  border-color: rgba(124,58,237,0.35);
  color: var(--accent3);
}
.preset-btn.active {
  background: rgba(124,58,237,0.18);
  border-color: rgba(124,58,237,0.5);
  color: var(--accent3);
}

/* ── Seed row ─────────────────────────────────────────────────────────────── */
.seed-row { display: flex; align-items: flex-end; gap: 0.5rem; margin-bottom: 0.5rem; }
.btn-icon {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 1.2rem;
  width: 42px; height: 42px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s, transform 0.3s;
}
.btn-icon:hover { background: rgba(124,58,237,0.15); color: var(--accent3); }
.btn-icon:active { transform: rotate(180deg); }

/* ── Copy button ──────────────────────────────────────────────────────────── */
.copy-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}
.copy-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); border-color: var(--border-bright); }
.copy-btn.copied { color: var(--green); border-color: rgba(34,197,94,0.4); }

/* ── Generate button ──────────────────────────────────────────────────────── */
.btn-generate {
  position: relative;
  width: 100%;
  padding: 1.05rem;
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #06b6d4 100%);
  background-size: 200% 200%;
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 1.25rem;
  overflow: hidden;
  transition: opacity 0.2s, transform 0.1s, box-shadow 0.2s;
  animation: gradientShift 4s ease infinite;
  letter-spacing: 0.5px;
}
.btn-generate:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  animation: none;
}
.btn-generate:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(124,58,237,0.5);
}
.btn-generate:not(:disabled):active { transform: translateY(0) scale(0.99); }

.btn-generate-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  position: relative;
  z-index: 1;
}

/* Spinner inside button */
.btn-spin {
  display: none;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.btn-generate.loading .btn-spin { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

.btn-shimmer {
  position: absolute;
  top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
  transform: skewX(-20deg);
  animation: shimmer 2.5s 1s infinite;
}
.btn-generate:disabled .btn-shimmer { display: none; }

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes shimmer {
  0%   { left: -100%; }
  100% { left: 200%; }
}

/* Submit hint */
.submit-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.65rem;
}
kbd {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-family: var(--mono);
  font-size: 0.72rem;
}

/* ── Status panel states ──────────────────────────────────────────────────── */
.state-screen { animation: fadeUp 0.4s ease both; }
.state-screen.hidden { display: none !important; }

/* ── Idle state ───────────────────────────────────────────────────────────── */
.idle-art {
  position: relative;
  width: 130px; height: 130px;
  margin: 1rem auto 1.75rem;
}
.idle-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid;
  inset: 0;
  animation: idleSpin 8s linear infinite;
}
.r1 { border-color: rgba(124,58,237,0.45); animation-duration: 8s; }
.r2 { border-color: rgba(168,85,247,0.28); inset: 14px; animation-duration: 13s; animation-direction: reverse; }
.r3 { border-color: rgba(6,182,212,0.22); inset: 28px; animation-duration: 18s; }
@keyframes idleSpin { to { transform: rotate(360deg); } }

.idle-icon {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.8rem;
}
#state-idle h3 { text-align: center; font-size: 1.15rem; margin-bottom: 0.5rem; }
#state-idle p { text-align: center; color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.5rem; line-height: 1.65; }

.spec-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-bottom: 1.5rem; }
.chip {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0.3rem 0.85rem;
  font-size: 0.74rem;
  color: var(--text-dim);
}

/* Timing breakdown in idle */
.idle-timings { display: flex; flex-direction: column; gap: 0.55rem; }
.timing-row {
  display: grid;
  grid-template-columns: 140px 1fr 60px;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
}
.timing-stage { color: var(--text-dim); }
.timing-bar-wrap { height: 4px; background: rgba(255,255,255,0.06); border-radius: 99px; overflow: hidden; }
.timing-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--cyan)); border-radius: 99px; }
.timing-val { color: var(--text-muted); text-align: right; }

/* ── Processing state ─────────────────────────────────────────────────────── */
.job-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 0.5rem;
}
.job-label { font-size: 0.68rem; color: var(--text-muted); display: block; margin-bottom: 0.2rem; text-transform: uppercase; letter-spacing: 0.5px; }
.job-id-row { display: flex; align-items: center; gap: 0.4rem; }
.job-id { font-family: var(--mono); font-size: 0.68rem; color: var(--text-dim); word-break: break-all; }

/* Badge */
.badge {
  font-size: 0.7rem; font-weight: 700;
  padding: 0.3rem 0.85rem;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
}
.badge.queued     { background: rgba(245,158,11,0.12); color: var(--yellow); border: 1px solid rgba(245,158,11,0.3); }
.badge.processing { background: rgba(124,58,237,0.12); color: var(--accent3); border: 1px solid rgba(124,58,237,0.3); animation: badgePulse 2s infinite; }
.badge.completed  { background: rgba(34,197,94,0.12);  color: var(--green);  border: 1px solid rgba(34,197,94,0.3); }
.badge.failed     { background: rgba(239,68,68,0.12);  color: var(--red);   border: 1px solid rgba(239,68,68,0.3); }
.badge.cancelled  { background: rgba(107,107,128,0.12); color: var(--text-muted); border: 1px solid var(--border); }
@keyframes badgePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* Circular progress */
.circle-progress-wrap {
  position: relative;
  width: 148px; height: 148px;
  margin: 0 auto 1.25rem;
}
.circle-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.circle-bg { fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 7; }
.circle-fg {
  fill: none;
  stroke: url(#progressGrad);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4,0,0.2,1);
  filter: drop-shadow(0 0 8px rgba(124,58,237,0.7));
}
.circle-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
}
.circle-pct {
  font-size: 1.7rem; font-weight: 900; line-height: 1;
  background: linear-gradient(135deg, var(--accent3), var(--cyan));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.circle-sub { font-size: 0.68rem; color: var(--text-muted); margin-top: 0.3rem; max-width: 80px; line-height: 1.4; }

/* Linear progress bar */
.linear-progress-track {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.linear-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 0 8px rgba(124,58,237,0.6);
}

/* Time bar */
.time-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.65rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.time-item { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; }
.time-label { font-size: 0.62rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; }
.time-value { font-size: 0.88rem; font-weight: 700; color: var(--text); }
.time-value.mono { font-family: var(--mono); font-size: 0.82rem; }
.time-sep { color: var(--border-bright); font-size: 1rem; }

/* Stages */
.stages { display: flex; flex-direction: column; gap: 0.55rem; margin-bottom: 1.25rem; }
.stage-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  transition: background 0.25s, border-color 0.25s;
}
.stage-item.active { background: rgba(124,58,237,0.1); border-color: rgba(124,58,237,0.35); }
.stage-item.done   { background: rgba(34,197,94,0.06); border-color: rgba(34,197,94,0.2); }

.stage-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
  transition: background 0.25s, box-shadow 0.25s;
}
.stage-item.active .stage-dot { background: var(--accent2); box-shadow: 0 0 8px var(--accent2); animation: pulse 1.5s infinite; }
.stage-item.done   .stage-dot { background: var(--green); box-shadow: 0 0 6px rgba(34,197,94,0.5); }

.stage-info { display: flex; flex-direction: column; gap: 0.1rem; flex: 1; min-width: 0; }
.stage-name  { font-size: 0.8rem; font-weight: 500; color: var(--text); }
.stage-status { font-size: 0.7rem; color: var(--text-muted); }
.stage-item.active .stage-status { color: var(--accent3); }
.stage-item.done   .stage-status { color: var(--green); }
.stage-time { font-family: var(--mono); font-size: 0.68rem; color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }

/* Log */
.log-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.log-controls { display: flex; align-items: center; gap: 0.75rem; }
.log-autoscroll {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.7rem; color: var(--text-muted);
  cursor: pointer; text-transform: none; letter-spacing: 0;
}
.log-autoscroll input { cursor: pointer; accent-color: var(--accent); }
.log-clear-btn {
  background: none; border: none;
  color: var(--text-muted); font-size: 0.7rem;
  cursor: pointer; transition: color 0.15s;
}
.log-clear-btn:hover { color: var(--text); }

.log-box {
  background: rgba(0,0,0,0.45);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  height: 160px;
  overflow-y: auto;
  margin-bottom: 1.1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.log-box::-webkit-scrollbar { width: 4px; }
.log-box::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.log-line { line-height: 1.75; white-space: pre-wrap; word-break: break-all; color: var(--text-muted); }
.log-line.node  { color: var(--accent3); }
.log-line.done  { color: var(--green); }
.log-line.error { color: var(--red); }
.log-line.info  { color: var(--text-muted); }

/* Cancel */
.btn-cancel {
  width: 100%;
  background: rgba(239,68,68,0.07);
  border: 1px solid rgba(239,68,68,0.22);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 0.85rem; font-weight: 600;
  padding: 0.65rem;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn-cancel:hover { background: rgba(239,68,68,0.14); box-shadow: 0 0 16px rgba(239,68,68,0.2); }

/* ── Result state ─────────────────────────────────────────────────────────── */
.result-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.result-badge {
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 99px;
  color: var(--green);
  font-size: 0.78rem; font-weight: 700;
  padding: 0.3rem 0.9rem;
}
.result-meta { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; }
.result-seed-tag { font-family: var(--mono); font-size: 0.75rem; color: var(--text-muted); }

.video-wrap {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  margin-bottom: 0.85rem;
  border: 1px solid var(--border);
  position: relative;
}
#result-video { width: 100%; display: block; max-height: 320px; object-fit: contain; }

.result-stats { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.85rem; }
.stat-chip {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0.25rem 0.75rem;
  font-size: 0.73rem;
  color: var(--text-dim);
}

.result-actions { display: flex; gap: 0.65rem; flex-wrap: wrap; }
.btn-download {
  flex: 2;
  padding: 0.75rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; border-radius: var(--radius-sm);
  color: #fff; font-size: 0.88rem; font-weight: 600;
  text-align: center; text-decoration: none;
  cursor: pointer; display: block;
  transition: opacity 0.15s, box-shadow 0.2s;
  min-width: 0;
}
.btn-download:hover { opacity: 0.88; box-shadow: 0 4px 20px rgba(124,58,237,0.4); }
.btn-outline {
  flex: 1;
  padding: 0.75rem;
  background: transparent;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-width: 0;
  white-space: nowrap;
}
.btn-outline:hover { background: rgba(255,255,255,0.05); color: var(--text); border-color: rgba(255,255,255,0.2); }

/* ── Error state ──────────────────────────────────────────────────────────── */
.error-icon { font-size: 2.8rem; text-align: center; margin-bottom: 1rem; }
#state-error h3 { text-align: center; color: var(--red); margin-bottom: 0.75rem; font-size: 1.1rem; }
.error-msg {
  background: rgba(239,68,68,0.05);
  border: 1px solid rgba(239,68,68,0.15);
  border-radius: 8px;
  padding: 0.8rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: pre-wrap; word-break: break-all;
  margin-bottom: 1rem;
  max-height: 160px;
  overflow-y: auto;
}

/* ── Job History ──────────────────────────────────────────────────────────── */
.history-panel {
  margin-top: 1.25rem;
  padding: 1.5rem;
  animation: fadeUp 0.6s 0.25s ease both;
}
.history-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; gap: 1rem;
}
.history-title {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-muted);
}
.history-count {
  font-size: 0.65rem !important;
  padding: 0.15rem 0.6rem !important;
  letter-spacing: 0 !important;
}
.btn-clear-history {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-clear-history:hover { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.3); color: var(--red); }

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
}
.history-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.history-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  cursor: default;
}
.history-card:hover { border-color: rgba(124,58,237,0.3); transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,0.3); }
.history-card.completed { border-left: 3px solid rgba(34,197,94,0.4); }
.history-card.failed    { border-left: 3px solid rgba(239,68,68,0.4); }
.history-card.cancelled { border-left: 3px solid rgba(107,107,128,0.3); }

.history-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.history-time { font-size: 0.7rem; color: var(--text-muted); }
.history-prompt { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.55rem; line-height: 1.5; }
.history-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.65rem; }
.history-meta span {
  font-size: 0.7rem; color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
}
.history-actions { display: flex; gap: 0.5rem; }
.history-dl-btn, .history-load-btn {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.72rem; font-weight: 600;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.history-dl-btn:hover { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.3); color: var(--green); }
.history-load-btn:hover { background: rgba(124,58,237,0.1); border-color: rgba(124,58,237,0.3); color: var(--accent3); }

/* ── Footer bar ───────────────────────────────────────────────────────────── */
.footer-bar {
  display: flex; align-items: center;
  gap: 1.5rem; flex-wrap: wrap;
  padding: 0.9rem 1.35rem;
  margin-top: 1.25rem;
  font-size: 0.8rem; color: var(--text-muted);
}
.footer-item { display: flex; align-items: center; gap: 0.5rem; }
.footer-right { margin-left: auto; }
.footer-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted); transition: background 0.3s, box-shadow 0.3s;
}
.footer-dot.online  { background: var(--green); box-shadow: 0 0 6px rgba(34,197,94,0.6); }
.footer-dot.offline { background: var(--red); }
.footer-icon { font-size: 0.9rem; }

/* ── Toast notifications ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 1.25rem; right: 1.25rem;
  z-index: 9999;
  display: flex; flex-direction: column;
  gap: 0.6rem;
  max-width: 340px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 0.65rem;
  background: rgba(14,14,22,0.95);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  pointer-events: all;
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s;
  opacity: 0;
}
.toast.toast-show { transform: translateX(0); opacity: 1; }
.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error   { border-left: 3px solid var(--red); }
.toast.toast-warning { border-left: 3px solid var(--yellow); }
.toast.toast-info    { border-left: 3px solid var(--cyan); }

.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 0.05rem; }
.toast-msg { font-size: 0.82rem; color: var(--text); line-height: 1.5; flex: 1; }
.toast-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 1rem; line-height: 1;
  padding: 0; flex-shrink: 0;
  transition: color 0.15s;
}
.toast-close:hover { color: var(--text); }

/* ── Global animations ────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }
