:root {
  --bg: #0b0b0c;
  --bg-raised: #131315;
  --ink: #ededea;
  --ink-dim: #9a9995;
  --ink-faint: #5c5b58;
  --amber: #e8a32e;
  --amber-soft: #f4c767;
  --red: #e84a4a;
  --green: #78b472;
  --blue: #6fa3c7;
  --rule: #27272a;
  --rule-soft: #1c1c1f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100vh; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Manrope', -apple-system, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
.mono { font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

.kicker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--amber);
}

h1 {
  font-family: 'Fraunces', serif; font-weight: 400;
  font-size: clamp(38px, 5vw, 64px); line-height: 1;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 144;
}
h1 em { font-style: italic; color: var(--amber); font-weight: 400; }
h2 {
  font-family: 'Fraunces', serif; font-weight: 500;
  font-size: 22px; letter-spacing: -0.01em;
}

/* ----- LOGIN ----- */
.login-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(232,163,46,0.06), transparent 60%),
    var(--bg);
}
.login-frame {
  width: 100%; max-width: 480px;
  position: relative;
}
.login-ornament {
  position: absolute; top: -80px; right: -60px;
  width: 180px; height: 180px; opacity: 0.35;
  pointer-events: none;
}
.login-card {
  padding: 48px 44px;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  position: relative;
}
.login-title {
  font-size: 48px; margin: 14px 0 12px;
}
.login-lede {
  color: var(--ink-dim); font-size: 14px;
  margin-bottom: 32px; line-height: 1.55;
}
.login-form { display: flex; flex-direction: column; gap: 20px; }
.login-error {
  color: var(--red); font-size: 12px;
  padding: 10px 14px; border: 1px solid var(--red);
  background: rgba(232,74,74,0.08);
}

/* ----- FIELDS ----- */
.field { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.field-label {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  color: var(--ink-dim); letter-spacing: 0.15em; text-transform: uppercase;
  font-weight: 500;
}
.field input, .field select, .field textarea,
.login-form input {
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 12px 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  transition: border-color .2s;
}
.field input:focus, .field select:focus, .field textarea:focus,
.login-form input:focus {
  outline: none; border-color: var(--amber);
}
.field-small { max-width: 220px; }

/* ----- BUTTONS ----- */
.btn-primary, .btn-secondary, .btn-ghost {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  font-family: 'Manrope', sans-serif;
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: all .15s ease;
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--amber); color: var(--bg);
  border-color: var(--amber);
}
.btn-primary:hover:not(:disabled) {
  background: var(--amber-soft); border-color: var(--amber-soft);
}
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-secondary {
  background: var(--bg-raised); color: var(--amber);
  border-color: var(--amber);
}
.btn-secondary:hover { background: rgba(232,163,46,0.1); }
.btn-ghost { color: var(--ink-dim); }
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-dim); }
.btn-icon { font-family: 'IBM Plex Mono', monospace; font-weight: 600; }

.link {
  background: none; border: none;
  color: var(--amber); cursor: pointer;
  font: inherit; text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  padding: 0;
}
.link:hover { color: var(--amber-soft); }

/* ----- APP HEADER ----- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 40px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.brand {
  display: flex; align-items: baseline; gap: 10px;
  font-family: 'Fraunces', serif; font-size: 20px;
  font-weight: 500;
}
.brand-mark { color: var(--amber); font-size: 14px; }
.brand-dim { color: var(--ink-dim); font-weight: 400; }
.header-right { display: flex; align-items: center; gap: 20px; }
.tag-subtle {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  color: var(--ink-dim); letter-spacing: 0.12em; text-transform: uppercase;
}

/* ----- APP MAIN ----- */
.app-main {
  flex: 1;
  max-width: 1100px; width: 100%;
  margin: 0 auto; padding: 56px 40px 80px;
}
.intro { margin-bottom: 56px; max-width: 760px; }
.intro .kicker { margin-bottom: 20px; }
.intro h1 { margin-bottom: 20px; }
.lede { font-size: 17px; color: var(--ink-dim); line-height: 1.55; }

.studio { display: flex; flex-direction: column; gap: 32px; }

/* ----- STEP ----- */
.step {
  border: 1px solid var(--rule);
  background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent);
  padding: 28px 32px 32px;
}
.step-head {
  display: flex; align-items: baseline; gap: 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rule-soft);
  margin-bottom: 24px;
}
.step-n {
  font-family: 'Fraunces', serif; font-style: italic;
  font-size: 32px; color: var(--amber); line-height: 1;
  font-weight: 400;
}
.step-head h2 { flex: 1; }
.step-status {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  color: var(--ink-dim); letter-spacing: 0.12em; text-transform: uppercase;
}
.step-status.ok { color: var(--green); }
.step-status.ok::before { content: '◉ '; }
.step-status.err { color: var(--red); }

