:root {
  color-scheme: dark;

  --bg: #0b0d0c;
  --bg-raised: #131614;
  --line: #262b27;
  --line-bright: #3a4138;

  --ink: #e7ede6;
  --ink-dim: #8a9389;
  --ink-faint: #5b6459;

  --amber: #f0a73c;
  --amber-dim: #8a6324;
  --green: #5fd38a;
  --green-dim: #2b5c3e;
  --red: #e2574c;
  --red-dim: #6b2c27;

  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, "Courier New", monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px) 0;
  position: relative;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 28px 28px;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---------- topbar ---------- */

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}

.topbar-id { display: flex; align-items: center; gap: 12px; }

.topbar h1 {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.18em;
  margin: 0;
  color: var(--ink);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink-faint);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.03);
  transition: background 0.3s;
}
.dot.running { background: var(--amber); animation: pulse 1.4s ease-in-out infinite; }
.dot.success { background: var(--green); }
.dot.failed, .dot.error { background: var(--red); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240,167,60,0.5); }
  50% { box-shadow: 0 0 0 6px rgba(240,167,60,0); }
}

.topbar-status {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 3px;
  background: var(--bg-raised);
}

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

.deck {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 32px 20px;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 28px;
  align-items: start;
}

@media (max-width: 860px) {
  .deck { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 26px;
  position: relative;
}

.panel::before {
  content: "";
  position: absolute;
  top: -1px; left: 18px;
  width: 36px; height: 2px;
  background: var(--amber);
}

.panel-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  text-transform: uppercase;
  margin: 0 0 20px;
}

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

fieldset.account {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 16px 16px 12px;
  margin: 0 0 16px;
}

fieldset.account legend {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  padding: 0 6px;
}

.field {
  display: block;
  margin-bottom: 12px;
}
.field:last-child { margin-bottom: 0; }

.field span {
  display: block;
  font-size: 12px;
  color: var(--ink-dim);
  margin-bottom: 6px;
}
.field span small { color: var(--ink-faint); font-size: 11px; }

.field input, .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-bright);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  padding: 9px 10px;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus, .field select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(240,167,60,0.12);
}

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M0 0L5 6L10 0Z' fill='%238a9389'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 10px 6px;
  padding-right: 30px;
}

.arrow {
  display: flex;
  justify-content: center;
  color: var(--ink-faint);
  margin: -4px 0 12px;
}

.dry-run {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--ink-dim);
  margin: 4px 0 20px;
  cursor: pointer;
}
.dry-run input { accent-color: var(--amber); width: 15px; height: 15px; }

.run-btn {
  width: 100%;
  background: var(--amber);
  color: #1a1304;
  border: none;
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 13px;
  text-transform: uppercase;
  padding: 13px;
  border-radius: 4px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.run-btn:hover { filter: brightness(1.08); }
.run-btn:active { transform: scale(0.99); }
.run-btn:disabled { background: var(--line-bright); color: var(--ink-faint); cursor: not-allowed; }

.form-error {
  color: var(--red);
  font-size: 12.5px;
  margin-top: 12px;
  font-family: var(--mono);
}

/* ---------- run panel ---------- */

.progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.progress-track {
  flex: 1;
  height: 10px;
  background: var(--bg);
  border: 1px solid var(--line-bright);
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--amber-dim), var(--amber));
  transition: width 0.3s ease, background 0.3s;
  border-radius: 5px 0 0 5px;
}
.progress-fill.success { background: linear-gradient(90deg, var(--green-dim), var(--green)); }
.progress-fill.failed { background: linear-gradient(90deg, var(--red-dim), var(--red)); }

.progress-label {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-dim);
  min-width: 90px;
  text-align: right;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
}

.stop-btn {
  background: transparent;
  border: 1px solid var(--red-dim);
  color: var(--red);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.stop-btn:hover { background: rgba(226,87,76,0.1); }

.console {
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
  background: #070808;
}

.console-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
}

.console-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--line-bright);
}

.console-title {
  margin-left: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

.console-body {
  margin: 0;
  padding: 16px;
  height: 420px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: #b7d9c0;
  white-space: pre-wrap;
  word-break: break-word;
}

.console-body::-webkit-scrollbar { width: 9px; }
.console-body::-webkit-scrollbar-track { background: transparent; }
.console-body::-webkit-scrollbar-thumb {
  background: var(--line-bright);
  border-radius: 5px;
}

.console-body .line-error { color: var(--red); }
.console-body .line-warn { color: var(--amber); }
.console-body .line-ok { color: var(--green); }

.footnote {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 32px 32px;
  font-size: 11.5px;
  color: var(--ink-faint);
  font-family: var(--mono);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: dark;
  }
}
