/* ClauseBuilder: a typeset agreement on a desk. Oxblood, brass and warm paper. */

:root {
  --serif: "Iowan Old Style", Charter, "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: "Avenir Next", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --desk: #ecdfd6;
  --desk-deep: #dfcec4;
  --panel: #f7eee8;
  --paper: #fffdf8;
  --ink: #251a18;
  --ink-2: #5d4b45;
  --rule: #d6c2b6;
  --rule-strong: #a58d80;
  --accent: #6e1423;
  --accent-deep: #540d19;
  --accent-text: #6e1423;
  --on-accent: #fff6ea;
  --accent-wash: #f4e4df;
  --brass: #8a5d12;
  --brass-wash: #f6ead0;
  --fill: #f4ead2;
  --hot: #f2cd6b;
  --gap-bg: #fbdf9c;
  --gap-ink: #5c3a00;
  --ok: #2c5a38;
  --error: #a3161f;
  --mast: #6e1423;
  --mark-paper: #fff6ea;
  --mark-ink: #6e1423;
  --mark-seal: #c9952f;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #1e1215;
    --desk-deep: #170d10;
    --panel: #281a1d;
    --paper: #2f2022;
    --ink: #f2e7da;
    --ink-2: #c9b5aa;
    --rule: #4b3237;
    --rule-strong: #7a5a5d;
    --accent: #a12c3d;
    --accent-deep: #8a2233;
    --accent-text: #f0a3ab;
    --on-accent: #fff6ea;
    --accent-wash: #3c1c22;
    --brass: #e0b057;
    --brass-wash: #3a2c18;
    --fill: #43301f;
    --hot: #8a6414;
    --gap-bg: #6b4a08;
    --gap-ink: #ffe9b8;
    --ok: #9fd0a8;
    --error: #ff9c9c;
    --mast: #2a0d13;
    --mark-paper: #f2e7da;
    --mark-ink: #6e1423;
    --mark-seal: #e0b057;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --desk: #1e1215;
  --desk-deep: #170d10;
  --panel: #281a1d;
  --paper: #2f2022;
  --ink: #f2e7da;
  --ink-2: #c9b5aa;
  --rule: #4b3237;
  --rule-strong: #7a5a5d;
  --accent: #a12c3d;
  --accent-deep: #8a2233;
  --accent-text: #f0a3ab;
  --on-accent: #fff6ea;
  --accent-wash: #3c1c22;
  --brass: #e0b057;
  --brass-wash: #3a2c18;
  --fill: #43301f;
  --hot: #8a6414;
  --gap-bg: #6b4a08;
  --gap-ink: #ffe9b8;
  --ok: #9fd0a8;
  --error: #ff9c9c;
  --mast: #2a0d13;
  --mark-paper: #f2e7da;
  --mark-ink: #6e1423;
  --mark-seal: #e0b057;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.5;
}
[hidden] { display: none !important; }
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.2; margin: 0; }
p { margin: 0 0 1rem; }
a { color: var(--accent-text); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -100px; z-index: 50; background: var(--paper); color: var(--ink); padding: 12px 16px; border: 2px solid var(--brass); }
.skip:focus { top: 8px; }

