/* Letter pages: the writing studio (two rooms: the desk and the counter), letters arriving, the letter box and
   the reading room. Sheets, inks, envelopes and wax are drawn here and in public/js/paper.js. No inline styles
   (strict CSP): anything that varies per letter is set from JavaScript through the DOM. */

/* ---------- handwriting and signature faces (self-hosted, OFL / Apache 2.0); the Latin Extended files cover accents */
@font-face { font-family: 'Homemade Apple'; src: url('/fonts/apple.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'La Belle Aurore'; src: url('/fonts/aurore.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: 'La Belle Aurore'; src: url('/fonts/aurore-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Cedarville Cursive'; src: url('/fonts/cedar.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Dawning of a New Day'; src: url('/fonts/dawn.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Caveat'; src: url('/fonts/hand.woff2') format('woff2'); font-weight: 400 700; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: 'Caveat'; src: url('/fonts/hand-ext.woff2') format('woff2'); font-weight: 400 700; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Covered By Your Grace'; src: url('/fonts/grace.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Covered By Your Grace'; src: url('/fonts/grace-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Sacramento'; src: url('/fonts/sacra.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Sacramento'; src: url('/fonts/sacra-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Zeyada'; src: url('/fonts/zeyada.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Zeyada'; src: url('/fonts/zeyada-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Give You Glory'; src: url('/fonts/glory.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Give You Glory'; src: url('/fonts/glory-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Shadows Into Light'; src: url('/fonts/shadows.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Shadows Into Light'; src: url('/fonts/shadows-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Indie Flower'; src: url('/fonts/indie.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Indie Flower'; src: url('/fonts/indie-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Kalam'; src: url('/fonts/kalam.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Kalam'; src: url('/fonts/kalam-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Waiting for the Sunrise'; src: url('/fonts/sunrise.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Waiting for the Sunrise'; src: url('/fonts/sunrise-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Architects Daughter'; src: url('/fonts/archi.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Architects Daughter'; src: url('/fonts/archi-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'The Girl Next Door'; src: url('/fonts/girl.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'The Girl Next Door'; src: url('/fonts/girl-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Over the Rainbow'; src: url('/fonts/rainbow.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Over the Rainbow'; src: url('/fonts/rainbow-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Pinyon Script'; src: url('/fonts/pinyon.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Pinyon Script'; src: url('/fonts/pinyon-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Petit Formal Script'; src: url('/fonts/petit.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Petit Formal Script'; src: url('/fonts/petit-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Meddon'; src: url('/fonts/meddon.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Meddon'; src: url('/fonts/meddon-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Reenie Beanie'; src: url('/fonts/reenie.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Nothing You Could Do'; src: url('/fonts/nothing.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Rock Salt'; src: url('/fonts/rock.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Mrs Saint Delafield'; src: url('/fonts/sig1.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Mrs Saint Delafield'; src: url('/fonts/sig1-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Herr Von Muellerhoff'; src: url('/fonts/sig2.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Herr Von Muellerhoff'; src: url('/fonts/sig2-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Monsieur La Doulaise'; src: url('/fonts/sig3.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Monsieur La Doulaise'; src: url('/fonts/sig3-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Great Vibes'; src: url('/fonts/vibes.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Great Vibes'; src: url('/fonts/vibes-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Alex Brush'; src: url('/fonts/alex.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Alex Brush'; src: url('/fonts/alex-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Allura'; src: url('/fonts/allura.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Allura'; src: url('/fonts/allura-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Parisienne'; src: url('/fonts/paris.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Parisienne'; src: url('/fonts/paris-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Mr De Haviland'; src: url('/fonts/havi.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Mr De Haviland'; src: url('/fonts/havi-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Miss Fajardose'; src: url('/fonts/faja.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Miss Fajardose'; src: url('/fonts/faja-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Italianno'; src: url('/fonts/ital.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: 'Italianno'; src: url('/fonts/ital-ext.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02BA, U+02BD-02FF, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }

/* ---------- the rooms */
body.letters main { min-height: 0; }
.room { --lh: 2.05em; --room-ink: #f3e9d6; --room-muted: #cdb995; --brass: #a8843e;
  color: var(--room-ink); padding-block: 18px 28px; }
.room > * { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: 16px; }
.room[data-room="desk"] {
  background:
    radial-gradient(70% 55% at 72% 0%, rgb(255 205 130 / .14), transparent 70%),
    repeating-linear-gradient(92deg, rgb(0 0 0 / 0) 0 18px, rgb(0 0 0 / .07) 18px 19px, rgb(255 255 255 / .02) 19px 41px),
    repeating-linear-gradient(88deg, rgb(255 230 190 / .025) 0 3px, transparent 3px 7px),
    linear-gradient(180deg, #4a3221, #33231a 60%, #2b1d15);
}
.room[data-room="counter"] { --room-ink: #22352c; --room-muted: #4d6357; background: linear-gradient(180deg, #d7e2d3, #c5d3c1); border-top: 6px solid var(--brass); }
.room-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 16px; }
.room-bar h1 { margin: 0 auto 0 0; font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 500; color: var(--room-ink); }
.seg { display: flex; gap: 4px; background: rgb(0 0 0 / .14); padding: 4px; border-radius: 10px; }
.seg button { border: 0; background: transparent; color: var(--room-ink); padding: 7px 12px; border-radius: 7px; cursor: pointer; font: 700 .88rem var(--f-ui); min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .25); }
.toggles { display: flex; gap: 8px; }
.tog { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid currentColor; background: transparent; color: var(--room-ink); border-radius: 999px; padding: 5px 12px; cursor: pointer; font: 700 .84rem var(--f-ui); min-height: 34px; }
.tog[aria-pressed="false"] { opacity: .55; text-decoration: line-through; }
.room-note { color: var(--room-muted); font: .9rem var(--f-ui); margin-top: 18px; }
.room-note a { color: var(--room-ink); }
.room .form-err { max-width: 660px; width: 100%; }

/* ---------- studio layout */
.studio { display: grid; gap: 18px; align-items: start; }
.room[data-room="desk"] .studio { grid-template-columns: minmax(0, 1fr) 360px; }
.room[data-room="counter"] .studio { grid-template-columns: 380px minmax(0, 1fr); }
.room[data-room="counter"] .tools { order: -1; }
@media (max-width: 900px) { .room .studio { grid-template-columns: minmax(0, 1fr) !important; } .room[data-room="counter"] .tools { order: 0; } }
.stage { position: relative; min-width: 0; display: flex; flex-direction: column; align-items: safe center; gap: 12px; }
/* Zooming the letter preview: the sheet keeps its layout and is drawn larger or smaller; if it's wider than the
   space, the stage scrolls sideways rather than spilling over the tools. */
.studio .stage { overflow-x: auto; }
.studio .sheet-wrap { zoom: var(--zoom, 1); flex: none; }
.zoombar { display: flex; align-items: center; gap: 4px; align-self: flex-end; background: rgb(0 0 0 / .14); padding: 3px; border-radius: 9px; }
.zoombar button { border: 0; background: var(--paper); color: var(--ink); min-width: 34px; min-height: 32px; border-radius: 6px; font: 700 .95rem var(--f-ui); cursor: pointer; padding: 0 .6rem; }
.zoombar button:disabled { opacity: .45; cursor: default; }
.zoombar output { min-width: 3.4em; text-align: center; font: 700 .85rem var(--f-ui); color: var(--room-ink); font-variant-numeric: tabular-nums; }
/* On wide screens the letter stays in view while the tools scroll beside it. */
@media (min-width: 901px) { .studio .stage { position: sticky; top: 10px; } }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.room .btn.primary { background: #9b2420; border-color: #9b2420; color: #fff7ee; }

/* ---------- tools */
.tools { min-width: 0; display: flex; flex-direction: column; gap: 12px; color: var(--ink); }
.toolnav, .stepnav { display: none; gap: 6px; flex-wrap: wrap; }
.stepnav { justify-content: space-between; }
.toolnav button { border: 1.5px solid #b9a882; background: var(--paper); border-radius: 8px; padding: 6px 10px; font: 700 .84rem var(--f-ui); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; color: var(--ink); min-height: 36px; }
.toolnav button[aria-current="true"] { border-color: var(--ink); background: #fff; }
.toolnav .num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid currentColor; font-size: .75rem; font-variant-numeric: tabular-nums; }
.room .panel { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; color: var(--ink); }
.room .panel h2 { margin: 0; font-weight: 600; font-size: 1.3rem; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.room .panel h2 small { font: .8rem var(--f-ui); color: var(--muted); }
.room .lbl { font: 700 .84rem var(--f-ui); display: block; margin-bottom: 4px; }
.room .panel textarea, .room .panel input[type="text"], .room .panel select { width: 100%; border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 10px; background: #fffdf8; font: 1rem var(--f-ui); color: var(--ink); min-height: 42px; }
.room .panel textarea { min-height: 190px; resize: vertical; line-height: 1.45; }
.room .hint { font: .82rem var(--f-ui); color: var(--muted); margin: 0; }
.room .hint[hidden] { display: none; }
.room .check { font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { border: 1.5px solid var(--line); background: #fffdf8; color: var(--ink); border-radius: 8px; padding: 6px 10px; cursor: pointer; font: .85rem var(--f-ui); display: inline-flex; align-items: center; gap: 7px; min-height: 36px; }
.pick[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: #fff; }
.pick .sw { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset 0 -3px 5px rgb(0 0 0 / .25), 0 0 0 1px rgb(0 0 0 / .15); }
.pick .pap { width: 18px; height: 24px; flex: none; box-shadow: 0 0 0 1px rgb(0 0 0 / .18); }
.pick .handprev { font-size: 1.05rem; line-height: 1; }
.pick canvas { width: 22px; height: 22px; }
.pick canvas.stampprev { width: 20px; height: 24px; }
.pick .penprev { width: 26px; height: 26px; flex: none; }
.pick .penprev svg { width: 100%; height: 100%; }
.group-label { font: 700 .72rem var(--f-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 2px 0 -2px; }
.group-label.small { font-size: .64rem; letter-spacing: .08em; opacity: .8; margin-top: 0; }
.room .lbl small { font-weight: 400; color: var(--muted); }
.pick canvas.kissprev { width: 30px; height: 18px; }
.linkrow select { flex: 1; min-width: 0; }
[data-body-wrap][hidden] { display: none; }
.room[data-room="desk"] .panel { background: linear-gradient(180deg, #f8f1e1, #f1e7d1); border-color: #c9b48d; box-shadow: 0 6px 16px rgb(0 0 0 / .25); }
.room[data-room="counter"] .toolnav, .room[data-room="counter"] .stepnav { display: flex; }
.room[data-room="counter"] .panel { border-radius: 4px; border-color: #b9a882; background: #fbf5e4; }
.room[data-room="counter"] .panel h2::before { content: attr(data-n); display: inline-grid; place-items: center; width: 30px; height: 30px; border: 2px solid #9b2420; color: #9b2420; border-radius: 50%; font: 700 .9rem var(--f-ui); transform: rotate(-8deg); flex: none; }
.room[data-room="counter"] .panel:not(.on) { display: none; }

/* ---------- the sheet */
.sheet-wrap { width: 100%; max-width: 660px; transform-origin: 50% 30%; }
.sheet { --hs: 1.02rem; position: relative; width: 100%; min-height: 560px; padding: 46px 52px 54px 58px; color: #222; font-size: var(--hs);
  box-shadow: 0 1px 1px rgb(0 0 0 / .12), 0 14px 34px rgb(0 0 0 / .28); background-color: #f6efdf; background-blend-mode: multiply; overflow: hidden; }
@media (max-width: 560px) { .sheet { padding: 30px 22px 36px 28px; min-height: 460px; font-size: calc(var(--hs) * .88); } }
.sheet::after { content: ''; position: absolute; inset: 0; background-image: var(--grain, none); opacity: .5; mix-blend-mode: multiply; pointer-events: none; }
/* Papers: the base colour (and the large-scale look) here; the texture is a tile multiplied over it by paper.js. */
.p-laid { background-color: #f5eedc; }
.p-linen { background-color: #faf7f0; }
.p-cotton { background-color: #fdfbf5; }
.p-ruled { background-color: #fbf8ef; }
.p-squared { background-color: #f7f4ea; background-image: repeating-linear-gradient(90deg, rgb(90 130 170 / .22) 0 1px, transparent 1px 22px), repeating-linear-gradient(0deg, rgb(90 130 170 / .22) 0 1px, transparent 1px 22px); }
.p-air { background-color: #dfe9f2; background-image: radial-gradient(120% 80% at 30% 20%, rgb(255 255 255 / .45), transparent 60%), radial-gradient(90% 60% at 80% 90%, rgb(120 150 190 / .12), transparent 70%); }
.p-grey { background-color: #dedbd3; }
.p-blush { background-color: #f5e4de; }
.p-sage { background-color: #e3e8da; }
.p-vellum { background-color: #eee5cf; }
.p-parch { background-color: #ecdcb4; background-image: radial-gradient(140% 110% at 50% 50%, transparent 55%, rgb(110 70 20 / .28)); }
.p-aged { background-color: #e8dbb8; background-image: radial-gradient(150% 120% at 50% 45%, transparent 58%, rgb(90 55 15 / .22)); }
.p-kraft { background-color: #c9a776; }
.p-night { background-color: #26272b; color: #e9e4d8; background-blend-mode: screen; }
.sheet.p-ruled::before { content: ''; position: absolute; top: 0; bottom: 0; left: 40px; width: 1.5px; background: rgb(196 70 70 / .45); }
@media (max-width: 560px) { .sheet.p-ruled::before { left: 18px; } }
.p-ruled .letter-body { background-image: repeating-linear-gradient(to bottom, transparent 0 calc(var(--lh) - 1px), rgb(70 110 170 / .25) calc(var(--lh) - 1px) var(--lh)); background-position: 0 .18em; }
.dateline { text-align: right; margin-bottom: .6em; }
.letter-body { line-height: var(--lh); min-height: 6em; overflow-wrap: break-word; }
.letter-body:empty::before { content: 'Your words will appear here, in ink, as you write.'; opacity: .35; font-style: italic; }
.letter-body p { margin: 0 0 calc(var(--lh) * .5); }
.closing { margin-top: calc(var(--lh) * .4); padding-left: 38%; }
@media (max-width: 560px) { .closing { padding-left: 18%; } }
.signoff { line-height: var(--lh); }
.signature { position: relative; display: inline-block; font-size: 2.6em; line-height: 1.3; padding-right: 20px; margin-top: -.1em; }
.signature svg { position: absolute; left: -6%; bottom: -.12em; width: 115%; height: .7em; overflow: visible; pointer-events: none; }
.ps { margin-top: 1em; line-height: var(--lh); }
.sig-1 { font-family: 'Mrs Saint Delafield', cursive; }
.sig-2 { font-family: 'Herr Von Muellerhoff', cursive; }
.sig-3 { font-family: 'Monsieur La Doulaise', cursive; }
.sig-vibes { font-family: 'Great Vibes', cursive; }
.sig-alex { font-family: 'Alex Brush', cursive; }
.sig-allura { font-family: 'Allura', cursive; }
.sig-paris { font-family: 'Parisienne', cursive; }
.sig-havi { font-family: 'Mr De Haviland', cursive; }
.sig-faja { font-family: 'Miss Fajardose', cursive; }
.sig-ital { font-family: 'Italianno', cursive; }
.sig-own { font-family: inherit; }
.h-apple { font-family: 'Homemade Apple', cursive; }
.h-aurore { font-family: 'La Belle Aurore', cursive; }
.h-cedar { font-family: 'Cedarville Cursive', cursive; }
.h-dawn { font-family: 'Dawning of a New Day', cursive; }
.h-caveat { font-family: 'Caveat', cursive; }
.h-grace { font-family: 'Covered By Your Grace', cursive; }
.h-sacra { font-family: 'Sacramento', cursive; }
.h-zeyada { font-family: 'Zeyada', cursive; }
.h-glory { font-family: 'Give You Glory', cursive; }
.h-shadows { font-family: 'Shadows Into Light', cursive; }
.h-indie { font-family: 'Indie Flower', cursive; }
.h-kalam { font-family: 'Kalam', cursive; }
.h-sunrise { font-family: 'Waiting for the Sunrise', cursive; }
.h-archi { font-family: 'Architects Daughter', cursive; }
.h-girl { font-family: 'The Girl Next Door', cursive; }
.h-rainbow { font-family: 'Over the Rainbow', cursive; }
.h-pinyon { font-family: 'Pinyon Script', cursive; }
.h-petit { font-family: 'Petit Formal Script', cursive; }
.h-meddon { font-family: 'Meddon', cursive; }
.h-reenie { font-family: 'Reenie Beanie', cursive; }
.h-nothing { font-family: 'Nothing You Could Do', cursive; }
.h-rock { font-family: 'Rock Salt', cursive; }
/* Ink: each word shaded on its own (it pools darker where the stroke ends); the nib sets the line width. */
.inked { --ink: #2147a8; --ink-hi: #4c74d8; --ink-lo: #16307a; --nib: .32px; --spread: 0 0 .35px #16307a; --sheen: 0 0 0 transparent; }
.inked .w, .inked .dateline, .inked .signoff, .inked .sig-name, .inked .ps, .inked .letter-body p:not(:has(.w)) {
  background-image: linear-gradient(var(--a, 100deg), var(--ink-hi) 0%, var(--ink) 48%, var(--ink-lo) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: var(--ink);
  -webkit-text-stroke: var(--nib) var(--ink-lo);
  text-shadow: var(--sheen), var(--spread);
  transition: filter 2.8s ease-out, opacity .3s;
}
/* Wet ink is glossier and a touch lighter; it dries over a few seconds after the pen moves on. */
.inked .w.wet { filter: brightness(1.22) saturate(1.2); transition: none; }
/* A dip pen or quill runs paler and thinner until it's dipped again (--d: 1 just dipped … 0.15 nearly dry). */
.inked.pen-dip .w, .inked.pen-quill .w { opacity: calc(.55 + .45 * var(--d, 1)); -webkit-text-stroke: calc(var(--nib) * (.4 + .8 * var(--d, 1))) var(--ink-lo); }
/* A ballpoint lays down one flat colour, a little uneven in pressure, with no pooling and no sheen. */
.inked.pen-ball .w, .inked.pen-ball .dateline, .inked.pen-ball .signoff, .inked.pen-ball .sig-name, .inked.pen-ball .ps { background-image: linear-gradient(var(--ink), var(--ink)); text-shadow: none; -webkit-text-stroke: var(--nib) var(--ink); opacity: var(--v, .92); }
.inked.pen-ball .w.wet { filter: none; }
/* A felt-tip is bold and soft-edged. */
.inked.pen-felt .w, .inked.pen-felt .dateline, .inked.pen-felt .signoff, .inked.pen-felt .sig-name, .inked.pen-felt .ps { background-image: linear-gradient(var(--a, 100deg), var(--ink) 0%, var(--ink) 70%, var(--ink-lo) 100%); -webkit-text-stroke: var(--nib) var(--ink); text-shadow: var(--spread); }
/* A pencil is grainy: the paper shows through the graphite in specks. */
.inked.pen-pencil .w, .inked.pen-pencil .dateline, .inked.pen-pencil .signoff, .inked.pen-pencil .sig-name, .inked.pen-pencil .ps {
  background-image: var(--graphite, none), linear-gradient(var(--a, 100deg), var(--ink-hi) 0%, var(--ink) 48%, var(--ink-lo) 100%); background-size: 48px 48px, auto; text-shadow: var(--spread); }
.inked.pen-pencil .w.wet { filter: none; }
.unwritten { clip-path: inset(-40% 110% -50% -10%); }
/* Finishing touches: a lipstick kiss pressed on the sheet, and the mist of a scent being sprayed. */
.kiss { position: absolute; right: 7%; bottom: 4%; width: 124px; height: 74px; transform: rotate(-12deg); pointer-events: none; z-index: 2; mix-blend-mode: multiply; }
.kiss[hidden] { display: none; }
.kiss.pending { opacity: 0; }
.p-night .kiss { mix-blend-mode: normal; }
.mist { position: absolute; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.mist[hidden] { display: none; }
.mist i { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle, rgb(255 255 255 / .7), rgb(255 255 255 / 0) 70%); }
.scent-note { margin: 0; font: italic 1.12rem var(--f-body); color: var(--room-ink); text-align: center; max-width: 52ch; opacity: 0; transition: opacity 1.6s ease; }
.scent-note.shown { opacity: 1; }
.scent-note[hidden] { display: none; }
.nibpen { position: absolute; left: 0; top: 0; width: 120px; height: 120px; pointer-events: none; z-index: 3; transform: translate(-200px, -200px); filter: drop-shadow(3px 8px 6px rgb(0 0 0 / .3)); }
.nibpen svg { display: block; width: 100%; height: 100%; }
.nibpen[hidden] { display: none; }

/* ---------- envelope and wax (the simple version; the 3D ceremony draws its own) */
.post { position: relative; width: 100%; max-width: 660px; min-height: 420px; display: flex; align-items: center; justify-content: center; perspective: 1400px; }
.post[hidden] { display: none; }
.envelope { position: relative; width: min(440px, 92%); aspect-ratio: 1.55; transform-style: preserve-3d; }
.env-back, .env-pocket, .env-flap { position: absolute; inset: 0; backface-visibility: hidden; }
.env-back { border-radius: 4px; background: var(--env); box-shadow: 0 16px 34px rgb(0 0 0 / .3); }
.env-letter { position: absolute; left: 6%; right: 6%; top: 8%; height: 76%; box-shadow: 0 1px 3px rgb(0 0 0 / .2); background-color: #f6efdf; backface-visibility: hidden; }
.env-letter::before, .env-letter::after { content: ''; position: absolute; left: 0; right: 0; height: 1px; background: rgb(0 0 0 / .08); }
.env-letter::before { top: 33%; } .env-letter::after { top: 66%; }
.env-pocket { background: var(--env); clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%); filter: brightness(.96); }
.env-pocket::after { content: ''; position: absolute; inset: 0; background: linear-gradient(160deg, rgb(255 255 255 / .12), transparent 40%, rgb(0 0 0 / .08)); }
.env-flap { clip-path: polygon(0 0, 100% 0, 50% 60%); background: var(--env); transform-origin: 50% 0; filter: brightness(.92); z-index: 2; }
.env-flap.open { transform: scaleY(-1); background: var(--liner); }
/* The front (addressed, stamped, postmarked) lies behind the back, facing away, and shows when the envelope turns over. */
.env-front { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 4px; transform: rotateY(180deg) translateZ(1px); backface-visibility: hidden; box-shadow: 0 16px 34px rgb(0 0 0 / .3); }
.envelope.flipped .wax, .envelope.flipped .wax-half, .envelope.flipped .stamp { visibility: hidden; }
.e-kraft { --env: linear-gradient(180deg, #b98c5a, #a97b4b); --liner: #8e6a42; }
.e-cream { --env: repeating-linear-gradient(90deg, rgb(140 115 70 / .06) 0 1px, transparent 1px 22px), #efe5cf; --liner: #c9b48a; }
.e-white { --env: linear-gradient(180deg, #faf8f3, #f1efe8); --liner: #c9d4e3; }
.e-air { --env: #f3f1ea; --liner: repeating-linear-gradient(135deg, #b5262b 0 14px, #f3f1ea 14px 22px, #1f3f86 22px 36px, #f3f1ea 36px 44px); }
.e-air .env-back { background: repeating-linear-gradient(135deg, #b5262b 0 14px, #f3f1ea 14px 22px, #1f3f86 22px 36px, #f3f1ea 36px 44px); }
.e-air .env-back::after { content: ''; position: absolute; inset: 9px; background: #f3f1ea; border-radius: 2px; }
.e-blush { --env: linear-gradient(180deg, #f2d5cf, #e8c4bd); --liner: #9b3a44; }
.e-slate { --env: linear-gradient(180deg, #767b87, #656a76); --liner: linear-gradient(135deg, #9ea3ab, #e6e8ec 45%, #8d929b); }
.e-forest { --env: linear-gradient(180deg, #335040, #29402f); --liner: #e7d9b4; }
.e-burgundy { --env: linear-gradient(180deg, #74222f, #5e1a25); --liner: linear-gradient(135deg, #b8902f, #e6c76e 45%, #a87f27); }
.e-midnight { --env: linear-gradient(180deg, #1f2a4a, #182241); --liner: linear-gradient(135deg, #b8902f, #e6c76e 45%, #a87f27); }
.e-black { --env: linear-gradient(180deg, #202022, #161618); --liner: linear-gradient(135deg, #9ea3ab, #e6e8ec 45%, #8d929b); }
.e-vellum { --env: rgb(239 233 218 / .82); --liner: #e9e2d1; }
.e-vellum .env-back { background: #efe9da; }
.wax, .wax-half { position: absolute; left: 50%; top: 60%; width: 34%; aspect-ratio: 1; transform: translate(-50%, -50%); z-index: 4; }
.wax { cursor: pointer; }
.wax-half { pointer-events: none; }
.stamp { position: absolute; left: 50%; top: 60%; width: 20%; aspect-ratio: .42; z-index: 5; transform: translate(-50%, -160%); opacity: 0; pointer-events: none;
  background: linear-gradient(90deg, #3a2414, #6b4528 40%, #3a2414); border-radius: 40% 40% 12% 12% / 20% 20% 6% 6%; box-shadow: 0 10px 18px rgb(0 0 0 / .35); }
.stamp::after { content: ''; position: absolute; left: -12%; right: -12%; bottom: -6%; height: 16%; border-radius: 4px; background: linear-gradient(180deg, #e3c06a, #a8843e); }

/* ---------- sealed and sent */
.sent { width: 100%; max-width: 660px; background: var(--paper); color: var(--ink); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 8px 24px rgb(0 0 0 / .2); }
.sent h2 { margin: 0; font-weight: 600; }
.sent p { margin: 0; font-family: var(--f-ui); font-size: .95rem; }
.linkrow { display: flex; gap: 8px; }
.linkrow input { flex: 1; min-width: 0; font: .9rem ui-monospace, Consolas, monospace; border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fffdf8; color: var(--ink); }
.room .btnrow { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- a letter arriving */
.reader { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.reader > .stage { width: 100%; }
.reader-status { margin: 0; font: 1.05rem var(--f-ui); color: var(--room-ink); text-align: center; max-width: 60ch; }
.reader-sheet { width: 100%; display: flex; justify-content: center; }
.reader-fine { color: var(--room-muted); text-align: center; }

/* ---------- the letter box */
.box { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .box { grid-template-columns: minmax(0, 1fr); } }
.box-list { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.kept { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.kept button { width: 100%; text-align: left; border: 1px solid var(--line); background: #fffdf8; color: var(--ink); border-radius: 8px; padding: 8px 10px; cursor: pointer; display: grid; gap: 1px; font: .9rem var(--f-ui); }
.kept button[aria-pressed="true"] { border-color: #9b2420; box-shadow: inset 4px 0 0 #9b2420; }
.kept b { font-family: var(--f-body); font-size: 1.05rem; }
.kept span { color: var(--muted); font-size: .8rem; }

/* ---------- the reading room */
.shelf-list { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.lettercard { display: grid; gap: 3px; height: 100%; text-decoration: none; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); }
.lettercard:hover { border-color: #9b2420; color: var(--ink); }
.lettercard b { font-size: 1.15rem; font-weight: 600; }
.lettercard span { font: .82rem var(--f-ui); color: var(--muted); }
.lettercard .blurb { color: var(--ink-2); font-size: .86rem; }
.historical { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .historical { grid-template-columns: minmax(0, 1fr); } }
.historical .context p { margin: 0; font-family: var(--f-ui); font-size: .93rem; }
.historical .context a { color: var(--accent-dark); }

@media (prefers-reduced-motion: reduce) { .room * { scroll-behavior: auto; } }

/* ---------- recreations: always labelled, on the card, the page and the sheet itself */
.recreation-tag { justify-self: start; font: 700 .7rem var(--f-ui) !important; letter-spacing: .06em; text-transform: uppercase; color: #9b2420 !important; border: 1.5px solid currentColor; border-radius: 4px; padding: .1rem .4rem; }
.recreation-note { background: #fbe9e4; border: 1.5px solid #9b2420; border-radius: 8px; padding: .6rem .8rem; color: #5c1714; }
.sheet-stamp { position: absolute; top: 14px; left: 16px; margin: 0; z-index: 2; font: 700 .68rem var(--f-ui); letter-spacing: .1em; text-transform: uppercase; color: rgb(155 36 32 / .75); border: 2px solid rgb(155 36 32 / .6); border-radius: 4px; padding: .2rem .5rem; transform: rotate(-4deg); pointer-events: none; }

/* ---------- the 3D ceremony: a canvas laid exactly over the letter, which waits underneath, invisible */
.ceremony { position: absolute; z-index: 4; pointer-events: none; }
.ceremony.live { pointer-events: auto; }
.ceremony.clickable { cursor: pointer; }
.ceremony-gl { display: block; width: 100%; height: 100%; }
.ghost { opacity: 0; pointer-events: none; }
.fade-in { transition: opacity .6s ease; }
.ceremony.fading { transition: opacity .6s ease; opacity: 0; }
