@font-face {
  font-family: "Nunito";
  src: url("/fonts/Nunito-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("/fonts/Nunito-Bold.woff2") format("woff2");
  font-weight: 600 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fredoka";
  src: url("/fonts/Fredoka-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Caveat";
  src: url("/fonts/Caveat-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --napkin: #FBF6EC;
  --fold: #EADFCB;
  --ink: #2B2A4A;
  --tangerine: #FF5B3A;
  --sun: #FFC94A;

  --bg: var(--napkin);
  --card: #FFFDF8;
  --muted: #5C5A74;
  --line: var(--fold);
  --field-line: #A3967F;
  --accent: var(--tangerine);
  --accent-ink: #ffffff;
  --danger: #A8321C;
  --radius: 14px;

  --font-ui: "Nunito", system-ui, sans-serif;
  --font-head: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-hand: "Caveat", "Segoe Script", "Bradley Hand", cursive;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--bg); color: var(--ink); }

body {
  font: 17px/1.5 var(--font-ui);
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 16px 48px;
}

.brand {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px 4px;
}
.brand img { display: block; width: 32px; height: 32px; flex: none; }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand-home { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.brand-word { font-family: "Fredoka", "Nunito", system-ui, sans-serif; font-weight: 600; font-size: 1.3rem; line-height: 1; color: #2B2A4A; white-space: nowrap; }
.brand-word span { color: #FF5B3A; }
.preview-tag {
  flex: none;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--ink);
  background: var(--card);
}
.preview-banner {
  max-width: 480px;
  margin: 6px auto 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.4;
}
@media (min-width: 520px) { .preview-banner { width: calc(100% - 32px); } }
@media (max-width: 519px) { .preview-banner { margin: 6px 16px 0; } }

/* Host setup hero + tagline */
.hero { margin: 8px 0 0; }
.hero img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 42vh;
  object-fit: cover;
  object-position: center 30%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--fold);
}
@media (min-width: 700px) {
  .hero img { object-position: center 35%; }
}
.tagline {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 2.1rem;
  line-height: 1.1;
  text-align: center;
  margin: 10px 0 2px;
}

/* Landing demo video slot (only inserted when the files exist; see qa/VIDEO-SLOT.md) */
.demo-video { margin: 12px 0 6px; }
.demo-frame {
  position: relative;
  display: flex;
  justify-content: center;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--ink);
}
.demo-video video { display: block; width: 100%; aspect-ratio: 16 / 9; background: var(--ink); }
.demo-video.portrait video { width: auto; max-width: 100%; height: min(70vh, 720px); aspect-ratio: 9 / 16; }
.demo-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-height: 48px;
  padding: 10px 20px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font: 700 1rem/1 var(--font-ui);
  cursor: pointer;
}
.demo-play[hidden] { display: none; }
.demo-video figcaption { text-align: center; margin-top: 6px; }

.check {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 400;
  font-size: 1rem;
  min-height: 48px;
}
.check input {
  width: 24px; height: 24px; min-height: 0; margin: 0; flex: none;
  accent-color: var(--tangerine);
}
.hint { margin: 8px 0 0; }

h1, h2 { font-family: var(--font-head); font-weight: 600; letter-spacing: 0.005em; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 8px 0 4px; overflow-wrap: anywhere; }
h2 { font-size: 1.2rem; margin: 28px 0 10px; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}

label { display: block; font-weight: 700; margin: 14px 0 6px; }
label .opt { font-weight: 400; color: var(--muted); }

input, textarea, select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--field-line);
  border-radius: 10px;
}
textarea { resize: vertical; min-height: 88px; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(43, 42, 74, 0.4);
  outline-offset: 1px;
}

button { font: inherit; cursor: pointer; }

