:root {
  --paper: #f5efe3;
  --paper-deep: #eadfc9;
  --cream: #fffaf0;
  --white: #ffffff;
  --ink: #17263b;
  --navy: #17263b;
  --navy-soft: #263a54;
  --rust: #b65336;
  --rust-dark: #913f2b;
  --gold: #efc16e;
  --gold-soft: #ffe3a7;
  --teal: #2f7374;
  --plum: #80556d;
  --muted: #5d6572;
  --line: rgba(23, 38, 59, .16);
  --shadow-sm: 0 10px 30px rgba(23, 38, 59, .09);
  --shadow-lg: 0 22px 60px rgba(23, 38, 59, .16);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--cream); color: var(--ink); font-family: var(--sans); line-height: 1.6; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }
.shell { width: min(1180px, calc(100% - 2rem)); margin-inline: auto; }
.narrow { width: min(820px, calc(100% - 2rem)); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; left: 1rem; top: 1rem; padding: .7rem 1rem; border-radius: .6rem; background: var(--white); color: var(--ink); font-weight: 800; transform: translateY(-180%); }
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.site-header { border-bottom: 1px solid var(--line); background: rgba(255, 250, 240, .96); }
.header-inner { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.brand { display: inline-flex; flex-direction: column; text-decoration: none; line-height: 1.1; }
.brand-name { font-family: var(--serif); font-size: 1.35rem; font-weight: 800; letter-spacing: -.03em; }
.brand-tagline { margin-top: .25rem; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .04em; }
.utility-nav { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; }
.utility-nav a { font-size: .88rem; font-weight: 800; text-underline-offset: .24em; }

.hero { position: relative; overflow: hidden; padding: clamp(4.2rem, 8vw, 7.6rem) 0; background: radial-gradient(circle at 14% 18%, rgba(239, 193, 110, .24), transparent 25rem), linear-gradient(135deg, var(--navy), #203654); color: var(--white); }
.hero::after { content: ""; position: absolute; right: -10rem; bottom: -13rem; width: 32rem; height: 32rem; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; box-shadow: 0 0 0 4rem rgba(255,255,255,.025), 0 0 0 8rem rgba(255,255,255,.018); }
.hero-grid { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(290px, .8fr); gap: clamp(2rem, 7vw, 6rem); align-items: center; }
.eyebrow { margin: 0 0 .8rem; color: var(--rust); font-size: .75rem; line-height: 1.25; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.hero .eyebrow { color: var(--gold); }
h1, h2, h3 { margin-top: 0; font-family: var(--serif); line-height: 1.06; letter-spacing: -.035em; }
h1 { max-width: 12ch; margin-bottom: 1.25rem; font-size: clamp(3rem, 6.7vw, 6.25rem); }
h1 > span:first-of-type { color: var(--gold); }
h2 { font-size: clamp(2.15rem, 4.3vw, 4rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.55rem); }
p { margin-top: 0; }
.hero-lead { max-width: 58ch; margin-bottom: 1.65rem; color: rgba(255,255,255,.8); font-size: clamp(1.05rem, 1.7vw, 1.27rem); }
.hero-note { position: relative; padding: clamp(1.8rem, 4vw, 3.1rem); border: 1px solid rgba(255,255,255,.18); border-radius: 1.4rem; background: rgba(255,255,255,.07); box-shadow: var(--shadow-lg); transform: rotate(1deg); }
.hero-note::before { content: ""; position: absolute; inset: .6rem; border: 1px solid rgba(239,193,110,.25); border-radius: 1rem; pointer-events: none; }
.paper-tab { position: relative; display: inline-block; margin-bottom: 1.2rem; padding: .35rem .7rem; border-radius: 999px; background: var(--gold); color: var(--ink); font-size: .7rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.hero-note blockquote { position: relative; margin: 0 0 1rem; font-family: var(--serif); font-size: clamp(1.5rem, 3vw, 2.35rem); font-style: italic; line-height: 1.25; }
.hero-note p { position: relative; margin-bottom: 0; color: rgba(255,255,255,.72); font-size: .9rem; }

.button { display: inline-flex; min-height: 50px; align-items: center; justify-content: center; padding: .78rem 1.2rem; border: 2px solid var(--rust); border-radius: 999px; background: var(--rust); color: var(--white); font-weight: 850; line-height: 1.2; text-decoration: none; box-shadow: 0 8px 18px rgba(182,83,54,.18); transition: transform .18s ease, background .18s ease, border-color .18s ease; }
.button:hover, .button:focus-visible { background: var(--rust-dark); border-color: var(--rust-dark); transform: translateY(-2px); }
.button-light { border-color: var(--gold); background: var(--gold); color: var(--ink); box-shadow: none; }
.button-light:hover, .button-light:focus-visible { border-color: var(--white); background: var(--white); }
.button-secondary { border-color: var(--ink); background: transparent; color: var(--ink); box-shadow: none; }
.button-secondary:hover, .button-secondary:focus-visible { border-color: var(--ink); background: var(--ink); color: var(--white); }
.button-compact { min-height: 44px; padding: .63rem 1rem; font-size: .88rem; }
.text-button { min-height: 44px; border: 0; background: transparent; color: var(--rust-dark); font-weight: 850; text-decoration: underline; text-underline-offset: .25em; }

.trust-strip { padding: clamp(3.5rem, 7vw, 6rem) 0; background: var(--paper); }
.section-heading { max-width: 850px; margin-bottom: 2rem; }
.section-heading.compact h2 { margin-bottom: 0; font-size: clamp(2rem, 3.8vw, 3.4rem); }
.label-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.label-card { min-height: 180px; padding: 1.4rem; border: 1px solid var(--line); border-top: 5px solid; border-radius: 1rem; background: var(--white); box-shadow: var(--shadow-sm); }
.label-card-fact { border-top-color: var(--teal); }
.label-card-account { border-top-color: var(--plum); }
.label-card-reconstruction { border-top-color: var(--rust); }
.label-card p { margin: 1.05rem 0 0; color: var(--muted); font-size: .9rem; }
.source-pill { display: inline-flex; align-items: center; min-height: 27px; padding: .22rem .55rem; border-radius: 999px; color: var(--white); font-size: .65rem; font-weight: 900; letter-spacing: .08em; line-height: 1.2; text-transform: uppercase; }
.source-fact { background: var(--teal); }
.source-account { background: var(--plum); }
.source-reconstruction { background: var(--rust); }

.lab-section { padding: clamp(4rem, 8vw, 7.5rem) 0; background: var(--cream); }
.lab-layout { display: grid; grid-template-columns: minmax(250px, .62fr) minmax(0, 1.38fr); gap: clamp(2rem, 6vw, 5rem); align-items: start; }
.lab-intro { position: sticky; top: 1rem; }
.lab-intro h2 { margin-bottom: 1rem; font-size: clamp(2.15rem, 4.2vw, 3.65rem); }
.lab-intro > p:not(.eyebrow) { color: var(--muted); }
.step-list { margin: 2rem 0 0; padding: 0; list-style: none; }
.step-list li { display: grid; grid-template-columns: 2rem 1fr; gap: .8rem; align-items: center; padding: .9rem 0; border-top: 1px solid var(--line); font-size: .9rem; font-weight: 750; }
.step-list span { width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 50%; background: var(--navy); color: var(--gold); font-family: var(--serif); font-weight: 800; }
.story-form { padding: clamp(1.2rem, 3vw, 2.3rem); border: 1px solid var(--line); border-radius: 1.4rem; background: var(--white); box-shadow: var(--shadow-sm); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
.field-wide { grid-column: 1 / -1; }
.field label, .field-group legend { display: block; margin-bottom: .35rem; color: var(--ink); font-weight: 850; }
.field-help { margin: 0 0 .55rem; color: var(--muted); font-size: .79rem; line-height: 1.45; }
input, select, textarea { width: 100%; border: 1px solid rgba(23,38,59,.28); border-radius: .75rem; background: #fffdf8; color: var(--ink); }
input, select { min-height: 50px; padding: .72rem .8rem; }
textarea { min-height: 95px; padding: .78rem .85rem; resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: rgba(23,38,59,.48); }
input:focus, select:focus, textarea:focus { border-color: var(--rust); outline: 3px solid rgba(239,193,110,.42); outline-offset: 1px; }
.field-group { min-width: 0; margin: 0; padding: 1rem; border: 1px solid var(--line); border-left: 5px solid; border-radius: .85rem; background: #fffdf8; }
.field-group legend { max-width: calc(100% - 1rem); padding: 0 .3rem; }
.field-group legend .source-pill { margin-right: .35rem; vertical-align: .12em; }
.source-group-fact { border-left-color: var(--teal); }
.source-group-account { border-left-color: var(--plum); }
.source-group-reconstruction { border-left-color: var(--rust); }
.privacy-note { margin-top: 1.5rem; padding: 1.1rem 1.2rem; border-left: 5px solid var(--gold); border-radius: .25rem .8rem .8rem .25rem; background: var(--paper); }
.privacy-note strong { font-family: var(--serif); font-size: 1.15rem; }
.privacy-note p { margin: .25rem 0 0; color: var(--muted); font-size: .78rem; }
.privacy-note .save-status { color: var(--teal); font-weight: 800; }
.form-actions { margin-top: 1.4rem; display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.form-error { margin: 1rem 0 0; padding: .7rem .9rem; border-radius: .6rem; background: #fff0ec; color: #8a2f1e; font-weight: 800; }

.output-section { padding: clamp(4rem, 8vw, 7rem) 0; background: var(--paper); }
.output-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 1.5rem; }
.output-heading h2 { margin-bottom: .5rem; }
.output-heading p:last-child { margin-bottom: 0; color: var(--muted); }
.output-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: .65rem; }
.map-legend { display: flex; flex-wrap: wrap; gap: .65rem 1.2rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--white); font-size: .75rem; font-weight: 850; }
.map-legend span { display: inline-flex; align-items: center; gap: .45rem; }
.legend-dot { width: .75rem; height: .75rem; border-radius: 50%; }
.dot-fact { background: var(--teal); }
.dot-account { background: var(--plum); }
.dot-reconstruction { background: var(--rust); }
.map-guidance { margin: 1rem 0 1.4rem; display: flex; flex-wrap: wrap; gap: .35rem .6rem; color: var(--muted); font-size: .82rem; }
.map-guidance strong { color: var(--ink); }
.seed-map { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.spread-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-top: 5px solid var(--rust); border-radius: 1rem; background: var(--white); box-shadow: var(--shadow-sm); }
.spread-card[data-source="fact"] { border-top-color: var(--teal); }
.spread-card[data-source="account"] { border-top-color: var(--plum); }
.spread-card[data-source="reconstruction"] { border-top-color: var(--rust); }
.spread-head { min-height: 74px; padding: 1rem 1rem .8rem; display: flex; align-items: start; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); background: #fffdf8; }
.spread-number { display: block; color: var(--rust); font-size: .66rem; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.spread-head h3 { margin: .18rem 0 0; font-size: 1.28rem; }
.source-control { min-width: 155px; }
.source-control label { display: block; margin-bottom: .25rem; color: var(--muted); font-size: .62rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.source-control select { min-height: 36px; padding: .35rem .45rem; border-radius: .55rem; font-size: .72rem; font-weight: 800; }
.spread-copy { min-height: 150px; padding: 1rem; white-space: pre-wrap; }
.spread-copy:focus { outline: 3px solid rgba(239,193,110,.52); outline-offset: -3px; }
.spread-prompt { margin: 0; padding: .8rem 1rem 1rem; border-top: 1px dashed var(--line); color: var(--muted); font-size: .72rem; }
.spread-prompt strong { color: var(--ink); }
.print-credit { display: none; }
.after-value { margin-top: 2rem; padding: clamp(1.3rem, 3vw, 2rem); display: flex; align-items: center; justify-content: space-between; gap: 2rem; border-radius: 1.2rem; background: var(--navy); color: var(--white); box-shadow: var(--shadow-lg); }
.after-value .eyebrow { color: var(--gold); }
.after-value h3 { margin-bottom: .45rem; font-size: clamp(1.7rem, 3vw, 2.5rem); }
.after-value p:last-child { max-width: 58ch; margin-bottom: 0; color: rgba(255,255,255,.75); }
.after-value .button { flex: 0 0 auto; }

.research-section { padding: clamp(4rem, 8vw, 7rem) 0; background: var(--navy); color: var(--white); }
.research-grid { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(0, 1.2fr); gap: clamp(2.5rem, 7vw, 6rem); align-items: start; }
.research-section .eyebrow { color: var(--gold); }
.research-list article { display: grid; grid-template-columns: 3rem 1fr; gap: 1rem; padding: 1.3rem 0; border-top: 1px solid rgba(255,255,255,.17); }
.research-list article > span { color: var(--gold); font-family: var(--serif); font-size: 1.4rem; font-weight: 800; }
.research-list h3 { margin-bottom: .35rem; }
.research-list p { margin-bottom: 0; color: rgba(255,255,255,.7); font-size: .88rem; }
.faq-section { padding: clamp(4rem, 8vw, 7rem) 0; background: var(--cream); }
.faq-list { margin-top: 2rem; border-top: 1px solid var(--line); }
.faq-list details { border-bottom: 1px solid var(--line); }
.faq-list summary { padding: 1.15rem 2.4rem 1.15rem 0; position: relative; cursor: pointer; font-family: var(--serif); font-size: 1.2rem; font-weight: 800; }
.faq-list summary::after { content: "+"; position: absolute; right: .25rem; color: var(--rust); font-family: var(--sans); font-size: 1.5rem; }
.faq-list details[open] summary::after { content: "–"; }
.faq-list details p { padding: 0 2.5rem 1.2rem 0; color: var(--muted); }
.site-footer { padding: 2.5rem 0; border-top: 1px solid var(--line); background: var(--paper); }
.footer-inner { display: flex; justify-content: space-between; gap: 2rem; }
.brand-footer { margin-bottom: .75rem; }
.footer-inner p { max-width: 48ch; margin-bottom: 0; color: var(--muted); font-size: .8rem; }
.footer-inner nav { display: flex; flex-direction: column; gap: .4rem; align-items: flex-end; }
.footer-inner nav a { font-size: .78rem; font-weight: 750; text-underline-offset: .2em; }
.noscript-note { margin: 0; padding: 1rem; background: #fff0ec; color: #8a2f1e; text-align: center; font-weight: 800; }

@media (max-width: 850px) {
  .hero-grid, .lab-layout, .research-grid { grid-template-columns: 1fr; }
  .hero-note { max-width: 620px; transform: none; }
  .lab-intro { position: static; }
  .label-grid { grid-template-columns: 1fr; }
  .label-card { min-height: 0; }
  .output-heading, .after-value { align-items: flex-start; flex-direction: column; }
  .output-actions { flex: 1 1 auto; }
  .after-value .button { flex: 0 1 auto; }
}

@media (max-width: 640px) {
  .shell, .narrow { width: min(100% - 1.2rem, 1180px); }
  .header-inner { min-height: 74px; align-items: flex-start; flex-direction: column; justify-content: center; gap: .5rem; }
  .utility-nav { gap: .5rem 1rem; }
  h1 { font-size: clamp(2.75rem, 14vw, 4.2rem); }
  .form-grid, .seed-map { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .story-form { padding: 1rem; }
  .field-group { padding: .85rem; }
  .field-group legend { line-height: 1.8; }
  .form-actions, .form-actions .button, .output-actions, .output-actions .button { width: 100%; }
  .form-actions .text-button { width: 100%; text-align: center; }
  .spread-head { align-items: stretch; flex-direction: column; }
  .source-control { min-width: 0; }
  .after-value .button { width: 100%; }
  .footer-inner { flex-direction: column; }
  .footer-inner nav { align-items: flex-start; }
}

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

@media print {
  @page { margin: .55in; }
  body { background: var(--white); color: #111; font-size: 10.5pt; }
  .site-header, .hero, .trust-strip, .lab-section, .research-section, .faq-section, .site-footer, .output-actions, .after-value, .map-guidance, .noscript-note { display: none !important; }
  .output-section[hidden] { display: none !important; }
  .output-section { display: block !important; padding: 0; background: var(--white); }
  .output-heading { display: block; margin-bottom: .18in; }
  .output-heading .eyebrow { margin-bottom: .05in; }
  .output-heading h2 { margin-bottom: .06in; font-size: 25pt; }
  .map-legend { margin-bottom: .16in; padding: .08in; box-shadow: none; }
  .seed-map { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .11in; }
  .spread-card { break-inside: avoid; box-shadow: none; }
  .spread-head { min-height: 0; padding: .09in; }
  .spread-head h3 { font-size: 13pt; }
  .source-control label, .source-control select { display: none; }
  .source-control::after { content: attr(data-print-label); display: inline-block; padding: .04in .07in; border: 1px solid currentColor; border-radius: 999px; font-size: 7pt; font-weight: 800; text-transform: uppercase; }
  .spread-copy { min-height: 0; padding: .1in; font-size: 9pt; line-height: 1.38; }
  .spread-prompt { padding: .07in .1in .09in; font-size: 7.5pt; }
  .print-credit { margin-top: .2in; display: flex; justify-content: space-between; gap: .2in; border-top: 1px solid #aaa; padding-top: .08in; font-size: 7.5pt; }
  .print-credit span { text-align: right; }
}
