/* Operon — Single-Point-of-Failure Continuity, on-device buyer surface.
   Theme-aware (light "document-review" default + dark), tokens mirror DESIGN.md. Self-contained:
   the whole diagnostic runs on the buyer's device; this stylesheet dresses the wizard + the draft. */

:root {
  --surface: #f6f7f9; --sheet: #fcfcfd; --inset: #eef0f4;
  --ink: #16181d; --ink-2: #555b66; --ink-3: #676d78;
  --accent: #4650c8; --accent-wash: #e8eafb; --accent-bright: #5a63e0;
  --line: #e3e5ea; --line-strong: #cdd0d8;
  --danger: #b3261e; --danger-wash: #f7e8e6; --danger-line: #e7c4bf;
  --warn: #8a5a0b; --ok: #1b7440; --ok-wash: #e3f1e8;
  --on-accent: #ffffff;
  --r-card: 12px; --r-sm: 9px; --r-pill: 999px;
  --measure: 40em;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #08090b; --sheet: #0e0f11; --inset: #191b1f;
    --ink: #f4f5f7; --ink-2: #9c9fa5; --ink-3: #86898e;
    --accent: #7b87ff; --accent-wash: #181b2d; --accent-bright: #9d8bff;
    --line: #1e1f21; --line-strong: #2f3032;
    --danger: #ff9a9a; --danger-wash: #241416; --danger-line: #4a2725;
    --warn: #d9b36a; --ok: #8fd0a0; --ok-wash: #14231a;
    --on-accent: #0a0a14;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --surface: #08090b; --sheet: #0e0f11; --inset: #191b1f;
  --ink: #f4f5f7; --ink-2: #9c9fa5; --ink-3: #86898e;
  --accent: #7b87ff; --accent-wash: #181b2d; --accent-bright: #9d8bff;
  --line: #1e1f21; --line-strong: #2f3032;
  --danger: #ff9a9a; --danger-wash: #241416; --danger-line: #4a2725;
  --warn: #d9b36a; --ok: #8fd0a0; --ok-wash: #14231a;
  --on-accent: #0a0a14;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --surface: #f6f7f9; --sheet: #fcfcfd; --inset: #eef0f4;
  --ink: #16181d; --ink-2: #555b66; --ink-3: #676d78;
  --accent: #4650c8; --accent-wash: #e8eafb; --accent-bright: #5a63e0;
  --line: #e3e5ea; --line-strong: #cdd0d8;
  --danger: #b3261e; --danger-wash: #f7e8e6; --danger-line: #e7c4bf;
  --warn: #8a5a0b; --ok: #1b7440; --ok-wash: #e3f1e8;
  --on-accent: #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--surface); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  padding: 28px 20px 72px;
}
@media (prefers-reduced-motion: no-preference) {
  .fade { animation: fade .28s ease both; }
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.wrap { max-width: 720px; margin: 0 auto; }

/* ---- shared wordmark / masthead ---- */
.wordmark {
  font-size: 13px; font-weight: 650; letter-spacing: .34em; color: var(--accent);
  display: inline-flex; align-items: center; gap: 9px;
}
.wordmark .orbit { width: 13px; height: 13px; position: relative; display: inline-block; }
.wordmark .orbit::before { content: ""; position: absolute; inset: 0; border: 1.5px solid var(--accent); border-radius: 50%; opacity: .5; }
.wordmark .orbit::after { content: ""; position: absolute; width: 4px; height: 4px; background: var(--accent); border-radius: 50%; top: -1px; left: 4.5px; }
.eyebrow { font-size: 12.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }

/* ================= WIZARD ================= */
.card {
  background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: clamp(24px, 4vw, 40px);
  box-shadow: 0 1px 2px rgba(10,11,20,.04), 0 14px 44px -26px rgba(10,11,20,.18);
}
:root[data-theme="dark"] .card, .card { }
@media (prefers-color-scheme: dark) { .card { box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 22px 60px -34px rgba(0,0,0,.7); } }
:root[data-theme="dark"] .card { box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 22px 60px -34px rgba(0,0,0,.7); }

/* intro */
.intro .wordmark { margin-bottom: 22px; }
.intro h1 {
  font-size: clamp(26px, 4.4vw, 34px); font-weight: 640; line-height: 1.14; letter-spacing: -.025em;
  margin: 0 0 14px; color: var(--ink); text-wrap: balance;
}
.intro p { color: var(--ink-2); max-width: var(--measure); margin: 0 0 14px; }
.intro .assurances { list-style: none; margin: 20px 0 26px; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.intro .assurances li { position: relative; padding-left: 28px; color: var(--ink-2); font-size: 14.5px; }
.intro .assurances li svg { position: absolute; left: 0; top: 2px; width: 18px; height: 18px; color: var(--accent); }
.intro .est { font-size: 13px; color: var(--ink-3); margin: 0 0 24px; }

/* progress */
.progress { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.progress .bar { flex: 1; height: 6px; background: var(--inset); border-radius: var(--r-pill); overflow: hidden; }
.progress .bar > span { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); transition: width .3s ease; }
.progress .count { font-family: var(--mono); font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; flex: none; }

.step .q-elicit { margin-bottom: 10px; }
.step h2 {
  font-size: clamp(20px, 3.2vw, 25px); font-weight: 640; line-height: 1.28; letter-spacing: -.02em;
  margin: 0 0 22px; color: var(--ink); text-wrap: balance; max-width: 20ch;
}
.step .hint { font-size: 13.5px; color: var(--ink-3); margin: -14px 0 20px; }

/* choice options */
.choices { display: flex; flex-direction: column; gap: 10px; margin: 0 0 8px; }
.choice {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left; cursor: pointer;
  background: var(--sheet); border: 1.5px solid var(--line); border-radius: var(--r-card);
  padding: 15px 17px; color: var(--ink); font: inherit; font-size: 15.5px;
  transition: border-color .12s, background .12s;
}
.choice:hover { border-color: var(--line-strong); }
.choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice .tick {
  flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line-strong);
  display: grid; place-items: center; transition: border-color .12s, background .12s;
}
.choice .tick::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: transparent; transition: background .12s; }
.choice[aria-checked="true"] { border-color: var(--accent); background: var(--accent-wash); }
.choice[aria-checked="true"] .tick { border-color: var(--accent); }
.choice[aria-checked="true"] .tick::after { background: var(--accent); }