.btn {
  display: block;
  width: 100%;
  min-height: 56px;
  margin: 18px 0 0;
  padding: 12px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.btn:disabled {
  background: #F7C3B5;
  color: #5A3A33;
  cursor: default;
}
.btn.secondary {
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--ink);
  font-size: 1rem;
  min-height: 48px;
}
.btn.secondary:disabled { background: var(--fold); color: var(--muted); border-color: var(--fold); }
.btn.danger { background: transparent; color: var(--danger); border: 2px solid var(--danger); }
.btn.danger:disabled { background: var(--fold); color: var(--muted); border-color: var(--fold); }

.link {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 4px;
  margin-right: 12px;
  background: none;
  border: 0;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--tangerine);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  font-size: 0.95rem;
}

.agreement { white-space: pre-wrap; margin: 0; }

.qr { display: flex; justify-content: center; padding: 8px 0; }
.qr img { width: 220px; height: 220px; image-rendering: pixelated; }

.share-row { display: flex; gap: 8px; align-items: stretch; }
.share-row input { flex: 1; font-size: 0.85rem; }
.share-row .btn { width: auto; margin: 0; min-height: 48px; font-size: 1rem; }

.share-extra { text-align: left; }
.share-extra .btn { margin-top: 12px; min-height: 48px; }
.share-extra .hint { margin: 6px 0 0; }
.share-extra #nfc-status:empty { display: none; }

.sig-wrap { position: relative; margin-top: 8px; }
#sig-canvas {
  display: block;
  width: 100%;
  height: 160px;
  background: #fff;
  border: 2px dashed var(--field-line);
  border-radius: 10px;
  touch-action: none;
}

.signers { list-style: none; padding: 0; margin: 0; }
.signers li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.signers li:last-child { border-bottom: 0; }
.signers .who { min-width: 0; }
.signers .who strong { display: block; overflow-wrap: anywhere; }
.signers img { height: 40px; max-width: 120px; object-fit: contain; }

/* "Signed ✓" state: tangerine pill, white bold large text. */
.done {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 20px auto 8px;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--tangerine);
  color: #fff;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.3;
}

.badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--tangerine);
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 0.03em;
}

.hash {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.error { color: var(--danger); font-weight: 700; min-height: 1.5em; margin: 8px 0 0; }
.hidden { display: none !important; }

/* Confetti burst (sun only). Skipped entirely under reduced motion in JS. */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}
.confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 12px;
  background: var(--sun);
  border-radius: 2px;
  opacity: 0;
  animation: confetti-fall var(--dur, 1.4s) cubic-bezier(.2,.6,.4,1) var(--delay, 0s) forwards;
}
.confetti i.round { border-radius: 50%; width: 9px; height: 9px; }
@keyframes confetti-fall {
  0%   { opacity: 1; transform: translate(0, 0) rotate(0); }
  85%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx, 0), var(--dy, 60vh)) rotate(var(--rot, 360deg)); }
}
@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
}

/* Pay screen (host, before the agreement opens). */
.pay { padding-top: 8px; }
.pay-mark { display: block; margin: 0 auto 8px; width: 72px; height: 72px; }
.pay-price {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.25;
  margin: 12px 0 16px;
}
.pay #pay-btn { min-height: 64px; font-size: 1.35rem; }
.test-note {
  display: inline-block;
  margin: 0 0 14px;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--sun);
  color: var(--ink);
  font-weight: 800;
}
#not-open { padding-top: 24px; }