/* ----- DROPZONE ----- */
.dropzone {
  border: 1px dashed var(--rule);
  transition: all .2s;
  position: relative;
}
.dropzone.drag-over {
  border-color: var(--amber);
  background: rgba(232,163,46,0.04);
}
.dz-empty {
  padding: 48px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center;
}
.dz-icon {
  font-size: 32px; color: var(--amber);
  margin-bottom: 8px;
  font-family: 'IBM Plex Mono', monospace;
}
.dz-main { font-size: 15px; color: var(--ink); }
.dz-sub {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  color: var(--ink-dim); letter-spacing: 0.12em; text-transform: uppercase;
  margin-top: 4px;
}
.dz-filled { padding: 20px 24px; }
.dz-file-row {
  display: flex; align-items: center; gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule-soft);
  margin-bottom: 16px;
}
.dz-file-icon {
  font-size: 20px; color: var(--amber);
  font-family: 'IBM Plex Mono', monospace;
}
.dz-file-info { flex: 1; }
.dz-file-name { font-size: 15px; font-weight: 500; }
.dz-file-meta {
  font-size: 11px; color: var(--ink-dim);
  margin-top: 4px; letter-spacing: 0.05em;
}
.file-preview {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; line-height: 1.6;
  color: var(--ink-dim);
  max-height: 180px; overflow: auto;
  padding: 12px 14px; background: var(--bg);
  border: 1px solid var(--rule-soft);
}
.file-preview table { border-collapse: collapse; font-size: 11px; }
.file-preview th, .file-preview td {
  padding: 4px 12px 4px 0;
  text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--rule-soft);
}
.file-preview th {
  color: var(--amber); font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; font-size: 10px;
}
.file-preview td { color: var(--ink); }

/* ----- SCENARIO ----- */
.scenario { display: flex; flex-direction: column; gap: 16px; }
.presets {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.presets-label {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  color: var(--ink-dim); letter-spacing: 0.12em; text-transform: uppercase;
  margin-right: 6px;
}
.chip {
  background: transparent; color: var(--ink-dim);
  border: 1px solid var(--rule);
  padding: 6px 12px;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  cursor: pointer; transition: all .15s;
  letter-spacing: 0.03em;
}
.chip:hover { color: var(--ink); border-color: var(--ink-dim); }
.chip.active {
  background: rgba(232,163,46,0.1); color: var(--amber); border-color: var(--amber);
}
.scenario-input {
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 16px 18px;
  font-family: 'Manrope', sans-serif; font-size: 14px;
  line-height: 1.55; resize: vertical; min-height: 140px;
}
.scenario-input:focus { outline: none; border-color: var(--amber); }
.hint-row {
  font-size: 11px; color: var(--ink-faint);
  letter-spacing: 0.05em;
}

/* ----- GEN ----- */
.gen-config {
  display: flex; flex-direction: column; gap: 14px;
  margin-bottom: 24px;
  padding: 20px 22px;
  background: var(--bg);
  border: 1px solid var(--rule-soft);
}
.gen-row { display: flex; gap: 16px; align-items: flex-end; }
.check-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--ink-dim);
  cursor: pointer;
}
.check-row input { accent-color: var(--amber); width: 14px; height: 14px; }
.gen-actions {
  display: flex; align-items: center; gap: 16px;
}
.gen-status {
  font-size: 11px; color: var(--ink-dim);
  letter-spacing: 0.05em;
}
.progress-panel {
  margin-top: 20px; padding: 16px 18px;
  background: var(--bg); border: 1px solid var(--rule-soft);
}
.progress-bar {
  height: 3px; background: var(--rule); margin-bottom: 14px;
  overflow: hidden; position: relative;
}
.progress-fill {
  position: absolute; top: 0; left: 0; height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--amber), var(--amber-soft));
  transition: width .3s ease;
}
.progress-bar.indet .progress-fill {
  width: 30%;
  animation: indet 1.4s ease-in-out infinite;
}
@keyframes indet {
  0% { left: -30%; }
  100% { left: 100%; }
}
.progress-stream {
  font-size: 11px; color: var(--ink-dim);
  line-height: 1.55;
  max-height: 150px; overflow-y: auto;
  white-space: pre-wrap;
}

/* ----- RESULT ----- */
.step-result .result-box {
  display: flex; flex-direction: column; gap: 20px;
}
.result-preview {
  height: 480px;
  border: 1px solid var(--rule-soft);
  overflow: hidden;
}
.result-preview iframe {
  width: 100%; height: 100%; border: none; background: #0b0b0c;
}
.result-actions {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.publish-result {
  padding: 16px 18px;
  background: rgba(232,163,46,0.05);
  border: 1px solid var(--amber);
}
.publish-label {
  font-size: 10px; color: var(--amber);
  letter-spacing: 0.15em; text-transform: uppercase;
  margin-bottom: 10px;
}
.publish-url-row { display: flex; gap: 8px; }
.publish-url-row input {
  flex: 1;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--rule);
  padding: 10px 12px;
  font-family: 'IBM Plex Mono', monospace; font-size: 12px;
}

/* ----- TOAST ----- */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  padding: 12px 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  opacity: 0; pointer-events: none;
  transition: all .3s;
  z-index: 100;
  max-width: 400px;
}
.toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}
.toast.err { border-color: var(--red); color: var(--red); }
.toast.ok { border-color: var(--green); color: var(--green); }

/* ----- SCROLLBAR ----- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

/* ----- RESPONSIVE ----- */
@media (max-width: 780px) {
  .app-header { padding: 14px 20px; }
  .app-main { padding: 32px 20px 60px; }
  .step { padding: 20px 20px 24px; }
  .gen-row { flex-direction: column; align-items: stretch; gap: 14px; }
  .field-small { max-width: none; }
  .login-card { padding: 32px 24px; }
  h1 { font-size: 36px; }
  .tag-subtle { display: none; }
}
