:root {
  --paper: #F4EBD9;
  --paper-2: #FBF6EA;
  --ink: #1B1A2E;
  --muted: #5B5870;
  --blue: #2B4BFF;
  --pink: #FF8FB1;
  --yellow: #FFE14D;
  --red: #D8322B;
  --rule: rgba(43, 75, 255, .13);
  --sale-bg: #FBF6EA;
  --sale-fg: #1B1A2E;
  --sale-accent: #2B4BFF;
  --share-bg: #FBF6EA;
  --share-fg: #1B1A2E;
  --share-border: rgba(27, 26, 46, .18);
  --serif: "Fraunces", Georgia, serif;
  --type: "Special Elite", "Courier New", monospace;
  --hand: "Caveat", "Comic Sans MS", cursive;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--paper);
  background-image: radial-gradient(rgba(27,26,46,.06) 1px, transparent 1.2px);
  background-size: 22px 22px;
  font: 400 19px/1.65 var(--serif);
  font-variation-settings: "SOFT" 50, "WONK" 1;
  overflow-x: hidden;
}
p { margin: 0; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 4px; }

/* ---------- Composer ---------- */
.masthead { display: flex; justify-content: space-between; align-items: center; gap: 12px; max-width: 1040px; margin: 0 auto; padding: 18px 16px; }
.logo { font-weight: 800; font-size: 24px; color: var(--ink); text-decoration: none; letter-spacing: -.02em; font-style: italic; }
.logo span { color: var(--pink); }
.stamp-small { font-family: var(--type); font-size: 13px; color: var(--red); border: 2px solid var(--red); padding: 3px 8px; transform: rotate(-3deg); border-radius: 4px; opacity: .85; white-space: nowrap; }
@media (max-width: 420px) { .stamp-small { display: none; } }

.compose { max-width: 1040px; margin: 0 auto; padding: 0 16px 64px; display: grid; gap: 40px; }
.left, .right { display: grid; gap: 40px; align-content: start; min-width: 0; }
@media (min-width: 900px) {
  .compose { grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); column-gap: 56px; align-items: start; padding-top: 32px; }
  .left { position: sticky; top: 32px; }
}
/* On phones: intro, then the form, then the examples. */
@media (max-width: 899px) {
  .left, .right { display: contents; }
  .intro { order: 1; } .sheet { order: 2; } .done { order: 3; } .examples { order: 4; }
}
.intro h1 { font-size: clamp(72px, 15vw, 168px); font-weight: 900; line-height: .86; letter-spacing: -.05em; margin: 12px 0 18px; }
.intro h1::after { content: ""; display: block; width: 1.6em; height: .14em; margin-top: .1em; background: var(--pink); border-radius: 99px; transform: rotate(-2deg); }
.lede { font-size: clamp(19px, 2.2vw, 23px); max-width: 30ch; color: var(--muted); }