/* ---------- Home chooser ---------- */
.chooser { display: grid; gap: 10px; margin: 16px 0 4px; }
.choice {
  display: block;
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  text-align: left;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}
.choice strong { display: block; font-size: 1.05rem; }
.choice small { display: block; color: var(--muted); font-size: 0.875rem; }
.choice[aria-pressed="true"] { border-color: var(--tangerine); box-shadow: inset 0 0 0 1px var(--tangerine); }
.choice[aria-pressed="true"] strong::after { content: "  ✓"; color: #B8381D; }
@media (min-width: 700px) { .chooser { grid-template-columns: 1fr 1fr; } }

/* ---------- Handshake ---------- */
.hs-steps {
  list-style: none;
  display: flex;
  gap: 6px;
  padding: 0;
  margin: 12px 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
}
.hs-steps li {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.2;
}
.hs-steps .dot {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--fold);
  color: var(--ink);
  font-size: 0.75rem;
}
.hs-steps li.current { border-color: var(--ink); color: var(--ink); background: #fff; }
.hs-steps li.current .dot { background: var(--ink); color: #fff; }
.hs-steps li.done { color: var(--ink); }
.hs-steps li.done .dot { background: var(--sun); color: var(--ink); }

.capture { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 4px; }
.btn-row { display: grid; gap: 8px; }
.btn-row .btn { margin: 8px 0 0; min-height: 48px; }
@media (min-width: 420px) { .btn-row { grid-template-columns: 1fr 1fr; } }
.capture .btn.secondary, .location-panel .btn.secondary { min-height: 48px; }
.status:empty { display: none; }
.status { margin: 8px 0 0; }
.error-text { color: var(--danger); font-weight: 700; }
.recovery { margin-top: 10px; padding: 10px; border: 1px dashed var(--field-line); border-radius: 10px; }
.two-col { display: grid; gap: 0 12px; }
@media (min-width: 420px) { .two-col { grid-template-columns: 1fr 1fr; } }
.field-label { font-weight: 700; margin: 18px 0 4px; }
.notice {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 4px solid var(--sun);
  background: #FFF7E0;
  border-radius: 6px;
  font-size: 0.9rem;
}
.mode-select { display: grid; gap: 8px; }
.mode-option {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--field-line);
  border-radius: 12px;
}
.mode-option strong { display: block; }
.mode-option small { display: block; color: var(--muted); }
.mode-option[aria-pressed="true"] { border-color: var(--tangerine); background: #FFF1EC; }
.mode-option[aria-pressed="true"] strong::after { content: "  ✓"; color: #B8381D; }

.kicker { margin: 8px 0 0; font-size: 0.8rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.status-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 6px 0 2px; }
.pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--fold);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.9rem;
}
.pill.ok { background: var(--ink); color: #fff; }

.doc h2 { margin: 6px 0 4px; }
.doc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.locked-tag {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.doc-people { margin: 0 0 8px; overflow-wrap: anywhere; }
.doc-label { margin: 12px 0 2px; font-weight: 800; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.mode-label { margin: 16px 0 4px; font-weight: 800; letter-spacing: 0.04em; color: #B8381D; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.doc-details { margin: 10px 0; border-top: 1px solid var(--line); padding-top: 4px; }
.doc-details summary { min-height: 44px; display: flex; align-items: center; font-weight: 700; cursor: pointer; }
.doc-foot { border-top: 1px solid var(--line); padding-top: 8px; margin: 12px 0 0; }

.hs-sig .who { display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.hs-sig { align-items: flex-start !important; }
.sig-typed { font-family: var(--font-hand); font-weight: 700; font-size: 1.5rem; }
.sig-canvas {
  display: block;
  width: 100%;
  height: 160px;
  background: #fff;
  border: 2px dashed var(--field-line);
  border-radius: 10px;
  touch-action: none;
}
.location-panel { margin: 4px 0 0; }
.location-panel .btn { margin-top: 10px; }
.hs-complete .done { font-size: 1.4rem; }
#hs-qr { flex-direction: column; align-items: center; }
#hs-qr img { width: auto; height: auto; max-width: 100%; background: #fff; }
.ref-list { padding-left: 18px; }
.ref-list li { margin: 4px 0; overflow-wrap: anywhere; }
#ref-page h1 { font-size: 1.5rem; }

@media print {
  .brand, .preview-banner, .btn, .link, #hs-sharing, #hs-owner-card, #hs-referrals, #hs-sign-card, .hs-steps { display: none !important; }
  .doc-details > *:not(summary) { display: block !important; }
  body { background: #fff; }
}
