:root {
  --carbon: #18201e;
  --paper: #f2efe6;
  --clean: #fffdf7;
  --red: #c94331;
  --blue: #1f5d6b;
  --pencil: #676c66;
  --rule: #c7c4b9;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--carbon);
  background-color: var(--paper);
  background-image: linear-gradient(rgba(24,32,30,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(24,32,30,.025) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: var(--sans);
  line-height: 1.55;
}
button, textarea, input { font: inherit; }
button { color: inherit; }
button:not(:disabled), label { cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 20; padding: .7rem 1rem; background: var(--carbon); color: white; }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.site-header, footer { max-width: 1440px; margin: auto; padding: 1.25rem clamp(1rem,4vw,4rem); display: flex; justify-content: space-between; align-items: center; }
.site-header { border-bottom: 1px solid var(--carbon); }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: .75rem; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; color: var(--clean); background: var(--carbon); font: 700 .72rem var(--mono); transform: rotate(-2deg); }
.workbench-label, footer { font: .7rem var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.workbench-label span { margin: 0 .5rem; color: var(--red); }
main { max-width: 1440px; margin: auto; padding: clamp(3.5rem,7vw,7rem) clamp(1rem,4vw,4rem) 3rem; }
.intro { max-width: 1020px; }
.eyebrow, .step-label { color: var(--red); font: 700 .7rem var(--mono); letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: .5rem 0 1.3rem; font: 400 clamp(3.1rem,7.7vw,7.4rem)/.89 var(--serif); letter-spacing: -.065em; }
h1 span { display: block; color: var(--pencil); font-style: italic; }
.intro-copy { max-width: 680px; margin: 0; font-size: clamp(1rem,2vw,1.25rem); color: #3f4946; }

.desk { position: relative; margin-top: clamp(3rem,7vw,6rem); }
.source-sheet, .result-sheet { border: 1px solid var(--carbon); background: var(--clean); box-shadow: 11px 11px 0 rgba(24,32,30,.13); }
.source-sheet { display: grid; grid-template-columns: 54px 1fr; max-width: 970px; }
.sheet-folio { padding: 1.25rem .65rem; border-right: 1px solid var(--rule); display: flex; flex-direction: column; align-items: center; justify-content: space-between; font: .65rem var(--mono); letter-spacing: .09em; }
.sheet-folio > span:last-child { writing-mode: vertical-rl; transform: rotate(180deg); }
.sheet-folio b { color: var(--red); font-weight: 700; }
.sheet-content { padding: clamp(1.4rem,4vw,3rem); min-width: 0; }
.section-heading, .result-header, .form-footer, .result-footer { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; }
.section-heading h2, .result-header h2 { margin: .25rem 0 1.5rem; font: 400 clamp(1.7rem,3.5vw,2.8rem)/1.05 var(--serif); letter-spacing: -.035em; }
.text-button { border: 0; border-bottom: 1px solid currentColor; padding: .3rem 0; background: transparent; font-size: .78rem; font-weight: 700; }
textarea { width: 100%; min-height: 250px; resize: vertical; border: 0; border-block: 1px solid var(--rule); border-radius: 0; padding: 1.3rem .2rem; color: var(--carbon); background: transparent; font: 1.07rem/1.7 var(--serif); }
textarea:focus { outline-offset: 5px; }
.input-meta { display: flex; justify-content: space-between; gap: 1rem; padding-top: .6rem; color: var(--pencil); font: .7rem var(--mono); }

.audience-fieldset { margin: 3rem 0 0; padding: 0; border: 0; }
.audience-fieldset legend { width: 100%; margin-bottom: 1rem; display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.audience-fieldset legend span { font: 400 1.35rem var(--serif); }
.audience-fieldset legend small { color: var(--pencil); font-size: .75rem; }
.audience-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.audience-option { position: relative; min-height: 78px; padding: 1rem 1.9rem 1rem 1rem; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); background: var(--clean); transition: background-color .15s, transform .15s; }
.audience-option:hover { background: #f7f2e8; }
.audience-option:has(input:checked) { z-index: 1; color: var(--clean); background: var(--carbon); box-shadow: inset 0 0 0 2px var(--carbon); transform: translate(-2px,-2px); }
.audience-option input { position: absolute; opacity: 0; }
.audience-option:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 2px; z-index: 2; }
.audience-option strong, .audience-option small { display: block; }
.audience-option strong { line-height: 1.2; }
.audience-option small { margin-top: .35rem; color: var(--pencil); font-size: .7rem; }
.audience-option:has(input:checked) small { color: #d5d9d4; }
.selection-mark { position: absolute; right: .75rem; top: .65rem; color: transparent; font-weight: 800; }
.audience-option:has(input:checked) .selection-mark { color: #ffcf64; }
.custom-audience { margin-top: 1rem; padding: 1.25rem; border-left: 4px solid var(--red); background: #f3eadf; }
.custom-audience label { display: block; margin-bottom: .5rem; font-weight: 700; }
.custom-audience input { width: 100%; border: 0; border-bottom: 1px solid var(--carbon); border-radius: 0; padding: .7rem .2rem; background: transparent; }
.custom-hints { margin: .7rem 0 0; color: var(--pencil); font: italic .78rem/1.5 var(--serif); }
.form-footer { margin-top: 2rem; align-items: center; }
.form-error { margin: 0; color: #a22819; font-size: .85rem; font-weight: 700; }
.primary-button, .secondary-button, .copy-button { min-height: 48px; border: 1px solid var(--carbon); padding: .8rem 1.15rem; font-weight: 750; }
.primary-button { margin-left: auto; color: white; background: var(--red); border-color: #922a1c; box-shadow: 4px 4px 0 var(--carbon); }
.primary-button:hover { transform: translate(1px,1px); box-shadow: 3px 3px 0 var(--carbon); }
.primary-button:disabled { opacity: .65; cursor: wait; }
.result-sheet { display: grid; grid-template-columns: 54px 1fr; max-width: 1040px; margin: clamp(4rem,8vw,8rem) 0 0 auto; border-color: var(--blue); box-shadow: -11px 11px 0 rgba(31,93,107,.16); }
.result-sheet[hidden] { display: none; }
.result-content { min-width: 0; padding: clamp(1.4rem,4vw,3.5rem); }
.result-body[hidden] { display: none; }
.result-body.is-arriving { animation: sheet-in .45s ease both; }

/* Waiting state: the desk reads, checks, and reorders — no spinner, no percentages */
.working-slip { padding: 1.5rem 0 2.5rem; }
.working-slip[hidden] { display: none; }
.working-steps { margin: 1.2rem 0 0; padding: 0; list-style: none; max-width: 420px; }
.working-steps li { position: relative; padding: .55rem 0 .55rem 1.9rem; border-bottom: 1px solid var(--rule); color: var(--rule); font: italic 1.05rem/1.4 var(--serif); transition: color .25s; }
.working-steps li::before { content: '○'; position: absolute; left: .2rem; font-style: normal; }
.working-steps li.is-active { color: var(--carbon); }
.working-steps li.is-active::before { content: '✎'; color: var(--red); }
.working-steps li.is-done { color: var(--pencil); }
.working-steps li.is-done::before { content: '✓'; color: var(--blue); }

.result-header { border-bottom: 1px solid var(--blue); flex-wrap: wrap; }
.result-header h2 { margin-bottom: 1.3rem; }
.result-header-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding-bottom: 1rem; }
.view-toggle { display: flex; border: 1px solid var(--rule); }
.view-toggle button { min-height: 42px; padding: .5rem .8rem; border: 0; background: transparent; color: var(--pencil); font: 700 .72rem var(--mono); letter-spacing: .05em; text-transform: uppercase; }
.view-toggle button + button { border-left: 1px solid var(--rule); }
.view-toggle button[aria-pressed="true"] { color: var(--clean); background: var(--carbon); }
.copy-button { min-height: 42px; padding: .5rem .8rem; color: var(--blue); background: transparent; border-color: var(--blue); }
.better-explanation { padding: clamp(2rem,4vw,3.5rem) 0; font: clamp(1.2rem,2.5vw,1.65rem)/1.55 var(--serif); }
.better-explanation[hidden] { display: none; }
.better-explanation p { margin: 0 0 1em; }
.better-explanation p:last-child { margin: 0; }

/* The original reads like the unedited page that crossed the desk */
.original-view { padding: clamp(2rem,4vw,3.5rem) 0; }
.original-view[hidden] { display: none; }
.original-label { margin: 0 0 1rem; color: var(--red); font: 700 .65rem var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.original-text { padding-left: 1.25rem; border-left: 3px solid var(--rule); color: #4a524f; font: 1.05rem/1.7 var(--serif); white-space: pre-wrap; }

.why-note { margin: 0 0 2rem; padding: 1.1rem 1.25rem; border-left: 4px solid var(--red); background: #faf5ea; }
.why-note h3 { margin: 0 0 .55rem; color: var(--red); font: italic 1.05rem var(--serif); }
.why-note ul { margin: 0; padding-left: 1.1rem; font-size: .88rem; }
.why-note li + li { margin-top: .3rem; }

.result-details { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.result-details section { padding: 1.4rem; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.result-details h3 { margin: 0 0 .7rem; font: 700 .67rem var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.detail-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.mini-copy { border: 0; border-bottom: 1px solid currentColor; padding: 0 0 .1rem; background: transparent; color: var(--blue); font: 700 .68rem var(--mono); letter-spacing: .05em; text-transform: uppercase; }
.result-details p, .result-details ul { margin: 0; font-size: .9rem; }
.result-details ul { padding-left: 1.1rem; }
.result-details li + li { margin-top: .4rem; }
.watch-out { background: #f3eadf; }
.result-footer { align-items: center; margin-top: 2rem; }
.result-footer p { max-width: 500px; margin: 0; color: var(--pencil); font-size: .75rem; }
.secondary-button { flex: 0 0 auto; background: transparent; border-color: var(--blue); color: var(--blue); }
.origin { max-width: 760px; margin: clamp(5rem,9vw,9rem) auto; text-align: center; font: italic clamp(1.5rem,3vw,2.4rem)/1.25 var(--serif); }
footer { border-top: 1px solid var(--carbon); }
.toast { position: fixed; z-index: 10; right: 1.5rem; bottom: 1.5rem; padding: .8rem 1rem; color: white; background: var(--blue); opacity: 0; transform: translateY(1rem); pointer-events: none; transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(20px) rotate(.2deg); } }

@media (max-width: 900px) {
  .audience-grid { grid-template-columns: repeat(2, 1fr); }
  .source-sheet, .result-sheet { max-width: none; }
}
@media (max-width: 620px) {
  .workbench-label { display: none; }
  main { padding-top: 3rem; }
  h1 { font-size: clamp(3rem,16vw,4.6rem); }
  .source-sheet, .result-sheet { grid-template-columns: 1fr; box-shadow: 6px 6px 0 rgba(24,32,30,.13); }
  .sheet-folio { min-height: 42px; padding: .5rem .8rem; border-right: 0; border-bottom: 1px solid var(--rule); flex-direction: row; }
  .sheet-folio > span:last-child { writing-mode: horizontal-tb; transform: none; }
  .section-heading { align-items: flex-start; }
  .audience-fieldset legend { display: block; }
  .audience-fieldset legend small { display: block; margin-top: .3rem; }
  .audience-grid { grid-template-columns: 1fr 1fr; }
  .audience-option { min-height: 82px; padding: .85rem 1.4rem .85rem .75rem; }
  .form-footer, .result-footer { display: block; }
  .primary-button, .secondary-button { width: 100%; margin-top: 1rem; }
  .result-header-actions { width: 100%; justify-content: space-between; }
  .result-details { grid-template-columns: 1fr; }
  .input-meta span:first-child { max-width: 65%; }
  footer { align-items: flex-start; gap: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
