@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 300 700; font-display: swap; src: url(/fonts/fraunces-normal-300-700.woff2) format("woff2"); }
@font-face { font-family: "Fraunces"; font-style: italic; font-weight: 300 700; font-display: swap; src: url(/fonts/fraunces-italic-300-700.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/atkinson-hyperlegible-normal-400.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/atkinson-hyperlegible-normal-700.woff2) format("woff2"); }
@font-face { font-family: "Caveat"; font-style: normal; font-weight: 500 700; font-display: swap; src: url(/fonts/caveat-normal-500-700.woff2) format("woff2"); }

/* The look: a letter in the post. Pillar-box red, airmail blue, writing-paper cream, navy ink. */
:root {
  --bg: #fbf3e2;
  --card: #fffdf8;
  --ink: #1f2a44;
  --muted: #566078;
  --line: #e4d8bf;
  --accent: #c8322b;
  --accent-dark: #9f241e;
  --accent-ink: #ffffff;
  --accent-soft: #fbe4de;
  --blue: #2a4e9b;
  --blue-soft: #e3eaf7;
  --sun: #f2b33d;
  --good: #1f6b43;
  --good-soft: #e0f0e6;
  --bad: #a3271d;
  --bad-soft: #fbe7e4;
  --radius: 14px;
  --gap: 16px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Atkinson Hyperlegible", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --hand: "Caveat", "Bradley Hand", cursive;
  --airmail: repeating-linear-gradient(-55deg, var(--accent) 0 14px, var(--bg) 14px 22px, var(--blue) 22px 36px, var(--bg) 36px 44px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 18px/1.55 var(--sans); }
body::before { content: ""; display: block; height: 8px; background: var(--airmail); }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0; }
a { color: var(--accent); }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid #1d5fd1; outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

.site-header { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); padding: 12px 16px; max-width: 1040px; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; font-family: var(--serif); font-weight: 600; font-size: 1.25rem; color: var(--ink); text-decoration: none; }
.site-header nav { display: flex; align-items: center; gap: 0 16px; flex-wrap: wrap; justify-content: flex-end; font-size: 0.95rem; }
.site-header nav form { margin: 0; }
.site-header nav a, .linklike { color: var(--ink); font: inherit; padding: 10px 0; min-height: 44px; display: inline-flex; align-items: center; }
.linklike { background: none; border: 0; text-decoration: underline; cursor: pointer; }
.linklike.danger { color: var(--bad); }

