:root {
  --room: #0e1114;
  --panel: #15191e;
  --raise: #1b2027;
  --line: #262d35;
  --line-soft: #1e242b;
  --ink: #e9ebee;
  --muted: #838b95;
  --faint: #5d656e;
  --amber: #f0a202;
  --amber-deep: #b87c00;
  --mount: #f4f5f7;
  --mount-line: #d3d6da;
  --on-amber: #14161a;
  --radius: 4px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--room);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

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

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

/* ---------- top bar ---------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #12161a, var(--room));
}

.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }

.lamp {
  align-self: center;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 12px 2px rgba(240, 162, 2, .55);
  flex: none;
}

h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.sub { color: var(--muted); font-size: 13px; white-space: nowrap; }

.status { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--muted); }

.stat { white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat.queue { color: var(--ink); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
  transition: background .2s ease;
}
.dot.on { background: #46c26a; }
.dot.off { background: #d0453b; }

/* ---------- layout ---------- */

main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 0;
  min-height: 0;
}

.stage-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 28px 18px;
  gap: 18px;
  border-right: 1px solid var(--line);
}

.controls {
  padding: 26px 26px 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--panel);
  overflow-y: auto;
}

/* ---------- stage ---------- */

.stage { display: flex; flex-direction: column; gap: 12px; }

.mount {
  position: relative;
  background: var(--mount);
  border: 1px solid var(--mount-line);
  border-radius: 3px;
  min-height: 320px;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 22px 60px -30px rgba(0, 0, 0, .9);
}

.mount::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,.5), transparent 60%);
  opacity: .35;
}

#preview {
  display: block;
  max-width: 100%;
  max-height: min(66vh, 760px);
  width: auto;
  height: auto;
  position: relative;
  z-index: 1;
}

.placeholder {
  position: relative;
  z-index: 1;
  color: #6b7077;
  font-size: 15px;
  padding: 48px 24px;
  text-align: center;
}
.placeholder p { margin: 0; }

.busy {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 16px 16px;
  background: linear-gradient(180deg, rgba(14,17,20,0), rgba(14,17,20,.92) 45%);
}

.busy-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #cfd4da;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.track { height: 3px; background: rgba(255,255,255,.16); border-radius: 2px; overflow: hidden; }
.fill {
  height: 100%;
  width: 0%;
  background: var(--amber);
  transition: width .35s cubic-bezier(.22,.61,.36,1);
}

.annotate {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line-soft);
}
.annotate .grow { margin-left: auto; }
.annotate .ok { color: #46c26a; }
.annotate .err { color: #e0685e; }

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

/* ---------- buttons ---------- */

.primary {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  background: var(--amber);
  color: var(--on-amber);
  font-weight: 600;
  font-size: 15.5px;
  letter-spacing: -.01em;
  padding: 13px 18px;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.primary:hover:not(:disabled) { background: #ffb524; }
.primary:active:not(:disabled) { transform: translateY(1px); }
.primary:disabled { background: #3a3d42; color: #7b828b; cursor: not-allowed; }

.ghost {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13.5px;
  padding: 7px 13px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.ghost:hover:not(:disabled) { color: var(--ink); border-color: #39414b; background: rgba(255,255,255,.03); }
.ghost:disabled { opacity: .4; cursor: not-allowed; }

.icon {
  appearance: none;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  width: 38px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.icon:hover { color: var(--amber); border-color: #3c444f; }
.icon.sm { width: auto; padding: 2px 8px; font-size: 12px; border: 0; background: transparent; }

/* ---------- filmstrip ---------- */

.strip-wrap { min-width: 0; }

.strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.strip::-webkit-scrollbar { height: 7px; }
.strip::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.thumb {
  flex: none;
  width: 104px;
  height: 104px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--raise);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: border-color .15s ease;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover { border-color: #3f4854; }
.thumb[aria-current="true"] { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }

.empty { color: var(--faint); font-size: 13.5px; margin: 4px 0 0; }

/* ---------- form ---------- */

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
label .note { font-size: 11.5px; color: var(--faint); font-weight: 400; }
output { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 500; }

textarea, input[type="number"], select {
  width: 100%;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 11px;
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
  transition: border-color .15s ease, background .15s ease;
}

textarea { resize: vertical; min-height: 74px; font-family: inherit; }
textarea::placeholder { color: var(--faint); }

textarea:hover, input[type="number"]:hover, select:hover { border-color: #333b45; }
textarea:focus, input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--amber);
  background: #1e242b;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23838b95' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

.hint { font-size: 12px; color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 14px;
}

.seedrow { display: flex; gap: 8px; }
.seedrow input { font-family: var(--mono); font-size: 13px; }
.seedrow .icon { flex: none; height: 42px; }

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid var(--room);
}
input[type="range"]::-moz-range-track { height: 3px; background: var(--line); border-radius: 2px; }
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border: 2px solid var(--room);
  border-radius: 50%; background: var(--amber);
}

.foot { margin: 0; font-size: 12.5px; color: var(--faint); line-height: 1.55; }

/* keeps the primary action reachable without scrolling the panel */
.actions {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 14px 0 18px;
  background: var(--panel);
  border-top: 1px solid var(--line-soft);
  z-index: 3;
}
.actions .primary { width: 100%; }
.actions .foot { margin-top: 9px; }

/* ---------- log ---------- */

.log {
  border: 1px solid var(--line);
  border-left: 2px solid var(--amber);
  border-radius: var(--radius);
  background: var(--raise);
  padding: 10px 12px;
}
.log.err { border-left-color: #d0453b; }
.log-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--faint); margin-bottom: 4px;
}
.log p { margin: 0; font-size: 13px; color: #c6ccd3; word-break: break-word; white-space: pre-wrap; }

/* ---------- filmstrip / stage reveal ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.arrive { animation: rise .45s cubic-bezier(.22,.61,.36,1) both; }

@media (prefers-reduced-motion: reduce) {
  .arrive { animation: none; }
  .fill { transition: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  body { height: auto; overflow: visible; }
  main { grid-template-columns: 1fr; }
  .stage-col { border-right: 0; border-bottom: 1px solid var(--line); padding: 20px 18px; overflow: visible; }
  .controls { padding: 22px 18px 40px; overflow: visible; }
  .sub { display: none; }
}

@media (max-width: 560px) {
  .bar { padding: 12px 16px; }
  .status { gap: 10px; font-size: 12px; }
  .grid { grid-template-columns: 1fr; }
  .mount { min-height: 220px; }
}