/* text input */
.field { display: flex; flex-direction: column; gap: 8px; }
.field textarea, .field input[type="text"] {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--sheet);
  border: 1.5px solid var(--line-strong); border-radius: var(--r-sm); padding: 13px 15px; resize: vertical;
}
.field textarea { min-height: 96px; line-height: 1.5; }
.field textarea:focus, .field input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.field .counter { align-self: flex-end; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.field .counter.over { color: var(--danger); }
.optional-tag { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); background: var(--inset); border-radius: var(--r-pill); padding: 3px 9px; margin-left: 8px; vertical-align: middle; }

.err { color: var(--danger); font-size: 13.5px; margin: 14px 0 0; min-height: 1.2em; }

/* nav */
.nav { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 30px; }
.btn {
  font: inherit; font-size: 15px; font-weight: 600; border-radius: var(--r-sm); padding: 12px 22px;
  cursor: pointer; border: 1.5px solid transparent; transition: background .12s, border-color .12s, opacity .12s;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-bright); border-color: var(--accent-bright); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink-3); color: var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-link { background: none; border: none; color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 6px 4px; }
.btn-link:hover { text-decoration: underline; }

/* review step */
.review-list { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; margin: 0 0 8px; }
.review-row { display: grid; grid-template-columns: 1fr auto; gap: 12px 16px; padding: 13px 16px; border-bottom: 1px solid var(--line); align-items: start; }
.review-row:last-child { border-bottom: none; }
.review-row .rq { font-size: 13px; color: var(--ink-3); }
.review-row .ra { font-size: 14.5px; color: var(--ink); }
.review-row .edit { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

/* building state */
.building { text-align: center; padding: 40px 0; }
.building .spin { width: 30px; height: 30px; border: 3px solid var(--inset); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto 18px; }
@media (prefers-reduced-motion: no-preference) { .building .spin { animation: spin .8s linear infinite; } }
@keyframes spin { to { transform: rotate(360deg); } }
.building p { color: var(--ink-2); margin: 0; }

/* ================= RESULT (the draft) ================= */
.result-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px;
}
.result-bar .grow { flex: 1 1 auto; }
.on-device {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ok);
  background: var(--ok-wash); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  padding: 5px 12px; border-radius: var(--r-pill);
}
.on-device svg { width: 14px; height: 14px; }

.sheet {
  background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: clamp(26px, 4.5vw, 54px);
  box-shadow: 0 1px 2px rgba(10,11,20,.04), 0 12px 40px -24px rgba(10,11,20,.18);
}
@media (prefers-color-scheme: dark) { .sheet { box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 20px 60px -30px rgba(0,0,0,.7); } }
:root[data-theme="dark"] .sheet { box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 20px 60px -30px rgba(0,0,0,.7); }

