:root {
  --bg: #ffffff;
  --bg-soft: #f5f6f8;
  --bg-card: #ffffff;
  --fg: #14161a;
  --fg-muted: #5b6472;
  --border: #e2e5ea;
  --accent: #1d4ed8;
  --accent-fg: #ffffff;
  --accent-soft: #eaf0ff;
  --ok: #1a7f4b;
  --ok-soft: #e7f6ee;
  --warn: #96580a;
  --warn-soft: #fdf3e3;
  --err: #b3261e;
  --err-soft: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 22, 26, .06), 0 8px 24px rgba(20, 22, 26, .06);
  --maxw: 1080px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --bg-soft: #15181e;
    --bg-card: #171a21;
    --fg: #e8eaee;
    --fg-muted: #9aa3b2;
    --border: #262b34;
    --accent: #6f95ff;
    --accent-fg: #0f1115;
    --accent-soft: #1b2233;
    --ok: #58d39a;
    --ok-soft: #14251d;
    --warn: #e0aa5a;
    --warn-soft: #2a2114;
    --err: #ff8a80;
    --err-soft: #2b1715;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --bg-soft: #15181e;
  --bg-card: #171a21;
  --fg: #e8eaee;
  --fg-muted: #9aa3b2;
  --border: #262b34;
  --accent: #6f95ff;
  --accent-fg: #0f1115;
  --accent-soft: #1b2233;
  --ok: #58d39a;
  --ok-soft: #14251d;
  --warn: #e0aa5a;
  --warn-soft: #2a2114;
  --err: #ff8a80;
  --err-soft: #2b1715;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 5vw, 3rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3, h2.h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* header */
header.site {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
header.site .wrap { display: flex; align-items: center; gap: 12px; height: 62px; }
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--fg); margin-right: auto; }
.brand span { color: var(--accent); }
header.site nav { display: none; gap: 18px; margin-right: 8px; }
header.site nav a { color: var(--fg-muted); text-decoration: none; font-size: .95rem; }
header.site nav a:hover { color: var(--fg); }
@media (min-width: 780px) { header.site nav { display: flex; } }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--accent); border-radius: 999px;
  background: var(--accent); color: var(--accent-fg);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--border); }
.btn.ghost:hover { background: var(--bg-soft); filter: none; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; white-space: nowrap; }
/* Below 360px the header button only fits on one line with tighter gaps. */
@media (max-width: 359px) { header.site .wrap { gap: 6px; } .btn.small { padding: 0 8px; } }
.icon-btn {
  min-height: 38px; min-width: 38px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px;
  background: transparent; color: var(--fg); font: inherit; cursor: pointer;
}
.icon-btn:hover { background: var(--bg-soft); }
:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* hero */
.hero { padding: 56px 0 32px; }
.hero p.lead { font-size: 1.12rem; color: var(--fg-muted); max-width: 46ch; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 18px; }
.hero .note { font-size: .9rem; color: var(--fg-muted); }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; padding: 0; list-style: none; }
.badges li {
  font-size: .85rem; color: var(--fg-muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; background: var(--bg-soft);
}
.hero-grid { display: grid; gap: 32px; align-items: center; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1.1fr .9fr; } }

