:root {
  --bg: #f2f4f1;
  --surface: #ffffff;
  --ink: #0e1a14;
  --muted: #55645b;
  --rule: #d5dbd6;
  --primary: #0f5a44;
  --primary-dark: #0a4332;
  --pencil: #f6c945;
  --pencil-dark: #e5b52c;
  --error: #b42318;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 var(--sans);
}
img, svg { max-width: 100%; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-dark); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* header and footer */
.site-head { border-bottom: 1px solid var(--rule); background: var(--surface); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 16px; }
.brand { font: 700 1.35rem/1 var(--serif); color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand:hover { color: var(--primary); }
.site-nav a { margin-left: 20px; font-size: 0.95rem; color: var(--ink); }
.site-foot { border-top: 1px solid var(--rule); padding: 36px 0 48px; margin-top: 24px; color: var(--muted); font-size: 0.92rem; }
.site-foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 32px; }
.site-foot a { color: var(--muted); margin-right: 18px; }

/* hero */
.hero { padding: 56px 0 48px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 56px; align-items: center; }
.hero h1, .page-title { font: 700 clamp(2rem, 4.4vw, 3.15rem)/1.1 var(--serif); letter-spacing: -0.02em; margin: 0 0 20px; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 56ch; margin: 0 0 28px; }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 22px; }
.fine { color: var(--muted); font-size: 0.92rem; margin: 0; }