.sheet p { margin: 0 0 1em; max-width: var(--measure); color: var(--ink-2); }
.sheet strong { color: var(--ink); font-weight: 600; }

.doc-masthead { border-bottom: 1px solid var(--line); padding-bottom: 26px; margin-bottom: 30px; }
.doc-masthead .wordmark { margin-bottom: 20px; }
.doc-masthead h1 {
  font-size: clamp(25px, 4vw, 34px); font-weight: 640; line-height: 1.12; letter-spacing: -.025em;
  margin: 12px 0 12px; color: var(--ink); text-wrap: balance; max-width: 15ch;
}
.doc-meta { display: flex; flex-wrap: wrap; gap: 9px 15px; align-items: center; font-size: 13.5px; color: var(--ink-3); }
.doc-meta .tenant { font-family: var(--mono); font-size: 12.5px; }
.risk-flag {
  display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 12.5px;
  padding: 4px 11px; border-radius: var(--r-pill);
}
.risk-flag .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.risk-flag.spof { color: var(--danger); background: var(--danger-wash); border: 1px solid var(--danger-line); }
.risk-flag.thin { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.risk-flag.resilient { color: var(--ok); background: var(--ok-wash); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }

.honest { margin: 24px 0 4px; background: var(--accent-wash); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r-sm); padding: 16px 18px; }
.honest .lab { font-weight: 600; color: var(--ink); font-size: 14.5px; margin: 0 0 6px; max-width: none; }
.honest p { font-size: 14px; margin: 0; max-width: none; color: var(--ink-2); }

.boundary { margin: 30px 0; background: var(--inset); border: 1px solid var(--line); border-radius: var(--r-card); padding: 22px 24px; }
.boundary h2 { font-size: 13px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 12px; }
.boundary p { font-size: 14.5px; margin: 0 0 10px; }
.boundary .close { color: var(--ink); font-weight: 500; margin: 14px 0 0; }
.no-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.no-list li { position: relative; padding-left: 26px; font-size: 14.5px; color: var(--ink-2); max-width: var(--measure); }
.no-list li::before { content: ""; position: absolute; left: 0; top: 8px; width: 14px; height: 2px; background: var(--ink-3); border-radius: 2px; }

.doc-section { margin: 38px 0; }
.sec-head { display: flex; align-items: baseline; gap: 14px; margin: 0 0 16px; }
.sec-num { flex: none; font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--accent); width: 26px; height: 26px; display: grid; place-items: center; background: var(--accent-wash); border-radius: 7px; transform: translateY(-2px); }
.sec-head h2 { font-size: 20px; font-weight: 640; letter-spacing: -.02em; line-height: 1.3; margin: 0; color: var(--ink); text-wrap: balance; }
.sec-head .sub { display: block; font-size: 14px; font-weight: 400; color: var(--ink-3); margin-top: 2px; }
.sec-body { padding-left: 40px; }
@media (max-width: 540px) { .sec-body { padding-left: 0; } }

.map { display: grid; grid-template-columns: minmax(130px, auto) 1fr; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; margin: 0 0 20px; }
.map dt { padding: 11px 16px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); background: var(--inset); border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.map dd { padding: 11px 16px; margin: 0; font-size: 14.5px; color: var(--ink); border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.map dt:last-of-type, .map dd:last-of-type { border-bottom: none; }
@media (max-width: 540px) { .map { grid-template-columns: 1fr; } .map dt { border-bottom: none; padding-bottom: 2px; background: transparent; } .map dd { padding-top: 2px; } .map dd:not(:last-of-type) { border-bottom: 1px solid var(--line); } }

.callout { border-radius: var(--r-card); padding: 16px 18px; margin: 0 0 8px; display: flex; gap: 13px; align-items: flex-start; }
.callout p { margin: 0; color: var(--ink); font-size: 14.5px; max-width: none; }
.callout .ic { flex: none; width: 20px; height: 20px; margin-top: 2px; }
.callout.spof { background: var(--danger-wash); border: 1px solid var(--danger-line); }
.callout.spof .ic { color: var(--danger); }
.callout.plain { background: var(--inset); border: 1px solid var(--line); }
.callout.plain .ic { color: var(--accent); }

.sheet blockquote { margin: 0 0 18px; padding: 2px 0 2px 18px; border-left: 3px solid var(--accent); }
.sheet blockquote p { color: var(--ink); font-style: italic; max-width: var(--measure); margin: 0; }

ul.check { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 11px; }
ul.check li { display: flex; gap: 12px; align-items: flex-start; }
ul.check input[type="checkbox"] {
  flex: none; appearance: none; -webkit-appearance: none; margin: 2px 0 0; width: 17px; height: 17px;
  border: 1.5px solid var(--line-strong); border-radius: 5px; background: var(--sheet); cursor: pointer; position: relative;
}
ul.check input[type="checkbox"]:hover { border-color: var(--accent); }
ul.check input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
ul.check input[type="checkbox"]:checked::after { content: ""; position: absolute; left: 5px; top: 1.5px; width: 4px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(42deg); }
ul.check input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
ul.check label { font-size: 14.5px; color: var(--ink-2); line-height: 1.5; }
ul.check li:has(input:checked) label { color: var(--ink-3); }

.proposals { display: flex; flex-direction: column; gap: 12px; margin: 0 0 16px; }
.proposal { border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px 16px; display: flex; gap: 13px; align-items: flex-start; background: var(--sheet); }
.chip { flex: none; font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); background: var(--accent-wash); border-radius: var(--r-pill); padding: 4px 9px; margin-top: 1px; }
.proposal p { margin: 0; font-size: 14.5px; color: var(--ink-2); max-width: none; }

