/* ============================================
   THE WORD BUNNY — the desk
   ============================================ */

:root {
  --ink: #4a3a35;
  --ink-soft: #7a655c;
  --rose: #e58aa0;
  --rose-d: #c4566f;
  --rose-l: #fbe3e8;
  --lav: #cdbbe9;
  --mint: #bfe3cd;
  --butter: #f7e09a;
  --sky: #a9c8e6;
  --paper: #fdf9f0;
  --paper-d: #f3ead9;
  --thread: #b8324a;

  /* daylight, driven by js/daylight.js */
  --amb: 20, 16, 48;
  --amb-a: 0;
  --blinds-a: 0.4;
  --blinds-x: 0vw;
  --blinds-r: 0deg;
  --warm-a: 0.25;
  --lamp-a: 0;

  --hand: 'Caveat', 'Comic Sans MS', cursive;
  --read: 'Literata', Georgia, serif;
  --type: 'Special Elite', 'Courier New', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #d8b88b url('../assets/desk/wood-tile.webp') center / 760px;
  font-family: var(--read);
  color: var(--ink);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
img { -webkit-user-drag: none; }

.skip {
  position: fixed; left: 8px; top: -60px; z-index: 500;
  background: #fff; padding: 8px 12px; border-radius: 8px; color: var(--ink);
}
.skip:focus { top: 8px; }

:focus-visible { outline: 3px solid var(--rose-d); outline-offset: 3px; border-radius: 6px; }

/* ── Desk + mat ───────────────────────────── */
.desk {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.mat {
  --u: 1cqw;
  position: relative;
  width: min(calc(100vw - 40px), calc((100dvh - 40px) * 1.74));
  aspect-ratio: 1.74;
  container-type: inline-size;
  border-radius: 26px;
}
.mat__felt {
  position: absolute; inset: 0;
  border-radius: inherit;
  background: var(--sky) url('../assets/desk/felt-tile.webp') center / 460px;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.25),
    inset 0 0 60px rgba(60,90,130,0.18),
    0 2px 3px rgba(60,35,10,0.35),
    0 14px 34px rgba(60,35,10,0.28);
}
.mat__stitch { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }

/* ── Title ───────────────────────────────── */
.title {
  position: absolute; left: 50%; top: 4.5%;
  transform: translateX(-50%);
  text-align: center;
  width: 70%;
  z-index: 2;
}
.title__letters {
  display: flex; justify-content: center; flex-wrap: wrap;
  gap: calc(0.25 * var(--u));
  margin: 0; line-height: 1;
}
.letter {
  width: calc(3.9 * var(--u));
  cursor: grab; user-select: none; touch-action: none;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.letter svg { display: block; width: 100%; height: auto; overflow: visible; }
.letter:hover { transform: translateY(-8%) rotate(var(--tilt, 4deg)); }
.letter.is-held { cursor: grabbing; transition: none; z-index: 5; position: relative; }
.title__space { width: calc(2 * var(--u)); }
.title__break { display: none; flex-basis: 100%; height: 0; }
.title__tag {
  margin: calc(0.5 * var(--u)) 0 0;
  font-family: var(--hand); font-weight: 500;
  font-size: calc(1.9 * var(--u));
  color: #5d6f8c;
}

/* ── Items on the desk ───────────────────── */
.item {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: calc(var(--w) * 1cqw);
  transform: translate(-50%, -50%) rotate(var(--r, 0deg)) scale(var(--s, 1));
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s, opacity 0.2s;
  filter: drop-shadow(0 0.35cqw 0.5cqw rgba(50,30,10,0.3));
  cursor: grab;
  user-select: none; -webkit-user-select: none;
  touch-action: pan-y;
  z-index: 3;
}
.item[data-open]:hover, .item--tea:hover { --s: 1.04; }
.item.is-held {
  --s: 1.08;
  cursor: grabbing;
  filter: drop-shadow(0 1.5cqw 1.4cqw rgba(50,30,10,0.32));
  transition: transform 0.15s, filter 0.2s;
}
.item.is-away { opacity: 0; pointer-events: none; }
.item__img { display: block; width: 100%; height: auto; pointer-events: none; }

.tag {
  position: absolute; left: 50%; bottom: -4%;
  transform: translateX(-50%) rotate(-3deg);
  font-family: var(--hand); font-weight: 700;
  font-size: calc(1.55 * var(--u));
  line-height: 1.1;
  white-space: nowrap;
  background: var(--rose-l);
  color: var(--rose-d);
  padding: 0.15em 0.7em 0.2em;
  border-radius: 0.25em;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
  pointer-events: none;
}
.tag::before {
  content: ''; position: absolute; left: 0.3em; top: 50%;
  width: 0.28em; height: 0.28em; border-radius: 50%;
  background: rgba(0,0,0,0.25); transform: translateY(-50%);
}
.tag--lav { background: #efe7fb; color: #7658b0; }
.tag--mint { background: #e3f4ea; color: #3f8560; }
.tag--butter { background: #fdf3cf; color: #9a7716; }

/* polaroid */
.polaroid {
  background: #fff; padding: 6% 6% 0; border-radius: 2px;
}
.polaroid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; pointer-events: none; }
.polaroid__cap {
  display: block; text-align: center;
  font-family: var(--hand); font-weight: 700;
  font-size: calc(1.7 * var(--u)); color: var(--ink);
  padding: 0.25em 0 0.35em;
}
.tape {
  position: absolute; left: 50%; top: -4%;
  width: 38%; height: 9%;
  transform: translateX(-50%) rotate(-4deg);
  background: repeating-linear-gradient(45deg, rgba(247,224,154,0.9) 0 6px, rgba(255,240,190,0.9) 6px 12px);
  box-shadow: 0 1px 1px rgba(0,0,0,0.12);
}

/* clock */
.clock {
  position: relative;
  background: #fffaf2; border-radius: calc(1.3 * var(--u));
  padding: calc(1.1 * var(--u)) calc(1 * var(--u)) calc(0.9 * var(--u));
  text-align: center;
  border: calc(0.25 * var(--u)) solid #f1dfd2;
}
.clock__time { font-weight: 700; font-size: calc(2.05 * var(--u)); white-space: nowrap; line-height: 1; letter-spacing: -0.02em; }
.clock__sub { font-family: var(--hand); font-size: calc(1.35 * var(--u)); color: var(--rose-d); margin-top: 0.1em; }
.clock__weather { font-family: var(--hand); font-size: calc(1.3 * var(--u)); color: var(--ink-soft); margin-top: 0.2em; white-space: nowrap; }
.clock__dot { opacity: 0.5; }
.clock__sky {
  position: absolute; right: -9%; top: -14%;
  width: 36%; aspect-ratio: 1; border-radius: 50%;
  border: 0; background: #fff3c9; cursor: pointer;
  font-size: calc(1.9 * var(--u)); line-height: 1;
  display: grid; place-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.clock__sky:hover { transform: scale(1.12) rotate(12deg); }

/* teacup */
.steam { position: absolute; left: 30%; top: 8%; width: 30%; height: 40%; pointer-events: none; }
.steam i {
  position: absolute; bottom: 0; width: 22%; height: 60%; border-radius: 50%;
  background: rgba(255,255,255,0.75); filter: blur(4px); opacity: 0;
  animation: steam 3.6s ease-in-out infinite;
}
.steam i:nth-child(1) { left: 10%; }
.steam i:nth-child(2) { left: 40%; animation-delay: 1.2s; }
.steam i:nth-child(3) { left: 68%; animation-delay: 2.3s; }
@keyframes steam {
  0% { transform: translateY(20%) scale(0.6); opacity: 0; }
  30% { opacity: 0.7; }
  100% { transform: translateY(-130%) scale(1.5) translateX(20%); opacity: 0; }
}
.tea-note {
  position: absolute; left: 50%; top: -22%;
  transform: translateX(-50%) rotate(2deg) scale(0);
  transform-origin: 50% 100%;
  font-family: var(--hand); font-weight: 700; font-size: calc(1.45 * var(--u));
  background: #fff; padding: 0.2em 0.7em; border-radius: 1em; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
.tea-note.is-on { transform: translateX(-50%) rotate(2deg) scale(1); }

/* record player */
.radio { position: relative; }
.radio__base { display: block; width: 100%; pointer-events: none; }
.radio__vinyl {
  position: absolute;
  left: 38.5%; top: 61.5%;
  width: 57%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 17%, rgba(255,255,255,0.07) 17.5% 18%, transparent 18.5% 30%, rgba(255,255,255,0.05) 30.5% 31%, transparent 31.5% 44%, rgba(255,255,255,0.06) 44.5% 45%, transparent 45.5% 58%, rgba(255,255,255,0.05) 58.5% 59%, transparent 59.5%),
    conic-gradient(#1c1b1e, #3a383d 12%, #1c1b1e 25%, #343237 37%, #1c1b1e 50%, #3a383d 62%, #1c1b1e 75%, #343237 87%, #1c1b1e);
  box-shadow: 0 1px 3px rgba(0,0,0,0.45);
  animation: spin 2.4s linear infinite;
  animation-play-state: paused;
}
.radio.is-playing .radio__vinyl { animation-play-state: running; }
.radio__label {
  position: absolute; inset: 31%; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle, #fff 0 9%, transparent 10%), linear-gradient(135deg, var(--rose), var(--lav));
}
.radio__label img { width: 100%; height: 100%; object-fit: cover; display: block; }
.radio__label::after { content: ''; position: absolute; left: 50%; top: 50%; width: 12%; height: 12%; border-radius: 50%; background: #eee; transform: translate(-50%, -50%); box-shadow: 0 0 0 1px #999; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.radio__arm {
  position: absolute;
  left: 74.6%; top: 45.5%;
  width: 2.8%; height: 30%;
  transform-origin: 50% 0;
  transform: rotate(2deg);
  transition: transform 0.9s cubic-bezier(0.34, 1.3, 0.64, 1);
  background: linear-gradient(90deg, #cfcfd4, #f4f4f6 45%, #a9a9b0);
  border-radius: 99px;
  box-shadow: 2px 3px 4px rgba(0,0,0,0.3);
  pointer-events: none;
}
.radio__arm::before { /* pivot */
  content: ''; position: absolute; left: 50%; top: 0;
  width: 420%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, #f6f6f8 0 30%, #b9b9c0 32% 60%, #e6e6ea 62%);
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
.radio__arm::after { /* head */
  content: ''; position: absolute; left: 50%; bottom: -4%;
  width: 300%; height: 20%; border-radius: 3px;
  transform: translateX(-50%) rotate(8deg);
  background: linear-gradient(#f3b7c4, #e58aa0);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.radio.is-playing .radio__arm { transform: rotate(28deg); }
.radio__btn {
  position: absolute;
  left: 38.5%; top: 61.5%;
  width: 57%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%; border: 0; background: transparent; cursor: pointer;
}
.radio__btn::after {
  content: '▶'; position: absolute; left: 50%; top: 50%;
  width: 34%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%);
  display: grid; place-items: center;
  background: rgba(255,255,255,0.92); color: var(--rose-d);
  font-size: calc(1.5 * var(--u)); padding-left: 6%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: opacity 0.25s, transform 0.25s;
}
.radio.is-playing .radio__btn::after { content: '❚❚'; opacity: 0; padding-left: 0; font-size: calc(1.1 * var(--u)); }
.radio.is-playing .radio__btn:hover::after, .radio.is-playing .radio__btn:focus-visible::after { opacity: 1; }
.radio__card {
  position: absolute; left: 50%; top: 86%;
  transform: translateX(-50%) rotate(-2deg);
  width: 96%;
  background: #fffaf2; border-radius: calc(0.5 * var(--u));
  padding: calc(0.5 * var(--u)) calc(0.8 * var(--u)) calc(0.6 * var(--u));
  text-align: center; line-height: 1.15;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.radio__live { display: block; font-family: var(--hand); font-size: calc(1.15 * var(--u)); color: var(--rose-d); }
.radio__live::before { content: '● '; color: #c9c0b8; }
.radio.is-playing ~ .radio__card .radio__live::before { color: #e2445c; animation: blink 1.4s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.radio__song { display: block; font-weight: 600; font-size: calc(1.05 * var(--u)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.radio__artist { display: block; font-family: var(--hand); font-size: calc(1.15 * var(--u)); color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.radio__vol { width: 70%; height: 12px; margin-top: 2px; accent-color: var(--rose); cursor: pointer; }

/* virtual pet */
.pet { position: relative; }
.pet__shell { display: block; width: 100%; pointer-events: none; }
.pet__screen {
  position: absolute;
  left: 27%; top: 47.2%;
  width: 47%; height: 29.6%;
  border-radius: 3%;
  background: #9bbc0f;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.35);
  overflow: hidden;
}
.pet__screen canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.pet__btn {
  position: absolute; width: 13%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 0; background: rgba(255,255,255,0); cursor: pointer;
  transition: background 0.1s, box-shadow 0.1s;
}
.pet__btn:hover { background: rgba(255,255,255,0.3); }
.pet__btn:active { background: rgba(0,0,0,0.18); box-shadow: inset 0 2px 4px rgba(0,0,0,0.35); }
.pet__btn--a { left: 30.5%; top: 86.2%; }
.pet__btn--b { left: 50%; top: 86.6%; }
.pet__btn--c { left: 69.2%; top: 86.2%; }

/* embroidered bunny */
.patch {
  position: absolute; right: 2.2%; bottom: 3.5%;
  width: calc(11 * var(--u));
  border: 0; background: none; padding: 0; cursor: pointer; z-index: 1;
  transform-origin: 60% 100%;
}
.patch img { display: block; width: 100%; pointer-events: none; filter: drop-shadow(0 1px 1px rgba(40,50,70,0.4)); }
.patch.is-hop { animation: hop 0.6s cubic-bezier(0.3, 0, 0.3, 1); }
@keyframes hop {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  20% { transform: translateY(2%) scale(1.06, 0.92); }
  50% { transform: translateY(-22%) scale(0.96, 1.06) rotate(-4deg); }
  80% { transform: translateY(1%) scale(1.04, 0.95); }
}

.stitch-tag {
  position: absolute; left: 36%; bottom: 2.4%;
  font-family: var(--hand); font-size: calc(1.3 * var(--u));
  color: #4c6386; text-decoration: none;
  border-bottom: 1px dashed rgba(76,99,134,0.5);
  z-index: 1;
}
.stitch-tag:hover { color: var(--thread); border-color: var(--thread); }
.stitch-tag[href="#"] { pointer-events: none; border: 0; }

/* placed stickers */
.stickers-layer { position: absolute; inset: 0; pointer-events: none; z-index: 40; }
.sticker {
  position: absolute;
  left: calc(var(--x) * 1%); top: calc(var(--y) * 1%);
  width: calc(var(--sz, 6) * var(--u));
  transform: translate(-50%, -50%) rotate(var(--r, 0deg));
  pointer-events: auto; cursor: grab; touch-action: none;
  filter: drop-shadow(0 1px 1.5px rgba(0,0,0,0.3));
}
.sticker img { display: block; width: 100%; pointer-events: none; }
.sticker.is-pop { animation: pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes pop { from { transform: translate(-50%, -50%) rotate(var(--r, 0deg)) scale(1.5); } }
.sticker-ghost { position: fixed; z-index: 400; pointer-events: none; transform: translate(-50%, -50%) scale(1.15) rotate(-6deg); filter: drop-shadow(0 8px 8px rgba(0,0,0,0.3)); }
.sticker-ghost img { display: block; width: 100%; }

/* ── Daylight ────────────────────────────── */
.light { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.light > div { position: absolute; inset: 0; }
.light__ambient { background: rgb(var(--amb)); opacity: var(--amb-a); mix-blend-mode: multiply; transition: opacity 1.2s, background 1.2s; }
.light__blinds {
  inset: -25% !important;
  opacity: var(--blinds-a);
  transform: translateX(var(--blinds-x)) rotate(var(--blinds-r));
  filter: blur(16px);
  background: linear-gradient(-38deg,
    transparent 0 8%, rgba(30,20,10,0.42) 8.5% 14%, transparent 14.5% 22%,
    rgba(30,20,10,0.36) 22.5% 30%, transparent 30.5% 40%, rgba(30,20,10,0.32) 40.5% 50%,
    transparent 50.5% 62%, rgba(30,20,10,0.28) 62.5% 72%, transparent 72.5%);
  transition: opacity 1.2s, transform 1.2s;
}
.light__warm {
  opacity: var(--warm-a);
  background: radial-gradient(ellipse at 82% 4%, rgba(255,206,150,0.6), rgba(255,180,120,0.16) 32%, transparent 58%);
  mix-blend-mode: screen;
  transition: opacity 1.2s;
}
.light__lamp {
  opacity: var(--lamp-a);
  background: radial-gradient(ellipse 60% 70% at 50% 46%, rgba(255,226,170,0.6), rgba(255,200,130,0.28) 40%, transparent 72%);
  mix-blend-mode: screen;
  transition: opacity 0.8s;
}

/* ── Tools + stickerbook ─────────────────── */
.tools { position: fixed; right: 12px; top: 12px; z-index: 60; display: flex; gap: 8px; }
.tool {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,250,242,0.9); font-size: 18px;
  box-shadow: 0 2px 6px rgba(60,35,10,0.3);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s, background 0.2s;
}
.tool:hover { transform: scale(1.1) rotate(-6deg); }
.tool[aria-pressed="true"] { background: #ffe9a8; box-shadow: 0 0 18px rgba(255,205,110,0.9), 0 2px 6px rgba(60,35,10,0.3); }

.stickerbook {
  position: fixed; left: 14px; bottom: 0; z-index: 60;
  width: min(330px, calc(100vw - 28px));
  background: #fffaf2;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -2px 16px rgba(60,35,10,0.28);
  transform: translateY(calc(100% - 38px));
  transition: transform 0.4s cubic-bezier(0.34, 1.3, 0.64, 1);
}
.stickerbook.is-open { transform: none; }
.stickerbook__tab {
  display: block; width: 100%; height: 38px; border: 0; background: none; cursor: pointer;
  font-family: var(--hand); font-weight: 700; font-size: 20px; color: var(--rose-d);
}
.stickerbook__sheet {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  padding: 4px 12px 6px;
  background: repeating-linear-gradient(0deg, transparent 0 23px, rgba(169,200,230,0.3) 23px 24px);
}
.stickerbook__item {
  border: 0; background: none; padding: 4px; cursor: grab; touch-action: none;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.stickerbook__item:hover { transform: scale(1.15) rotate(-5deg); }
.stickerbook__item img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; pointer-events: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.25)); }
.stickerbook__hint { margin: 0; padding: 2px 12px 10px; font-family: var(--hand); font-size: 15px; color: var(--ink-soft); text-align: center; }
.stickerbook.is-target { box-shadow: 0 0 0 3px var(--rose), 0 -2px 16px rgba(60,35,10,0.28); }

.hint {
  position: fixed; left: 50%; bottom: 14px; z-index: 55;
  transform: translateX(-50%);
  margin: 0; padding: 6px 16px;
  font-family: var(--hand); font-size: 19px; color: var(--ink);
  background: rgba(255,250,242,0.94); border-radius: 99px;
  box-shadow: 0 2px 10px rgba(60,35,10,0.25);
  transition: opacity 0.6s, transform 0.6s;
  pointer-events: none; white-space: nowrap;
}
.hint.is-gone { opacity: 0; transform: translateX(-50%) translateY(12px); }

/* ── Scene (opened things) ───────────────── */
.scene { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.scene[hidden] { display: none; }
.scene__backdrop {
  position: absolute; inset: 0;
  background: rgba(58,38,24,0.5);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity 0.4s;
}
.scene.is-in .scene__backdrop { opacity: 1; }
.scene__stage { position: relative; z-index: 1; max-width: 100vw; }
.scene__close {
  position: absolute; right: 14px; top: 12px; z-index: 3;
  border: 0; cursor: pointer;
  font-family: var(--hand); font-weight: 700; font-size: 19px;
  background: #fffaf2; color: var(--rose-d);
  padding: 5px 16px 7px; border-radius: 99px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  opacity: 0; transition: opacity 0.4s 0.2s, transform 0.2s;
}
.scene.is-in .scene__close { opacity: 1; }
.scene__close:hover { transform: scale(1.06) rotate(-2deg); }

/* shared reading type */
.prose { font-size: var(--fs, 17px); line-height: 1.62; }
.prose p { margin: 0 0 0.9em; text-wrap: pretty; }
.prose h2 { font-size: 1.7em; line-height: 1.12; margin: 0 0 0.3em; font-weight: 700; text-wrap: balance; }
.prose h3 { font-family: var(--hand); font-size: 1.5em; margin: 0 0 0.2em; color: var(--rose-d); font-weight: 700; }
.prose a { color: var(--rose-d); }
.prose .ornament { text-align: center; letter-spacing: 0.6em; color: var(--rose); margin: 1.1em 0; break-after: avoid; }
.hand { font-family: var(--hand); }
.meta { font-family: var(--hand); font-size: 1.25em; color: var(--ink-soft); line-height: 1.25; }
.stars { color: #e3a520; letter-spacing: 0.08em; font-size: 1.25em; }
.stars i { color: #dcd3c4; font-style: normal; }
.chip { display: inline-block; font-family: var(--hand); font-size: 1.1em; padding: 0 0.6em; border-radius: 99px; background: var(--rose-l); color: var(--rose-d); margin: 0 0.25em 0.25em 0; }

/* ── Codex: the opening book / notebook ──── */
.codex {
  --pw: min(46vw, 540px, calc((100dvh - 120px) / 1.38));
  --ph: calc(var(--pw) * 1.38);
  --fs: clamp(13.5px, calc(var(--pw) / 30), 18px);
  position: relative;
  width: calc(var(--pw) * 2); height: var(--ph);
  perspective: 2600px;
  margin-bottom: 56px;
}
.codex__board {
  position: absolute; inset: -9px -11px; border-radius: 10px;
  background: var(--board, #8faa8b);
  box-shadow: 0 18px 50px rgba(30,15,5,0.5);
  opacity: 0; transition: opacity 0.3s 0.45s;
}
.codex.is-open .codex__board { opacity: 1; }
.codex__page {
  position: absolute; top: 0; width: 50%; height: 100%;
  background: var(--paper);
  padding: calc(var(--pw) * 0.085) calc(var(--pw) * 0.095) calc(var(--pw) * 0.13);
}
.codex__page--l { left: 0; border-radius: 5px 0 0 5px; background-image: linear-gradient(90deg, transparent 80%, rgba(90,60,30,0.16)); opacity: 0; transition: opacity 0.01s 0.42s; }
.codex__page--r { left: 50%; border-radius: 0 5px 5px 0; background-image: linear-gradient(270deg, transparent 80%, rgba(90,60,30,0.16)); }
.codex.is-open .codex__page--l { opacity: 1; }
.codex__win { position: relative; width: 100%; height: 100%; overflow: hidden; }
.codex__flow { height: 100%; column-fill: auto; column-gap: 60px; }
.codex__flow > :first-child { margin-top: 0; }
.codex__folio { position: absolute; bottom: calc(var(--pw) * 0.045); font-family: var(--hand); font-size: calc(var(--fs) * 1.05); color: #a8947f; }
.codex__page--l .codex__folio { left: calc(var(--pw) * 0.095); }
.codex__page--r .codex__folio { right: calc(var(--pw) * 0.095); }

.codex__cover {
  position: absolute; left: 50%; top: 0; width: 50%; height: 100%;
  transform-origin: 0 50%; transform-style: preserve-3d;
  transition: transform 0.95s cubic-bezier(0.4, 0.05, 0.2, 1);
  z-index: 5;
}
.codex__cover > div { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 3px 6px 6px 3px; }
.codex__cover-front { background: center / 100% 100% no-repeat; filter: drop-shadow(0 10px 18px rgba(30,15,5,0.45)); }
.codex__cover-back { transform: rotateY(180deg); background: var(--endpaper, #e9dcc6); border-radius: 6px 3px 3px 6px; }
/* The art includes bits that hang past the cover (ribbon, spiral, page tabs). Let those
   overhang so the cover itself sits exactly over the pages and nothing peeks out. */
.codex--book .codex__cover-front { bottom: -12%; }
.codex--notebook .codex__cover-front { left: -5.25%; right: -5.1%; }
.codex:not(.is-open) .codex__page--r { opacity: 0; transition: opacity 0.01s 0.8s; }
.codex.is-open .codex__cover { transform: rotateY(-180deg); }
.codex.is-settled .codex__cover { visibility: hidden; }

.codex__leaf { position: absolute; top: 0; width: 50%; height: 100%; transform-style: preserve-3d; z-index: 8; }
.codex__leaf--fwd { left: 50%; transform-origin: 0 50%; }
.codex__leaf--back { left: 0; transform-origin: 100% 50%; }
.codex__leaf .codex__page { width: 100%; left: 0; opacity: 1; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 0 20px rgba(30,15,5,0.2); }
.codex__leaf .is-backface { transform: rotateY(180deg); }

.codex__nav {
  position: absolute; left: 50%; bottom: -54px; transform: translateX(-50%);
  display: flex; gap: 8px; align-items: center;
  opacity: 0; transition: opacity 0.4s 0.6s;
}
.codex.is-open .codex__nav { opacity: 1; }
.codex__nav button {
  border: 0; cursor: pointer; white-space: nowrap;
  font-family: var(--hand); font-weight: 700; font-size: 19px;
  background: #fffaf2; color: var(--ink);
  padding: 4px 16px 6px; border-radius: 99px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.15s;
}
.codex__nav button:hover:not(:disabled) { transform: translateY(-2px); }
.codex__nav button:disabled { opacity: 0.4; cursor: default; }

/* page content pieces */
.cx-title { font-family: var(--hand); font-weight: 700; font-size: 3em; line-height: 0.95; color: var(--rose-d); margin: 0 0 0.2em; }
.cx-lede { font-family: var(--hand); font-size: 1.45em; line-height: 1.25; color: var(--ink-soft); }
.cx-break { break-after: column; }
.cx-cover {
  display: block; width: 47%; margin: 1% auto 5%;
  border-radius: 2px 5px 5px 2px;
  box-shadow: 3px 5px 14px rgba(40,25,10,0.38);
  transform: rotate(-2.5deg);
  aspect-ratio: 2 / 3; object-fit: cover; background: var(--paper-d);
}
.cx-grid { font-size: 0; margin: 0 -1.6%; }
.cx-grid button {
  display: inline-block; width: 16.8%; margin: 0 1.6% 4.4%; vertical-align: top;
  border: 0; padding: 0; background: none; cursor: pointer; break-inside: avoid;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cx-grid button:hover { transform: translateY(-5%) rotate(-2deg); }
.cx-grid img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 1px 3px 3px 1px; box-shadow: 1px 2px 5px rgba(40,25,10,0.35); background: var(--paper-d); }
.cx-list { list-style: none; padding: 0; margin: 0.6em 0 0; }
.cx-list li { break-inside: avoid; border-bottom: 1px dashed rgba(120,90,60,0.3); }
.cx-list button { display: block; width: 100%; text-align: left; border: 0; background: none; cursor: pointer; padding: 0.55em 0; }
.cx-list button:hover b { color: var(--rose-d); }
.cx-list b { display: block; font-size: 1.15em; line-height: 1.2; }
.cx-list span { font-family: var(--hand); font-size: 1.2em; color: var(--ink-soft); }
.cx-review::first-letter { font-family: var(--hand); font-weight: 700; font-size: 3.4em; float: left; line-height: 0.75; padding: 0.08em 0.08em 0 0; color: var(--rose-d); }
.cx-empty { font-family: var(--hand); font-size: 1.4em; color: var(--ink-soft); }
.cx-stat { display: flex; gap: 1.2em; margin: 1em 0; }
.cx-stat div { text-align: center; }
.cx-stat b { display: block; font-size: 2em; line-height: 1; color: var(--rose-d); }
.cx-stat span { font-family: var(--hand); font-size: 1.15em; color: var(--ink-soft); }

/* notebook skin: everything sits on the ruled lines */
.codex--notebook { --board: #e9a9b6; --endpaper: #f6d6dc; --lh: calc(var(--fs) * 1.72); }
.codex--notebook .codex__page { background-color: #fffdf6; }
.codex--notebook .codex__win { background: repeating-linear-gradient(transparent 0 calc(var(--lh) - 1px), rgba(120,160,210,0.3) calc(var(--lh) - 1px) var(--lh)); }
.codex--notebook .prose, .codex--notebook .prose p, .codex--notebook .cx-list span { line-height: var(--lh); }
.codex--notebook .prose p { margin: 0; text-indent: 1.4em; }
.codex--notebook .prose h2 { font-size: 1.55em; line-height: calc(var(--lh) * 2); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.codex--notebook .prose .cx-title { font-size: 2.6em; line-height: calc(var(--lh) * 2); white-space: nowrap; }
.codex--notebook .prose .meta, .codex--notebook .prose .cx-lede, .codex--notebook .prose .cx-empty { text-indent: 0; font-size: 1.3em; line-height: var(--lh); margin: 0; }
.codex--notebook .prose .ornament { margin: 0; text-indent: 0; }
.codex--notebook .prose .ornament + p { text-indent: 0; }
.codex--notebook .cx-list { margin: 0; }
.codex--notebook .cx-list li { border: 0; }
.codex--notebook .cx-list button { padding: 0; }
.codex--notebook .cx-list b { font-size: 1.1em; line-height: var(--lh); }
.codex--notebook.is-open::after {
  content: ''; position: absolute; left: 50%; top: 3%; width: 22px; height: 94%;
  transform: translateX(-50%); z-index: 9; pointer-events: none;
  background: repeating-linear-gradient(180deg, transparent 0 9px, #b9b9c2 9px 11px, #ececf0 11px 13px, #9d9da8 13px 15px, transparent 15px 24px);
  border-radius: 8px; opacity: 0.95;
}

/* single-page mode (phones) */
.codex.is-single { --pw: min(94vw, 520px); width: var(--pw); height: calc(100dvh - 110px); --fs: 16.5px; }
.codex.is-single .codex__page--l { display: none; }
.codex.is-single .codex__page--r { left: 0; width: 100%; border-radius: 5px; padding: 26px 22px 18px; background-image: none; }
.codex.is-single .codex__win { overflow-y: auto; overscroll-behavior: contain; }
.codex.is-single .codex__flow { height: auto; }
.codex.is-single .codex__cover { left: 0; width: 100%; }
.codex.is-single.is-open .codex__cover { transform: rotateY(-105deg); opacity: 0; transition: transform 0.8s cubic-bezier(0.4, 0.05, 0.2, 1), opacity 0.3s 0.45s; }
.codex.is-single .codex__folio { display: none; }
.codex.is-single .cx-cover { width: 46%; }
.codex.is-single::after { display: none; }
.codex.is-single .cx-grid { margin: 0; }
.codex.is-single .cx-grid button { width: 22%; margin: 0 1.5% 5%; }

/* ── Typewriter ──────────────────────────── */
.tw { position: relative; width: min(94vw, 640px); height: calc(100dvh - 40px); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.tw__tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 44px 0 10px; }
.tw__tabs button {
  border: 0; cursor: pointer; font-family: var(--hand); font-weight: 700; font-size: 17px;
  background: rgba(255,250,242,0.85); color: var(--ink); padding: 2px 12px 4px; border-radius: 99px;
}
.tw__tabs button[aria-current="true"] { background: var(--mint); }
.tw__paper {
  position: relative; flex: 1; min-height: 0; width: 88%;
  background: #fffdf7; border-radius: 3px 3px 0 0;
  box-shadow: 0 6px 30px rgba(30,15,5,0.4);
  padding: 7% 9% 26%;
  overflow-y: auto; overscroll-behavior: contain;
  font-family: var(--type); font-size: clamp(14px, 2.5vw, 17px); line-height: 1.75; color: #3b302c;
  margin-bottom: -20%;
  cursor: pointer;
}
.tw__paper h2 { font-family: var(--type); font-weight: 400; font-size: 1.35em; margin: 0 0 1.4em; text-decoration: underline; text-underline-offset: 5px; }
.tw__text { white-space: pre-wrap; margin: 0; font: inherit; }
.tw__caret { display: inline-block; width: 0.55em; height: 1.05em; background: #3b302c; vertical-align: text-bottom; animation: blink 1s steps(2) infinite; }
.tw__date { margin-top: 2em; color: #9c8b80; }
.tw__machine { position: relative; z-index: 2; width: min(78%, 430px); filter: drop-shadow(0 14px 22px rgba(30,15,5,0.5)); pointer-events: none; }
.tw__machine img { display: block; width: 100%; }
.tw__keys { position: absolute; z-index: 3; bottom: 18px; left: 0; right: 0; display: flex; justify-content: space-between; padding: 0 2%; pointer-events: none; }
.tw__keys button {
  width: 52px; height: 52px; border-radius: 50%; cursor: pointer; pointer-events: auto;
  border: 3px solid #d8cdb8; background: #fffaf0; color: var(--ink);
  font-family: var(--type); font-size: 18px;
  box-shadow: 0 3px 0 #b5a88f, 0 5px 8px rgba(0,0,0,0.35);
}
.tw__keys button:active { transform: translateY(3px); box-shadow: 0 0 0 #b5a88f, 0 2px 4px rgba(0,0,0,0.35); }
.tw__keys button:disabled { opacity: 0.45; }

/* ── Sheets: about, favourites, letter ───── */
.sheet {
  --fs: clamp(15px, 1.25vw + 9px, 18px);
  position: relative;
  width: min(94vw, 800px); max-height: calc(100dvh - 90px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper);
  padding: clamp(22px, 5vw, 52px);
  border-radius: 4px;
  box-shadow: 0 18px 50px rgba(30,15,5,0.5);
}
.sheet--about { background: #fbf3e4 radial-gradient(rgba(180,140,90,0.14) 1px, transparent 1.5px) 0 0 / 14px 14px; }
.about { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: clamp(18px, 4vw, 44px); align-items: start; }
.about__pic { position: relative; background: #fff; padding: 5% 5% 0; transform: rotate(-3deg); box-shadow: 0 4px 14px rgba(40,25,10,0.3); margin-top: 6%; }
.about__pic img { display: block; width: 100%; }
.about__pic figcaption { font-family: var(--hand); font-weight: 700; font-size: 1.5em; text-align: center; padding: 0.3em 0 0.4em; }
.about__pic .tape { top: -5%; }
.about__links { margin-top: 2em; display: grid; gap: 10px; }
.about__links a {
  display: block; text-decoration: none; color: var(--ink);
  font-family: var(--hand); font-weight: 700; font-size: 1.35em; line-height: 1.1;
  padding: 0.3em 0.9em; transform: rotate(var(--r, -1deg));
  background: repeating-linear-gradient(90deg, var(--c1, #cdbbe9) 0 10px, var(--c2, #d9cbee) 10px 20px);
  clip-path: polygon(0 0, 100% 0, 98% 50%, 100% 100%, 0 100%, 2% 50%);
}
.about__links a span { display: block; font-weight: 500; font-size: 0.8em; opacity: 0.8; }
.about__links a:hover { transform: rotate(0) scale(1.03); }
.about__hello { font-family: var(--hand); font-weight: 700; font-size: 2.8em; line-height: 1; color: var(--rose-d); margin: 0 0 0.3em; }
.about__more { font-family: var(--hand); font-size: 1.3em; color: var(--ink-soft); margin: 1.2em 0 0.4em; }

.sheet--favs { background: #f9e7a6; border: 10px solid #f1d27a; border-radius: 28px; box-shadow: inset 0 4px 18px rgba(120,90,10,0.25), 0 18px 50px rgba(30,15,5,0.5); }
.favs__title { font-family: var(--hand); font-weight: 700; font-size: 2.6em; margin: 0 0 0.5em; text-align: center; color: #86650f; line-height: 1; }
.favs { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 12px; list-style: none; padding: 0; margin: 0; }
.favs li {
  background: #fffdf6; border-radius: 10px; padding: 10px 16px 12px; text-align: center;
  transform: rotate(var(--r, 0deg));
  box-shadow: 0 3px 8px rgba(90,60,0,0.25);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: fav-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
  animation-delay: calc(var(--i) * 45ms + 250ms);
  min-width: 128px;
}
.favs li:hover { transform: rotate(0deg) scale(1.08); }
.favs li span { display: block; font-size: 2em; line-height: 1.1; }
.favs li b { display: block; font-size: 1em; }
.favs li small { display: block; font-family: var(--hand); font-size: 1.15em; color: var(--ink-soft); line-height: 1.1; }
@keyframes fav-in { from { opacity: 0; transform: translateY(30px) scale(0.5) rotate(20deg); } }

.sheet--letter {
  background: #fffdf8;
  border: 12px solid transparent;
  border-image: repeating-linear-gradient(-45deg, #e58aa0 0 12px, #fffdf8 12px 24px, #8fb4dd 24px 36px, #fffdf8 36px 48px) 12;
  width: min(94vw, 620px);
}
.letter-form label { display: block; font-family: var(--hand); font-weight: 700; font-size: 1.3em; margin: 0.7em 0 0.1em; }
.letter-form input, .letter-form textarea {
  width: 100%; font: inherit; color: var(--ink);
  border: 0; border-bottom: 2px dashed #d9c9b7; background: transparent; padding: 6px 2px; border-radius: 0;
}
.letter-form textarea { min-height: 8.5em; resize: vertical; line-height: 1.7; background: repeating-linear-gradient(transparent 0 calc(1.7em - 1px), #eadfce calc(1.7em - 1px) 1.7em); border-bottom: 0; }
.letter-form input:focus, .letter-form textarea:focus { outline: 0; border-color: var(--rose); }
.btn {
  display: inline-block; margin-top: 1.1em; border: 0; cursor: pointer; text-decoration: none;
  font-family: var(--hand); font-weight: 700; font-size: 1.4em;
  background: var(--rose); color: #fff; padding: 0.25em 1.2em 0.35em; border-radius: 99px;
  box-shadow: 0 3px 0 var(--rose-d);
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--rose-d); }
.letter-note { font-family: var(--hand); font-size: 1.2em; color: var(--ink-soft); }

.sheet--plain h2 { margin-top: 1.2em; }
.sheet--plain ul { padding-left: 1.2em; }

/* ── Phone layout ────────────────────────── */
@media (max-width: 760px), (max-aspect-ratio: 4/5) {
  .desk { padding: 8px 8px 60px; place-items: start center; }
  .mat { --u: 2.5cqw; width: calc(100vw - 16px); aspect-ratio: 9 / 27; border-radius: 18px; }
  .title { top: 4.2%; width: 94%; }
  .letter { width: calc(3.9 * var(--u)); }
  .title__break { display: block; }
  .title__space { display: none; }
  .patch { width: calc(11 * var(--u)); bottom: 1.2%; }
  .stitch-tag { bottom: 0.9%; left: 5%; }
  .hint { font-size: 16px; bottom: 50px; white-space: normal; width: max-content; max-width: 90vw; text-align: center; }
  .scene__close { top: 8px; right: 8px; }
  .about { grid-template-columns: 1fr; }
  .favs li { min-width: 0; flex: 0 1 calc(50% - 8px); padding: 8px 8px 10px; }
  .about__pic { width: 62%; margin: 0 auto; }
  .tw { height: calc(100dvh - 16px); }
  .tw__machine { width: 82%; }
  .codex__nav { bottom: -50px; }
  .codex__nav button { font-size: 17px; padding: 3px 12px 5px; }
}


/* ── Default object positions: x%, y%, width% of mat, rotation. Kept in CSS so the desk
   is laid out before any script runs. Dragging overrides these inline. ── */
.item[data-id="clock"] { --x: 9.5; --y: 30; --w: 12; --r: -3deg; }
.item[data-id="about"] { --x: 25.5; --y: 52; --w: 13.5; --r: -5deg; }
.item[data-id="books"] { --x: 42.5; --y: 60; --w: 12.5; --r: 3deg; }
.item[data-id="blog"] { --x: 58.5; --y: 52; --w: 12.5; --r: -4deg; }
.item[data-id="poems"] { --x: 75; --y: 75; --w: 18; --r: 2deg; }
.item[data-id="favourites"] { --x: 11; --y: 73; --w: 13.5; --r: -2deg; }
.item[data-id="hello"] { --x: 56; --y: 87; --w: 12.5; --r: -6deg; }
.item[data-id="tea"] { --x: 28.5; --y: 84; --w: 9; --r: 0deg; }
.item[data-id="radio"] { --x: 79; --y: 33; --w: 14.5; --r: 2deg; }
.item[data-id="pet"] { --x: 93.3; --y: 19; --w: 8.8; --r: 6deg; }
@media (max-width: 760px), (max-aspect-ratio: 4/5) {
  .item[data-id="clock"] { --x: 27; --y: 23.5; --w: 40; --r: -3deg; }
  .item[data-id="pet"] { --x: 77; --y: 25.5; --w: 31; --r: 5deg; }
  .item[data-id="about"] { --x: 29; --y: 37.5; --w: 44; --r: -4deg; }
  .item[data-id="books"] { --x: 73; --y: 40.5; --w: 38; --r: 3deg; }
  .item[data-id="blog"] { --x: 27; --y: 56; --w: 38; --r: -3deg; }
  .item[data-id="radio"] { --x: 72; --y: 60; --w: 44; --r: 2deg; }
  .item[data-id="poems"] { --x: 33; --y: 76; --w: 54; --r: 2deg; }
  .item[data-id="favourites"] { --x: 79; --y: 78; --w: 36; --r: -3deg; }
  .item[data-id="tea"] { --x: 20; --y: 91; --w: 26; --r: 0deg; }
  .item[data-id="hello"] { --x: 57; --y: 91.5; --w: 36; --r: -5deg; }
}

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