:root {
  --brown: #3e2513;
  --brown-2: #5a3a22;
  --cream: #f3e3d8;
  --paper: #f7f3f0;
  --card: #ffffff;
  --ink: #201b18;
  --muted: #504c49;
  --line: #e5e0df;
  --ok: #3f7a4f;
  --warn: #a4581c;
  --bad: #a3322a;
  --radius: 14px;
  --serif: "Source Serif 4", Georgia, serif;
  --display: "Platypi", Georgia, serif;
  --ui: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--ui); font-size: 16px; line-height: 1.55; }
h1, h2, h3 { font-family: var(--display); color: var(--brown); line-height: 1.2; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: clamp(1.5rem, 3.4vw, 2rem); }
button { font: inherit; cursor: pointer; }

/* ---------- Top bar ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 24px; background: var(--brown); color: var(--cream); }
.brand { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-family: var(--display); font-size: 1.2rem; font-weight: 600; color: #fff; }
.brand span { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
.save-status { font-size: .82rem; opacity: .85; }
.save-status.bad { color: #ffd2c9; opacity: 1; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 32px; max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; }
.steps ol { list-style: none; margin: 0; padding: 0; position: sticky; top: 24px; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding: 7px 0 7px 38px; font-size: .94rem; color: var(--muted); }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 5px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 600; background: var(--card); border: 1.5px solid var(--line); color: var(--muted); }
.steps li.done::before { content: "✓"; background: var(--cream); border-color: var(--cream); color: var(--brown); }
.steps li.now { color: var(--brown); font-weight: 600; }
.steps li.now::before { background: var(--brown); border-color: var(--brown); color: #fff; }
.steps button { all: unset; cursor: pointer; }
.steps button:hover, .steps button:focus-visible { text-decoration: underline; }
.mobile-progress { display: none; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(20px, 4vw, 40px); box-shadow: 0 1px 2px rgba(62, 37, 19, .04), 0 8px 24px rgba(62, 37, 19, .05); }
.card + .card { margin-top: 24px; }
.eyebrow { font-size: .78rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--brown-2); margin: 0 0 10px; }
.lead { font-family: var(--serif); font-size: 1.15rem; color: var(--ink); }
.intro { font-family: var(--serif); font-size: 1.08rem; background: var(--paper); border-left: 3px solid var(--cream); padding: 12px 16px; border-radius: 0 8px 8px 0; margin: 0 0 20px; }
.question { font-family: var(--serif); font-weight: 600; font-size: clamp(1.3rem, 3vw, 1.65rem); color: var(--ink); }
.hint { color: var(--muted); margin: -4px 0 16px; }
.tip, .note { font-size: .9rem; color: var(--muted); }
.note-box { background: var(--paper); border-radius: 10px; padding: 12px 16px; margin-top: 16px; }
.what-you-get { background: var(--paper); border-radius: 12px; padding: 18px 22px; margin: 20px 0; }
.what-you-get h2 { font-size: 1.1rem; }
.checks { list-style: none; padding: 0; margin: 12px 0; }
.checks li { position: relative; padding: 4px 0 4px 28px; }
.checks li::before { content: "✓"; position: absolute; left: 4px; color: var(--ok); font-weight: 700; }

/* ---------- Inputs ---------- */
textarea, input[type=text] { width: 100%; font: inherit; font-family: var(--serif); font-size: 1.05rem; line-height: 1.6; color: var(--ink); background: #fffdfb; border: 1.5px solid var(--line); border-radius: 10px; padding: 14px 16px; resize: vertical; transition: border-color .15s, box-shadow .15s; }
input[type=text] { padding: 10px 14px; }
textarea:focus, input[type=text]:focus { outline: none; border-color: var(--brown-2); box-shadow: 0 0 0 3px rgba(90, 58, 34, .15); }
textarea.mono { font-family: ui-monospace, Menlo, monospace; font-size: .9rem; }
.shake { animation: shake .35s; border-color: var(--bad); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.form { display: grid; gap: 20px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; }
.field > span, .field legend { font-weight: 600; color: var(--ink); padding: 0; }
.field small { color: var(--muted); font-size: .88rem; margin-top: -2px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.opt { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 999px; background: #fffdfb; font-size: .95rem; cursor: pointer; }
.opt:has(input:checked) { border-color: var(--brown); background: var(--cream); }
.opt input[type=checkbox], .opt input[type=radio] { accent-color: var(--brown); }
.opt.other { margin-top: 8px; border-radius: 10px; width: 100%; }
.opt.other input { border: 0; padding: 4px 6px; background: transparent; }
.opt.other input:focus { box-shadow: none; }
.form-error { color: var(--bad); font-weight: 500; }

.choices { display: grid; gap: 12px; margin: 8px 0 4px; }
.choice { text-align: left; display: grid; gap: 2px; padding: 18px 20px; border: 1.5px solid var(--line); border-radius: 12px; background: #fffdfb; transition: border-color .15s, background .15s, transform .1s; }
.choice strong { font-size: 1.08rem; color: var(--ink); }
.choice span { color: var(--muted); font-size: .92rem; }
.choice:hover { border-color: var(--brown-2); }
.choice.picked { border-color: var(--brown); background: var(--cream); }
.choice:active { transform: scale(.99); }

/* ---------- Buttons ---------- */
.actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.actions.left { justify-content: flex-start; }
.actions .right { display: flex; gap: 10px; flex-wrap: wrap; margin-left: auto; justify-content: flex-end; }
.btn { border: 1.5px solid transparent; border-radius: 10px; padding: 11px 18px; font-weight: 600; font-size: .96rem; line-height: 1.2; transition: background .15s, border-color .15s, color .15s; }
.btn.primary { background: var(--brown); color: #fff; }
.btn.primary:hover { background: var(--brown-2); }
.btn.secondary { background: var(--cream); color: var(--brown); }
.btn.secondary:hover { border-color: var(--brown-2); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--brown); background: var(--paper); }
.btn:focus-visible, .choice:focus-visible { outline: 3px solid rgba(90, 58, 34, .35); outline-offset: 2px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---------- Drafts ---------- */
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.badge { font-size: .8rem; font-weight: 600; background: var(--paper); color: var(--ok); border-radius: 999px; padding: 4px 10px; }
.badge.warn { color: var(--warn); }
.draft { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px; }
.streaming:empty { display: none; }
.prose { font-family: var(--serif); font-size: 1.07rem; line-height: 1.7; overflow-wrap: anywhere; }
.prose h1 { font-size: 1.8rem; margin-top: 1.2em; }
.prose h2 { font-size: 1.4rem; margin-top: 1.4em; }
.prose h3 { font-size: 1.15rem; margin-top: 1.3em; }
.prose h4 { font-size: 1.02rem; margin-top: 1.2em; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose li { margin: .25em 0; }
.prose a { color: var(--brown-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose blockquote { margin: 1em 0; padding: 4px 16px; border-left: 3px solid var(--cream); color: var(--muted); }
.prose table { border-collapse: collapse; width: 100%; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.review { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 20px; }
.check { font-family: var(--serif); font-size: 1.12rem; font-weight: 600; color: var(--ink); margin: 0 0 8px; }
.panel { background: var(--paper); border-radius: 12px; padding: 18px; margin-top: 12px; }
.panel .actions { margin-top: 14px; }
.error { background: #fbeeec; border: 1px solid #efc9c4; color: var(--bad); border-radius: 12px; padding: 14px 18px; margin: 16px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.error p { margin: 0; }

.busy { display: flex; align-items: center; gap: 12px; color: var(--brown-2); font-weight: 500; }
.dots { width: 34px; height: 10px; background: radial-gradient(circle closest-side, var(--brown-2) 90%, transparent) 0 50% / 10px 10px no-repeat, radial-gradient(circle closest-side, var(--brown-2) 90%, transparent) 50% 50% / 10px 10px no-repeat, radial-gradient(circle closest-side, var(--brown-2) 90%, transparent) 100% 50% / 10px 10px no-repeat; animation: dots 1.2s infinite linear; flex: none; }
@keyframes dots { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.search-log { list-style: none; padding: 0; margin: 8px 0 16px; display: grid; gap: 4px; font-size: .94rem; }
.search-log li { position: relative; padding-left: 26px; color: var(--muted); }
.search-log li.ok::before { content: "✓"; position: absolute; left: 4px; color: var(--ok); font-weight: 700; }
.search-log li.spin::before { content: ""; position: absolute; left: 3px; top: .35em; width: 12px; height: 12px; border: 2px solid var(--cream); border-top-color: var(--brown-2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dots, .search-log li.spin::before, .shake { animation: none; } }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; padding: 16px 16px 60px; gap: 0; }
  .steps { display: none; }
  .topbar { padding: 12px 16px; }
  .mobile-progress { display: block; padding: 12px 16px 0; font-size: .85rem; color: var(--muted); }
  .mobile-progress .bar { height: 6px; background: var(--line); border-radius: 999px; margin-top: 6px; overflow: hidden; }
  .mobile-progress .bar i { display: block; height: 100%; background: var(--brown); border-radius: 999px; transition: width .3s; }
  .actions .right { width: 100%; margin-left: 0; }
  .actions .right .btn { flex: 1 1 auto; }
  .actions .right .btn.primary { order: -1; flex-basis: 100%; }
}

/* ---------- Print: just the playbook ---------- */
@media print {
  body { background: #fff; }
  .topbar, .steps, .mobile-progress, .card.done { display: none !important; }
  .layout { display: block; padding: 0; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .prose { font-size: 11.5pt; }
  .prose h2 { break-before: page; }
}
