:root {
  --table: #efe6d8;
  --ink: #1d1a16;
  --muted: #6b6157;
  --line: #d9cdbb;
  --card: #f7f0e4;
  --paper: #fffdf8;
  --paper-edge: #e4dccd;
  --napkin-ink: #2a251f;
  --napkin-muted: #8a7f72;
  --pen: #1f3fa0;
  --seal: #b3261e;
  --seal-dark: #7d1812;
  --btn-bg: #1d1a16;
  --btn-fg: #fbf6ee;
  --shadow: 0 1px 0 var(--paper-edge), 0 14px 30px -14px rgba(60, 35, 10, .45);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --table: #1b1714;
    --ink: #f2ece2;
    --muted: #a89c8e;
    --line: #3a322b;
    --card: #25201b;
    --paper: #f6efe3;
    --paper-edge: #cfc3b1;
    --btn-bg: #f2ece2;
    --btn-fg: #1b1714;
    --shadow: 0 1px 0 #000, 0 16px 34px -12px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--table);
  color: var(--ink);
  font: 16px/1.5 "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }

.top { max-width: 560px; margin: 0 auto; padding: 14px 16px 0; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
#app { max-width: 560px; margin: 0 auto; padding: 8px 16px 48px; }
.wrap { max-width: 560px; margin: 0 auto; padding: 16px; }

h1 { font-size: clamp(28px, 7.5vw, 38px); line-height: 1.08; letter-spacing: -.025em; margin: 18px 0 8px; text-wrap: balance; }
h2 { font-size: 21px; letter-spacing: -.015em; margin: 0 0 6px; }
.lede { color: var(--muted); margin: 0 0 22px; font-size: 17px; text-wrap: pretty; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- form bits ---------- */
.field { margin: 0 0 16px; }
.label { display: block; font-size: 14px; font-weight: 500; color: var(--muted); margin: 0 0 6px; }
.input, .select {
  width: 100%; height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); padding: 0 14px; font-size: 16px; outline: none;
}
.input:focus, .select:focus { border-color: var(--ink); }


.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 54px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--btn-bg); color: var(--btn-fg); font-weight: 700; font-size: 17px; text-decoration: none;
  transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn.seal { background: var(--seal); color: #fff; }
.btns { display: grid; gap: 10px; margin-top: 14px; }
.btns.two { grid-template-columns: 1fr 1fr; }
.hint { font-size: 14px; color: var(--muted); margin: 10px 2px 0; text-align: center; }
.error { color: var(--seal); font-weight: 500; font-size: 15px; min-height: 1.5em; margin: 8px 2px 0; text-align: center; }
@media (prefers-color-scheme: dark) { .error { color: #ff8a80; } }

/* ---------- napkins ---------- */
.napkin {
  position: relative;
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent calc(50% - .5px), rgba(80, 60, 30, .07) 50%, transparent calc(50% + .5px)),
    linear-gradient(0deg, transparent calc(50% - .5px), rgba(80, 60, 30, .07) 50%, transparent calc(50% + .5px)),
    radial-gradient(rgba(80, 60, 30, .06) .8px, transparent 1.2px);
  background-size: 100% 100%, 100% 100%, 7px 7px;
  color: var(--napkin-ink);
  border-radius: 5px;
  box-shadow: var(--shadow);
  padding: 18px 16px;
}
.napkin .cap { font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--napkin-muted); }

.napkin.big { transform: rotate(-.8deg); padding: 20px 20px 26px; margin: 6px 0 4px; }
.napkin.big .cap { display: flex; justify-content: space-between; }
.scribble {
  display: block; width: 100%; min-height: 1.6em; resize: none; overflow: hidden; border: 0; outline: none; background: transparent;
  font-family: Caveat, cursive; font-weight: 700; font-size: clamp(34px, 10vw, 46px); line-height: 1.15;
  color: var(--pen); caret-color: var(--pen); padding: 10px 2px 4px; margin-top: 4px;
  border-bottom: 2px dashed rgba(31, 63, 160, .35);
}
.scribble::placeholder { color: rgba(31, 63, 160, .25); }
.preview { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--napkin-muted); min-height: 20px; margin-top: 6px; }
.preview #count { font-variant-numeric: tabular-nums; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0 8px; }
.pair .napkin { min-height: 170px; display: flex; flex-direction: column; padding: 14px 12px; }
.pair .napkin:nth-child(1) { transform: rotate(-1.6deg); }
.pair .napkin:nth-child(2) { transform: rotate(1.4deg); }
.pair .body { flex: 1; display: grid; place-items: center; text-align: center; }
.pair .foot { font-size: 13px; color: var(--napkin-muted); text-align: center; line-height: 1.3; min-height: 2.6em; }

/* folded + sealed */
.napkin.sealed::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(135deg, rgba(80, 60, 30, .10) 0 50%, transparent 50%);
  mix-blend-mode: multiply;
}
.wax {
  display: block; width: 84px; height: 84px; flex: none; overflow: visible;
  transform: rotate(-14deg); filter: drop-shadow(0 2px 1.5px rgba(40, 5, 0, .35)) drop-shadow(0 6px 10px rgba(80, 10, 0, .18));
  position: relative; z-index: 1;
}
.wax.stamp-in { animation: stamp .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes stamp { from { transform: scale(2.2) rotate(-34deg); opacity: 0; } to { transform: scale(1) rotate(-14deg); opacity: 1; } }

/* empty / waiting napkin */
.napkin.empty { background-image: none; background-color: transparent; box-shadow: none; border: 2px dashed var(--line); color: var(--muted); }
.napkin.empty .cap, .napkin.empty .foot { color: var(--muted); }
.pen-dots { display: inline-flex; gap: 5px; }
.pen-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--pen); opacity: .25; animation: dot 1.2s infinite; }
.pen-dots i:nth-child(2) { animation-delay: .2s; }
.pen-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 50% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-color-scheme: dark) { .napkin.empty .pen-dots i { background: var(--ink); } }

