:root {
  color-scheme: light;
  --ink: #292820; --muted: #655c50; --faint: #796f61;
  --page: #f5f1e8; --paper: #fffdf8; --edge: #e4dacb; --soft: #f4eee3;
  --rust: #9c472e; --rust-dark: #76321f; --rust-pale: #f7e8de;
  --good: #48684e; --warn: #9c402b;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--page); font: 14px/1.55 var(--sans); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; }
a { color: var(--rust-dark); text-underline-offset: .21em; }
button, input, select, textarea, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--rust); outline-offset: 3px; }
[hidden] { display: none !important; }
.wrap { width: min(1216px, calc(100% - 64px)); margin-inline: auto; }
.skip { position: fixed; z-index: 9; top: 12px; left: 12px; background: var(--paper); padding: 10px; transform: translateY(-200%); }
.skip:focus { transform: none; }
.top { background: #faf7f0; border-bottom: 1px solid var(--edge); }
.top-inner { min-height: 69px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand strong { font: bold 20px/1.1 var(--serif); display: block; }
.brand small { display: block; font-size: 9px; font-weight: 800; letter-spacing: .18em; color: var(--faint); margin-top: 4px; }
.top-actions, .quick-links, .button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.icon { width: 17px; height: 17px; flex: 0 0 auto; vertical-align: middle; }
.btn, .text-button, .tag-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 7px; min-height: 38px; padding: 7px 13px; font-weight: 700; font-size: 13px; border: 1px solid var(--edge); background: var(--paper); text-decoration: none; }
.btn:hover { border-color: #b6a28e; background: #fcf5eb; }
.btn.primary { background: var(--rust); border-color: var(--rust); color: white; }
.btn.primary:hover { background: var(--rust-dark); border-color: var(--rust-dark); }
.btn.small { min-height: 33px; padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.text-button { border-color: transparent; background: transparent; padding-inline: 7px; color: var(--rust-dark); }
.text-button:hover { background: var(--rust-pale); }
.tag-button { background: var(--paper); min-height: 32px; padding: 4px 10px; font-size: 12px; color: var(--muted); }
.tag-button:hover { color: var(--rust-dark); border-color: var(--rust); }
.hero { position: relative; isolation: isolate; overflow: hidden; margin-top: 26px; min-height: 194px; display: flex; align-items: center; border: 1px solid #49372b; border-radius: 13px; background: #30281f url('./assets/woodcut.svg') center right / cover no-repeat; color: #fff2dd; }
.hero-content { padding: 30px 36px; position: relative; }
.hero-label, .eyebrow { font-size: 10px; letter-spacing: .16em; font-weight: 800; text-transform: uppercase; }
.hero-label { color: #ebba87; display: flex; gap: 8px; align-items: center; }
.hero-label span { width: 7px; height: 7px; background: #c78051; transform: rotate(45deg); }
.hero h1 { margin: 7px 0 2px; font: 600 clamp(40px, 5vw, 59px)/1.1 var(--serif); letter-spacing: -.045em; }
.hero p { margin: 9px 0 0; color: #f0d9bc; font-size: 15px; }
.workbar { min-height: 59px; padding-block: 9px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.draft-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #63816a; box-shadow: 0 0 0 3px #e4eadf; flex-shrink: 0; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(310px, 360px); gap: 22px; align-items: start; }
.workbench { background: var(--paper); border: 1px solid var(--edge); border-radius: 12px; min-width: 0; box-shadow: 0 3px 8px #36251607; }
.steps { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding: 10px 13px 0; gap: 3px; border-bottom: 1px solid var(--edge); }
.step { border: 0; border-bottom: 2px solid transparent; background: transparent; min-width: 0; color: var(--muted); padding: 8px 1px 12px; display: flex; align-items: center; flex-direction: column; gap: 6px; font-size: 11px; line-height: 1.25; font-weight: 650; white-space: nowrap; }
.step:hover { color: var(--rust-dark); background: #faf3e9; border-radius: 6px 6px 0 0; }
.step[aria-current="step"] { color: var(--rust-dark); border-bottom-color: var(--rust); font-weight: 800; }
.step-number { display: grid; place-items: center; width: 23px; height: 23px; background: var(--soft); border-radius: 50%; font-size: 11px; font-variant-numeric: tabular-nums; }
.step[aria-current="step"] .step-number { background: var(--rust); color: white; }
.step.is-visited:not([aria-current]) .step-number { background: #e9ede4; color: #406249; }
.stage { padding: 25px 28px 28px; }
.eyebrow { color: var(--rust-dark); }
.stage h2 { margin: 4px 0 3px; font: bold 32px/1.15 var(--serif); letter-spacing: -.033em; }
.intro { margin: 8px 0 21px; color: var(--muted); max-width: 64ch; }
.stage h3 { margin: 0 0 8px; font: bold 20px/1.25 var(--serif); }
.section { border-top: 1px solid var(--edge); margin-top: 21px; padding-top: 18px; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.section-head h3 { margin: 0; }
.fields { display: grid; gap: 14px; margin: 13px 0 0; align-items: start; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields .wide { grid-column: 1/-1; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 5px; font-weight: 700; font-size: 12px; }
.field input, .field select, .field textarea, .search { width: 100%; min-width: 0; border: 1px solid #ddd0bd; border-radius: 7px; padding: 8px 10px; background: #fffefa; color: var(--ink); min-height: 42px; font-size: 14px; font-weight: 450; }
.field textarea { resize: vertical; min-height: 70px; }
.field small, .micro, .hint { font-size: 12px; color: var(--muted); font-weight: 450; }
.hint { margin: 5px 0 10px; }
.check { display: flex; align-items: flex-start; gap: 8px; line-height: 1.4; cursor: pointer; font-size: 13px; }
.check input { accent-color: var(--rust); width: 16px; height: 16px; margin: 1px 0 0; flex: 0 0 auto; cursor: pointer; }
.check strong { font-weight: 720; }
.check small { display: block; color: var(--muted); margin-top: 3px; }
.option-grid, .rank-grid, .score-grid { display: grid; gap: 8px; margin-top: 11px; }
.option-grid, .rank-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.score-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.rank-choice, .option { background: #fcf8f0; border: 1px solid var(--edge); border-radius: 8px; padding: 11px; }
.rank-choice.selected, .option.selected { background: #fbefe6; border-color: #ba7359; }
.rank-choice input { accent-color: var(--rust); margin: 0 7px 0 0; }
.rank-choice span { font-size: 13px; font-weight: 750; }
.rank-choice small { display: block; margin: 2px 0 0 22px; color: var(--muted); font-size: 11px; }
.rank-choice { cursor: pointer; }
.option { display: flex; align-items: flex-start; justify-content: space-between; gap: 5px; }
.option .check { flex: 1; }
.pill { display: inline-flex; align-items: center; background: var(--soft); border-radius: 20px; color: var(--muted); padding: 3px 8px; font-size: 11px; font-weight: 750; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill.rust { color: var(--rust-dark); background: var(--rust-pale); }
.callout, .empty { border-radius: 8px; background: #f8f2e7; border: 1px solid #e9decb; padding: 10px 12px; margin: 13px 0 0; color: var(--muted); font-size: 13px; }
.callout.error { background: #faeae4; color: #803522; border-color: #e7c0af; }
.callout.success { background: #eef2e8; color: #385a43; border-color: #d9e2d1; }
.callout p { margin: 4px 0; }
.row-card { border: 1px solid var(--edge); background: #fffaf3; border-radius: 8px; padding: 12px; margin-top: 10px; }
.row-card .fields { margin-top: 6px; }
.row-card .text-button { margin-inline-start: auto; }
.row-card .compact { margin-top: 10px; }
.compact { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
details { margin-top: 14px; }
details > summary { font-weight: 720; cursor: pointer; color: var(--rust-dark); }
.catalog { border: 1px solid var(--edge); padding: 13px; border-radius: 8px; background: #fcf8f0; }
.catalog-list { display: grid; gap: 7px; max-height: 340px; overflow: auto; margin-top: 10px; padding: 2px 5px 3px 2px; }
.search { margin-top: 10px; }
.step-controls { border-top: 1px solid var(--edge); padding: 14px 27px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.step-controls > span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; }
.side { position: sticky; top: 12px; min-width: 0; }
.stat-card { overflow: hidden; border: 1px solid #d7c5ae; border-radius: 12px; background: #fcf8ef; box-shadow: 0 3px 8px #3625160a; }
.stat-head { background: #eee4d4; padding: 16px 17px 13px; border-bottom: 1px solid #ddcdb8; }
.stat-head .eyebrow { display: flex; align-items: center; gap: 7px; }
.stat-head .icon { width: 14px; height: 14px; }
.stat-head h2 { font: bold 29px/1.1 var(--serif); margin: 7px 0; letter-spacing: -.04em; overflow-wrap: anywhere; }
.stat-head p { margin: 0; color: #584b3d; font-size: 12px; overflow-wrap: anywhere; }
.stat-body { padding: 13px 16px 16px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.metric { background: #fffdf8; border: 1px solid var(--edge); border-radius: 7px; padding: 7px 3px 8px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.metric span { text-transform: uppercase; font-weight: 800; letter-spacing: .08em; font-size: 9px; color: var(--muted); }
.metric strong { font: bold 27px/1.14 var(--serif); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin: 11px 0 0; }
.stats div { display: flex; justify-content: space-between; gap: 5px; background: var(--soft); padding: 5px 6px; font-size: 11px; border-radius: 4px; }
.stats dt { color: var(--muted); }
.stats dd { font-weight: 750; margin: 0; }
.stat-meta { font-size: 12px; color: var(--muted); margin: 11px 0; }
.stat-attack { border-block: 1px solid var(--edge); padding: 9px 0; margin: 9px 0; font-size: 12px; overflow-wrap: anywhere; }
.stat-attack b { font-family: var(--serif); font-size: 15px; }
.stat-attack small { display: block; color: var(--muted); }
.budget { margin-top: 12px; }
.budget-label { display: flex; justify-content: space-between; align-items: center; gap: 7px; font-size: 12px; font-weight: 750; }
.budget-label span:last-child { color: var(--muted); font-weight: 650; }
.budget.bad .budget-label { color: var(--warn); }
.budget progress { width: 100%; height: 6px; display: block; margin-top: 5px; border: 0; border-radius: 8px; overflow: hidden; background: #e8dfd0; accent-color: var(--rust); }
progress::-webkit-progress-bar { background: #e8dfd0; }
progress::-webkit-progress-value { background: var(--rust); }
progress::-moz-progress-bar { background: var(--rust); }
.budget.sp progress::-webkit-progress-value { background: #81744e; }
.budget.sp progress::-moz-progress-bar { background: #81744e; }
.stat-actions { display: flex; gap: 6px; margin-top: 15px; }
.stat-actions .btn { flex: 1; }
.footer { border-top: 1px solid var(--edge); margin: 26px 0 12px; padding: 15px 0; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 12px; }
.footer a { margin-inline-end: 12px; }
dialog { width: min(510px, calc(100% - 30px)); max-height: 85vh; overflow: auto; padding: 24px; border: 1px solid var(--edge); background: var(--paper); color: var(--ink); border-radius: 13px; box-shadow: 0 12px 45px #231a1555; }
dialog::backdrop { background: #2c201aaa; }
dialog h2 { margin: 0 0 8px; font: bold 29px/1.2 var(--serif); }
dialog p { color: var(--muted); }
dialog .button-row { margin-top: 15px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 5; max-width: min(380px, calc(100vw - 44px)); padding: 12px 16px; background: #342820; color: #fff6e9; border-radius: 8px; box-shadow: 0 4px 20px #2d211836; }
.review-block { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.65 var(--sans); background: #fbf6eb; border: 1px solid var(--edge); border-radius: 8px; padding: 14px; }
.ledger { margin: 10px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ledger div { background: var(--soft); border-radius: 6px; padding: 7px; text-align: center; font-size: 12px; }
.ledger strong { display: block; }
@media (max-width: 950px) {
  .layout { grid-template-columns: minmax(0, 1fr) 302px; gap: 13px; }
  .wrap { width: calc(100% - 36px); }
  .stage { padding-inline: 18px; }
  .step-controls { padding-inline: 18px; }
  .score-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 735px) {
  .layout { grid-template-columns: 1fr; gap: 14px; }
  .side { position: static; }
  .hero { margin-top: 15px; min-height: 163px; background-position: 68% center; }
  .hero::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, #2c251ee8 7%, #2c251e77 66%, transparent); z-index: -1; }
  .hero-content { padding: 24px; }
  .workbar { flex-wrap: wrap; }
  .step { font-size: 10px; }
}
@media (max-width: 440px) {
  .wrap { width: calc(100% - 22px); }
  .top-inner { min-height: 60px; }
  .brand { gap: 7px; }
  .brand img { width: 29px; height: 29px; }
  .brand strong { font-size: 16px; }
  .brand small { font-size: 8px; }
  .top-actions { gap: 4px; }
  .top-actions .btn { font-size: 11px; padding: 5px 6px; gap: 4px; }
  .top-actions .icon { width: 13px; height: 13px; }
  .three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { padding-inline: 4px; }
  .step { font-size: 9px; }
  .stage { padding-inline: 14px; }
}
@media print {
  .top, .hero, .workbar, .steps, .side, .footer, .step-controls, .review-buttons, .skip, .callout, .ledger { display: none !important; }
  .wrap, .layout, .workbench { display: block; width: 100%; background: white; border: 0; box-shadow: none; }
  .review-block { border: 0; background: white; padding: 0; }
}
.status-dot.unsaved { background: var(--warn); box-shadow: 0 0 0 3px var(--rust-pale); }
#stage-checks:not(:empty) { margin-bottom: 16px; }
#stage-checks .text-button { min-height: 26px; padding-block: 1px; }
.mobile-stats { display: none; }
@media (max-width: 735px) {
  body { padding-bottom: 61px; }
  .mobile-stats { position: fixed; z-index: 3; bottom: 0; inset-inline: 0; display: flex; align-items: center; justify-content: space-around; gap: 6px; padding: 8px 12px max(8px, env(safe-area-inset-bottom)); background: #f7efe2; border-top: 1px solid #d8c9b6; box-shadow: 0 -4px 14px #3b271316; color: var(--muted); font-size: 12px; }
  .mobile-stats b { font: bold 20px/1 var(--serif); color: var(--ink); }
  .mobile-stats .over, .mobile-stats .over b { color: var(--warn); }
  .toast { bottom: 66px; }
}
@media print { .mobile-stats { display: none !important; } }
