:root {
  --ink: #0f1d2e;
  --muted: #5a6b7e;
  --faint: #8da0b3;
  --mist: #f3f7fb;
  --card: #ffffff;
  --line: #dfe8f1;
  --line-soft: #eaf1f7;
  --signal: #2e8fe0;
  --signal-deep: #1f6fb8;
  --signal-tint: #e9f4fe;
  --go: #1e9d66;
  --go-tint: #e7f6ef;
  --warn: #8a6512;
  --warn-tint: #fcf4e2;
  --danger: #c24b3f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 29, 46, 0.05), 0 6px 18px rgba(15, 29, 46, 0.06);
  --font-display: "Sora", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--mist);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 296px 1fr; min-height: 100vh; }
.main { display: flex; flex-direction: column; min-width: 0; }
.screen-wrap { flex: 1; padding: 44px 48px 120px; display: flex; justify-content: center; }
.screen { width: 100%; max-width: 780px; animation: rise 0.28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Rail ---------- */
.rail {
  background: #0e1b2c;
  color: #cfe0f0;
  padding: 28px 0 28px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.rail-head { padding: 0 24px 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.rail-mark { font-family: var(--font-display); font-weight: 700; font-size: 18px; color: #fff; letter-spacing: 0.2px; }
.rail-mark span { color: var(--signal); }
.rail-sub { font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.6px; color: #6f86a0; margin-top: 2px; }
.rail-client { margin-top: 14px; }
.rail-client .name { font-family: var(--font-display); font-weight: 600; font-size: 15px; color: #fff; word-break: break-word; }
.rail-client .chips { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.rail-chip { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.6px; padding: 3px 8px; border-radius: 99px; background: rgba(46,143,224,0.18); color: #8fc4f2; }

.rail-section { padding: 16px 24px 4px; }
.rail-label { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 1.6px; color: #6f86a0; margin-bottom: 8px; }
.rail-steps { list-style: none; margin: 0; padding: 0; }
.rail-steps li { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 13px; color: #8da3ba; cursor: pointer; }
.rail-steps li .dot { width: 7px; height: 7px; border-radius: 99px; background: #33485f; flex: none; }
.rail-steps li.current { color: #fff; font-weight: 600; }
.rail-steps li.current .dot { background: var(--signal); box-shadow: 0 0 0 3px rgba(46,143,224,0.25); }
.rail-steps li.done { color: #9fc0de; }
.rail-steps li.done .dot { background: var(--go); }

.build-list { list-style: none; margin: 0; padding: 0; position: relative; }
.build-list::before { content: ""; position: absolute; left: 10px; top: 8px; bottom: 8px; width: 1px; background: rgba(255,255,255,0.1); }
.build-list li {
  position: relative; padding: 7px 0 7px 30px; font-size: 13px; color: #aebfd2;
  animation: slideIn 0.22s ease both; cursor: default;
}
.build-list li.jump { cursor: pointer; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
.build-list .idx {
  position: absolute; left: 0; top: 9px; width: 21px; height: 21px; border-radius: 99px;
  background: #16273c; border: 1px solid #2c4259; color: #7e97b1;
  font-family: var(--font-mono); font-size: 9.5px; display: flex; align-items: center; justify-content: center;
}
.build-list li.configuring { color: #fff; font-weight: 600; }
.build-list li.configuring .idx { border-color: var(--signal); color: var(--signal); }
.build-list li.done { color: #8fb89f; }
.build-list li.done .idx { background: rgba(30,157,102,0.18); border-color: rgba(30,157,102,0.55); color: #5ecf9a; }
.build-empty { font-size: 12.5px; color: #5d7390; padding-left: 2px; font-style: italic; }

/* ---------- Screen typography ---------- */
.eyebrow { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: var(--signal-deep); margin-bottom: 10px; }
h1.title { font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1.18; margin: 0 0 8px; letter-spacing: -0.3px; }
.lede { color: var(--muted); font-size: 15.5px; margin: 0 0 28px; max-width: 60ch; }
.csd-note { font-size: 13px; color: var(--faint); font-style: italic; margin: -16px 0 26px; }

/* ---------- Cards & blocks ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px 26px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 17px; }
.card-sub { color: var(--muted); font-size: 13.5px; margin: 2px 0 16px; }
.mono-chip { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.4px; color: var(--signal-deep); background: var(--signal-tint); padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.block-q { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin: 0 0 4px; }
.helper { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.divider { border: 0; border-top: 1px solid var(--line-soft); margin: 22px 0; }

/* ---------- Fields ---------- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
label.flabel { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 7px; }
label.flabel .opt { color: var(--faint); font-weight: 400; }
input[type="text"], input[type="number"], input[type="url"], input[type="email"], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 13px;
}
textarea { min-height: 82px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #a9b8c6; }
input:focus, textarea:focus, select:focus { border-color: var(--signal); outline: none; box-shadow: 0 0 0 3px rgba(46,143,224,0.14); }
.input-xl { font-size: 19px; padding: 14px 16px; font-family: var(--font-display); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- Pills (radio groups) ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 9px; }
.pill {
  border: 1px solid var(--line); background: #fff; border-radius: 99px;
  padding: 8px 15px; font-size: 13.5px; font-weight: 500; cursor: pointer; color: var(--ink);
  display: inline-flex; align-items: center; gap: 7px; transition: border-color 0.15s, background 0.15s;
}
.pill:hover { border-color: var(--signal); }
.pill.on { border-color: var(--signal); background: var(--signal-tint); color: var(--signal-deep); font-weight: 600; }
.pill .rec { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--go); background: var(--go-tint); padding: 2px 6px; border-radius: 99px; }
.pill-reason { font-size: 12.5px; color: var(--faint); margin-top: 8px; }

/* ---------- Choice cards (checkbox grids) ---------- */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 760px) { .choices { grid-template-columns: 1fr; } }
.choice {
  display: flex; gap: 11px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; background: #fff; transition: border-color 0.15s, background 0.15s;
}
.choice:hover { border-color: var(--signal); }
.choice.on { border-color: var(--signal); background: var(--signal-tint); }
.choice.dim { opacity: 0.45; pointer-events: none; }
.choice input { margin-top: 3px; accent-color: var(--signal); }
.choice .c-label { font-weight: 600; font-size: 14px; }
.choice .c-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.pick-count { font-family: var(--font-mono); font-size: 11.5px; color: var(--signal-deep); margin-top: 10px; }

/* ---------- Toggle rows ---------- */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; }
.toggle-row + .toggle-row { border-top: 1px solid var(--line-soft); }
.toggle-row .t-label { font-weight: 600; font-size: 14px; }
.toggle-row .t-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.switch { position: relative; width: 42px; height: 24px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.switch .knob {
  position: absolute; inset: 0; background: #cfdae5; border-radius: 99px; transition: background 0.15s;
}
.switch .knob::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 99px;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: transform 0.15s;
}
.switch input:checked + .knob { background: var(--signal); }
.switch input:checked + .knob::after { transform: translateX(18px); }

/* ---------- Recommended badge & notes ---------- */
.badge-rec { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--go); background: var(--go-tint); padding: 2.5px 8px; border-radius: 99px; vertical-align: middle; }
.note { background: var(--signal-tint); border: 1px solid #cfe6fa; color: var(--signal-deep); border-radius: 10px; padding: 11px 14px; font-size: 13px; margin: 14px 0 0; }
.note.warn { background: var(--warn-tint); border-color: #f0e2bd; color: var(--warn); }
.undoc { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.5px; color: var(--warn); background: var(--warn-tint); padding: 3px 8px; border-radius: 99px; }

/* ---------- Advanced ---------- */
details.adv { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 12px; }
details.adv summary {
  cursor: pointer; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--faint); list-style: none; display: flex; align-items: center; gap: 6px;
}
details.adv summary::before { content: "▸"; transition: transform 0.15s; }
details.adv[open] summary::before { transform: rotate(90deg); }
details.adv .adv-body { padding-top: 14px; }

/* ---------- Dest summary ---------- */
.dest-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--mist); border: 1px solid var(--line-soft); border-radius: 9px; padding: 10px 13px; font-size: 13.5px; }
.dest-line .where { font-weight: 600; }
.linkish { background: none; border: none; color: var(--signal-deep); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Footer bar ---------- */
.footbar {
  position: sticky; bottom: 0; background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: 14px 48px; display: flex; align-items: center; gap: 16px;
}
.footbar .spacer { flex: 1; }
.step-ind { font-family: var(--font-mono); font-size: 11.5px; color: var(--faint); letter-spacing: 0.5px; }
.email-chip { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.4px; color: var(--signal-deep); background: var(--signal-tint); border: 1px solid #cfe6fa; padding: 5px 11px; border-radius: 99px; }
.email-chip.hot { color: var(--warn); background: var(--warn-tint); border-color: #f0e2bd; }
.btn {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 11px 22px; cursor: pointer; border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--signal); color: #fff; }
.btn-primary:hover { background: var(--signal-deep); }
.btn-primary:disabled { background: #b9d4eb; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--signal); }
.btn-danger { background: #fff; color: var(--danger); border-color: #ecd1cd; }
.btn-danger:hover { border-color: var(--danger); }
.btn-lg { font-size: 16px; padding: 14px 28px; font-family: var(--font-display); }

/* ---------- Start screen ---------- */
.start-hero { text-align: left; padding-top: 24px; }
.start-hero .mark { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--signal-deep); letter-spacing: 0.3px; margin-bottom: 22px; }
.start-hero h1 { font-size: 38px; max-width: 16ch; }
.resume-bar { display: flex; align-items: center; gap: 14px; background: var(--signal-tint); border: 1px solid #cfe6fa; border-radius: 10px; padding: 12px 16px; margin-bottom: 22px; font-size: 14px; color: var(--signal-deep); flex-wrap: wrap; }

/* ---------- Review / recap ---------- */
.recap-block { margin-bottom: 14px; }
.recap-auto { border-left: 3px solid var(--signal); padding: 4px 0 4px 16px; margin-bottom: 18px; }
.recap-auto .ra-name { font-family: var(--font-display); font-weight: 600; font-size: 15.5px; }
.recap-auto .ra-sent { font-size: 14px; color: var(--ink); margin: 3px 0 6px; }
.recap-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.rchip { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.4px; padding: 3px 8px; border-radius: 99px; background: var(--mist); border: 1px solid var(--line-soft); color: var(--muted); }
.rchip.blue { background: var(--signal-tint); color: var(--signal-deep); border-color: #cfe6fa; }
.rchip.green { background: var(--go-tint); color: var(--go); border-color: #cdeadd; }
.kvline { font-size: 13px; color: var(--muted); margin: 2px 0; }
.kvline b { color: var(--ink); font-weight: 600; }

.success-wrap { text-align: center; padding: 60px 0; }
.success-wrap .big-check { width: 64px; height: 64px; border-radius: 99px; background: var(--go-tint); color: var(--go); display: inline-flex; align-items: center; justify-content: center; font-size: 30px; margin-bottom: 18px; }
.success-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.record-id { font-family: var(--font-mono); font-size: 12px; color: var(--faint); margin-top: 10px; }

/* ---------- Admin ---------- */
.admin-shell { max-width: 1000px; margin: 0 auto; padding: 44px 28px 80px; }
.admin-top { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
table.subs { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.subs th { text-align: left; font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--faint); padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--mist); }
table.subs td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
table.subs tr.rowlink { cursor: pointer; }
table.subs tr.rowlink:hover td { background: var(--signal-tint); }
.gate { max-width: 420px; margin: 12vh auto 0; }
pre.jsonview { background: #0e1b2c; color: #cfe0f0; border-radius: var(--radius); padding: 20px; font-family: var(--font-mono); font-size: 12px; overflow: auto; max-height: 480px; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 26px; }
.muted { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: relative; height: auto; max-height: 38vh; }
  .screen-wrap { padding: 28px 20px 110px; }
  .footbar { padding: 12px 20px; }
}
