/* Slow Post. Colours, fonts and shapes come from design/README.md.
   No inline styles anywhere: the Content-Security-Policy in _headers does not allow them. */

:root {
  --paper: #F4EFE6;
  --card: #FFFDF8;
  --paper-dark: #EAE2D3;
  --paper-dark-2: #E9E1D2;
  --ink: #1F2A44;
  --red: #C8322B;
  --red-hover: #B02A24;
  --red-dark: #861E19;
  --teal: #2F6F6A;
  --mustard: #8A6A1F;
  --airmail: #DCE8EA;
  --muted: #6B6253;
  --muted-2: #5C5446;
  --rule: #DDD3C2;
  --rule-2: #D3C8B4;
  --wood: #4A3322;
  --serif: 'Young Serif', Georgia, serif;
  --sans: 'Inter', system-ui, sans-serif;
  --mono: 'Courier Prime', 'Courier New', monospace;
  --hand: 'Caveat', cursive;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 17px; line-height: 1.6; }
body.bg-letter { background: var(--paper-dark-2); }
body.bg-desk { background: var(--wood); }
a { color: var(--red-hover); }
a:hover { color: var(--red-dark); }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; line-height: 1.1; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
.visually-hidden { 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: 10; }
.skip:focus { left: 8px; }

/* ---------- header ---------- */
.site-header { border-bottom: 1px solid var(--rule); background: var(--paper); }
body.bg-letter .site-header { border-bottom-color: var(--rule-2); }
.site-header .inner { max-width: 1200px; margin: 0 auto; padding: 14px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 32px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-height: 44px; }
.brand:hover { color: var(--ink); }
.brand span { font-family: var(--serif); font-size: 24px; }
.main-nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.main-nav a { color: var(--ink); text-decoration: none; padding: 10px 14px; border-bottom: 3px solid transparent; }
.main-nav a[aria-current="page"] { font-weight: 600; border-bottom-color: var(--red); }
.who { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--teal); color: var(--card); display: flex; align-items: center; justify-content: center; font-family: var(--serif); flex: none; }
.link-button { font: inherit; font-size: 14px; background: none; border: none; padding: 8px; color: var(--muted-2); text-decoration: underline; cursor: pointer; }