/* revealed */
.said { font-family: Caveat, cursive; font-weight: 700; color: var(--pen); line-height: 1.1; white-space: pre-wrap; overflow-wrap: anywhere; padding: 8px 0; }
.said.xl { font-size: clamp(34px, 10vw, 50px); }
.said.l { font-size: clamp(28px, 8vw, 40px); }
.said.m { font-size: clamp(22px, 6vw, 30px); }
.said.s { font-size: clamp(18px, 4.8vw, 23px); line-height: 1.2; }
.napkin.open { animation: unfold .7s cubic-bezier(.2, .9, .3, 1.2) both; }
.pair .napkin.open:nth-child(2) { animation-delay: .12s; }
@keyframes unfold { from { transform: perspective(600px) rotateY(88deg) scale(.9); opacity: 0; } }

/* mini sealed chip (guest's view of creator's napkin) */
.their-chip { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 14px 0 18px; }
.their-chip .wax { width: 46px; height: 46px; }
.their-chip b { display: block; }
.their-chip span { font-size: 14px; color: var(--muted); }


/* share box */
.share { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 18px 0 6px; }
.linkbox { font: 13px/1.4 ui-monospace, "Cascadia Mono", Menlo, monospace; background: var(--table); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; word-break: break-all; color: var(--muted); user-select: all; }


/* countdown */
.countdown { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: color-mix(in srgb, var(--table) 72%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.countdown .n { text-align: center; font-family: Caveat, cursive; font-weight: 700; font-size: 180px; line-height: 1; color: var(--ink); animation: pop .9s ease-out both; }
.countdown p { text-align: center; margin: 0; color: var(--muted); font-weight: 500; }
@keyframes pop { from { transform: scale(1.6); opacity: .35; } 30% { transform: scale(1); opacity: 1; } to { opacity: .85; } }

/* lists & notes */
.trust { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); margin: 18px 2px 0; }
.trust svg { flex: none; margin-top: 2px; }
.history { margin: 34px 0 0; }
.history ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.history a { display: flex; justify-content: space-between; gap: 12px; text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.history a span:first-child { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.how { margin: 34px 0 0; display: grid; gap: 12px; }
.how div { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; font-size: 15px; }
.how b.n { font-family: Caveat, cursive; font-size: 26px; line-height: 1; color: var(--pen); }
@media (prefers-color-scheme: dark) { .how b.n { color: #9db3ff; } }
.center { text-align: center; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition: none !important; }
}

/* demos */
.try { margin: 0 0 26px; }
.try .btns { margin-top: 6px; }
.try .btn { height: 46px; font-size: 16px; }
.demo-tag { display: inline-block; margin: 14px 0 0; padding: 4px 12px; border-radius: 99px; font-size: 13px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); }
.demo-tag b { color: var(--seal); letter-spacing: .06em; }
@media (prefers-color-scheme: dark) { .demo-tag b { color: #ff8a80; } }
.demo-title { display: flex; align-items: center; color: var(--muted); }

/* your napkins */
.said-preview { display: block; font-size: 13px; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history a span:first-child { min-width: 0; }
.vault-note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); margin: 14px 2px 0; }
.vault-note svg { flex: none; margin-top: 2px; }
.vault-actions { display: flex; gap: 10px; align-items: center; margin: 8px 2px 0; font-size: 14px; color: var(--muted); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; font-size: 14px; font-weight: 500; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.rename { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 10px 0 6px; }
.rename .btn { height: 48px; width: auto; padding: 0 16px; font-size: 15px; }
