:root {
  --bg: #08090c;
  --bg-2: #0c0e13;
  --panel: #11141b;
  --panel-2: #151922;
  --line: #1f2431;
  --line-2: #2a3040;
  --text: #e9ecf2;
  --muted: #8a93a8;
  --muted-2: #646d80;
  --lime: #e8ff5a;
  --lime-soft: rgba(232, 255, 90, 0.12);
  --teal: #5eead4;
  --red: #ff6b6b;
  --amber: #fbbf24;
  --radius: 14px;
}

* { box-sizing: border-box; }

/* The UI toggles sections with the `hidden` attribute, which author display
   rules (.login, .gallery) would otherwise override. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(232, 255, 90, 0.07), transparent 62%),
    radial-gradient(760px 460px at 88% -4%, rgba(94, 234, 212, 0.05), transparent 58%),
    var(--bg);
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.02em; }
p { margin: 0; }
code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

/* ------------------------------------------------------------- buttons */
.btn {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.08s, color 0.15s;
}
.btn:hover { border-color: #3a4257; background: #1a1f2b; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--lime); border-color: var(--lime); color: #101308; }
.btn.primary:hover { background: #f0ff7d; border-color: #f0ff7d; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.big { width: 100%; padding: 13px; font-size: 15px; border-radius: 12px; margin-top: 4px; }
.btn.danger { color: var(--red); border-color: rgba(255, 107, 107, 0.3); }
.btn.danger:hover { background: rgba(255, 107, 107, 0.1); }

/* -------------------------------------------------------------- login */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px 28px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { font-size: 24px; }
.login-sub { color: var(--muted); font-size: 12.5px; margin-top: -8px; }
.login-error {
  color: var(--red);
  font-size: 12.5px;
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
}

/* --------------------------------------------------------------- shell */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: rgba(8, 9, 12, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 12px;
  background: var(--lime);
  color: #101308;
  border-radius: 7px;
  padding: 5px 8px;
}
.brand-mark.small { font-size: 10.5px; padding: 4px 7px; }
.brand-name { font-weight: 600; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 12.5px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 5px 11px;
}
.pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.03);
}
.pill.ok .dot { background: var(--teal); box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.15); }
.pill.bad .dot { background: var(--red); box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.15); }
.pill.busy .dot { background: var(--lime); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.layout {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 20px;
  max-width: 1560px;
  margin: 0 auto;
  padding: 20px 22px 60px;
  align-items: start;
}
.composer { position: sticky; top: 76px; }

/* --------------------------------------------------------------- panel */
.panel {
  background: linear-gradient(180deg, var(--panel), #0e1117);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; }
.panel-head h2 { font-size: 15px; }
.hint { color: var(--muted-2); font-size: 12px; line-height: 1.5; }
.hint.tight { margin-top: -6px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 550; letter-spacing: 0.01em; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.row-between b { color: var(--text); font-weight: 600; }

input[type="text"], input[type="number"], input[type="email"], input[type="password"],
textarea, select {
  width: 100%;
  background: #0a0c11;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  padding: 10px 11px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 92px; line-height: 1.55; }
input:focus, textarea:focus, select:focus {
  border-color: rgba(232, 255, 90, 0.5);
  box-shadow: 0 0 0 3px rgba(232, 255, 90, 0.09);
}
select.mini {
  width: auto;
  padding: 6px 9px;
  font-size: 12.5px;
  border-radius: 8px;
  background: var(--panel-2);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seed-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }

/* ----------------------------------------------------------- segmented */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  background: #0a0c11;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
}
.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  border-radius: 7px;
  padding: 7px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: background 0.15s, color 0.15s;
}
.segmented button em { font-style: normal; font-size: 10px; color: var(--muted-2); }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--lime-soft); color: var(--lime); }
.segmented button.active em { color: rgba(232, 255, 90, 0.65); }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chips button {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
}
.chips button:hover { border-color: var(--line-2); color: var(--text); }
.chips button.active { border-color: rgba(232, 255, 90, 0.4); color: var(--lime); background: var(--lime-soft); }

/* --------------------------------------------------------------- range */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--lime) var(--fill, 23%), #1c2130 var(--fill, 23%));
  border-radius: 999px;
  outline: none;
  margin: 8px 0 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--lime);
  border: 3px solid #0a0c11;
  box-shadow: 0 0 0 1px rgba(232, 255, 90, 0.5);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--lime);
  border: 3px solid #0a0c11;
  cursor: pointer;
}
.range-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted-2); }