/* ---------- layout ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 48px 24px 72px; display: flex; flex-wrap: wrap; gap: 40px; align-items: flex-start; }
.col-main { flex: 999 1 640px; min-width: 0; }
.col-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.eyebrow { font-family: var(--mono); font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.label { font-family: var(--mono); font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.page-title { font-size: 52px; margin-bottom: 28px; }
.hint { margin-top: 18px; font-size: 15px; color: var(--muted); }

/* ---------- buttons and cards ---------- */
.btn { display: block; text-align: center; background: var(--red); color: #fff; text-decoration: none; padding: 15px 20px; border-radius: 6px; font: inherit; font-weight: 600; font-size: 17px; border: none; cursor: pointer; }
.btn:hover { background: var(--red-hover); color: #fff; }
.btn[disabled] { opacity: 0.6; cursor: wait; }
.btn-outline { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); font-weight: 500; }
.btn-outline:hover { background: rgba(31, 42, 68, 0.06); color: var(--ink); }
.btn-post { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 17px 20px; font-size: 19px; box-shadow: 0 6px 0 var(--red-dark); }
.btn-post:hover { background: var(--red); }
.btn-post:active:not([disabled]) { transform: translateY(4px); box-shadow: 0 2px 0 var(--red-dark); }
.card { background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: 24px; }
body.bg-letter .card { border-color: var(--rule-2); }
.card-ink { background: var(--ink); color: var(--paper); border-radius: 10px; padding: 24px; }
.card-ink .big { font-family: var(--serif); font-size: 30px; line-height: 1.15; }
.card-ink .label { color: var(--paper); margin-bottom: 6px; }
.card-ink p + p { margin-top: 10px; font-size: 15px; }
.row { display: flex; justify-content: space-between; gap: 12px; }
.row .mono { font-family: var(--mono); font-size: 14px; text-align: right; }
.stack { display: flex; flex-direction: column; gap: 12px; font-size: 16px; }
.card .more { display: inline-block; margin-top: 16px; padding: 10px 0; font-weight: 600; }
.banner { background: var(--teal); color: var(--card); border-radius: 8px; padding: 14px 18px; margin-bottom: 24px; }
.error { color: var(--red-dark); font-weight: 500; margin-top: 12px; min-height: 1.6em; }

/* ---------- stamps and postmarks ---------- */
.stamp { display: inline-block; background: var(--card); border: 4px dotted var(--card); padding: 4px; box-shadow: 0 1px 2px rgba(31, 42, 68, 0.2); }
.stamp-face { display: flex; flex-direction: column; align-items: center; justify-content: space-between; width: 46px; height: 56px; padding: 4px 0; color: var(--card); font-family: var(--mono); font-size: 9px; font-weight: 700; line-height: 1.2; }
.stamp-face .glyph { font-family: var(--serif); font-size: 20px; font-weight: 400; line-height: 1; }
.stamp-face svg { display: block; }
.stamp-town { background: var(--teal); }
.stamp-pillar { background: var(--red); }
.stamp-bloom { background: var(--ink); }
.stamp-night { background: #3D4A63; }
.stamp-rare { background: var(--mustard); }
.stamp-lg { border-color: var(--wood); box-shadow: none; }
.stamp-lg .stamp-face { width: 52px; height: 64px; padding: 5px 0; }
.stamp-lg .stamp-face .glyph { font-size: 22px; }
.postmark { width: 66px; height: 66px; border: 2px solid rgba(31, 42, 68, 0.45); border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--mono); font-size: 9px; line-height: 1.2; text-align: center; color: var(--ink); }
.postmark b { font-weight: 700; }
.postmark-lg { width: 76px; height: 76px; font-size: 10px; flex: none; transform: rotate(-10deg); }

/* ---------- the doormat ---------- */
.coir { background-color: #B88A4E; background-image: repeating-linear-gradient(90deg, rgba(80, 52, 20, 0.18) 0 2px, transparent 2px 6px), repeating-linear-gradient(0deg, rgba(255, 240, 210, 0.12) 0 1px, transparent 1px 5px); border-radius: 14px; padding: 44px 36px; min-height: 460px; box-shadow: inset 0 0 0 10px rgba(80, 52, 20, 0.25), inset 0 0 40px rgba(60, 36, 10, 0.35); }
.envelopes { display: flex; flex-wrap: wrap; gap: 36px 32px; justify-content: center; align-items: center; }
.env { display: block; position: relative; width: 300px; max-width: 100%; height: 186px; background: var(--card); border-radius: 3px; box-shadow: 0 12px 22px rgba(40, 24, 6, 0.4); text-decoration: none; color: var(--ink); transition: transform 0.15s ease; transform: rotate(var(--tilt, -3deg)); }
.env:hover { color: var(--ink); transform: translateY(-4px) rotate(0deg); }
.env:nth-child(5n+1) { --tilt: -6deg; }
.env:nth-child(5n+2) { --tilt: 4deg; }
.env:nth-child(5n+3) { --tilt: -2deg; }
.env:nth-child(5n+4) { --tilt: 3deg; }
.env:nth-child(5n+5) { --tilt: -4deg; }
.env-plain { background: #F2E3C6; }
.env-airmail { background: var(--airmail); }
.env-plain .stamp { border-color: #F2E3C6; background: #F2E3C6; }
.env-airmail .stamp { border-color: var(--airmail); background: var(--airmail); }
.env .stamp { position: absolute; right: 14px; top: 12px; }
.env .postmark { position: absolute; right: 54px; top: 26px; transform: rotate(-12deg); }
.env:nth-child(even) .postmark { transform: rotate(10deg); }
.env .from { position: absolute; left: 22px; top: 18px; font-family: var(--mono); font-size: 11px; color: var(--muted-2); text-transform: uppercase; }
.env .addr { position: absolute; left: 26px; bottom: 22px; font-family: var(--hand); font-size: 25px; line-height: 1.1; }
.env .addr span { display: block; padding-left: 20px; }
.env .when { position: absolute; right: 16px; bottom: 14px; font-family: var(--mono); font-size: 11px; color: var(--muted-2); }
.empty-card { background: var(--card); border-radius: 8px; padding: 32px 36px; max-width: 420px; text-align: center; box-shadow: 0 10px 22px rgba(40, 24, 6, 0.35); transform: rotate(-1.5deg); }
.empty-card svg { display: block; margin: 0 auto; }
.empty-card .big { margin: 14px 0 6px; font-family: var(--serif); font-size: 28px; line-height: 1.2; }
.coir-empty { display: flex; align-items: center; justify-content: center; min-height: 372px; }
.read-list { margin-top: 28px; }
.read-list a { display: block; padding: 10px 0; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.read-list a:hover { color: var(--red-hover); }
.read-list .mono { font-family: var(--mono); font-size: 14px; color: var(--muted); float: right; }

/* ---------- reading a letter ---------- */
.back { display: inline-flex; align-items: center; gap: 8px; padding: 10px 0; color: var(--ink); font-weight: 500; }
.read { display: flex; flex-wrap: wrap; gap: 48px; align-items: flex-start; margin-top: 20px; }
.letter-wrap { flex: 999 1 600px; min-width: 0; position: relative; padding-top: 70px; }
.torn { position: absolute; left: 6%; right: 10%; top: 0; height: 170px; background: #F7F1E4; border-radius: 3px; box-shadow: 0 8px 18px rgba(31, 42, 68, 0.15); transform: rotate(-2.5deg); }
.torn::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 36px; background: repeating-linear-gradient(135deg, #F7F1E4 0 8px, #EDE4D1 8px 16px); clip-path: polygon(0 0, 100% 0, 100% 60%, 96% 100%, 92% 55%, 88% 100%, 84% 50%, 80% 100%, 76% 55%, 72% 100%, 68% 50%, 64% 100%, 60% 55%, 56% 100%, 52% 50%, 48% 100%, 44% 55%, 40% 100%, 36% 50%, 32% 100%, 28% 55%, 24% 100%, 20% 50%, 16% 100%, 12% 55%, 8% 100%, 4% 50%, 0 100%); }
.torn .stamp { position: absolute; right: 18px; top: 44px; border-color: #F7F1E4; background: #F7F1E4; }
.sheet { position: relative; border-radius: 2px; box-shadow: 0 18px 40px rgba(31, 42, 68, 0.22); padding: 56px 64px 64px; transform: rotate(0.6deg); font-family: var(--hand); font-size: 27px; line-height: 40px; color: var(--ink); background-color: var(--card); overflow-wrap: anywhere; }
.paper-ruled { background-color: var(--card); background-image: repeating-linear-gradient(180deg, transparent 0 39px, rgba(47, 111, 106, 0.22) 39px 40px); }
.paper-plain { background-color: #F7EEDB; background-image: none; }
.paper-airmail { background-color: var(--airmail); background-image: repeating-linear-gradient(180deg, transparent 0 39px, rgba(31, 42, 68, 0.14) 39px 40px); }
.sheet .dateline { text-align: right; margin-bottom: 40px; }
.sheet .text { white-space: pre-wrap; }
.journey-head { display: flex; gap: 18px; align-items: center; margin-bottom: 16px; }
.journey-head .big { font-family: var(--serif); font-size: 22px; line-height: 1.2; }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---------- the writing desk ---------- */
.desk { background-color: var(--wood); background-image: repeating-linear-gradient(92deg, rgba(255, 220, 170, 0.05) 0 3px, transparent 3px 11px), repeating-linear-gradient(88deg, rgba(0, 0, 0, 0.08) 0 1px, transparent 1px 23px); padding: 48px 24px 80px; min-height: calc(100vh - 77px); }
.desk-inner { max-width: 1200px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 44px; align-items: flex-start; }
.desk-main { flex: 999 1 620px; min-width: 0; }
.desk h1 { font-size: 44px; color: var(--paper); margin-bottom: 6px; }
.desk .lede { color: #E6D9C4; margin-bottom: 28px; }
.page-sheet { border-radius: 2px; box-shadow: 0 24px 50px rgba(0, 0, 0, 0.45); padding: 44px 56px 48px; transform: rotate(-0.6deg); }
.sheet-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 20px; font-family: var(--mono); font-size: 15px; }
.sheet-top label { display: flex; align-items: center; gap: 10px; }
.sheet-top select { font: inherit; color: var(--ink); background: transparent; border: none; border-bottom: 1.5px solid var(--ink); padding: 8px 4px; min-height: 44px; max-width: 100%; }
.sheet-top .date { color: var(--muted-2); }
#letter { width: 100%; border: none; background: transparent; resize: vertical; font-family: var(--hand); font-size: 27px; line-height: 40px; color: var(--ink); padding: 0; min-height: 560px; }
#letter:focus { outline: 3px solid var(--red); outline-offset: 4px; }
.count { margin-top: 8px; text-align: right; font-family: var(--mono); font-size: 13px; color: var(--muted-2); }
.choices { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 36px; }
.choices fieldset { border: none; margin: 0; padding: 0; flex: 1 1 320px; min-width: 0; }
.choices fieldset.papers { flex-basis: 260px; }
.choices legend { padding: 0; margin-bottom: 12px; font-family: var(--mono); font-size: 14px; letter-spacing: 0.08em; color: var(--paper); text-transform: uppercase; }
.pick-row { display: flex; flex-wrap: wrap; gap: 14px; }
.stamp-pick { background: transparent; border: none; padding: 6px; cursor: pointer; border-radius: 6px; outline: 3px solid transparent; outline-offset: 2px; }
.stamp-pick[aria-pressed="true"] { outline-color: var(--paper); }
.paper-pick { font: inherit; font-size: 15px; min-height: 44px; padding: 8px 16px; border-radius: 999px; cursor: pointer; border: 2px solid #E6D9C4; background: var(--card); color: var(--ink); margin-right: 4px; }
.paper-pick[aria-pressed="true"] { border-color: var(--red); }
.desk-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 20px; margin-top: 106px; }
.estimate { background: var(--paper); border-radius: 10px; padding: 26px; }
.estimate .big { font-family: var(--serif); font-size: 26px; line-height: 1.2; margin-bottom: 16px; }
.estimate ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.estimate li { display: flex; gap: 12px; }
.estimate li b { font-family: var(--mono); color: var(--red-hover); }
.estimate .fine { margin-top: 14px; font-size: 14px; color: var(--muted); }
.desk-note { margin-top: 6px; text-align: center; color: var(--paper); font-size: 15px; }
.btn-ghost { font: inherit; font-size: 15px; background: transparent; color: var(--paper); border: 1.5px solid #E6D9C4; border-radius: 6px; padding: 12px 18px; cursor: pointer; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.desk .error { color: #FFD9D4; }

/* ---------- the front page ---------- */
.hero { max-width: 1200px; margin: 0 auto; padding: 64px 24px 40px; display: flex; flex-wrap: wrap; gap: 48px; align-items: center; }
.hero-text { flex: 1 1 460px; min-width: 0; }
.hero h1 { font-size: 64px; line-height: 1.03; margin-bottom: 20px; }
.hero .lede { font-size: 21px; max-width: 34em; color: var(--muted-2); }
.hero .box { flex: 1 1 360px; min-width: 0; max-width: 460px; }
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--rule); }
.tabs button { font: inherit; background: none; border: none; border-bottom: 3px solid transparent; padding: 10px 14px; cursor: pointer; color: var(--ink); }
.tabs button[aria-selected="true"] { font-weight: 600; border-bottom-color: var(--red); }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.field small { display: block; font-size: 14px; color: var(--muted); margin-top: 4px; }
.field input, .field select { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1.5px solid var(--rule-2); border-radius: 6px; padding: 10px 12px; min-height: 44px; }
.form .btn { width: 100%; }
.how { max-width: 1200px; margin: 0 auto; padding: 24px 24px 80px; }
.how h2 { font-size: 36px; margin-bottom: 8px; }
.how .lede { color: var(--muted-2); margin-bottom: 28px; max-width: 40em; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; }
.steps li { background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: 22px; }
.steps b { display: block; font-family: var(--mono); font-size: 14px; letter-spacing: 0.08em; color: var(--red-hover); margin-bottom: 6px; }
.steps h3 { font-size: 22px; margin-bottom: 8px; }
.steps p { font-size: 15px; color: var(--muted-2); }

@media (max-width: 640px) {
  .page-title { font-size: 40px; }
  .hero h1 { font-size: 44px; }
  .coir { padding: 28px 16px; }
  .sheet { padding: 36px 24px 44px; font-size: 24px; }
  .page-sheet { padding: 28px 22px 32px; }
  .desk-side { margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .env { transition: none; }
}

/* ---------- small extras ---------- */
.col-full { flex: 1 1 100%; min-width: 0; }
.page-letter { padding-top: 32px; }
.welcome-line { font-size: 19px; }
.gap { margin-top: 18px; }

/* ---------- on its way ---------- */
.track-page { max-width: 1200px; margin: 0 auto; padding: 48px 24px 80px; }
.track-page .page-title { margin-bottom: 32px; }
.flight { background: var(--card); border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; margin-bottom: 28px; }
.flight-top { background: var(--ink); color: var(--paper); padding: 28px 32px 8px; }
.flight-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; align-items: baseline; }
.flight-row h2 { font-size: 30px; }
.flight-row .mono { font-family: var(--mono); font-size: 15px; }
.route { display: block; width: 100%; height: auto; margin-top: 8px; }
.route-town { font-family: var(--mono); font-size: 20px; fill: var(--paper); }
.route-note { font-family: var(--mono); font-size: 18px; fill: var(--paper); }
.flight-body { padding: 32px; }
.stages { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.stage { border-top: 4px solid var(--teal); padding-top: 12px; }
.stage p { margin: 0; }
.stage .state { font-family: var(--mono); font-size: 14px; color: var(--muted-2); }
.stage .name { margin-top: 2px; font-weight: 600; }
.stage .when { font-size: 15px; color: var(--muted-2); }
.stage-done .state { color: var(--teal); font-weight: 700; }
.stage-now { border-top-color: var(--red); }
.stage-now .state { color: var(--red-hover); font-weight: 700; }
.stage-next, .stage-then { border-top: 4px dashed #B9AE9B; }
.track-lower h2 { font-size: 28px; margin: 12px 0 14px; }
.sent-list { display: flex; flex-direction: column; border-top: 1px solid var(--rule); max-width: 720px; }
.sent-list .hint { margin: 14px 0; }
.sent-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
.sent-row p { margin: 0; }
.sent-row .who-line { font-weight: 600; }
.sent-row .sub { font-size: 15px; color: var(--muted-2); }
.chip { align-self: center; font-family: var(--mono); font-size: 14px; background: var(--paper-dark); padding: 4px 10px; border-radius: 999px; }
.chip-done { background: #D7E6E4; }
.big-line { font-family: var(--serif); font-size: 26px; line-height: 1.2; }
@media (max-width: 640px) { .flight-top { padding: 22px 18px 8px; } .flight-body { padding: 22px 18px; } }

/* ---------- pen pals and invites ---------- */
.block { margin-bottom: 40px; }
.block h2 { font-size: 28px; margin-bottom: 14px; }
.lede-sm { color: var(--muted-2); margin-bottom: 18px; max-width: 38em; }
.pal-list { display: flex; flex-direction: column; border-top: 1px solid var(--rule); max-width: 720px; margin-top: 18px; }
.pal-list:empty { display: none; }
.pal-list .hint { margin: 14px 0; }
.more-link { align-self: center; font-weight: 600; padding: 8px 0; }
.btn-fit { display: inline-block; width: auto; }
.btn-small { padding: 10px 16px; font-size: 15px; width: auto; }
.link-card { margin-top: 18px; max-width: 720px; }
.link-row { display: flex; flex-wrap: wrap; gap: 10px; }
.link-row input { flex: 1 1 260px; min-width: 0; font: inherit; font-family: var(--mono); font-size: 15px; padding: 10px 12px; border: 1.5px solid var(--rule-2); border-radius: 6px; background: #fff; color: var(--ink); }
.invite-banner { background: var(--teal); color: var(--card); border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; font-weight: 500; }
.invite-banner.bad { background: var(--paper-dark); color: var(--ink); }
.error.ok { color: var(--teal); }
