:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --bg: #f6f4ee;
  --surface: #fff;
  --ink: #1d1b16;
  --muted: #5f5a4e;
  --line: #ddd7c6;
  --gold: #8a6414;
  --gold-dark: #6f4f0d;
  --gold-soft: #f3ead2;
  --focus: #1a5fb4;
  --radius: 8px;
  --z-sticky: 20;
  --z-nav: 50;
  --z-dropdown: 150;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fs-body: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --fs-h1: clamp(1.625rem, 1.3rem + 1.6vw, 2.5rem);
  --fs-h2: clamp(1.25rem, 1.1rem + 0.8vw, 1.625rem);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.6;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--gold-dark); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { width: min(100% - 2 * var(--space-4), 1280px); margin-inline: auto; }
.wrap.narrow { width: min(100% - 2 * var(--space-4), 860px); }
.skip-link { position: absolute; left: var(--space-2); top: -64px; background: var(--ink); color: #fff; padding: var(--space-2) var(--space-4); border-radius: var(--radius); z-index: var(--z-nav); }
.skip-link:focus { top: var(--space-2); }

.site-header { position: sticky; top: 0; z-index: var(--z-nav); background: var(--ink); color: #fff; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 56px; position: relative; }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); color: #f0d68a; font-weight: 700; font-size: 1.125rem; text-decoration: none; min-height: 44px; }
.brand:hover { color: #fff; }
.brand svg { width: 28px; height: 28px; flex: none; }
.site-nav { display: flex; align-items: center; }
.nav-list { display: flex; gap: var(--space-1); list-style: none; margin: 0; padding: 0; }
.nav-list a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--space-3); color: #efe9d6; text-decoration: none; border-radius: var(--radius); white-space: nowrap; }
.nav-list a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.nav-list a[aria-current="page"] { color: #f0d68a; box-shadow: inset 0 -3px 0 #f0d68a; border-radius: 0; }
.nav-toggle { display: none; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; background: transparent; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: var(--radius); color: #fff; cursor: pointer; }
.nav-toggle svg { width: 22px; height: 22px; }
@media (max-width: 799px) {
  .nav-toggle { display: inline-flex; }
  .nav-list { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; gap: 0; background: var(--ink); padding: var(--space-2) 0 var(--space-4); border-top: 1px solid rgba(255, 255, 255, 0.15); z-index: var(--z-dropdown); }
  .nav-list.is-open { display: flex; }
  .nav-list a { width: 100%; padding: 0 var(--space-4); }
  .nav-list a[aria-current="page"] { box-shadow: inset 4px 0 0 #f0d68a; }
}

main { padding-block: var(--space-5) var(--space-7); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--space-3); }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: 1.125rem; }
p, ul, ol, dl { margin: 0 0 var(--space-4); }
.lead { font-size: 1.125rem; color: var(--muted); max-width: 70ch; }
.intro { margin-bottom: var(--space-5); }
.intro h1 { margin-bottom: var(--space-2); }

[hidden] { display: none !important; }
.btn, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-4);
  border-radius: var(--radius); border: 1px solid var(--gold); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn { background: var(--gold); color: #fff; }
.btn:hover { background: var(--gold-dark); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--gold-dark); }
.btn-ghost:hover { background: var(--gold-soft); color: var(--ink); }

.tabs { display: none; gap: var(--space-2); margin-bottom: var(--space-4); }
.tabs button { flex: 1; min-height: 44px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); }
.tabs button[aria-pressed="true"] { background: var(--ink); color: #f0d68a; border-color: var(--ink); }
.workspace { display: grid; gap: var(--space-5); align-items: start; }
.pane-form { min-width: 0; }
.pane-preview { min-width: 0; }
@media screen and (max-width: 999px) {
  .tabs { display: flex; }
  .workspace[data-view="form"] .pane-preview { display: none; }
  .workspace[data-view="preview"] .pane-form { display: none; }
}
@media (min-width: 1000px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pane-preview { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; }
}
.paper-wrap { background: #e9e5d8; padding: var(--space-4); border-radius: var(--radius); }
.paper-wrap .inv { box-shadow: 0 2px 12px rgba(40, 30, 0, 0.18); max-width: 820px; margin-inline: auto; }
@media (max-width: 599px) { .paper-wrap { padding: var(--space-2); } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); margin-bottom: var(--space-4); }
.panel > legend, .panel > h2 { font-size: 1.0625rem; font-weight: 700; margin: 0 0 var(--space-3); padding: 0; }
fieldset.panel { min-width: 0; }
.grid2 { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; margin-bottom: var(--space-3); }
.grid2 > .field { margin-bottom: 0; }
.grid2 { margin-bottom: var(--space-3); }
.field label, .field .label { font-size: 0.875rem; font-weight: 600; color: var(--muted); }
input[type="text"], input[type="number"], input[type="date"], input[type="email"], select, textarea {
  width: 100%; min-height: 44px; padding: var(--space-2) var(--space-3);
  border: 1px solid #b9b29d; border-radius: var(--radius); background: #fff; color: var(--ink); font: inherit; font-size: 1rem;
}
textarea { min-height: 88px; resize: vertical; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); gap: var(--space-2); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice span { display: flex; align-items: center; justify-content: center; min-height: 44px; border: 1px solid #b9b29d; border-radius: var(--radius); background: #fff; font-weight: 600; }
.choice input:checked + span { background: var(--ink); color: #f0d68a; border-color: var(--ink); }
.choice input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.items { display: grid; gap: var(--space-3); margin-bottom: var(--space-3); }
.item { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3); background: #fbfaf6; }
.item .desc { grid-column: 1 / -1; }
.item .line-total { display: flex; align-items: center; font-weight: 700; min-height: 44px; min-width: 0; overflow-wrap: anywhere; }
.item .remove { justify-self: end; }
@media (min-width: 560px) {
  .item { grid-template-columns: 6rem 1fr 1fr auto; align-items: end; }
  .item .field { margin-bottom: 0; }
}
.row-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.status { min-height: 1.5em; color: var(--muted); font-size: 0.875rem; margin: var(--space-2) 0 0; }
.logo-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.hint { font-size: 0.875rem; color: var(--muted); margin: var(--space-1) 0 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.actions .status { margin: 0 0 0 var(--space-2); }

.prose { max-width: 70ch; }
.prose h2 { margin-top: var(--space-6); }
.prose ul, .prose ol { padding-left: var(--space-5); }
.prose .facts { padding-left: 0; }
.prose li { margin-bottom: var(--space-2); }
.crumbs { font-size: 0.875rem; color: var(--muted); margin-bottom: var(--space-3); }
.split > .paper-wrap { align-self: start; }
@media (min-width: 900px) { .split > .paper-wrap { position: sticky; top: 72px; } }
.more { margin-top: var(--space-6); }
.split { display: grid; gap: var(--space-5); align-items: start; }
@media (min-width: 900px) { .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.cards { list-style: none; margin: 0 0 var(--space-5); padding: 0; display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.card .paper-wrap { padding: var(--space-2); }
.card h3 { margin: 0; }
.card > p { margin: 0; color: var(--muted); }
.facts { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); list-style: none; padding: 0; margin: 0 0 var(--space-5); }
.facts li { background: var(--gold-soft); border-radius: var(--radius); padding: var(--space-3); font-size: 0.9375rem; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: var(--space-2); }
.faq summary { cursor: pointer; padding: var(--space-3) var(--space-4); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.faq details p { padding: 0 var(--space-4); }
.center { text-align: center; padding-block: var(--space-7); }

.site-footer { background: var(--ink); color: #cfc8b2; padding-block: var(--space-5); font-size: 0.9375rem; }
.site-footer p { margin: 0 0 var(--space-2); }
.site-footer a { color: #f0d68a; display: inline-flex; align-items: center; min-height: 44px; }
.footer-links { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-4); padding: 0; margin: 0 0 var(--space-3); }

@media screen and (min-width: 1000px) {
  .pane-preview .inv { aspect-ratio: 210 / 297; }
}
