/* Gallery of Body Feelings. Values from Figma section 151:5282. */
:root {
  /* Figma variables: "Variable collection / Gallery of Body Feeling/*" */
  --bg: #5d0506;            /* Bg: wall, active button, selected chip */
  --bg-card: #fbefe3;       /* bg-card: Card panel and dialogs */
  --white: #ffffff;
  --grey-100: #dddddd;
  --grey-200: #c3c3c3;      /* disabled, placeholders that read as empty, rules */
  --grey-300: #acabab;
  --grey-400: #939292;      /* hints */
  --grey-500: #7d7c7c;      /* dates on cards */
  --grey-600: #666464;
  --grey-700: #514f4f;
  --grey-800: #3c3a3a;
  --grey-900: #292727;      /* text and icons */

  /* Roles (point at the variables above) */
  --wall: var(--bg);
  --panel: var(--bg-card);
  --ink: var(--grey-900);
  --ink-soft: var(--grey-500);
  --hint: var(--grey-400);
  --disabled: var(--grey-200);
  --rule: var(--grey-200);
  --title: #ffef87;         /* hand-written title (not a variable in Figma yet) */
  --chip: rgba(255, 255, 255, 0.6);
  --pink: rgba(223, 180, 181, 0.1);   /* selected seal background: #DFB4B5 at 10% */
  --k: 1;                   /* card scale on the wall, set from JS */
  --card-w: 240px;
  --card-h: 402px;
  --cursor-heart: url("/assets/cursor-heart.png") 14 14, pointer;
  --serif: "Halant", Georgia, serif;
  --hand: "Reenie Beanie", "Comic Sans MS", cursive;
  color-scheme: light;
}
@supports (cursor: image-set(url("x.png") 1x) 0 0, auto) {
  :root { --cursor-heart: image-set(url("/assets/cursor-heart.png") 1x, url("/assets/cursor-heart@2x.png") 2x) 14 14, pointer; }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow-x: hidden; }
body {
  background: var(--wall);
  color: var(--ink);
  font-family: var(--serif);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--title); outline-offset: 3px; }
dialog :focus-visible { outline-color: var(--wall); }