.phases { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.phase { border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.phase-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--inset); border-bottom: 1px solid var(--line); }
.phase-head .days { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-wash); padding: 3px 9px; border-radius: var(--r-pill); flex: none; }
.phase-head .name { font-size: 14px; font-weight: 600; color: var(--ink); }
.phase ul { margin: 0; padding: 14px 18px 14px 34px; display: flex; flex-direction: column; gap: 9px; }
.phase li { font-size: 14.5px; color: var(--ink-2); line-height: 1.5; }

ul.qs { margin: 0 0 16px; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
ul.qs li { font-size: 14.5px; color: var(--ink-2); line-height: 1.5; }
.lead { font-size: 14.5px; margin: 0 0 14px; }
.close-note { font-size: 14px; color: var(--ink-3); margin: 0; max-width: var(--measure); }

.doc-foot { margin-top: 44px; padding-top: 24px; border-top: 1px solid var(--line); }
.doc-foot p { font-size: 13px; color: var(--ink-3); line-height: 1.65; max-width: none; margin: 0; }
.doc-foot .own { color: var(--ink-2); font-weight: 500; }

/* print: just the draft */
@media print {
  body { padding: 0; background: #fff; }
  .result-bar, .app-footer { display: none !important; }
  .sheet { border: none; box-shadow: none; padding: 0; }
}

.app-footer { text-align: center; margin: 28px auto 0; max-width: 720px; font-size: 12px; color: var(--ink-3); }
.app-footer a { color: var(--accent); }

/* end-of-draft upsell (funnel exit — the section-6 bridge to the flagship) */
.upsell { max-width: 768px; margin: 20px auto 0; background: var(--accent-wash); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r-card); padding: 22px 24px; }
.upsell h3 { margin: 0 0 8px; font-size: 16px; font-weight: 640; color: var(--ink); letter-spacing: -.01em; }
.upsell p { margin: 0 0 14px; font-size: 14.5px; color: var(--ink-2); max-width: var(--measure); }
.upsell-cta { display: inline-flex; align-items: center; gap: 6px; font-size: 14.5px; font-weight: 600; color: var(--accent); text-decoration: none; }
.upsell-cta:hover { text-decoration: underline; }
@media print { .upsell { display: none !important; } }

/* opt-in capture band (funnel exit — BUILT-INERT until activation) */
.capture { max-width: 768px; margin: 20px auto 0; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-card); padding: 22px 24px; }
.capture h3 { margin: 0 0 8px; font-size: 16px; font-weight: 640; color: var(--ink); letter-spacing: -.01em; }
.capture > p { margin: 0 0 14px; font-size: 14.5px; color: var(--ink-2); max-width: var(--measure); }
.capture-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.capture-row input[type="email"] { flex: 1 1 240px; font: inherit; font-size: 15px; color: var(--ink); background: var(--sheet); border: 1.5px solid var(--line-strong); border-radius: var(--r-sm); padding: 11px 14px; }
.capture-row input[type="email"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.capture-consent { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--ink-3); line-height: 1.45; }
.capture-consent input { margin-top: 2px; flex: none; }
.capture-fine { margin: 10px 0 0; font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }
.capture-msg { margin: 10px 0 0; font-size: 13.5px; min-height: 1.1em; color: var(--ink-2); }
.capture-msg.err { color: var(--danger); }
.capture-ok { margin: 0; font-size: 14.5px; color: var(--ok); font-weight: 500; }
@media print { .capture { display: none !important; } }