/* letter preview graphic */
.sheet {
  position: relative; aspect-ratio: 210 / 297; width: 100%; max-width: 340px; margin: 0 auto;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow);
  overflow: hidden;
}
.sheet .window {
  position: absolute; border: 2px dashed var(--accent); border-radius: 3px;
  background: var(--accent-soft);
}
.sheet .window::after {
  content: attr(data-label);
  position: absolute; left: 0; top: -1.35em; font-size: .62rem; color: var(--accent); white-space: nowrap;
}
.sheet .block { position: absolute; border-radius: 2px; background: var(--border); }
.sheet .addr {
  position: absolute; line-height: 1.35; color: var(--fg-muted); padding: 4px 5px;
  overflow-wrap: break-word;
}
.sheet.ok .window { border-color: var(--ok); background: var(--ok-soft); }
.sheet.ok .window::after { color: var(--ok); }
.sheet.bad .window { border-color: var(--warn); background: var(--warn-soft); }
.sheet.bad .window::after { color: var(--warn); }
.sheet-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.gray .sheet-bg, .gray .pdf-preview { filter: grayscale(1); }
.sheet.with-bg .window { background: transparent; }
.sheet.with-bg .window::after { display: none; }
.cols.two .sheet { max-width: 260px; }
.sheet-caption { margin: 0 0 10px; font-size: .9rem; color: var(--fg-muted); }
/* The text scales with the sheet, so the window holds as much as the real one. */
.sheet.cover { container-type: inline-size; background: #fff; color: #111; }
.sheet.cover .window { background: transparent; padding: 1.2cqw 1.5cqw; overflow: hidden; }
.cover-sender { font-size: 1.5cqw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid currentColor; margin-bottom: 1.2cqw; min-height: 1.3em; }
.cover-recipient { font-size: 2.3cqw; line-height: 1.3; white-space: pre-line; overflow-wrap: anywhere; }

.sheet-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.sheet-item { position: relative; }
.sheet-badge {
  position: absolute; top: -10px; right: -10px; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 1rem; line-height: 1;
  border: 1px solid; background: var(--bg-card); box-shadow: var(--shadow);
}
.sheet-badge.ok { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.sheet-badge.warn { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }

/* ponytail: assumes the browser's built-in PDF viewer fits pages to width, so height =
   1.5 page-heights at that width shows ~1.5 pages before it scrolls. A viewer that fits by
   height instead (some mobile browsers) will show more or less; that's an acceptable ceiling. */
.pdf-preview {
  width: 100%; aspect-ratio: 210 / 445.5; max-height: 80vh;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg-card);
}
.upload-preview { max-width: 480px; margin: 0 auto 20px; }
.preview-title { font-size: 1.15rem; margin: 28px 0 8px; }
.preview-note { margin: 4px 0 12px; font-size: .9rem; color: var(--fg-muted); }

/* sections */
section { padding: 44px 0; border-top: 1px solid var(--border); scroll-margin-top: 63px; }
section.plain { border-top: 0; }
.sub { color: var(--fg-muted); max-width: 60ch; }
.cols { display: grid; gap: 18px; }
@media (min-width: 720px) { .cols.three { grid-template-columns: repeat(3, 1fr); } .cols.two { grid-template-columns: 1fr 1fr; } }

.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
}
.card .num {
  display: inline-grid; place-items: center; width: 28px; height: 28px; margin-bottom: 10px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .9rem;
}
.card p:last-child { margin-bottom: 0; }
.card .muted { color: var(--fg-muted); }

/* price cards */
.price { display: flex; flex-direction: column; gap: 12px; }
.price .amount { font-size: 1.8rem; font-weight: 700; }
.price .amount small { font-size: .8rem; font-weight: 500; color: var(--fg-muted); }
.price ul { margin: 0; padding-left: 1.1em; color: var(--fg-muted); font-size: .92rem; }
.price .btn { margin-top: auto; }
.price.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.price .addon-total { margin: 0; font-size: .85rem; color: var(--fg-muted); }

/* wizard */
.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 24px; flex-wrap: wrap; font-size: .85rem; }
.steps li { display: flex; align-items: center; gap: 6px; color: var(--fg-muted); }
.steps li + li::before { content: "›"; margin-right: 6px; }
.steps li.on { color: var(--fg); font-weight: 600; }
.steps li.done { color: var(--accent); }
.timer { margin: -16px 0 24px; font-size: .85rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.timer.soon { color: var(--warn); }

.drop {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 36px 20px; text-align: center;
  background: var(--bg-soft);
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input[type=file] { display: none; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }

.notice { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 16px 0; }
.notice.ok { border-color: var(--ok); background: var(--ok-soft); }
.notice.warn { border-color: var(--warn); background: var(--warn-soft); }
.notice.err { border-color: var(--err); background: var(--err-soft); }
.notice p:last-child { margin-bottom: 0; }
.notice strong { display: block; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: .85rem; color: var(--fg-muted); }
.field label .req { color: var(--err); margin-left: 2px; }
.field input {
  min-height: 44px; padding: 0 12px; font: inherit;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px;
}
.field .msg { font-size: .8rem; color: var(--err); min-height: 1em; }
label.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; font-size: .95rem; color: var(--fg); cursor: pointer; }
.field label.check { font-size: .95rem; color: var(--fg); margin-bottom: 0; }
label.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
progress { display: block; width: 100%; height: 8px; margin-top: 8px; accent-color: var(--accent); }
.grid2 { display: grid; gap: 12px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 90px 1fr; } }

.summary { list-style: none; padding: 0; margin: 0; }
.summary li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.summary.prices { margin-top: 18px; border-top: 2px solid var(--border); }
.summary li.total { font-weight: 700; font-size: 1.1rem; border-bottom: 0; }
.summary li span:first-child { color: var(--fg-muted); }

.actions-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; border: 1px solid var(--border); }
.pill.ok { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.pill.warn { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.pill.err { color: var(--err); border-color: var(--err); background: var(--err-soft); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; word-break: break-all; }

.prose { max-width: 70ch; }
.prose h2 { margin-top: 1.6em; }
.prose dl dt { font-weight: 600; margin-top: 1em; }

footer.site { border-top: 1px solid var(--border); padding: 28px 0 44px; color: var(--fg-muted); font-size: .9rem; }
footer.site .wrap { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
footer.site a { color: var(--fg-muted); }

.skip { position: absolute; left: 12px; top: 12px; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
.skip:focus { clip-path: none; width: auto; height: auto; overflow: visible; background: var(--bg-card); padding: 8px 12px; border-radius: 8px; z-index: 20; }