/* ---------------------------------------------------------------- refs */
.refs {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #0b0d13;
  overflow: hidden;
}
.refs summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--muted);
}
.refs summary::-webkit-details-marker { display: none; }
.refs[open] summary { border-bottom: 1px solid var(--line); color: var(--text); }
.refs-badge {
  font-size: 10.5px;
  color: var(--muted-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}
.refs-badge.on { color: var(--lime); border-color: rgba(232, 255, 90, 0.35); }
.refs-body { padding: 13px; display: flex; flex-direction: column; gap: 9px; }

.dropzone {
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.over { border-color: rgba(232, 255, 90, 0.5); background: rgba(232, 255, 90, 0.04); }
.dz-label { font-size: 12.5px; font-weight: 550; }
.dz-hint { font-size: 11px; color: var(--muted-2); }

.ref-list { display: flex; flex-direction: column; gap: 6px; }
.ref-item {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 8px;
  font-size: 12px;
}
.ref-item img, .ref-item video {
  width: 44px;
  height: 32px;
  object-fit: cover;
  border-radius: 5px;
  background: #000;
  flex: none;
}
.ref-item .ref-icon {
  width: 44px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: #1b2030;
  color: var(--muted);
  font-size: 10px;
  flex: none;
}
.ref-item .ref-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-item .ref-size { color: var(--muted-2); font-size: 10.5px; }
.ref-item button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 5px;
}
.ref-item button:hover { color: var(--red); background: rgba(255, 107, 107, 0.1); }
.ref-item.uploading { opacity: 0.6; }

/* ------------------------------------------------------------ estimate */
.estimate {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: #0a0c11;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px;
}
.estimate div { display: flex; flex-direction: column; gap: 2px; }
.estimate b { font-size: 13.5px; font-weight: 650; }
.estimate span { font-size: 10px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------------------------------------------------------------- tabs */
.board { min-width: 0; }
.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}
.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  font-size: 13px;
  border-radius: 9px;
  padding: 7px 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel); border-color: var(--line); color: var(--text); }
.tab .count {
  font-size: 10.5px;
  background: var(--lime-soft);
  color: var(--lime);
  border-radius: 999px;
  padding: 1px 7px;
}
.tabs-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* --------------------------------------------------------------- queue */
.queue { display: flex; flex-direction: column; gap: 14px; }
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.empty {
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  padding: 46px 24px;
  text-align: center;
  color: var(--muted);
}
.empty p { font-weight: 550; margin-bottom: 5px; color: var(--text); }
.empty span { font-size: 12.5px; color: var(--muted-2); }

.job {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.job-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px 12px;
}
.job-prompt {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.job-id {
  font-family: ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--muted-2);
  white-space: nowrap;
}

.state {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 9px;
  white-space: nowrap;
  border: 1px solid var(--line);
  color: var(--muted);
}
.state.running { color: var(--lime); border-color: rgba(232, 255, 90, 0.35); background: var(--lime-soft); }
.state.succeeded { color: var(--teal); border-color: rgba(94, 234, 212, 0.3); background: rgba(94, 234, 212, 0.09); }
.state.failed { color: var(--red); border-color: rgba(255, 107, 107, 0.3); background: rgba(255, 107, 107, 0.08); }

.progress {
  height: 3px;
  background: #171b25;
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--lime), var(--teal));
  transition: width 0.6s ease;
}
.progress.indeterminate i {
  width: 32% !important;
  animation: slide 1.5s ease-in-out infinite;
}
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(320%); } }

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 11px 16px;
  font-size: 11.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.job-meta b { color: var(--text); font-weight: 550; }
.job-meta .eta { color: var(--muted-2); }

.job-body { padding: 0; }
.job-body video {
  width: 100%;
  display: block;
  background: #000;
  max-height: 62vh;
}
.job-error {
  padding: 13px 16px;
  font-size: 12px;
  color: #ffb4b4;
  background: rgba(255, 107, 107, 0.07);
  border-bottom: 1px solid rgba(255, 107, 107, 0.2);
  font-family: ui-monospace, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
}
.job-actions a.btn { text-decoration: none; }

/* ------------------------------------------------------------- gallery */
.g-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.g-thumb { position: relative; aspect-ratio: 16 / 9; background: #000; }
.g-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 5px; }
.g-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-meta { font-size: 10.5px; color: var(--muted-2); display: flex; justify-content: space-between; gap: 8px; }
.g-actions { display: flex; gap: 6px; padding: 0 12px 12px; }
.g-actions .btn { flex: 1; text-align: center; text-decoration: none; font-size: 11.5px; padding: 6px 8px; }

/* --------------------------------------------------------------- toast */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #171b25;
  border: 1px solid var(--line-2);
  color: var(--text);
  font-size: 12.5px;
  border-radius: 10px;
  padding: 10px 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  z-index: 90;
  max-width: 90vw;
}
.toast.bad { border-color: rgba(255, 107, 107, 0.45); color: #ffc9c9; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .composer { position: static; }
}
@media (max-width: 620px) {
  .topbar { padding: 10px 14px; }
  .brand-name { display: none; }
  .who { display: none; }
  .layout { padding: 14px 14px 50px; }
  .panel { padding: 14px; }
  .estimate { grid-template-columns: 1fr 1fr; }
  .tabs { flex-wrap: wrap; }
  .tabs-right { width: 100%; margin-left: 0; }
}