.sheet {
  background: var(--paper-2);
  background-image: linear-gradient(var(--rule) 1px, transparent 1px);
  background-size: 100% 34px;
  padding: 28px clamp(18px, 4vw, 34px) 26px;
  border-radius: 6px;
  box-shadow: 0 1px 0 rgba(27,26,46,.06), 0 30px 60px -32px rgba(27,26,46,.45), 6px 6px 0 -1px var(--paper-2), 6px 6px 0 0 rgba(27,26,46,.12);
  position: relative; transform: rotate(.6deg);
  display: grid; gap: 20px;
}
.sheet::before { content: ""; position: absolute; top: -14px; left: 42px; width: 22px; height: 58px; border: 3px solid #9AA0B4; border-radius: 12px; border-bottom-color: transparent; transform: rotate(-8deg); }
.sheet-head { display: flex; justify-content: space-between; gap: 12px; font-family: var(--type); font-size: 14px; color: var(--muted); border-bottom: 2px solid var(--ink); padding-bottom: 8px; }
.field { display: grid; gap: 6px; }
.label { font-weight: 700; font-size: 17px; }
.label em { font-weight: 400; color: var(--muted); }
.field input, .field textarea {
  font: inherit; font-size: 18px; color: var(--ink); width: 100%;
  background: rgba(255,255,255,.6); border: 2px solid var(--ink); border-radius: 10px; padding: 12px 14px;
}
.big-field textarea { font-family: var(--hand); font-size: 30px; line-height: 1.2; resize: vertical; min-height: 110px; }
.field input::placeholder, .field textarea::placeholder { color: rgba(27,26,46,.35); }
.hint { font-size: 15px; color: var(--muted); font-style: italic; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 420px) { .pair { grid-template-columns: 1fr; } }

.depth { border: 0; padding: 0; margin: 0; }
.depth legend { margin-bottom: 10px; padding: 0; }
.depth-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 560px) { .depth-grid { grid-template-columns: repeat(2, 1fr); } }
.depth label { position: relative; cursor: pointer; }
.depth input { position: absolute; opacity: 0; inset: 0; }
.depth span {
  display: grid; gap: 2px; text-align: center; padding: 14px 6px 12px; border-radius: 10px; border: 2px solid var(--ink);
  background: #fff; transition: transform .15s ease, background .15s ease, box-shadow .15s;
}
.depth label:nth-child(1) span { box-shadow: 2px 2px 0 var(--ink); }
.depth label:nth-child(2) span { box-shadow: 2px 2px 0 var(--ink), 5px 5px 0 -1px #fff, 5px 5px 0 1px var(--ink); }
.depth label:nth-child(3) span { box-shadow: 2px 2px 0 var(--ink), 5px 5px 0 -1px #fff, 5px 5px 0 1px var(--ink), 8px 8px 0 -1px #fff, 8px 8px 0 1px var(--ink); }
.depth label:nth-child(4) span { box-shadow: 2px 2px 0 var(--ink), 5px 5px 0 -1px #fff, 5px 5px 0 1px var(--ink), 8px 8px 0 -1px #fff, 8px 8px 0 1px var(--ink), 11px 11px 0 -1px #fff, 11px 11px 0 1px var(--ink); }
.depth b { font-size: 17px; }
.depth small { font-family: var(--type); font-size: 12px; color: var(--muted); }
.depth input:checked + span { background: var(--yellow); transform: translate(-2px, -2px); }
.depth input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 3px; }

.error { color: var(--red); font-weight: 700; min-height: 0; }
.error:empty { display: none; }
.bury {
  font-family: var(--type); font-size: 26px; letter-spacing: .04em; text-transform: uppercase; text-decoration: none; text-align: center;
  color: var(--red); background: transparent; border: 4px solid var(--red); border-radius: 10px; padding: 12px 22px; cursor: pointer;
  transform: rotate(-2deg); justify-self: start; display: inline-block;
  box-shadow: inset 0 0 0 2px rgba(216,50,43,.25);
  transition: transform .12s ease, background .15s, color .15s;
}
.bury:hover { background: var(--red); color: var(--paper-2); }
.bury:active { transform: rotate(-2deg) scale(.95); }

.done { background: var(--ink); color: var(--paper-2); border-radius: 18px; padding: clamp(22px, 4vw, 34px); display: grid; gap: 18px; outline: none; --share-bg: rgba(255,255,255,.08); --share-fg: #FBF6EA; --share-border: rgba(255,255,255,.18); }
.done h2 { font-size: clamp(40px, 6vw, 56px); font-weight: 900; line-height: 1; letter-spacing: -.03em; margin: 0; }
.done-lede { opacity: .85; }
.scribble { font-family: var(--hand); color: var(--pink); font-weight: 700; font-size: 1.05em; display: inline-block; transform: rotate(-4deg); }
.linkbox { display: flex; gap: 8px; }
.linkbox input { flex: 1; min-width: 0; font: 15px var(--type); padding: 14px 12px; border-radius: 12px; border: 0; background: rgba(255,255,255,.1); color: #fff; }
.linkbox button { font: 800 17px var(--serif); padding: 0 20px; border-radius: 12px; border: 0; background: var(--yellow); color: var(--ink); cursor: pointer; min-height: 52px; white-space: nowrap; }

.preview-card { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 20px; padding: 16px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14); color: #fff; text-decoration: none; transition: background .15s, transform .15s; }
.preview-card:hover { background: rgba(255,255,255,.1); transform: translateY(-1px); }
.mini { display: grid; gap: 5px; align-content: start; height: 150px; padding: 12px 10px; background: var(--paper-2); border-radius: 4px; transform: rotate(-3deg); box-shadow: 0 10px 20px -8px rgba(0,0,0,.6); overflow: hidden; }
.mini-hi { font: 700 15px/1 var(--hand); color: var(--ink); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-line { height: 4px; border-radius: 2px; background: rgba(27,26,46,.22); }
.mini-line.short { width: 60%; }
.mini-gap { color: rgba(27,26,46,.35); font-size: 12px; line-height: 1; text-align: center; }
.mini-ps { font: 7px/1.2 var(--type); color: var(--red); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-cta { font-weight: 800; font-size: clamp(22px, 3vw, 28px); line-height: 1.1; letter-spacing: -.02em; }
@media (max-width: 420px) { .preview-card { grid-template-columns: 90px 1fr; } .mini { height: 120px; } }

.share-toggle { font: 700 17px var(--serif); min-height: 50px; border-radius: 999px; border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff; cursor: pointer; }
.share-toggle:hover { background: rgba(255,255,255,.08); }
.small-actions { font-size: 15px; opacity: .8; }
.small-actions button { font: inherit; background: none; border: 0; padding: 4px 0; color: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.examples h2 { font-family: var(--hand); font-weight: 700; font-size: 34px; margin: 0 0 10px; color: var(--blue); transform: rotate(-1.5deg); }
.examples ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.examples button { font: 500 17px var(--serif); padding: 8px 14px; border-radius: 999px; border: 1.5px dashed var(--ink); background: transparent; color: var(--ink); cursor: pointer; }
.examples button:hover { background: var(--yellow); border-style: solid; }

/* ---------- Reader ---------- */
.letter-title { margin: 0 0 30px; }
.letter-title h1 { font-size: clamp(40px, 7vw, 72px); font-weight: 900; line-height: .95; letter-spacing: -.035em; margin: 0 0 12px; }
.letter-title p { font-family: var(--hand); font-size: 26px; color: var(--blue); transform: rotate(-1.5deg); display: inline-block; }
.letter-wrap { max-width: 680px; margin: 0 auto; padding: 48px 16px 40px; }
@media (min-width: 900px) { .letter-wrap { padding-top: 72px; } }
.letter {
  background: var(--paper-2);
  background-image: linear-gradient(90deg, transparent 54px, rgba(216,50,43,.28) 54px, rgba(216,50,43,.28) 56px, transparent 56px), linear-gradient(var(--rule) 1px, transparent 1px);
  background-size: 100% 100%, 100% 33px;
  padding: 36px 26px 44px 74px; border-radius: 4px;
  box-shadow: 0 30px 70px -40px rgba(27,26,46,.5), 0 1px 0 rgba(27,26,46,.08);
  position: relative;
}
@media (max-width: 520px) { .letter { padding: 28px 18px 36px 40px; background-image: linear-gradient(90deg, transparent 26px, rgba(216,50,43,.28) 26px, rgba(216,50,43,.28) 28px, transparent 28px), linear-gradient(var(--rule) 1px, transparent 1px); } }
.letter-head { display: flex; flex-wrap: wrap; gap: 6px 18px; font-family: var(--type); font-size: 13px; color: var(--muted); border-bottom: 2px solid var(--ink); padding-bottom: 8px; margin-bottom: 26px; }
.letter p { margin: 0 0 1.25em; font-size: 20px; line-height: 1.65; }
.letter .greet { font-family: var(--hand); font-size: 34px; font-weight: 700; line-height: 1.1; }
.letter .fake { font-style: italic; color: var(--blue); }
.letter .fake::before { content: "→ "; }
.letter .aside-left { position: relative; }
.letter .aside-left::after {
  content: ""; position: absolute; right: -14px; top: -18px; width: 76px; height: 76px; border-radius: 50%;
  border: 5px solid rgba(139, 94, 52, .14); box-shadow: inset 0 0 0 2px rgba(139, 94, 52, .08); pointer-events: none;
}
.letter p:nth-of-type(7n)::before { content: "✎"; position: absolute; margin-left: -40px; color: var(--pink); font-size: 22px; }
@media (max-width: 520px) { .letter p:nth-of-type(7n)::before { margin-left: -30px; } }
.letter .sig { font-family: var(--hand); font-size: 28px; line-height: 1.15; margin-top: 1.6em; }
.letter .sig .name { font-weight: 700; font-size: 38px; }

.void { height: 140vh; display: grid; place-items: center; color: rgba(27,26,46,.25); font-size: 30px; letter-spacing: .4em; }
.ps-wrap { position: relative; padding: 24px 0 120px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.ps { font-family: var(--type); font-size: 11px; color: #8A8799; cursor: zoom-in; max-width: 52ch; transition: font-size .35s cubic-bezier(.2,.8,.2,1), color .3s; line-height: 1.5; }
.ps.big { font-size: clamp(26px, 6vw, 40px); color: var(--ink); cursor: zoom-out; line-height: 1.25; }
.stamp {
  font-family: var(--type); text-transform: uppercase; font-size: 22px; letter-spacing: .1em; color: var(--red);
  border: 4px double var(--red); padding: 6px 14px; border-radius: 6px; transform: rotate(-12deg) scale(2.4); opacity: 0;
  mix-blend-mode: multiply;
}
.stamp.on { opacity: .9; transform: rotate(-12deg) scale(1); transition: transform .28s cubic-bezier(.3,1.6,.5,1), opacity .12s; }
@media (prefers-reduced-motion: reduce) { .stamp.on { transition: none; } .ps { transition: none; } }

.distance { text-align: center; font-family: var(--hand); font-size: 26px; color: var(--blue); min-height: 1.2em; margin-bottom: 24px; }
.cta { text-align: center; padding: 40px 0 20px; border-top: 2px dashed rgba(27,26,46,.2); display: grid; gap: 14px; justify-items: center; }
.cta .bury { justify-self: center; }
.cta p { font-family: var(--hand); font-size: 32px; font-weight: 700; }

.meter { position: fixed; z-index: 5; pointer-events: none; }
.meter-fill { background: var(--pink); transform-origin: top; }
.meter-label { font-family: var(--type); font-size: 13px; background: var(--ink); color: var(--paper-2); padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
@media (min-width: 900px) {
  .meter { left: 28px; top: 28px; bottom: 28px; width: 14px; border: 2px solid var(--ink); border-radius: 99px; background: repeating-linear-gradient(var(--paper-2) 0 18px, var(--ink) 18px 20px); }
  .meter-fill { position: absolute; inset: 0; border-radius: 99px; transform: scaleY(0); }
  .meter-label { position: absolute; left: 26px; top: calc(var(--p, 0) * (100% - 32px)); }
}
@media (max-width: 899px) {
  .meter { left: 0; right: 0; top: 0; height: 6px; background: rgba(27,26,46,.12); }
  .meter-fill { height: 100%; transform-origin: left; transform: scaleX(var(--p, 0)) !important; }
  .meter-label { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); font-size: 12px; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
}

.foot { max-width: 1040px; margin: 0 auto; padding: 24px 16px 44px; border-top: 2px dashed rgba(27,26,46,.2); font-size: 15px; color: var(--muted); display: grid; gap: 6px; }
#read-view:not([hidden]) ~ .foot { max-width: 680px; }

.foot-link { color: inherit; text-underline-offset: 3px; }
.foot-link:hover { color: var(--accent, inherit); }