main { max-width: 900px; margin: 0 auto; padding: 8px 16px 48px; display: flex; flex-direction: column; gap: var(--gap); }
main.narrow { max-width: 520px; }
.site-footer { max-width: 1040px; margin: 0 auto; padding: 16px 16px 40px; color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--line); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head.plain { margin-top: 8px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; padding-top: 8px; }
.sticky-head { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: 10px 0; }
.section-title { margin-top: 12px; }
.quiet, .hint { color: var(--muted); font-size: 0.95rem; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .two { grid-template-columns: 1fr; } }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.inline { display: inline; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.grow { flex: 1 1 220px; }
label { font-weight: 600; font-size: 0.95rem; }
.optional { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input:not([type]), textarea {
  font: inherit; color: inherit; background: #fff; border: 1.5px solid #b9aea1; border-radius: 8px; padding: 11px 12px; width: 100%; min-height: 46px;
}
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #8b8178; }
input.num { width: 76px; }
input.copy { font-size: 0.85rem; min-width: 260px; }

.btn { font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px; border-radius: 10px; border: 1.5px solid #a99f8c; background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 var(--accent-dark); }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-dark); }
.btn.big { min-height: 54px; padding: 12px 26px; font-size: 1.08rem; }
.btn.small { min-height: 44px; padding: 6px 14px; font-size: 0.95rem; }
.btn.danger-outline { color: var(--bad); border-color: var(--bad); }
.btn[disabled], .btn[aria-disabled=true] { opacity: 0.55; cursor: not-allowed; }
.btn.busy::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn.busy::before { animation: none; } html { scroll-behavior: auto; } }

.error { color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 10px 12px; }
.notice { background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.notice.good { background: var(--good-soft); }
.save-state { color: var(--muted); font-size: 0.95rem; }
.save-state.bad { color: var(--bad); font-weight: 600; }
.summary { line-height: 1.5; }
.count { color: var(--muted); font-size: 0.95rem; }

/* Landing */
main.landing { max-width: 1040px; gap: 0; padding-bottom: 0; }
.lp-hero { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 40px; align-items: center; padding: 28px 0 56px; }
.lp-copy { display: flex; flex-direction: column; gap: 20px; }
.lp-copy h1 { font-size: clamp(2.1rem, 5.4vw, 3.5rem); font-weight: 600; line-height: 1.04; letter-spacing: -0.02em; }
.lp-copy h1 em { font-style: italic; color: var(--accent); white-space: nowrap; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 12' preserveAspectRatio='none'%3E%3Cpath d='M2 8 C 40 2, 70 11, 110 6 S 170 3, 198 7' fill='none' stroke='%23f2b33d' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 0 100% / 100% 0.32em; padding-bottom: 0.12em; }
.lead { font-size: 1.2rem; max-width: 34em; }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; }
.lp-art { position: relative; aspect-ratio: 10 / 11.6; max-width: 500px; width: 100%; justify-self: center; }
.envelope { position: absolute; left: 0; right: 22%; bottom: 2%; height: 40%; background: #fffaf0; border: 14px solid transparent; border-image: var(--airmail) 14; box-shadow: 0 14px 30px rgba(31, 42, 68, 0.18); transform: rotate(-5deg); }
.envelope .stamp { position: absolute; top: 10px; right: 10px; width: 54px; height: 64px; background: var(--accent); border: 4px dotted #fffaf0; outline: 4px solid var(--accent); display: grid; place-items: center; }
.envelope .stamp svg { width: 30px; height: 30px; }
.envelope .lines { position: absolute; left: 12%; top: 44%; width: 46%; display: grid; gap: 8px; }
.envelope .lines i { height: 6px; border-radius: 3px; background: #d9cdb3; }
.envelope .lines i:nth-child(2) { width: 78%; } .envelope .lines i:nth-child(3) { width: 55%; }
.lp-art .page { position: absolute; top: 0; right: 0; width: 64%; height: auto; border-radius: 4px; box-shadow: 0 18px 40px rgba(31, 42, 68, 0.25), 0 0 0 1px rgba(31, 42, 68, 0.06); transform: rotate(4deg); background: #fff; }
.polaroid { position: absolute; left: 0; top: 14%; width: 38%; background: #fff; padding: 8px 8px 0; box-shadow: 0 12px 26px rgba(31, 42, 68, 0.22); transform: rotate(-7deg); }
.polaroid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; object-position: 30% 70%; }
.polaroid span { display: block; font-family: var(--hand); font-size: 1.35rem; line-height: 1; text-align: center; padding: 8px 0 10px; color: var(--ink); }
.scribble { position: absolute; font-family: var(--hand); font-size: 1.5rem; line-height: 1.05; color: var(--blue); transform: rotate(-4deg); }
.scribble.one { right: -6%; bottom: 12%; text-align: left; }
.scribble svg { display: block; width: 46px; margin: 0 0 4px 10px; }

.band { padding: 56px 0; }
/* Full-width background without leaving the centred column. */
/* (named "tint", because .paper is the letter sheet in the editor) */
.band.tint { background: var(--card); box-shadow: 0 0 0 100vmax var(--card); clip-path: inset(0 -100vmax); }
.band h2 { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 600; }
.band .intro { margin-top: 10px; font-size: 1.1rem; max-width: 40em; }

.how { list-style: none; margin: 28px auto 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; counter-reset: step; }
.how li { counter-increment: step; background: var(--bg); border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 12px; position: relative; box-shadow: 5px 5px 0 var(--ink); }
.how li::before { content: counter(step); position: absolute; top: -18px; left: 16px; width: 40px; height: 40px; border-radius: 50%; background: var(--sun); border: 1.5px solid var(--ink); display: grid; place-items: center; font: 600 1.25rem var(--serif); }
.how h3 { font-size: 1.3rem; font-weight: 600; margin-top: 10px; }
.how .demo { margin-top: auto; padding-top: 8px; }
.mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mini-grid img, .mini-grid .more { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.mini-grid .more { border: 2px dashed #a99f8c; display: grid; place-items: center; font-size: 1.5rem; color: var(--accent); background: #fff; }
.chat { display: flex; flex-direction: column; gap: 8px; }
.bubble { border-radius: 16px; padding: 10px 14px; font-size: 0.95rem; line-height: 1.35; max-width: 92%; }
.bubble.me { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; display: flex; align-items: center; gap: 10px; }
.bubble.them { align-self: flex-start; background: #fff; border: 1.5px solid var(--line); border-bottom-left-radius: 4px; }
.wave { display: flex; align-items: center; gap: 3px; height: 24px; }
.wave i { width: 3px; border-radius: 2px; background: #fff; }
.post-demo { display: flex; align-items: center; gap: 14px; }
.post-demo img { width: 38%; border-radius: 3px; box-shadow: 0 4px 12px rgba(31, 42, 68, 0.2); transform: rotate(-3deg); background: #fff; }
.fake-btn { background: var(--accent); color: #fff; font-weight: 700; font-size: 0.95rem; line-height: 1.2; padding: 10px 12px; border-radius: 10px; box-shadow: 0 3px 0 var(--accent-dark); text-align: center; }

.sample-pages { margin-top: 28px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.sample-pages img { display: block; width: 100%; background: #fff; border-radius: 4px; box-shadow: 0 16px 36px rgba(31, 42, 68, 0.18), 0 0 0 1px rgba(31, 42, 68, 0.06); }
.sample-pages figure { margin: 0; }
.sample-pages figure:first-child { transform: rotate(-1deg); } .sample-pages figure:last-child { transform: rotate(1deg); }
.fine { margin-top: 18px; color: var(--muted); font-size: 0.95rem; }

.gets { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: 44px; align-items: center; }
.gets .photo { position: relative; }
.gets .photo img { display: block; width: 100%; border-radius: 6px; border: 10px solid #fff; box-shadow: 0 14px 32px rgba(31, 42, 68, 0.2); transform: rotate(-2deg); }
.gets ul { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.gets li { padding-left: 34px; position: relative; font-size: 1.08rem; }
.gets li::before { content: ""; position: absolute; left: 0; top: 0.2em; width: 22px; height: 22px; border-radius: 50%; background: var(--good-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='%231f6b43' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat; }

.invite { margin: 56px 0; background: #fffaf0; border: 14px solid transparent; border-image: var(--airmail) 14; padding: 32px 28px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px 32px; }
.invite h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); font-weight: 600; }
.invite p { margin-top: 8px; max-width: 34em; }

@media (max-width: 820px) {
  .lp-hero { grid-template-columns: 1fr; gap: 28px; padding-bottom: 40px; }
  .lp-art { max-width: 420px; }
  .scribble { display: none; }
  .how { grid-template-columns: 1fr; gap: 30px; }
  .gets { grid-template-columns: 1fr; gap: 28px; }
  .gets .photo { max-width: 360px; }
  .band { padding: 44px 0; }
}
@media (max-width: 560px) {
  .sample-pages { grid-template-columns: 1fr; }
  .invite { padding: 22px 16px; }
}

/* Lists of letters */
.row-card { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; }
.link-card { color: inherit; text-decoration: none; }
.link-card:hover { border-color: var(--ink); }
.chev { font-size: 1.6rem; color: var(--muted); }
.empty { align-items: flex-start; }
.start-row { display: flex; }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.photo-grid.small { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #eee9e2; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.pending { display: grid; place-items: center; color: var(--muted); font-size: 0.85rem; text-align: center; padding: 6px; }
.thumb-x { position: absolute; top: 4px; right: 4px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(30, 24, 20, 0.72); color: #fff; font-size: 1rem; cursor: pointer; display: grid; place-items: center; }
.thumb .put-back { position: absolute; left: 4px; right: 4px; bottom: 4px; min-height: 44px; border-radius: 8px; border: 0; background: rgba(255, 255, 255, 0.94); font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.add-photos { aspect-ratio: 1; border: 2px dashed #b9aea1; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; text-align: center; font-size: 0.9rem; color: var(--ink); background: #fff; }
.add-photos:hover { border-color: var(--accent); }
.add-photos input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.add-photos:focus-within { outline: 3px solid #1d5fd1; outline-offset: 2px; }
.add-photos .plus { font-size: 1.7rem; line-height: 1; color: var(--accent); }
.add-photos.full { display: none; }

.questions { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.make-row { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }

/* The letter on screen */
.paper-wrap { width: 100%; overflow: hidden; overflow: clip; } /* clip: never becomes a hidden scroll area */
.paper { transform-origin: top left; width: 210mm; box-shadow: 0 6px 24px rgba(60, 40, 20, 0.14); border: 1px solid var(--line); }
.sheet.is-editing { padding: 15mm; min-height: 120mm; }
.sheet.is-editing [data-role]:hover { background: #fbf3e6; }
.sheet.is-editing [data-role] { border-radius: 1mm; cursor: text; outline-offset: 1.5mm; }
.sheet.is-editing [data-role]:focus { outline: 0.6mm solid #1d5fd1; background: #fff; }
.sheet.is-editing [data-role]:empty::before { content: attr(data-placeholder); color: #9a8f85; }
.sheet .missing { color: #9a8f85; font-style: italic; }
.sheet .photo-tools { position: absolute; top: 2mm; right: 2mm; display: none; flex-direction: column; align-items: flex-end; gap: 6px; transform: scale(calc(1 / var(--sheet-scale, 1))); transform-origin: top right; }
.sheet figure:hover .photo-tools, .sheet figure:focus-within .photo-tools, .sheet figure.show-tools .photo-tools { display: flex; }
.sheet .photo-tools button { font: 600 14px var(--sans); min-height: 44px; padding: 6px 12px; border-radius: 8px; border: 0; background: rgba(255, 255, 255, 0.95); color: #2a2522; cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); }
.left-out { display: flex; flex-direction: column; gap: 10px; }
.send-bar { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.send-bar .hint { margin-top: 6px; max-width: 46ch; }
.delete-form { margin-top: 8px; }
#letter-section { display: flex; flex-direction: column; gap: 12px; }
#letter-section[hidden] { display: none; }

dialog { border: 0; border-radius: var(--radius); padding: 22px; width: min(480px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: rgba(30, 24, 20, 0.5); }
dialog > * + * { margin-top: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.address-preview { white-space: pre-line; background: var(--bg); border-radius: 8px; padding: 12px; font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #2a2522; color: #fff; padding: 12px 16px; border-radius: 10px; z-index: 60; display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); }
.toast[hidden] { display: none; }
.toast button { background: none; border: 0; color: #ffd9a8; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; min-height: 44px; padding: 0 4px; }

/* Sent page */
.sent { align-items: flex-start; }
.tick { width: 56px; height: 56px; border-radius: 50%; background: var(--good-soft); color: var(--good); display: grid; place-items: center; font-size: 1.8rem; font-weight: 700; }
.facts { margin: 0; display: flex; flex-direction: column; gap: 8px; width: 100%; }
.facts div { display: flex; gap: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.facts dt { color: var(--muted); min-width: 84px; }
.facts dd { margin: 0; }

/* Admin */
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.inline-form.tight { gap: 8px; align-items: center; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 10px 12px 10px 0; border-top: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; border-top: 0; }
.auth h1 { font-size: 1.5rem; }
