:root {
  --desk: #e7eae6;
  --ink: #11202d;
  --muted: #566370;
  --line: #c6cdc7;
  --accent: #0b6b4f;
  --warn: #9a3412;
  --sheet: #ffffff;
  --sans: "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --letter: Arial, Helvetica, sans-serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--desk);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 16.5px; line-height: 1.5; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
button, input, textarea { font: inherit; color: inherit; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
[hidden] { display: none !important; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 12px; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 10; }

header.site .wrap, footer.site .wrap { display: flex; align-items: baseline; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
header.site .wrap { padding-top: 22px; padding-bottom: 18px; }
.brand { font-size: 26px; font-weight: 800; letter-spacing: -0.8px; text-decoration: none; }
.brand::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 3px; background: var(--accent); }
.site nav { display: flex; gap: 22px; flex-wrap: wrap; }
.site nav a { text-decoration: none; color: var(--muted); font-size: 15px; font-weight: 600; }
.site nav a[aria-current="page"] { color: var(--ink); box-shadow: 0 2px 0 var(--ink); }
footer.site { border-top: 1px solid var(--line); margin-top: 96px; }
footer.site .wrap { padding-top: 28px; padding-bottom: 40px; }
footer.site .brand { font-size: 20px; }

.start { padding: 36px 0 30px; max-width: 800px; }
h1 { font-size: clamp(34px, 5.4vw, 58px); line-height: 1.02; letter-spacing: -1.8px; margin: 0 0 14px; font-weight: 800; text-wrap: balance; }
.lead { font-size: 18px; color: var(--muted); margin: 0; max-width: 40em; }

.workspace { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 56px; align-items: start; border-top: 2px solid var(--ink); }
form section { padding: 22px 0 24px; border-bottom: 1px solid var(--line); }
form h2 { margin: 0 0 14px; font-size: 13px; letter-spacing: 1.4px; text-transform: uppercase; font-weight: 700; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.field { min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label, .choice legend { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; padding: 0; }
input[type="text"], textarea { width: 100%; min-height: 46px; padding: 10px 12px; font-size: 16px; background: var(--sheet); border: 1px solid var(--line); border-radius: 4px; font-variant-numeric: tabular-nums; transition: border-color 0.15s ease; }
textarea { resize: vertical; line-height: 1.4; display: block; }
input[type="text"]:hover, textarea:hover { border-color: var(--muted); }
input[aria-invalid="true"] { border-color: var(--warn); box-shadow: inset 3px 0 0 var(--warn); }
input::placeholder { color: #8b96a0; }
textarea:disabled { background: transparent; }
.hint { font-size: 13.5px; color: var(--muted); margin: 5px 0 0; }
.error { font-size: 13.5px; color: var(--warn); margin: 5px 0 0; font-weight: 600; }
.error:empty { display: none; }
.warn { font-size: 14px; color: var(--warn); margin: 10px 0 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.choice + .choice { margin-top: 16px; }
.segments { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.segments label { position: relative; margin: 0; cursor: pointer; }
.segments input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.segments span { display: flex; align-items: center; min-height: 46px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--sheet); font-size: 15px; font-weight: 600; transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease; }
.segments input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.segments input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; padding: 8px 0; font-size: 15.5px; cursor: pointer; }
.check small { color: var(--muted); font-size: 13.5px; }
input[type="checkbox"] { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--ink); cursor: pointer; }
#default-since-field, form section > .field { margin: 8px 0 6px; }
.breakdown { overflow-x: auto; }
.breakdown table { margin: 12px 0 6px; font-size: 13.5px; }
.breakdown caption { font-size: 14px; color: var(--ink); font-weight: 700; }

button { cursor: pointer; border: 1.5px solid var(--accent); background: var(--accent); color: #fff; border-radius: 4px; padding: 10px 16px; min-height: 46px; font-size: 15.5px; font-weight: 700; transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease; }
button:hover:not(:disabled) { background: var(--ink); border-color: var(--ink); }
button.secondary { background: transparent; border-color: var(--ink); color: var(--ink); }
button.secondary:hover:not(:disabled) { color: #fff; }
button:disabled { opacity: 0.35; cursor: not-allowed; }
button.link, .analytics-settings { border: 0; background: none; color: var(--muted); padding: 0; min-height: 32px; font-weight: 400; font-size: inherit; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover:not(:disabled), .analytics-settings:hover { background: none; color: var(--accent); }
#reset { margin-top: 14px; font-size: 15px; }

.output { position: sticky; top: 0; align-self: start; container-type: inline-size; min-width: 0; }
.output-inner { padding-top: 18px; display: flex; flex-direction: column; max-height: 100vh; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.sheet-label { margin: 0; font-size: 13px; letter-spacing: 1.4px; text-transform: uppercase; font-weight: 700; }
.exports { display: flex; gap: 8px; flex-wrap: wrap; }
.status { margin: 10px 0 0; font-size: 15px; font-weight: 600; color: var(--muted); }
.status[data-state="ready"] { color: var(--accent); }
.status[data-state="error"] { color: var(--warn); }
#export-note:empty { display: none; }
.sheet { margin: 14px 0 24px; background: var(--sheet); color: #111; font-family: var(--letter); font-size: max(12.5px, 1.76cqi); line-height: 1.38; padding: 9.5cqi 9.5cqi 10cqi 11.9cqi; box-shadow: 0 1px 0 rgba(17, 32, 45, 0.08), 0 18px 40px -18px rgba(17, 32, 45, 0.35); overflow-y: auto; min-height: 0; overflow-wrap: anywhere; animation: sheet-in 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.sheet > * { transition: opacity 0.25s ease; }
.sheet.is-example > * { opacity: 0.45; }
.sheet p { margin: 0 0 1em; }
.l-sender { text-align: right; font-size: 0.86em; margin-bottom: 3.2em; }
.l-sender::first-line { font-weight: 700; }
.l-return { font-size: 0.68em; border-bottom: 1px solid #999; display: inline-block; margin-bottom: 0.9em; }
.l-recipient { font-style: normal; min-height: 6.9em; }
.l-date { text-align: right; margin: 1.4em 0 1.6em; }
.l-subject { font-size: 1.14em; margin: 0 0 1.3em; font-weight: 700; }
.l-claim { width: 100%; border-collapse: collapse; margin: 0 0 1.1em; font-size: 1em; }
.l-claim th { text-align: left; font-weight: 400; padding: 0.15em 1em 0.15em 0; border: 0; }
.l-claim td { text-align: right; white-space: nowrap; padding: 0.15em 0; border: 0; font-variant-numeric: tabular-nums; vertical-align: top; }
.l-claim tbody + tfoot th, .l-claim tbody + tfoot td { font-weight: 700; }
.l-claim tbody:not(:empty) + tfoot th, .l-claim tbody:not(:empty) + tfoot td { border-top: 1px solid #111; padding-top: 0.4em; }
.l-greeting { margin-top: 1.6em !important; }
.l-signature { margin-top: 2.6em !important; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px); } }

.notice { color: var(--muted); border-left: 3px solid var(--line); padding-left: 14px; }
.next { margin-top: 72px; border-top: 2px solid var(--ink); padding-top: 26px; transition: border-color 0.4s ease; }
.next.is-current { border-top-color: var(--accent); }
.next > h2 { font-size: clamp(26px, 3.4vw, 38px); letter-spacing: -0.9px; line-height: 1.1; margin: 0 0 26px; font-weight: 800; }
.next ol { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; }
.next li { counter-increment: step; }
.next li::before { content: counter(step, decimal-leading-zero); display: block; font-size: 13px; font-weight: 700; letter-spacing: 1.4px; color: var(--accent); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.next h3 { margin: 0 0 8px; font-size: 19px; line-height: 1.25; letter-spacing: -0.2px; }
.next p { margin: 0 0 10px; color: var(--muted); font-size: 15.5px; }
details { border-top: 1px solid var(--line); padding: 10px 0; }
summary { cursor: pointer; font-weight: 600; font-size: 15.5px; min-height: 28px; }
summary:hover { color: var(--accent); }
details p { margin: 8px 0 2px; }

.article { max-width: 740px; margin-top: 80px; }
.article.page { margin-top: 40px; }
.article h1 { font-size: clamp(32px, 5vw, 48px); }
.article h2 { font-size: 27px; line-height: 1.15; letter-spacing: -0.6px; margin: 52px 0 12px; font-weight: 800; }
.article h3 { font-size: 18.5px; margin: 30px 0 8px; }
.article p, .article ul, .article dl { margin: 0 0 14px; }
.article ul { padding-left: 20px; }
.article li { margin-bottom: 5px; }
.formula { font-weight: 700; font-size: 18px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stages dt { font-weight: 700; margin-top: 12px; }
.stages dd { margin: 2px 0 0; color: var(--muted); }
table { border-collapse: collapse; width: 100%; margin: 18px 0; font-size: 15px; font-variant-numeric: tabular-nums; }
caption { text-align: left; color: var(--muted); font-size: 14px; padding-bottom: 8px; }
th, td { text-align: left; padding: 8px 14px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: 12.5px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); border-bottom-color: var(--ink); }
td:last-child, th:last-child { padding-right: 0; }
.article table { display: block; overflow-x: auto; }

.analytics-settings { display: block; margin: 0 24px 8px auto; font-size: 14px; }
footer .notice { margin: 0 24px 24px; font-size: 14px; }
footer .notice:empty { display: none; }
.analytics-consent { position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 560px; margin: 0 auto; background: var(--ink); color: #fff; padding: 18px 20px; border-radius: 6px; z-index: 20; font-size: 15px; }
.analytics-consent p { margin: 0 0 12px; }
.analytics-consent .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.analytics-consent button { background: #fff; border-color: #fff; color: var(--ink); }
.analytics-consent button.secondary { background: transparent; color: #fff; border-color: #fff; }

@media (max-width: 920px) {
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .output { position: static; margin-top: 28px; }
  .output-inner { max-height: none; padding-top: 0; }
  .sheet { overflow-y: visible; padding: 26px 20px 30px 24px; }
  .next ol { grid-template-columns: minmax(0, 1fr); gap: 28px; }
}
@media (max-width: 520px) {
  .wrap { padding: 0 16px; }
  body { font-size: 16px; }
  .start { padding: 22px 0 22px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .exports { width: 100%; }
  .exports button { flex: 1 1 auto; padding: 10px 10px; }
  .l-sender { margin-bottom: 1.8em; }
  .l-recipient { min-height: 0; margin-bottom: 1.2em; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  header.site, footer.site, form, .toolbar, .status, .next, .article, .start, #export-note, .analytics-consent { display: none !important; }
  .workspace { display: block; border: 0; }
  .sheet { box-shadow: none; margin: 0; padding: 0; font-size: 10.5pt; }
  .sheet.is-example > * { opacity: 1; }
}