.btn, .btn-cta {
  display: inline-block;
  font: 700 1rem/1 var(--sans);
  padding: 15px 22px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-cta { background: var(--pencil); color: var(--ink); border-color: #cda321; }
.btn-cta:hover { background: var(--pencil-dark); color: var(--ink); }
.btn { background: var(--primary); color: #fff; }
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn.alt { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.btn.alt:hover { background: #e8f0ec; color: var(--primary-dark); }
.btn:disabled { opacity: 0.6; cursor: wait; }

/* sample thumbnail in the hero */
.thumb-wrap { justify-self: center; }
.thumb { width: 343px; height: 444px; overflow: hidden; border: 1px solid var(--rule); background: #fff; transform: rotate(1.4deg); margin: 0; position: relative; }
.thumb .paper { transform: scale(0.42); transform-origin: 0 0; pointer-events: none; user-select: none; }
.thumb-cap { text-align: center; font-size: 0.85rem; color: var(--muted); margin: 14px 0 0; }

/* sections */
.sec { padding: 56px 0; border-top: 1px solid var(--rule); }
.sec h2 { font: 700 clamp(1.5rem, 3vw, 2rem)/1.2 var(--serif); letter-spacing: -0.01em; margin: 0 0 20px; }
.sec-intro { color: var(--muted); max-width: 62ch; margin: -6px 0 28px; }
.prose { max-width: 68ch; }
.prose p { margin: 0 0 16px; }
.plain { list-style: none; margin: 0; padding: 0; max-width: 68ch; }
.plain li { padding: 14px 0; border-top: 1px solid var(--rule); }
.plain li:first-child { border-top: 0; padding-top: 0; }
.plain li p { margin: 0; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; }
.dash { margin: 0; padding-left: 20px; }
.dash li { margin-bottom: 10px; }
.words { color: var(--muted); max-width: 68ch; }

details { border-top: 1px solid var(--rule); padding: 0; max-width: 72ch; }
details:last-of-type { border-bottom: 1px solid var(--rule); }
summary { cursor: pointer; padding: 16px 0; font-weight: 600; list-style: none; position: relative; padding-right: 28px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; position: absolute; right: 4px; top: 14px; font-size: 1.3rem; color: var(--primary); }
details[open] summary::after { content: "\2212"; }
details p { margin: 0 0 18px; color: var(--muted); }
.letter { background: var(--surface); border: 1px solid var(--rule); padding: 20px 24px; margin: 0 0 18px; max-width: 68ch; }
.letter p { margin: 0 0 12px; color: var(--ink); }

.related { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 0; padding: 0; list-style: none; }

/* home page list of groups */
.group-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.group-list li { border-bottom: 1px solid var(--rule); }
.group-list a { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 8px 32px; padding: 18px 4px; text-decoration: none; color: var(--ink); align-items: baseline; }
.group-list a:hover { background: #e8f0ec; }
.group-list .g-name { font: 700 1.3rem/1.2 var(--serif); }
.group-list .g-desc { color: var(--muted); }
.steps { margin: 0; padding-left: 22px; max-width: 62ch; }
.steps li { margin-bottom: 12px; padding-left: 6px; }

/* builder */
.builder { display: grid; grid-template-columns: minmax(0, 430px) minmax(0, 1fr); gap: 32px; align-items: start; }
.viewtoggle { display: none; }
.preview-col { position: sticky; top: 12px; min-width: 0; }
.form-col { min-width: 0; }

fieldset { border: 0; border-top: 1px solid var(--rule); margin: 0 0 20px; padding: 14px 0 0; min-width: 0; }
legend { font: 700 1.1rem/1.2 var(--serif); padding: 0 8px 0 0; }
.fld { margin-bottom: 12px; min-width: 0; }
.fld label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 4px; }
.fld input, .fld textarea {
  width: 100%;
  font: 16px/1.4 var(--sans);
  padding: 10px 11px;
  border: 1px solid #aeb8b1;
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}
.fld textarea { resize: vertical; }
.fld input:focus, .fld textarea:focus { outline: 3px solid rgba(15, 90, 68, 0.35); border-color: var(--primary); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.hint { color: var(--muted); font-size: 0.86rem; margin: 4px 0 0; }
.entry { border-top: 1px solid var(--rule); padding-top: 14px; margin-top: 14px; }
.entry:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.linkbtn { background: none; border: 0; padding: 4px 0; font: 600 0.9rem var(--sans); color: var(--primary); text-decoration: underline; cursor: pointer; }
.linkbtn:hover { color: var(--primary-dark); }
.addbtn { font: 600 0.95rem var(--sans); color: var(--primary); background: var(--surface); border: 1px dashed var(--primary); border-radius: 4px; padding: 10px 14px; cursor: pointer; margin-top: 8px; }
.addbtn:hover { background: #e8f0ec; }
.form-foot { padding: 4px 0 24px; }
.notice { border-left: 4px solid var(--pencil); background: var(--surface); padding: 12px 14px; margin-bottom: 18px; }
.notice p { margin: 0 0 6px; font-size: 0.95rem; }

.tabs { display: flex; border-bottom: 1px solid var(--rule); margin-bottom: 12px; }
.tabs button { font: 700 1rem var(--serif); background: none; border: 0; padding: 10px 18px 10px 0; margin-right: 18px; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--primary); }
.style-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid #aeb8b1; border-radius: 4px; overflow: hidden; }
.seg button { font: 600 0.88rem var(--sans); background: var(--surface); border: 0; padding: 8px 12px; cursor: pointer; color: var(--ink); }
.seg button + button { border-left: 1px solid #aeb8b1; }
.seg button[aria-pressed="true"] { background: var(--primary); color: #fff; }
.swatches { display: flex; gap: 6px; }
.sw { width: 30px; height: 30px; padding: 3px; border-radius: 50%; border: 2px solid transparent; background: none; cursor: pointer; }
.sw span { display: block; width: 100%; height: 100%; border-radius: 50%; }
.sw[aria-pressed="true"] { border-color: var(--ink); }
.warn { border-left: 4px solid var(--error); background: var(--surface); color: var(--error); padding: 8px 12px; margin-bottom: 12px; font-size: 0.92rem; font-weight: 600; }
.warn[hidden], .notice[hidden] { display: none; }
.paper-wrap { width: 100%; overflow: hidden; border: 1px solid var(--rule); background: #fff; }

.paybox { margin-top: 16px; padding: 16px 0 0; border-top: 1px solid var(--ink); }
.pay-title { font: 700 1.2rem/1.3 var(--serif); margin: 0 0 6px; }
.price { font-size: 1.6rem; }
.pay-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 8px; }
.paybox .btn { margin-top: 6px; }
.pay-actions .btn { margin-top: 0; }
.msg { color: var(--error); font-size: 0.92rem; margin: 8px 0 0; min-height: 1.2em; }

/* the paper itself (screen preview, thumbnail and print) */
.paper {
  width: 816px;
  min-height: 1056px;
  padding: 48px;
  background: #fff;
  color: #111;
  font: 13.5px/1.42 var(--sans);
  position: relative;
  transform-origin: 0 0;
  --accent: #0f5a44;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.paper p { margin: 0 0 8px; }
.paper ul { margin: 3px 0 0; padding-left: 18px; }
.paper li { margin: 1px 0; }
.paper .r-name { font-size: 28px; line-height: 1.15; font-weight: 700; }
.paper .r-title { font-size: 15px; margin-top: 2px; }
.paper .r-contact { margin-top: 6px; font-size: 13px; }
.paper .r-contact span + span::before { content: "|"; margin: 0 0.6em; color: var(--accent); }
.paper .r-h { font-weight: 700; margin: 16px 0 6px; }
.paper .r-row { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; }
.paper .r-dates { font-weight: 400; white-space: nowrap; }
.paper .r-job { margin-bottom: 9px; break-inside: avoid; }
.paper .r-sub, .paper .r-note { color: #333; }
.paper .c-body { margin-top: 26px; font-size: 14px; line-height: 1.55; }
.paper .c-body p { margin: 0 0 12px; }
.paper .c-sign { margin-top: 20px; }

.tpl-classic { font-family: Georgia, "Times New Roman", serif; }
.tpl-classic .r-head { text-align: center; }
.tpl-classic .r-name { letter-spacing: 0.02em; }
.tpl-classic .r-h { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); border-bottom: 1.5px solid var(--accent); padding-bottom: 2px; }
.tpl-classic .r-sub { font-style: italic; }

.tpl-modern .r-name { color: var(--accent); font-size: 31px; }
.tpl-modern .r-title { color: #333; }
.tpl-modern .r-head { border-bottom: 3px solid var(--accent); padding-bottom: 12px; }
.tpl-modern .r-h { font-size: 13px; color: var(--accent); border-left: 4px solid var(--accent); padding-left: 8px; }

.tpl-compact { font-size: 12.5px; line-height: 1.34; }
.tpl-compact .r-name { font-size: 24px; }
.tpl-compact .r-title { font-size: 13.5px; }
.tpl-compact .r-h { font-size: 12px; color: var(--accent); border-bottom: 1px solid #bbb; margin: 12px 0 5px; padding-bottom: 1px; }
.tpl-compact .r-job { margin-bottom: 6px; }
.tpl-compact .c-body { font-size: 13px; }

.paper.wm::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='200'%3E%3Ctext x='150' y='110' font-family='Arial' font-size='34' font-weight='700' fill='%23B42318' fill-opacity='.16' text-anchor='middle' transform='rotate(-28 150 100)'%3EPREVIEW%3C/text%3E%3C/svg%3E") repeat;
}

#print-root { display: none; }

/* legal pages */
.legal { max-width: 70ch; padding: 48px 0; }
.legal h1 { font: 700 2.2rem/1.15 var(--serif); margin: 0 0 8px; }
.legal h2 { font: 700 1.3rem/1.2 var(--serif); margin: 32px 0 8px; }
.legal p, .legal li { color: #26332b; }

@media (max-width: 959px) {
  .builder { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .preview-col { position: static; }
  .viewtoggle { display: flex; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; border-bottom: 1px solid var(--rule); gap: 8px; }
  .viewtoggle button { flex: 1; font: 700 0.95rem var(--sans); padding: 11px; border-radius: 4px; border: 1px solid var(--primary); background: var(--surface); color: var(--primary); cursor: pointer; }
  .viewtoggle button[aria-pressed="true"] { background: var(--primary); color: #fff; }
  .builder[data-view="edit"] .preview-col { display: none; }
  .builder[data-view="preview"] .form-col { display: none; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .two-col { grid-template-columns: minmax(0, 1fr); gap: 32px; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero { padding: 36px 0 32px; }
  .sec { padding: 40px 0; }
  .site-nav a { margin-left: 14px; }
  .thumb { width: 294px; height: 380px; }
  .thumb .paper { transform: scale(0.36); }
  .group-list a { grid-template-columns: minmax(0, 1fr); }
  .row2 { grid-template-columns: 1fr; }
  .btn-cta { width: 100%; }
}

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

@page { size: letter; margin: 0.5in; }
@media print {
  body.printing { background: #fff; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  #print-root .paper { width: auto; min-height: 0; padding: 0; transform: none; }
  #print-root .paper.cover-page { break-before: page; page-break-before: always; }
}