/* ---------- masthead ---------- */
.masthead { background: var(--mast); color: var(--on-accent); }
.masthead-in { max-width: 85rem; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; color: inherit; text-decoration: none; }
.brand-name { font-family: var(--serif); font-size: 1.375rem; font-weight: 700; letter-spacing: 0.005em; }
.brand-name span { font-weight: 400; font-style: italic; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { color: inherit; text-decoration: none; padding: 10px 12px; border-radius: 4px; font-size: 1rem; }
.nav a:hover { background: rgba(255, 246, 234, 0.14); }
.theme-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; background: transparent; color: inherit; border: 1px solid rgba(255, 246, 234, 0.45); border-radius: 4px; font: inherit; font-size: 0.9375rem; cursor: pointer; }
.theme-btn:hover { background: rgba(255, 246, 234, 0.14); }
.masthead :focus-visible { outline-color: #f2cd6b; }

/* ---------- workbench ---------- */
.workbench { max-width: 85rem; margin: 0 auto; padding: 0 24px; display: grid; grid-template-columns: minmax(0, 24.5rem) minmax(0, 1fr); gap: 32px; align-items: start; }
.questions { padding: 32px 0 48px; min-width: 0; }
h1 { font-size: clamp(2rem, 1.5rem + 1vw, 2.375rem); letter-spacing: -0.01em; margin-bottom: 16px; text-wrap: balance; }
.lead { font-size: 1.0625rem; color: var(--ink-2); max-width: 34rem; }
.example-note { border-left: 3px solid var(--mark-seal); background: var(--brass-wash); padding: 10px 14px; font-size: 0.9375rem; }
.notice { border-left: 3px solid var(--error); background: var(--panel); padding: 10px 14px; font-size: 0.9375rem; }

.step { border: 0; padding: 0; margin: 32px 0 0; min-width: 0; }
.step > legend, .step > h2 { display: flex; align-items: center; gap: 12px; padding: 0; margin: 0 0 12px; font-family: var(--serif); font-size: 1.375rem; font-weight: 700; }
.step-n { display: inline-grid; place-items: center; width: 32px; height: 32px; background: var(--accent); color: var(--on-accent); font-family: var(--serif); font-size: 1.0625rem; font-weight: 700; border-radius: 3px; flex: none; }
.hint { color: var(--ink-2); font-size: 0.9375rem; margin-bottom: 16px; }

.type-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-choice { position: relative; display: block; padding: 12px 12px 12px 40px; border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--panel); cursor: pointer; transition: background-color 160ms, border-color 160ms; }
.type-choice input { position: absolute; left: 12px; top: 15px; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.type-choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-wash); }
.type-choice:has(input:focus-visible) { outline: 3px solid var(--brass); outline-offset: 2px; }
.type-name { display: block; font-weight: 600; line-height: 1.3; }
.type-hint { display: block; font-size: 0.875rem; color: var(--ink-2); line-height: 1.35; margin-top: 4px; }
.caution { margin: 12px 0 0; border-left: 3px solid var(--mark-seal); background: var(--brass-wash); padding: 10px 14px; font-size: 0.9375rem; }

/* ---------- clause cards and fields ---------- */
.cards { list-style: none; margin: 0; padding: 0; }
.card { border: 1px solid var(--rule); border-left: 3px solid var(--accent); background: var(--panel); border-radius: 0 4px 4px 0; margin: 0 0 8px; transition: opacity 160ms; }
.card.is-off { border-left-color: var(--rule-strong); border-style: dashed; border-left-style: solid; background: transparent; }
.card.is-off .card-title { color: var(--ink-2); font-weight: 400; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px; min-height: 52px; }
.card-toggle { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 44px; cursor: pointer; }
.card-toggle input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }
.card-num { font-family: var(--serif); font-variant-numeric: tabular-nums; color: var(--accent-text); font-weight: 700; min-width: 1.6em; }
.card-num:empty { display: none; }
.card-title { font-family: var(--serif); font-size: 1.0625rem; font-weight: 700; margin: 0; }
h3.card-title { flex: 1; padding: 10px 0; }
.card-fixed { font-size: 0.8125rem; color: var(--ink-2); white-space: nowrap; }
.card-pre .card-fixed { padding-right: 8px; }
.card-moves { display: flex; flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: var(--ink); border-radius: 4px; cursor: pointer; }
.icon-btn:hover:not(:disabled) { background: var(--accent-wash); color: var(--accent-text); }
.icon-btn:disabled { color: var(--rule-strong); cursor: default; }
.card-moves .icon-btn { width: 44px; }
.card-body { padding: 4px 16px 16px; border-top: 1px solid var(--rule); }

