:root {
  --bg: #fbf6ef;
  --card: #ffffff;
  --text: #2b2420;
  --muted: #7a6d64;
  --line: #eadfd3;
  --red: #b8352b;
  --red-ink: #ffffff;
  --green: #2f6b55;
  --green-soft: #e3f1ea;
  --gold: #c8912b;
  --gold-soft: #fbefd5;
  --warn: #9a4b00;
  --warn-soft: #fde9d4;
  --wa: #1f9d55;
  --focus: #1c64d8;
  --radius: 16px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1715;
    --card: #26201d;
    --text: #f3ece6;
    --muted: #b3a59a;
    --line: #3a312c;
    --red: #e0564a;
    --green: #6cc39d;
    --green-soft: #1e3a2f;
    --gold: #e7b75a;
    --gold-soft: #3a2f1a;
    --warn: #ffb36b;
    --warn-soft: #3d2a17;
    --wa: #2bb866;
    --focus: #7fb0ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 var(--sans);
}
.wrap { max-width: 640px; margin: 0 auto; padding: 20px 16px calc(48px + env(safe-area-inset-bottom)); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.stack > * + * { margin-top: 16px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 24px; font-weight: 600; }
.brand img { width: 32px; height: 32px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.step { display: inline-block; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--red); margin-bottom: 4px; }

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=tel], input[type=password], select, textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 48px;
}
textarea { min-height: 120px; resize: vertical; }
.field + .field { margin-top: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; margin-top: 0; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 400; font-size: 16px; margin-top: 12px; }
.check input { width: 22px; height: 22px; accent-color: var(--red); }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600;
  min-height: 48px; padding: 10px 18px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text);
  text-decoration: none; cursor: pointer;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--red); color: var(--red-ink); border-color: transparent; }
.btn-wa { background: var(--wa); color: #fff; border-color: transparent; }
.btn-big { width: 100%; min-height: 64px; font-size: 20px; }
.btn-small { min-height: 40px; padding: 6px 14px; font-size: 15px; }
.btn-link { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 6px 8px; min-height: 40px; font-weight: 400; }
.btn-danger { color: var(--red); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.error { color: var(--red); font-size: 15px; margin-top: 8px; }
.error:empty { display: none; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.list li:first-child { border-top: 0; }
.list .who { flex: 1 1 160px; min-width: 0; }
.list .who strong { display: block; }
.list .actions { display: flex; gap: 4px; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--line); color: var(--text); white-space: nowrap; }
.badge-sent { background: var(--gold-soft); color: var(--gold); }
.badge-open { background: var(--green-soft); color: var(--green); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

progress { width: 100%; height: 10px; appearance: none; border: 0; border-radius: 999px; background: var(--line); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--green); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--green); border-radius: 999px; }

.next { text-align: center; padding: 28px 20px; }
.next .label { color: var(--muted); font-size: 15px; }
.next .name { font-family: var(--serif); font-size: 40px; font-weight: 600; margin: 4px 0 2px; overflow-wrap: anywhere; }
.next .phone { color: var(--muted); margin-bottom: 20px; }

.qr { display: flex; gap: 16px; align-items: center; }
.qr .code { width: 132px; height: 132px; flex: none; background: #fff; border-radius: 8px; padding: 4px; }
.qr .code svg { width: 100%; height: 100%; display: block; }

.notice { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 12px 14px; font-size: 15px; }
.preview { white-space: pre-wrap; background: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: 15px; overflow-wrap: anywhere; }
details summary { cursor: pointer; color: var(--muted); font-size: 15px; min-height: 32px; }

dialog {
  border: 0; border-radius: 20px; padding: 24px; width: min(420px, calc(100vw - 32px));
  background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog h2 { margin-bottom: 4px; }
dialog .buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
.next .btn-big + p { margin-top: 12px; }
.more summary { list-style: none; display: inline-flex; color: var(--muted); }
.more summary::-webkit-details-marker { display: none; }
.more[open] summary { color: var(--text); }
.more-menu { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.list-send .actions { flex-basis: 100%; }
.btn-sms { background: #2a6fdb; color: #fff; border-color: transparent; }
.row > .field-narrow { flex: 0 1 140px; }
.next .btn-link { margin-top: 4px; }
.add-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