/* ---------- Header / footer ---------- */
/* Lives inside the scrolling wall: scrolls away vertically, stays put horizontally. Scales with --k like the cards. */
.site-header { position: sticky; left: 0; width: 100%; max-width: 100vw; text-align: center; padding: calc(48px * var(--k)) 16px 0; height: calc(153px * var(--k)); box-sizing: border-box; }
.site-title {
  margin: 0;
  font: 400 calc(70px * var(--k))/1.5 var(--hand);
  white-space: nowrap;
  color: var(--title);
  letter-spacing: 0.02em;
}
.site-intro {   /* Figma "Desktop - 1": x 124, y 201, Reenie Beanie 32/1.5, white */
  position: absolute; left: calc(124px * var(--k)); top: calc(217px * var(--k)); margin: 0;   /* 64px below the title row (Figma had 48) */
  font: 400 calc(32px * var(--k))/1.5 var(--hand); color: var(--white); text-align: left; white-space: nowrap;
}
/* Wishing well (Figma "Desktop - 1" 260:6678): top right, 60% until hovered. Placed from the title's centre so it keeps its place on wide windows. */
.wishing {
  position: absolute; top: calc(68px * var(--k));
  left: min(calc(50% + 491px * var(--k)), calc(100% - 24px - 210px * var(--k)));   /* Figma x 1111 + 100px, but never closer than 24px to the right edge (link is 210px wide at scale 1) */
  display: flex; align-items: center; gap: calc(16px * var(--k)); padding: 0; border: 0; background: none;
  font: 400 calc(40px * var(--k))/1.5 var(--hand); color: var(--title); white-space: nowrap;
  opacity: .6; transition: opacity .2s; cursor: pointer;
}
.wishing:hover, .wishing:focus-visible { opacity: 1; }
.wishing img { width: calc(40px * var(--k)); height: calc(40px * var(--k)); }
.wishing-well { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); border: 0; border-radius: 32px; padding: 84px 44px 44px; background: var(--panel); color: var(--ink); overflow: auto; scrollbar-width: none; }
.wishing-well[open] { animation: added-in .35s cubic-bezier(.2, .8, .3, 1.2); }
.wishing-well .panel-close { position: absolute; left: 32px; top: 32px; }   /* the × itself sits 12px inside its 40px button, so it lines up with the 44px text edge */
.nowrap { white-space: nowrap; }
.wishing-well .heart { display: inline-block; width: auto; height: 1.2em; margin-left: 12px; vertical-align: -0.12em; }   /* 12px after the text */   /* Figma heart with sparkles (260:6698) instead of the emoji; the heart itself stays about the text height */
.wishing-well h2 { margin: 0 0 20px; font: 600 24px/1.4 var(--serif); outline: none; }
.well-form { display: flex; flex-direction: column; margin: 0 0 8px; }
.well-form label { margin: 0 0 8px; font: 500 18px/1.4 var(--serif); color: var(--ink); }
.well-form textarea { margin: 0 0 20px; padding: 12px 16px; border: 1px solid var(--grey-100); border-radius: 12px; background: rgba(255, 255, 255, 0.6); font: 400 17px/1.5 var(--serif); color: var(--ink); resize: vertical; min-height: 84px; }
.well-form textarea::placeholder { color: var(--hint); opacity: 1; }
.well-form textarea:focus { outline: none; border-color: var(--wall); background: #fff; }
.wishing-well .well-send { width: 100%; max-width: none; height: auto; padding: 14px 16px; font-size: 20px; margin: 24px 0 0; }
.well-mail p:last-child { margin-bottom: 0; }
.wishing-well .well-send[hidden] { display: none; }
.well-error { margin: 16px 0 0; color: var(--wall); font: 400 16px/1.4 var(--serif); }
/* After sending: the whole card becomes a thank-you note */
.well-thanks .well-thanks-title { margin: 0 0 8px; }
.wishing-well.thanked { padding-top: 44px; }
.wishing-well.thanked .panel-close { display: none; }
.well-thanks p { margin: 0; }
.wishing-well .well-back { width: 100%; max-width: none; height: auto; padding: 14px 16px; font-size: 20px; margin: 32px 0 0; }
.wishing-well p { margin: 0 0 8px; font: 400 18px/1.6 var(--serif); color: var(--grey-700); }
.wishing-well a { color: var(--wall); font-weight: 600; text-underline-offset: 3px; }
.site-footer {
  flex: none;
  display: flex; gap: 6px 24px; flex-wrap: wrap; justify-content: center;
  padding: 8px 16px max(12px, env(safe-area-inset-bottom));
  font-size: 13px; color: rgba(251, 239, 227, 0.72);
}
.site-footer p { margin: 0; }

/* ---------- Wall ---------- */
main { flex: 1; min-height: 0; display: flex; }
.wall {
  flex: 1; min-width: 0;
  overflow-x: auto; overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(255, 239, 135, 0.35) transparent;
  touch-action: pan-x pan-y;
}
.wall.panning { cursor: grabbing; user-select: none; }
.wall-grid { position: relative; }
.wall-grid .slot { position: absolute; left: 0; top: 0; }
.wall-status {
  position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%);
  background: var(--panel); color: var(--ink); border-radius: 100px;
  padding: 10px 20px; font-size: 16px; display: flex; gap: 12px; align-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.wall-status[hidden] { display: none; }

/* A slot reserves the scaled size; the card inside is drawn at Figma size and scaled. */
.slot { position: relative; width: calc(var(--card-w) * var(--k)); height: calc(var(--card-h) * var(--k)); }
.card-scale { position: absolute; left: 0; top: 0; width: var(--card-w); height: var(--card-h); transform: scale(var(--k)); transform-origin: 0 0; }
.card {
  position: absolute; inset: 0;
  display: block; padding: 0; border: 0; background: none; text-align: center;
  cursor: var(--cursor-heart);
  transform-origin: 120px 52px;            /* hangs from the centre of the seal */
  transform: rotate(var(--tilt, 0deg));
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}
.card:focus-visible { outline-offset: -6px; }
.card .paper { position: absolute; left: 0; top: 52px; width: 240px; height: 350px; object-fit: contain; pointer-events: none; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.28)); }
.card .seal { position: absolute; left: 68px; top: 0; width: 104px; height: auto; pointer-events: none; z-index: 2; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.3)); }
.card .zoom { position: absolute; left: 65px; top: 104px; width: 110px; height: 210px; overflow: hidden; }
.card .zoom img { position: absolute; left: 50%; top: 0; height: 210px; width: auto; transform: translateX(-50%); pointer-events: none; }
.card .info { position: absolute; left: 0; right: 0; top: 328px; margin: 0; display: flex; justify-content: center; gap: 20px; font: 400 16px/1.5 var(--serif); }
.card .info .name { color: var(--ink); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .info .date { color: var(--ink-soft); }
.card.pin .pin-label { position: absolute; left: 0; right: 0; top: 149px; margin: 0; font: 400 64px/1.3 var(--hand); color: #3b3636; }
.pin-arrow { position: absolute; pointer-events: none; overflow: visible; }   /* Figma "Desktop - 1": yellow arrow pointing at Pin yours */
/* Draw-on: the mask line grows from a dot at the top right to the tip, then the head's two barbs */
.pin-arrow .draw { fill: none; stroke: #fff; stroke-width: 13; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.pin-arrow .draw.line { animation: arrow-draw 1.3s cubic-bezier(.55, .1, .35, 1) .5s forwards; }
.pin-arrow .draw.barb { stroke-width: 11; animation: arrow-draw .28s ease-out 1.8s forwards; }
@keyframes arrow-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .pin-arrow .draw { animation: none; stroke-dashoffset: 0; } }
.card.pin .pin-plus { position: absolute; left: 0; right: 0; top: 226px; margin: 0; font: 400 80px/1 var(--hand); color: #3b3636; }
.card.is-new { animation: arrive 1.4s ease-out; }
@keyframes arrive { 0% { filter: brightness(1.25) drop-shadow(0 0 18px rgba(255, 239, 135, 0.9)); } 100% { filter: none; } }

/* ---------- Dialog basics ---------- */
dialog { border: 0; padding: 0; color: var(--ink); max-width: none; max-height: none; }
dialog::backdrop { background: rgba(30, 5, 5, 0.62); }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 100px; background: none; }
.icon-btn:hover { background: rgba(0, 0, 0, 0.05); }
.icon-btn:disabled { cursor: default; background: none; }
.icon { display: block; width: 28px; height: 28px; background-color: var(--grey-900); -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.icon-btn.small .icon { width: 20px; height: 20px; }
:disabled > .icon { background-color: var(--disabled); }
.icon-btn.small { width: 20px; height: 20px; }
.text-btn { border: 0; background: none; padding: 8px 4px; color: var(--ink-soft); text-decoration: none; }   /* no underline; darkens on hover */
.text-btn:hover { color: var(--ink); }
.text-btn.with-icon { display: inline-flex; align-items: center; gap: 6px; }
.text-btn .icon { width: 16px; height: 16px; background-color: currentColor; transform: translateY(-2px); }   /* measured: the icon sits on the text baseline and its top meets the tall letters (l, t, D); follows the text colour */
.pill-btn { border: 0; border-radius: 100px; padding: 10px 22px; background: var(--wall); color: #fff; font-weight: 500; }
.pill-btn.danger { background: var(--wall); }

/* "action btn" (Figma 207:6322) */
.action-btn {
  display: block; width: 280px; max-width: 100%; height: 50px; margin: 0 auto;
  border: 0; border-radius: 12px; padding: 8px 16px;
  background: var(--wall); color: #fff; font: 500 18px/1.3 var(--serif);
  transition: background-color 0.15s;
}
.action-btn:disabled { background: var(--disabled); cursor: default; }
.action-btn[aria-busy="true"], .action-btn[aria-busy="true"]:disabled { background: var(--wall); opacity: 0.75; cursor: progress; }   /* "Pinning…": stays red, slightly faded */

/* ---------- Card panel (Figma "Card", 620 × 1381) ---------- */
/* Card panel: the dialog is a transparent, scrollable layer over the wall. The card inside is scaled (--pk, from JS)
   so the first view shows it from the top down to the end of the body canvas, 20px from the window's top and bottom;
   the note and topics are further down. */
.panel { inset: 0; width: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; background: transparent; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }   /* never scrolls sideways */
.panel-stage { position: relative; margin: 20px auto; width: calc(620px * var(--pk, 1)); height: var(--stage-h, auto); }
.panel-stage > .panel-inner { position: absolute; left: 0; top: 0; width: 620px; background: var(--panel); border-radius: 32px; transform: scale(var(--pk, 1)); transform-origin: 0 0; }
.panel-inner { position: relative; padding: 104px 44px 64px; }   /* Figma 156:5291: content 44px from each side, name row at y 104 */
@property --unroll { syntax: '<length>'; inherits: true; initial-value: 0px; }
.panel-stage.unrolling, .viewer.unrolling { animation: unroll .8s cubic-bezier(.33, .1, .25, 1); clip-path: inset(0 -40px calc(100% - var(--unroll)) -40px); }   /* opens like paper unrolling from the top */
@keyframes unroll { from { --unroll: 0px; } to { --unroll: var(--reveal-h, 100%); } }
.panel-stage.unrolling::after, .viewer.unrolling::after { content: ""; position: absolute; z-index: 2; left: 0; right: 0; top: calc(var(--unroll) - 34px * var(--pk, 1)); height: calc(34px * var(--pk, 1)); border-radius: 8px; background: linear-gradient(to bottom, #f3e4d4 0%, #fffaf3 30%, #f6e9db 55%, #dcc6b0 85%, #c4ab93 100%); box-shadow: 0 -6px 10px -6px rgba(60, 30, 20, .25); pointer-events: none; }   /* the rolled-up paper at the edge */
.panel[open]::backdrop { animation: backdrop-in .35s ease-out; }
@keyframes backdrop-in { from { opacity: 0; } }   /* 64px below Seal it */
.panel-close { position: absolute; left: 44px; top: 32px; }   /* Figma 156:5291 / 260:6547: lines up with the 44px margin */
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 32px; }   /* paper at y 172 */
.nickname { flex: 1; min-width: 0; border: 0; background: none; padding: 0 0 0 12px; font: 600 24px/1.5 var(--serif); color: var(--ink); }
.nickname::placeholder { color: var(--grey-200); opacity: 1; }
.nickname:focus { outline: none; }
.panel-date { font: 600 24px/1.5 var(--serif); white-space: nowrap; }

.canvas-paper {
  position: relative; width: 100%; max-width: 532px; aspect-ratio: 532 / 670;
  background: url("/assets/canvas-paper.png") center / 102.6% 100% no-repeat;
  border-radius: 8px;
}
.canvas-view { position: absolute; left: 8.27%; top: 3.58%; width: 83.46%; height: 76.12%; overflow: hidden; touch-action: none; }
#draw-canvas { width: 100%; height: 100%; display: block; }
.canvas-view[data-mode="brush"] { cursor: none; }
.canvas-view[data-mode="eraser"] { cursor: none; }
.canvas-view[data-mode="shape"] { cursor: default; }
.canvas-view[data-mode="select"] { cursor: default; }
.shape-handles[data-kind="stroke"] .handle-regenerate { display: none; }   /* lines: no regenerate */
.canvas-view.panning, .canvas-view.space-pan { cursor: grab; }
.canvas-view.rotating, .canvas-view.rotating *, .canvas-view.resizing, .canvas-view.resizing * { cursor: var(--drag-cursor) !important; }   /* keep the corner cursor (turned) for the whole drag */
.brush-cursor { position: absolute; left: 0; top: 0; pointer-events: none; border-radius: 50%; z-index: 3; transform: translate(-50%, -50%); display: none; }
.brush-cursor.eraser { border: 1.5px solid var(--ink); background: rgba(255, 255, 255, 0.4); }
.shape-handles { position: absolute; pointer-events: none; transform-origin: 50% 50%; }   /* turned to match the item */
.shape-handles[hidden] { display: none; }
/* Regenerate handle: Figma "expand" style (C7C7C7 at 50%, white icon), 32px */
.handle { position: absolute; width: 32px; height: 32px; border: 0; border-radius: 100px; padding: 0; display: grid; place-items: center; pointer-events: auto; background: rgba(199, 199, 199, 0.5); }
.handle:hover { background: rgba(160, 160, 160, 0.6); }
.handle .icon { width: 24px; height: 24px; background-color: var(--white); }
.corner { position: absolute; width: 0; height: 0; pointer-events: none; }
.corner[data-corner="tr"] { right: 0; top: 0; }
.corner[data-corner="tl"] { left: 0; top: 0; }
.corner[data-corner="br"] { right: 0; bottom: 0; }
.resize-zone, .rotate-zone { position: absolute; pointer-events: auto; touch-action: none; transform: translate(-50%, -50%); border-radius: 4px; }
.resize-zone { width: 18px; height: 18px; outline: none; }   /* right on the corner: stretch */
.rotate-zone { width: 52px; height: 52px; }                  /* just outside the corner: rotate (inner quarter cut away below) */
.corner[data-corner="tr"] .rotate-zone { clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 100%, 50% 50%, 0 50%); cursor: url(/assets/cursors/rotate-tr.svg) 12 12, alias; }
.corner[data-corner="tl"] .rotate-zone { clip-path: polygon(0 0, 100% 0, 100% 50%, 50% 50%, 50% 100%, 0 100%); cursor: url(/assets/cursors/rotate-tl.svg) 12 12, alias; }
.corner[data-corner="br"] .rotate-zone { clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 50%, 50% 50%, 50% 0); cursor: url(/assets/cursors/rotate-br.svg) 12 12, alias; }
.corner[data-corner="tr"] .resize-zone { cursor: url(/assets/cursors/resize-nesw.svg) 12 12, nesw-resize; }
.corner[data-corner="tl"] .resize-zone, .corner[data-corner="br"] .resize-zone { cursor: url(/assets/cursors/resize-nwse.svg) 12 12, nwse-resize; }
.resize-zone:focus-visible { outline: 3px solid #d49a3a; }
.handle-regenerate { left: -16px; bottom: -16px; transform: rotate(calc(-1 * var(--frame-angle, 0rad))); }   /* icon stays upright when the frame turns */
/* Dashed frame: longer dashes with round ends */
.shape-frame { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.shape-frame rect { fill: none; stroke: rgba(41, 39, 39, 0.35); stroke-width: 1.5; stroke-dasharray: 9 6; stroke-linecap: round; }

.zoom-ctl { position: absolute; right: 9.4%; top: 74.3%; display: flex; align-items: center; gap: 8px; }
.zoom-label { font: 600 16px/1.5 var(--serif); min-width: 37px; text-align: center; }
.toolbar { position: absolute; left: 8.46%; right: 9.02%; top: 84.2%; display: flex; align-items: center; gap: 16px; }   /* 16px between the colour and the brush */
.swatch { position: relative; width: 44px; height: 44px; flex: none; padding: 0; border: 0; border-radius: 50%; background: none; }
.swatch-dot { position: absolute; inset: 0; border-radius: 50%; background: var(--color, #b4533a); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7), 0 0 0 1px rgba(0, 0, 0, 0.08); pointer-events: none; }

/* Colour picker popover (radius 20) */
.color-pop {
  position: absolute; z-index: 5; left: 6%; bottom: calc(100% - 84.2% + 10px);
  width: 264px; padding: 14px; border-radius: 20px; background: var(--white);
  box-shadow: 0 6px 18px rgba(41, 39, 39, 0.08), 0 0 0 1px rgba(41, 39, 39, 0.04);   /* light shadow */
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px;   /* content never wider than the popover */
}
.cp-sv {
  position: relative; height: 150px; border-radius: 12px; cursor: crosshair; touch-action: none;
  background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, var(--hue, red));
}
.cp-sv-knob { position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 1px 4px rgba(0, 0, 0, 0.3); transform: translate(-50%, -50%); pointer-events: none; }
.cp-hue {
  position: relative; height: 10px; margin: 4px 9px; border-radius: 10px; cursor: pointer; touch-action: none;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.cp-hue::before { content: ""; position: absolute; inset: -9px -9px; }  /* bigger touch target */
.cp-hue-knob { position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 1px 4px rgba(0, 0, 0, 0.3); transform: translate(-50%, -50%); pointer-events: none; }
.cp-sv:focus-visible, .cp-hue:focus-visible { outline: 3px solid var(--bg); outline-offset: 3px; }
.color-pop:focus { outline: none; }
.cp-hex { min-width: 0; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 6px 0 12px; border: 1px solid var(--grey-200); border-radius: 10px; }
.cp-hex:focus-within { border-color: var(--grey-500); }
.cp-hex input { flex: 1; min-width: 0; width: 100%; border: 0; padding: 0; background: none; font: 400 16px/1 -apple-system, system-ui, sans-serif; letter-spacing: 0.02em; color: var(--ink); text-transform: uppercase; }
.cp-hex input:focus { outline: none; }
.cp-chip { width: 28px; height: 28px; border-radius: 6px; flex: none; }
.tools { display: flex; gap: 8px; }
.tool-btn { width: 44px; height: 44px; padding: 8px; border: 0; border-radius: 100px; background: none; display: grid; place-items: center; }
/* Figma "tool" (221:6442): default grey-200 · hover Bg icon on Bg 2% · selected Bg */
.tool-btn .icon { background-color: var(--grey-200); transition: background-color 0.12s; }
.tool-btn:hover { background: rgba(93, 5, 6, 0.02); }   /* Figma hover: Bg at 2% */
.tool-btn:hover .icon, .tool-btn[aria-pressed="true"] .icon { background-color: var(--bg); }
.history { margin-left: auto; display: flex; gap: 16px; }

/* "What's on your mind?" on the hand-drawn rules (rows 35.5px like the POI screen) */
.message {
  display: block; width: 100%; max-width: 532px; margin: 40px 0 0; padding: 0; border: 0; resize: none; overflow: hidden;
  min-height: calc(35.5px * 3);
  font: 400 20px/35.5px var(--serif); color: var(--ink);
  background: url("/assets/rules/lined-tile.svg") 0 var(--rule-shift, 0px) / 100% 106.5px repeat-y;   /* lines sit 4px below the descenders */
}
.message::placeholder { color: var(--hint); opacity: 1; }
.message:focus { outline: none; }

.topics { border: 0; padding: 0; margin: 31px 0 0; min-width: 0; }   /* Figma: 1007 − (869 + 3 rows) */
.topics-title { padding: 0; font: 600 20px/1.5 var(--serif); }
.topics-hint { margin: 12px 0 12px; font: 400 20px/1.4 var(--serif); color: var(--hint); }
.chips { display: flex; flex-wrap: wrap; gap: 12px 8px; }
/* "hashtag" (Figma 207:6281): Default / hover / selected */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 100px; padding: 8px 20px; min-height: 53px;
  background: var(--chip); color: var(--ink); font: 500 20px/1.5 var(--serif);
  transition: background-color 0.12s, color 0.12s;
}
.chip:hover { background: #fff; }
.chip[aria-pressed="true"] { background: var(--wall); color: #fff; }
.chip .remove { margin: 0 -10px 0 2px; width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; opacity: 0.85; }
.chip .remove::before { content: ""; width: 16px; height: 16px; background-color: currentColor; -webkit-mask: url(/assets/icons/close.svg) center / contain no-repeat; mask: url(/assets/icons/close.svg) center / contain no-repeat; }   /* the panel's close icon, 16px (was a 16px text ×) */
.chip .remove:hover { background: rgba(255, 255, 255, 0.25); opacity: 1; }
.chip-add { width: 44px; height: 44px; margin: 4px 0; padding: 0; border: 0; border-radius: 100px; background: url("/assets/icons/add.svg") center / 46px 46px no-repeat; }
.chip-add:hover { background-color: rgba(255, 255, 255, 0.5); }
.chip-input { min-height: 53px; width: 200px; border: 1.5px dashed #919191; border-radius: 100px; padding: 8px 20px; background: rgba(255, 255, 255, 0.6); font: 500 20px/1.5 var(--serif); }
.chip-input:focus { outline: none; border-style: solid; border-color: var(--wall); }

.form-error { margin: 24px 0 0; color: var(--wall); font-size: 17px; text-align: center; }
/* Seal it spans the card with 44px on each side (card padding is 47px left / 41px right) */
.panel .action-btn { width: 100%; max-width: none; height: auto; padding: 16px; font-size: 20px; line-height: 1.3; margin: 64px 0 0; }   /* Figma 221:6434: 532 × 58, padding 16, Halant Medium 20/130%; 64px above */

/* ---------- Seal picker ---------- */
.seal-picker { width: 620px; max-width: 100vw; max-height: 100dvh; border-radius: 32px; background: var(--panel); overflow: auto; scrollbar-width: none; }   /* still scrolls on short screens, no scrollbar shown */
.seal-picker::-webkit-scrollbar { display: none; }
.seal-inner { position: relative; padding: 40px 32px 40px; text-align: center; }
.seal-inner h2 { margin: 24px 0 8px; font: 600 24px/1.5 var(--serif); }
.seal-preview { position: relative; width: 240px; height: 402px; margin: 8px auto 16px; }
.seal-preview .card { cursor: default; }
.seal-preview .seal { transition: transform 0.25s, opacity 0.25s; }
.seal-preview .seal.empty { opacity: 0; transform: translateY(-14px) scale(1.25); }
.seal-preview .seal.stamp { animation: stamp 0.55s cubic-bezier(0.2, 0.8, 0.3, 1.25) both; }
@keyframes stamp {
  0% { opacity: 0; transform: translateY(-40px) scale(1.6); }
  60% { opacity: 1; transform: translateY(2px) scale(0.94); }
  100% { opacity: 1; transform: none; }
}
.seal-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px 8px; justify-items: center; }
.seal-option { width: 80px; height: 80px; padding: 8px; border: 0; border-radius: 10px; background: none; display: grid; place-items: center; }
.seal-option img { width: 64px; height: auto; transition: transform 0.15s; }
.seal-option:hover img { transform: scale(1.08) rotate(-4deg); }
.seal-option[aria-checked="true"] { background: var(--pink); }   /* selected: #DFB4B5 at 10%, 8px padding, 10px corners */
.seal-option:focus-visible { outline: 3px solid var(--grey-400); outline-offset: 2px; }
.seal-inner h2:focus { outline: none; }
.seal-grid.busy { pointer-events: none; opacity: 0.6; }
.seal-picker .action-btn { margin-top: 24px; width: 100%; max-width: 532px; height: auto; padding: 16px; font-size: 20px; line-height: 1.3; }   /* same as Pin My Card */

/* ---------- Card viewer ---------- */
.viewer { width: 620px; max-width: 100vw; max-height: 100dvh; border-radius: 32px; background: var(--panel); overflow: auto; scrollbar-width: none; }   /* scrolls, no scrollbar shown */
.viewer::-webkit-scrollbar { display: none; }
.viewer-inner { position: relative; padding: 32px 44px; }   /* Figma "Card-filled" 260:6547: same top spacing as the input card */
.viewer .panel-close { position: static; margin-bottom: 32px; }   /* name row at y 104 */
.viewer-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; font: 600 24px/1.5 var(--serif); }
.viewer-inner:focus { outline: none; }
.viewer-head h2 { margin: 0; padding-left: 12px; font: inherit; overflow-wrap: anywhere; }   /* name text at x 56, like the nickname field */
.viewer-art { position: relative; margin: 32px 0 0; width: 100%; max-width: 532px; aspect-ratio: 532 / 580; background: url("/assets/canvas-paper.png") center top / 102.6% auto no-repeat; border-radius: 8px; }
.viewer-art .layer { position: absolute; left: 8.27%; top: 5.17%; width: 83.46%; height: auto; aspect-ratio: 444 / 510; }
.viewer-art .layer img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.viewer-art .layer .outline { left: 24.1%; width: 51.8%; object-fit: fill; }
.viewer-message { margin: 40px 0 0; font: 400 20px/35.5px var(--serif); white-space: pre-wrap; overflow-wrap: anywhere; background: url("/assets/rules/lined-tile.svg") 0 var(--rule-shift, 0px) / 100% 106.5px repeat-y; min-height: calc(35.5px * 3); }   /* three ruled lines, like the input card */
.viewer-tags { display: flex; flex-wrap: wrap; gap: 12px 8px; margin: 31.5px 0 0; padding: 0; list-style: none; }   /* Figma: 40px below the 98px ruled block */
.viewer-art + .viewer-tags { margin-top: 40px; }   /* no note: 40px below the drawing */
.viewer-tags li { display: inline-flex; align-items: center; border-radius: 100px; padding: 8px 20px; min-height: 53px; background: var(--chip); color: var(--ink); font: 500 20px/1.5 var(--serif); }   /* same size as the input card's chips */
.viewer-actions { display: flex; justify-content: flex-end; gap: 16px; margin-top: 24px; }

/* ---------- Confirm + toast ---------- */
.added { width: 270px; max-width: calc(100vw - 32px); padding: 32px 16px; border: 0; border-radius: 32px; background: var(--panel); text-align: center; cursor: default; }   /* Figma "pop up" 260:6638: 270 × 261, cream like the cards */
.added[open] { animation: added-in .5s cubic-bezier(.22, 1, .36, 1); }   /* soft ease-out, no bounce */
.added[open]::backdrop { animation: backdrop-in .5s ease-out; }
.added.closing { animation: added-out .45s cubic-bezier(.4, 0, .6, 1) forwards; }
.added.closing::backdrop { animation: backdrop-out .45s ease-in forwards; }
@keyframes added-out { to { opacity: 0; transform: scale(.97) translateY(4px); } }
@keyframes backdrop-out { to { opacity: 0; } }
@keyframes added-in { from { opacity: 0; transform: scale(.96) translateY(6px); } }
.added h2 { margin: 0; font: 600 22px/26px var(--serif); color: var(--ink); outline: none; }
.added img { display: block; margin: 20px auto 24px; }
.phone-note { width: 300px; padding: 32px 24px 24px; }
.added.phone-note p { margin: 12px 0 24px; line-height: 1.5; }
.phone-note .action-btn { width: 100%; height: auto; padding: 12px 16px; font-size: 18px; }
.added p { margin: 0; font: 500 18px/1.3 var(--serif); color: #545151; }
.confirm { width: min(420px, calc(100vw - 32px)); border-radius: 24px; background: var(--panel); padding: 28px; }
.confirm h2 { margin: 0 0 8px; font: 600 22px/1.4 var(--serif); }
.confirm h2:focus { outline: none; }   /* the title takes focus on open, so no button shows a focus ring by default */
.confirm p { margin: 0 0 8px; color: #4b4747; }
.confirm-actions { display: flex; justify-content: flex-end; align-items: center; gap: 24px; margin-top: 16px; }
.confirm-actions .text-btn { padding: 8px 0; }
.confirm-actions .text-btn:hover { color: var(--ink); }
#toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 1000; transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px); padding: 12px 20px; border-radius: 100px;
  background: var(--panel); color: var(--ink); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: #fff; color: var(--wall); }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  /* Phones: every card floats over the dimmed wall like the Wishing Well: 16px from the screen edges, 32px corners */
  .seal-picker, .viewer { width: calc(100vw - 32px); max-width: none; height: auto; max-height: calc(100dvh - 32px); margin: auto; border-radius: 32px; }
  .panel-stage { margin: 16px auto calc(16px + env(safe-area-inset-bottom)); width: calc(100% - 32px); height: auto; }
  .panel-stage > .panel-inner { position: relative; width: 100%; transform: none; border-radius: 32px; }
  .panel-inner { padding: 72px 24px 32px; }
  .panel .action-btn { width: 100%; margin-left: 0; }
  .panel-close { left: 12px; top: 20px; }   /* × at 24px, the text edge */
  /* Phones: the title is left-aligned at 24px and shrinks if space is tight so it keeps ≥ 24px from the envelope
     (title ≈ 8.6 × its font size wide); the envelope sits on the title's centre line (title box: 48px × k down, 1.5 × font size tall). */
  .site-header { --title-fs: min(calc(70px * var(--k)), calc((100vw - 100px) / 8.6)); padding-left: 24px; padding-right: 76px; text-align: left; }   /* title starts at 24px like the text below and keeps ≥ 24px from the envelope */
  .site-title { font-size: var(--title-fs); }
  .wishing { left: auto; right: 24px; top: calc(48px * var(--k) + var(--title-fs) * 0.75 - 14px); }
  .wishing span { display: none; }   /* phones: the envelope only, top right */
  .wishing img { width: 28px; height: 28px; }
  .wishing-well { padding: 72px 24px 32px; }
  .wishing-well h2 { font-size: 22px; }   /* heading and heart fit on one line at 390px */
  .wishing-well.thanked { padding-top: 32px; }
  .wishing-well .panel-close { left: 12px; top: 20px; }   /* × at 24px, the phone text edge */
  .site-intro { white-space: normal; left: 24px; width: calc(100% - 48px); font-size: 20px; text-align: left; }   /* phones: 20px, left-aligned, 24px each side */
  .nickname, .panel-date, .viewer-head { font-size: 20px; }
  .nickname { padding-left: 0; }
  /* 16px from the paper edge to the swatch and to the redo arrow (the arrow sits 5px inside its 34px button) */
  .toolbar { gap: 4px; top: 83.5%; left: 16px; right: 11px; }
  .swatch { width: 36px; height: 36px; }
  .tools { gap: 0; }
  .tool-btn { width: 34px; height: 34px; padding: 5px; }
  .history { gap: 2px; }
  .history .icon-btn { width: 34px; height: 34px; }
  .toolbar .icon { width: 24px; height: 24px; }
  .zoom-ctl { top: 73.5%; right: 16px; gap: 4px; }   /* + lines up with the redo icon's right edge */
  .zoom-ctl .icon-btn.small, .zoom-ctl .icon-btn.small .icon { width: 16px; height: 16px; }   /* smaller zoom controls on phones */
  .zoom-label { font-size: 13px; min-width: 32px; }
  .panel-head { margin-bottom: 24px; }   /* 8px less space under the nickname row on phones */
  .message, .viewer-message { font-size: 17px; --rule-shift: -1.6px; }   /* 17px text sits 1.6px higher; keep the 4px gap */
  .topics-title { font-size: 18px; }
  .topics-hint { font-size: 17px; }
  .chip, .viewer-tags li { font-size: 17px; min-height: 44px; padding: 6px 16px; }
  .chip-input { min-height: 44px; font-size: 17px; }
  .viewer-inner { padding: 20px 24px 32px; }
  .viewer .panel-close { margin-left: -12px; }   /* × at 24px, the text edge */
  .viewer .panel-close { margin-bottom: 8px; }
  .viewer-head h2 { padding-left: 0; }
  .seal-inner { padding: 24px 12px 32px; }
  .seal-grid { grid-template-columns: repeat(6, 1fr); gap: 12px 4px; }   /* 6 per row like desktop: red row, cream row */
  .seal-option { width: 52px; height: 52px; }   /* 8px padding kept; 6 per row inside the inset card */
  .seal-option img { width: 36px; }
  .seal-preview { transform: scale(0.8); margin: -24px auto -24px; }   /* 16px clear between the torn edge and the seals */
}

/* Very narrow phones (under 360px): slightly smaller tool buttons so the toolbar still fits between the 16px edges */
@media (max-width: 359px) {
  .swatch { width: 32px; height: 32px; }
  .tool-btn { width: 28px; height: 28px; padding: 4px; }
  .history .icon-btn { width: 28px; height: 28px; }
  .toolbar .icon { width: 20px; height: 20px; }
  .toolbar { right: 12px; }   /* the arrow sits 4px inside its 28px button */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