.field { margin-top: 14px; }
.field label { display: block; font-weight: 600; font-size: 0.9375rem; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="date"], input[type="number"], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 4px;
}
textarea { resize: vertical; line-height: 1.45; min-height: 5.5rem; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-2); }
.field.is-missing input, .field.is-missing textarea { background: var(--brass-wash); border-color: var(--mark-seal); border-style: dashed; }
[aria-invalid="true"] { border-color: var(--error) !important; border-style: solid !important; }
.with-unit { display: flex; align-items: stretch; max-width: 17rem; }
.with-unit input { border-radius: 0; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; min-width: 0; }
.with-unit input:first-child { border-radius: 4px 0 0 4px; }
.with-unit input:last-child { border-radius: 0 4px 4px 0; }
.unit { display: grid; place-items: center; padding: 0 12px; background: var(--desk-deep); border: 1px solid var(--rule-strong); font-size: 0.9375rem; color: var(--ink-2); white-space: nowrap; }
.unit:first-child { border-right: 0; border-radius: 4px 0 0 4px; }
.unit:last-child { border-left: 0; border-radius: 0 4px 4px 0; }
.field-text input[maxlength="5"] { max-width: 7rem; }
.help { font-size: 0.875rem; color: var(--ink-2); margin: 4px 0 0; }
.error { font-size: 0.875rem; color: var(--error); font-weight: 600; margin: 4px 0 0; }
.status { font-size: 0.875rem; color: var(--ink-2); margin: 10px 0 0; }

.parties { margin-top: 16px; border-top: 1px solid var(--rule); padding-top: 4px; }
.parties summary, .faq summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; font-weight: 600; list-style: none; }
.parties summary::-webkit-details-marker, .faq summary::-webkit-details-marker { display: none; }
.parties summary::before, .faq summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--accent-text); border-bottom: 2px solid var(--accent-text); transform: rotate(-45deg); transition: transform 160ms; flex: none; margin-right: 4px; }
.parties[open] summary::before, .faq details[open] summary::before { transform: rotate(45deg); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; font: inherit; font-size: 0.9375rem; font-weight: 600; color: var(--ink); background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 4px; cursor: pointer; text-decoration: none; transition: background-color 160ms, border-color 160ms; }
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); font-weight: 400; text-decoration: underline; text-underline-offset: 3px; padding: 0 10px; }
.btn-quiet:hover { color: var(--ink); border-color: var(--rule-strong); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.quiet-row { margin-top: 16px; }
.with-btn { display: flex; gap: 8px; }
.with-btn input { flex: 1; min-width: 0; }
.with-btn .btn { flex: none; }

.draft-list { list-style: none; margin: 16px 0 0; padding: 0; border-top: 1px solid var(--rule); }
.draft-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.draft-info { min-width: 0; }
.draft-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.draft-meta { display: block; font-size: 0.875rem; color: var(--ink-2); }
.draft-actions { display: flex; gap: 4px; flex: none; }
#draft-empty { margin-top: 12px; }

/* ---------- preview pane ---------- */
.preview { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 16px 0; min-width: 0; }
.toolbar { flex: none; padding-bottom: 12px; }
.toolbar-title { font-size: 1.375rem; margin-bottom: 10px; }
.draft-close, .card-open, .checklist-more { display: none; }
.card-flag { font-family: var(--sans); font-size: 0.8125rem; font-weight: 600; color: var(--gap-ink); background: var(--gap-bg); padding: 1px 6px; margin-left: 10px; border-radius: 3px; white-space: nowrap; vertical-align: 2px; }
.card-flag:empty { display: none; }
.guide-caveat { font-size: 0.9375rem; color: var(--ink-2); border-left: 3px solid var(--mark-seal); padding-left: 12px; }

.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.btn-main { min-height: 48px; padding: 0 20px; font-size: 1rem; gap: 10px; }
.btn-group { display: flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 4px 0 0 4px; }
.btn-group .btn:last-child { border-radius: 0 4px 4px 0; margin-left: -1px; }
.btn-group .btn:hover, .btn-group .btn:focus-visible { position: relative; z-index: 1; }
.other-formats { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; margin-top: 6px; font-size: 0.9375rem; color: var(--ink-2); }
.text-btn { min-height: 44px; padding: 0 8px; font: inherit; color: var(--accent-text); background: transparent; border: 0; border-radius: 4px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.text-btn:hover { text-decoration-thickness: 2px; background: var(--accent-wash); }
.toolbar-opts { display: flex; flex-wrap: wrap; gap: 0 24px; margin-top: 0; }
.check { display: inline-flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 0; cursor: pointer; font-size: 0.9375rem; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.legal-line { font-size: 0.875rem; color: var(--ink-2); margin: 0; }
.legal-line strong { color: var(--accent-text); }
.export-status { font-size: 0.9375rem; font-weight: 600; color: var(--ok); margin: 6px 0 0; min-height: 0; }
.export-status:empty { display: none; }
.summary { font-size: 0.9375rem; margin: 6px 0 0; min-height: 1.5em; line-height: 1.9; }
.progress-panel { margin: 0 0 12px; }
.pp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 0 6px; }
.pp-count { font-family: var(--serif); font-size: 1.125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pp-fig { font-variant-numeric: tabular-nums lining-nums; }
.pp-clauses { font-size: 0.9375rem; color: var(--ink-2); }
.pp-bar { height: 8px; background: var(--desk-deep); border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.pp-fill { display: block; height: 100%; width: 0; background: var(--mark-seal); transition: width 200ms; }
.pp-bar.is-done .pp-fill { background: var(--ok); }
.summary-note { display: block; color: var(--ink-2); font-size: 0.875rem; line-height: 1.5; }
.gap-chip.is-invalid { border-bottom-color: var(--error); color: var(--error); }
.mobile-progress { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mobile-track { display: block; width: 9rem; max-width: 100%; height: 6px; background: var(--desk-deep); border-radius: 3px; overflow: hidden; }
.mobile-fill { display: block; height: 100%; width: 0; background: var(--mark-seal); transition: width 200ms; }
.summary .ok { color: var(--ok); font-weight: 600; }
/* Missing-answer buttons: the visible chip is small, the button around it is a 44px target that does not change the line height. */
.link-btn, .gap { font: inherit; color: inherit; background: none; border: 0; padding: 12px 0; margin: -12px 1px; cursor: pointer; border-radius: 3px; }
.link-btn .gap-chip { color: var(--gap-ink); background: var(--gap-bg); border-bottom: 1px dashed var(--gap-ink); padding: 1px 6px; border-radius: 3px; }
.link-btn:hover .gap-chip { border-bottom-style: solid; }

.preview-scroll { flex: 1; min-height: 0; overflow-y: auto; background: var(--desk-deep); border: 1px solid var(--rule); border-radius: 4px; padding: 16px; container-type: inline-size; scrollbar-gutter: stable; }
.sheet { position: relative; max-width: 53rem; min-height: 40rem; margin: 0 auto; padding: 56px 28px 48px 40px; background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-bottom-width: 3px; font-family: var(--serif); font-size: 1.0625rem; line-height: 1.55; }
.sheet.no-notes { max-width: 42rem; padding-right: 40px; }
.sheet p { margin: 0 0 0.55rem; }
.stamp { position: absolute; top: 18px; right: 20px; margin: 0; padding: 3px 10px; border: 2px solid var(--accent-text); color: var(--accent-text); font-family: var(--sans); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; transform: rotate(2deg); }
.doc-title { font-size: 1.625rem; text-align: center; margin: 12px 0 24px; text-wrap: balance; }
.doc-pre { margin-bottom: 8px; }
.cl { margin-top: 22px; }
.cl h4 { display: grid; grid-template-columns: 2.9rem minmax(0, 1fr); font-size: 1.0625rem; font-variant-caps: small-caps; letter-spacing: 0.05em; margin-bottom: 6px; }
.sub { display: grid; grid-template-columns: 2.9rem minmax(0, 1fr); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "lnum"; }
.cl h4 .num { color: var(--accent-text); font-variant-caps: normal; letter-spacing: 0; }
.sub-text { overflow-wrap: anywhere; hyphens: auto; }
.term { font-weight: 700; }
.fill { text-decoration: underline dotted var(--mark-seal) 1.5px; text-underline-offset: 4px; border-radius: 2px; transition: background-color 220ms; }
.fill.is-hot { background: var(--hot); }
.gap { vertical-align: baseline; hyphens: none; min-width: 44px; }
.gap .gap-chip { display: inline-block; font-family: var(--sans); font-size: 0.8125rem; font-weight: 600; line-height: 1.3; color: var(--gap-ink); background: var(--gap-bg); border: 1px dashed var(--gap-ink); border-radius: 3px; padding: 2px 8px; transition: background-color 220ms; }
.gap .gap-chip::before { content: "Missing: "; font-weight: 400; }
.gap:hover .gap-chip, .gap.is-hot .gap-chip { border-style: solid; background: var(--hot); }
.note { margin: 10px 0 0 2.9rem; padding: 10px 12px; border-left: 2px solid var(--mark-seal); background: var(--brass-wash); font-family: var(--sans); font-size: 0.875rem; line-height: 1.45; color: var(--ink); }
.note p { margin: 0 0 6px; }
.note p:last-child { margin: 0; }
.note strong { display: block; font-size: 0.8125rem; color: var(--brass); }
.no-notes .note { display: none; }
.sig { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 36px; }
.sig-who { font-weight: 700; }
.sig-line { border-bottom: 1px solid var(--ink); padding-top: 22px; font-family: var(--sans); font-size: 0.8125rem; color: var(--ink-2); }
.doc-notes { margin-top: 40px; padding: 12px 16px; border-top: 3px double var(--ink); border-bottom: 1px solid var(--rule-strong); background: var(--panel); font-family: var(--sans); font-size: 0.875rem; line-height: 1.5; color: var(--ink); }
.doc-notes p { margin: 0 0 4px; }
.doc-notes-title { font-family: var(--serif); font-size: 1rem; font-weight: 700; margin-bottom: 6px !important; }
.ack { margin: 12px 0 4px; padding: 12px 16px; border: 2px solid var(--accent); border-radius: 4px; background: var(--paper); }
.ack-title { font-family: var(--serif); font-size: 1.0625rem; font-weight: 700; margin: 0; }
.ack .check { display: flex; font-size: 0.9375rem; }
.ack .btn-row { margin-top: 4px; }
.ack .error { margin: 0 0 4px; }
.footer-terms { font-weight: 600; }

/* Notes move into the margin when the sheet is wide enough. */
@container (min-width: 42rem) {
  .sheet:not(.no-notes) .cl { display: grid; grid-template-columns: minmax(0, 1fr) 12.5rem; gap: 0 24px; align-items: start; }
  .sheet:not(.no-notes) .note { margin: 2px 0 0; background: transparent; padding: 0 0 0 12px; }
  .sheet:not(.no-notes) .doc-title, .sheet:not(.no-notes) .doc-pre, .sheet:not(.no-notes) .sig, .sheet:not(.no-notes) .doc-notes { margin-right: calc(12.5rem + 24px); }
  .cl .sub-text { text-align: justify; }
}

/* ---------- checklist band ---------- */
.band { background: var(--paper); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin-top: 32px; }
.band-in { max-width: 85rem; margin: 0 auto; padding: 48px 24px; }
.checklist-wrap { display: grid; grid-template-columns: minmax(0, 24rem) minmax(0, 1fr); gap: 48px; align-items: start; }
.band h2, .guide h2 { font-size: clamp(1.625rem, 1.2rem + 1.2vw, 2.125rem); margin-bottom: 12px; }
.checklist-head p { color: var(--ink-2); }
.progress-line { margin-bottom: 6px; }
.count { font-family: var(--serif); font-size: 1.25rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.progress { height: 10px; background: var(--desk-deep); border: 1px solid var(--rule); margin-bottom: 12px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 220ms; }
.checklist { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.checklist li { border-bottom: 1px solid var(--rule); }
.checklist .check { display: flex; padding: 12px 4px; font-size: 1.0625rem; font-family: var(--serif); }
.checklist input:checked + span { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--rule-strong); }

/* ---------- guide ---------- */
.guide { max-width: 85rem; margin: 0 auto; padding: 56px 24px 0; }
.guide > * { max-width: 44rem; }
.guide > .guide-cols { max-width: none; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 0 64px; align-items: start; }
.guide-side .glossary > div { grid-template-columns: 8rem minmax(0, 1fr); }
.guide-lead { font-family: var(--serif); font-size: 1.25rem; line-height: 1.5; }
.guide h3 { font-size: 1.375rem; margin: 40px 0 12px; }
.guide ul { padding-left: 1.25rem; margin: 0 0 1rem; }
.guide li { margin-bottom: 8px; }
.guide dl { margin: 0; border-top: 2px solid var(--ink); }
.guide dl > div { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.guide dt { font-family: var(--serif); font-weight: 700; color: var(--accent-text); }
.guide dd { margin: 0; }
.faq { padding-bottom: 64px; }
.faq details { border-bottom: 1px solid var(--rule); }
.faq details:first-of-type { border-top: 2px solid var(--ink); }
.faq summary { font-family: var(--serif); font-size: 1.125rem; padding: 8px 0; }
.faq details p { padding: 0 0 8px 24px; }

/* ---------- footer ---------- */
.footer { background: var(--mast); color: var(--on-accent); }
.footer-in { max-width: 85rem; margin: 0 auto; padding: 40px 24px 48px; }
.footer p { max-width: 46rem; font-size: 0.9375rem; }
.footer-brand { font-family: var(--serif); font-size: 1.25rem; font-weight: 700; }

/* ---------- footer links, text pages, ad slots ---------- */
.footer a { color: inherit; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 0 24px; margin: 8px 0; }
.footer-nav a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
.footer-small { font-size: 0.875rem; margin: 0; opacity: 0.85; }
.page { max-width: 85rem; margin: 0 auto; padding: 32px 24px 72px; }
.page > * { max-width: 42rem; }
.page h1 { margin-bottom: 20px; }
.page h2 { font-size: 1.5rem; margin: 40px 0 12px; }
.page ul { padding-left: 1.25rem; margin: 0 0 1rem; }
.page li { margin-bottom: 8px; }
.page-lead { font-family: var(--serif); font-size: 1.25rem; line-height: 1.5; }
.page-small { font-size: 0.9375rem; color: var(--ink-2); }
.crumbs { font-size: 0.9375rem; color: var(--ink-2); margin-bottom: 12px; }
.crumbs a { display: inline-flex; align-items: center; min-height: 44px; }
.plain-warning { border-left: 3px solid var(--accent); background: var(--accent-wash); padding: 4px 20px 8px; margin-top: 32px; }
.plain-warning h2 { margin-top: 16px; }
.delete-box { border: 1px solid var(--rule-strong); background: var(--panel); border-radius: 4px; padding: 16px; margin-top: 16px; }
.delete-box p { margin: 0 0 12px; }
.delete-box .btn-row { margin-top: 0; }
.delete-box .status { margin: 10px 0 0; color: var(--ok); font-weight: 600; font-size: 0.9375rem; }
.delete-box .status:empty { display: none; }
.ad-slot { max-width: calc(85rem - 48px); margin: 48px auto 0; padding: 8px 0 12px; min-height: 120px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); overflow: hidden; }
.ad-slot + .footer, main > .ad-slot:last-child { margin-bottom: 48px; }
.ad-label { font-size: 0.75rem; color: var(--ink-2); text-align: center; margin: 0 0 8px; }
@media (max-width: 85rem) { .ad-slot { margin-left: 24px; margin-right: 24px; } }
@media (max-width: 62rem) { .ad-slot { margin-left: 16px; margin-right: 16px; } .page { padding: 24px 16px 56px; } body.plain { padding-bottom: 0; } }
@media (max-width: 600px) { .ad-slot { min-height: 280px; } }

/* ---------- article page and sibling links ---------- */
.byline { font-size: 0.9375rem; color: var(--ink-2); margin: -8px 0 20px; }
.article section h2 { font-size: 1.375rem; }
.ticklist { list-style: none; padding-left: 0 !important; }
.ticklist li { position: relative; padding-left: 28px; }
.ticklist li::before { content: ""; position: absolute; left: 6px; top: 0.62em; width: 8px; height: 8px; background: var(--accent-text); transform: rotate(45deg); }
.article .ad-slot { margin-left: 0; margin-right: 0; max-width: 42rem; }
.more-tools { background: var(--panel); border-top: 1px solid var(--rule); }
.more-in { max-width: 85rem; margin: 0 auto; padding: 32px 24px; }
.more-in h2 { font-size: 1.375rem; margin-bottom: 8px; }
.more-in ul { list-style: none; margin: 0; padding: 0; max-width: 46rem; }
.more-in li { padding: 6px 0; border-bottom: 1px solid var(--rule); }
.more-in li:last-child { border-bottom: 0; }
.more-in a { font-family: var(--serif); font-weight: 700; display: inline; padding: 10px 0; }
.more-in li { line-height: 1.6; padding: 10px 0; }
@media (max-width: 62rem) { .more-in { padding: 28px 16px; } }

/* ---------- mobile bar and toast ---------- */
.mobile-bar { display: none; }
/* Wide screens: the draft pane is sticky beside the questions. Once it has scrolled out of view
   (guide, checklist, FAQ), the same progress bar appears at the bottom. */
@media (min-width: 62.0625rem) {
  body:not(.plain) { padding-bottom: 66px; }
  body.bar-desk .mobile-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; justify-content: center; gap: 32px; padding: 7px 24px; background: var(--paper); border-top: 2px solid var(--accent); font-size: 0.9375rem; font-weight: 600; }
  body.bar-desk .bar-fig { font-family: var(--serif); font-size: 1.375rem; font-weight: 700; font-variant-numeric: tabular-nums lining-nums; color: var(--ink); }
  .pp-fig { font-size: 2rem; line-height: 1.1; }
}
/* Messages ("Cleared every answer. Undo") sit in a compact strip directly above the bottom bar
   (or the bottom edge when there is none), never over the middle of the form. */
.toast { position: fixed; left: 50%; bottom: calc(var(--bar-h, 0px) + 12px); transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px); padding: 4px 4px 4px 16px; background: var(--ink); color: var(--desk); border-radius: 4px; font-size: 0.9375rem; }
.toast .btn { min-height: 44px; }
.toast .icon-btn { color: inherit; width: 44px; height: 44px; }
.toast .icon-btn:hover { background: transparent; color: var(--mark-seal); }

/* ---------- narrower screens ---------- */
@media (max-width: 62rem) {
  .workbench { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 16px; }
  .questions { padding: 24px 0 32px; }
  /* The draft is a full-screen layer opened from the bottom bar. */
  .preview { display: none; }
  body.draft-open { overflow: hidden; }
  body.draft-open .preview { display: block; position: fixed; inset: 0; z-index: 35; height: auto; overflow-y: auto; overscroll-behavior: contain; background: var(--desk); padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
  .toolbar-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--desk); padding: 8px 0; margin-bottom: 4px; border-bottom: 1px solid var(--rule); }
  .toolbar-title { margin: 0; }
  .draft-close { display: inline-flex; }
  /* One card's questions at a time. */
  .card-open { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 44px; min-height: 44px; padding: 0 10px; margin-left: auto; font: inherit; color: var(--ink); background: transparent; border: 0; border-radius: 4px; cursor: pointer; }
  .card-open-label { color: var(--accent-text); font-size: 0.9375rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
  .card-flag { display: table; margin: 2px 0 0; }
  .card:not(.is-open) .card-body { display: none; }
  .card-pre .card-fixed { display: none; }
  .card-moves .icon-btn { width: 44px; }
  .card-head { padding-left: 10px; gap: 0; }
  .card-toggle { gap: 8px; }
  .checklist.is-short li:nth-child(n+4) { display: none; }
  .checklist-more { display: inline-flex; margin-top: 12px; }
  .preview-scroll { overflow: visible; padding: 12px; margin: 0 -8px; }
  .sheet { padding: 48px 20px 32px; }
  .sheet.no-notes { padding-right: 20px; }
  .masthead-in { padding: 8px 16px; gap: 8px; flex-wrap: wrap; }
  .nav { order: 3; width: 100%; margin: 0 -8px; flex-wrap: wrap; }
  .nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; white-space: nowrap; }
  .theme-btn { margin-left: auto; }
  .checklist-wrap { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .guide > .guide-cols { grid-template-columns: minmax(0, 1fr); max-width: 44rem; }
  .band-in { padding: 40px 16px; }
  .guide { padding: 40px 16px 0; }
  .footer-in { padding: 32px 16px 40px; }
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .mobile-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 16px calc(7px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 2px solid var(--accent); font-size: 0.9375rem; font-weight: 600; }
  .mobile-bar .btn { white-space: nowrap; flex: none; }
  .bar-fig { font-family: var(--serif); font-size: 1.375rem; font-weight: 700; font-variant-numeric: tabular-nums lining-nums; color: var(--ink); }
  body.draft-open .mobile-bar { visibility: hidden; }
  /* Typing: the bar sits at the top instead, out of the keyboard's way. */
  body.field-focus .mobile-bar { top: 0; bottom: auto; padding: calc(7px + env(safe-area-inset-top)) 16px 7px; border-top: 0; border-bottom: 2px solid var(--accent); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.04); }
  .pp-fig { font-size: 2rem; line-height: 1.1; }
  .toast { left: 0; right: 0; transform: none; max-width: none; bottom: calc(var(--bar-h, 0px) + env(safe-area-inset-bottom)); border-radius: 0; padding: 0 4px 0 16px; min-height: 48px; }
  body.field-focus .toast { bottom: env(safe-area-inset-bottom); }
  #toast-text { flex: 1; min-width: 0; }
}
@media (max-width: 30rem) {
  .type-options { grid-template-columns: minmax(0, 1fr); }
  .cl h4, .sub { grid-template-columns: 2.5rem minmax(0, 1fr); }
  .note { margin-left: 0; }
  .sub-text { hyphens: manual; }
  .sig { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .guide dl > div, .guide-side .glossary > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .toolbar-actions .btn-primary { width: 100%; }
  .btn-group { width: 100%; }
  .btn-group .btn { flex: 1; }
  .card-fixed { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

/* ---------- print: only the document (and the checklist when it is included) ---------- */
@media print {
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) {
    --paper: #fff; --ink: #000; --ink-2: #333; --rule: #999; --rule-strong: #666; --accent-text: #6e1423;
    color-scheme: light;
  }
  @page { margin: 22mm 20mm; }
  body { background: #fff; color: #000; padding: 0; font-size: 11.5pt; }
  .ad-slot { display: none !important; }
  .masthead, .skip, .questions, .toolbar, .guide, .footer, .mobile-bar, .toast, .note, .checklist-head p, .progress, #btn-uncheck { display: none !important; }
  .workbench { display: block; max-width: none; padding: 0; }
  body, body.draft-open { overflow: visible !important; }
  .preview, body.draft-open .preview { position: static !important; height: auto; display: block !important; padding: 0; overflow: visible; }
  .checklist.is-short li:nth-child(n+4) { display: list-item !important; }
  .checklist-more { display: none !important; }
  .preview-scroll { overflow: visible; background: none; border: 0; padding: 0; margin: 0; }
  .sheet, .sheet.no-notes { max-width: none; min-height: 0; padding: 0; border: 0; background: #fff; color: #000; font-size: 11.5pt; }
  .sheet .cl { display: block !important; }
  .sub { break-inside: avoid; }
  .sheet .doc-title, .sheet .doc-pre, .sheet .sig, .sheet .doc-notes { margin-right: 0 !important; }
  .doc-notes { background: none; break-inside: avoid; }
  .cl h4 { break-after: avoid; }
  .stamp { position: static; display: inline-block; transform: none; margin-bottom: 12pt; }
  .fill { background: none; text-decoration: none; }
  .gap { padding: 0; margin: 0 1px; }
  .gap .gap-chip { background: none; border: 0; border-bottom: 1px solid #000; border-radius: 0; color: transparent; min-width: 9em; }
  .gap .gap-chip::before { content: ""; }
  .sig { break-inside: avoid; }
  .band { display: none; border: 0; margin: 0; background: #fff; }
  .print-checklist .band { display: block; break-before: page; }
  .band-in { padding: 0; max-width: none; }
  .checklist-wrap { display: block; }
  .checklist input:checked + span { color: #000; text-decoration: none; }
}

/* Long URLs in running text must wrap on narrow phones. */
main p a, main li a, main dd a { overflow-wrap: anywhere; }
