/* room.css — the desk room. Dark glow/glass. All colors from :root tokens. */

:root {
  --bg: #07080c;
  --ink: #e8ecf4;
  --ink-dim: rgba(232, 236, 244, 0.62);
  --ink-faint: rgba(232, 236, 244, 0.38);
  --line: rgba(255, 255, 255, 0.1);
  --panel: rgba(16, 19, 28, 0.88);
  --panel-2: rgba(22, 26, 38, 0.82);
  --accent: #7c5cff;
  --accent-2: #10b981;
  --paper: #f2eee3;
  --paper-2: #e7e1d1;
  --paper-ink: #1c1a14;
  --paper-ink-2: #4c473a;
  --paper-line: rgba(28, 26, 20, 0.18);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --focus: 0 0 0 2px rgba(124, 92, 255, 0.85);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
  touch-action: none;
}
#scene.grabbing { cursor: grabbing; }

/* ---- boot veil ---- */
#veil {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 90% at 50% 20%, #0d1017 0%, #05060a 70%);
  transition: opacity 1.1s var(--ease);
}
#veil.gone { opacity: 0; pointer-events: none; }
.veil-inner { text-align: center; max-width: min(520px, 86vw); }
.veil-kicker {
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 18px;
}
.veil-title {
  font-size: clamp(26px, 5.5vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.08;
  margin: 0 0 14px;
}
.veil-title em {
  font-style: normal;
  background: linear-gradient(92deg, #b3a1ff, #7c5cff 55%, #10b981);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.veil-sub { color: var(--ink-dim); font-size: 14px; line-height: 1.65; margin: 0 0 26px; }
.veil-hint { color: var(--ink-faint); font-size: 11.5px; letter-spacing: 0.08em; margin-top: 22px; }
.veil-hint kbd {
  font: 600 11px 'Inter', sans-serif;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 2px 7px;
  color: var(--ink-dim);
  background: rgba(255, 255, 255, 0.04);
  margin: 0 2px;
}
#enterBtn {
  appearance: none;
  border: 1px solid rgba(124, 92, 255, 0.55);
  color: #dcd2ff;
  background: rgba(124, 92, 255, 0.14);
  font: 600 14px 'Inter', sans-serif;
  letter-spacing: 0.02em;
  padding: 13px 30px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.25s var(--ease), background 0.25s, box-shadow 0.25s;
  box-shadow: 0 0 24px rgba(124, 92, 255, 0.25), inset 0 0 12px rgba(124, 92, 255, 0.12);
}
#enterBtn:hover { background: rgba(124, 92, 255, 0.26); transform: translateY(-1px); box-shadow: 0 6px 32px rgba(124, 92, 255, 0.4); }
#enterBtn:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---- HUD ---- */
#hud {
  position: fixed;
  z-index: 20;
  left: 18px;
  bottom: 16px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: flex;
  gap: 14px;
  align-items: center;
  user-select: none;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s var(--ease) 0.4s;
}
#hud.on { opacity: 1; }
#hud .sep { width: 1px; height: 12px; background: var(--line); }
#hud b { color: var(--ink-dim); font-weight: 600; }
#resetHint { pointer-events: auto; cursor: pointer; color: var(--ink-faint); }
#resetHint:hover { color: var(--ink-dim); }
#resetHint:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }

/* ---- tooltip over 3D objects ---- */
#tip {
  position: fixed;
  z-index: 25;
  transform: translate(-50%, calc(-100% - 14px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 13px;
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(124, 92, 255, 0.08);
}
#tip.on { opacity: 1; }
#tip small { display: block; color: var(--ink-faint); font-size: 10.5px; letter-spacing: 0.06em; margin-top: 2px; }
#tip .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 7px; background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }

/* ---- 2D overlay shells (book / OS / phone) ---- */
.shell {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 3vw, 40px);
  background: radial-gradient(120% 100% at 50% 45%, rgba(4, 5, 9, 0.42) 30%, rgba(4, 5, 9, 0.78) 100%);
  -webkit-backdrop-filter: blur(7px) saturate(1.05);
  backdrop-filter: blur(7px) saturate(1.05);
}

.shell.on { display: flex; animation: shellIn 0.5s var(--ease); }
@keyframes shellIn { from { opacity: 0; } }
/* mid-flight merge: the content grows out of the object being entered.
 * The geometric part (left/top/width/height) is driven inline by app.js's pinStep();
 * this keyframe only fades the frame in so the growth reads as the object's own content emerging. */
.shell.on > .frame { animation: frameMerge 0.45s var(--ease); }
@keyframes frameMerge { from { opacity: 0; } to { opacity: 1; } }
/* exit: shrink away (the camera then pulls back out).
 * The geometric part is inline (leave()); this keyframe only fades it. */
.shell.leave > .frame { animation: frameLeave 0.34s ease-in forwards; pointer-events: none; }
@keyframes frameLeave { to { opacity: 0; } }
.shell > .frame {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 1180px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.03), 0 0 60px rgba(124, 92, 255, 0.07);
}

.shell-close {
  position: absolute;
  z-index: 5;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(10, 12, 18, 0.8);
  color: var(--ink-dim);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
  display: grid;
  place-items: center;
}
.shell-close:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.3); transform: rotate(90deg); }
.shell-close:focus-visible { outline: none; box-shadow: var(--focus); }

/* ============ the exact handoff: the camera lands ON the object ============
 * app.js adds .match when room.js solved a pose that makes the object's own flat surface fill
 * the frame exactly, then pins the frame to the surface's projected rect. The overlay is no
 * longer a page floating over the room: it IS the screen / the open diary / the phone display,
 * so it drops its blur backdrop, border and rounding and lets the room stay visible around it. */
.shell.match {
  padding: 0;
  background: radial-gradient(120% 100% at 50% 45%, rgba(4, 5, 9, 0.08) 30%, rgba(4, 5, 9, 0.46) 100%);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.shell.match > .frame {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}
/* book: the frame is the spread plus a strip under it for the page nav */
.shell.match .book-stage { padding: 0 0 58px; background: none; }
.shell.match .book { width: 100%; height: 100%; }
.shell.match .page { border-radius: 2px; }
.shell.match #bookFrame .shell-close { top: auto; bottom: 9px; right: 12px; }
/* phone: keep the bezel + glass rounding, they sit exactly on the object's body */
.shell.match #phoneFrame { background: #060709; }
/* note: the frame is the sheet plus a strip under it for the back control — same shape as the book's
 * spread + nav strip, so the same 54 px of chrome room.js reserves is exactly what is under the paper */
.shell.match .note-stage { padding: 0 0 54px; background: none; }
.shell.match .note-paper { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 2px; box-shadow: none; }
.shell.match #noteFrame .shell-close { top: auto; bottom: 8px; right: 12px; }

/* the invisible dry run used to paint the object's surface from the overlay's own DOM:
 * laid out at its final geometry, but not painted and not interactive */
.shell.prepare {
  display: flex;
  opacity: 0;
  pointer-events: none;
}
/* …and while it is a dry run, nothing may be mid-animation: an element sitting at the `from` state of
 * its entrance (opacity 0) is SKIPPED by the painter, which is how a whole grid of icons once came out
 * of the paint as an empty wallpaper. */
.shell.prepare .os-app,
.shell.prepare .os-widget,
.shell.prepare .os-bar,
.shell.prepare .os-dock,
.shell.prepare .os-wall svg {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}
/* the boot sheet fades out over 0.7s, so a paint taken two frames after prepare caught it at ~90%
 * opacity and stamped the boot text across the bottom of the desk screen */
.shell.prepare .os-boot {
  transition: none !important;
  opacity: 0 !important;
}
.shell.prepare,
.shell.prepare > .frame { animation: none !important; }

/* ================= BOOK ================= */
#bookFrame { background: #14120d; max-width: 1240px; }
.book-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(46px, 6vh, 64px) clamp(14px, 4vw, 54px);
  background:
    radial-gradient(90% 70% at 50% 0%, rgba(124, 92, 255, 0.09), transparent 60%),
    radial-gradient(120% 100% at 50% 110%, rgba(16, 185, 129, 0.05), transparent 55%);
}
.book {
  position: relative;
  width: min(920px, 100%);
  height: min(640px, 100%);
  perspective: 2600px;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.page {
  position: relative;
  width: 50%;
  background: var(--paper);
  border-radius: 3px 12px 12px 3px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.page.left { border-radius: 12px 3px 3px 12px; transform-origin: right center; }
.page.right { transform-origin: left center; }
.page.left::after { /* inner-edge shading toward the spine */
  content: '';
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 30px;
  background: linear-gradient(270deg, rgba(0,0,0,0.13), transparent);
  pointer-events: none;
}
.page.right::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 30px;
  background: linear-gradient(90deg, rgba(0,0,0,0.13), transparent);
  pointer-events: none;
}

/* sheets that flip over the right page */
.sheet {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 50%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.85s var(--ease);
  z-index: 6;
}
.sheet .face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 0 12px 12px 0;
  overflow: hidden;
}
.sheet .face.front { background: var(--paper); }
.sheet .face.back {
  transform: rotateY(180deg);
  background: var(--paper-2);
  border-radius: 12px 0 0 12px;
  box-shadow: inset 14px 0 26px -18px rgba(0, 0, 0, 0.5);
}
.sheet.flipped { transform: rotateY(-180deg); z-index: 4; }
.book::before { /* spine shadow */
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 44px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(0,0,0,0.14) 45%, rgba(0,0,0,0.24) 50%, rgba(0,0,0,0.14) 55%, transparent);
  z-index: 8;
  pointer-events: none;
}
.page-content { position: absolute; inset: 0; padding: clamp(18px, 4%, 40px); }

/* ---------- the first spread: an endpaper and a title page ----------
 * These two pages are PAPER with ink on them, like every other page in the diary. They used to be a
 * website hero panel dropped into a book: a violet radial gradient, a 44px display headline with a
 * gradient-clipped word, and a 2x2 grid of giant numerals. A book opens on a title page. */
.cover, .inside-cover { color: var(--paper-ink); background: none; box-shadow: none; border-radius: 0; }
.cover { display: flex; flex-direction: column; padding: clamp(18px, 4%, 40px) clamp(18px, 4%, 40px) 34px; }
.cover h1 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(19px, 2.5vw, 30px);
  line-height: 1.16;
  letter-spacing: -0.005em;
  font-weight: 700;
  margin: 14px 0 8px;
}
.cover h1 em { font-style: italic; color: var(--accent); background: none; -webkit-text-fill-color: currentColor; }
.cover .sub {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(11px, 1.5vh, 13.5px);
  line-height: 1.7;
  color: var(--paper-ink-2);
  max-width: 42ch;
}
.hair-rule { height: 1px; background: var(--paper-line); margin: 12px 0; }
.toc-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--paper-ink-2);
}
.toc { display: flex; flex-direction: column; gap: 4px; margin: 9px 0 0; }
.toc-row { display: flex; align-items: baseline; gap: 10px; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(10.5px, 1.5vh, 13px); }
.toc-num { font-size: 9.5px; letter-spacing: 0.14em; color: var(--paper-ink-2); }
.toc-title { flex: 1; border-bottom: 1px dotted rgba(60, 48, 30, 0.28); padding-bottom: 2px; }
.cover .stats {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  padding-top: 14px;
  border-top: 1px solid var(--paper-line);
}
.cover .stat b { display: block; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(15px, 2.1vh, 20px); font-weight: 700; letter-spacing: 0; }
.cover .stat span { font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--paper-ink-2); }
.cover .open-hint {
  position: absolute; right: 16px; bottom: 14px;
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--paper-ink-2);
  animation: nudge 2.4s ease-in-out infinite;
}
@keyframes nudge { 50% { transform: translateX(4px); opacity: 0.55; } }

/* the inside cover: a bookplate, ruled, and a colophon under it */
.inside-cover { display: flex; flex-direction: column; padding: clamp(18px, 4%, 40px); }
.plate { border: 1px solid rgba(60, 48, 30, 0.3); padding: 6px; margin: 14px 0 18px; }
.plate-inner { border: 1px solid rgba(60, 48, 30, 0.16); padding: clamp(12px, 3vh, 22px) 12px; text-align: center; }
.plate-kicker { margin: 0 0 9px; font-size: 9px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--paper-ink-2); }
.plate h2 { margin: 0 0 5px; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(15px, 2.1vh, 21px); font-weight: 700; }
.plate-sub, .plate-dates { margin: 2px 0; font-family: Georgia, 'Times New Roman', serif; font-size: 11px; color: var(--paper-ink-2); }
.plate-sign { margin-top: clamp(10px, 2.4vh, 18px); font-family: 'Dancing Script', cursive; font-size: clamp(17px, 2.7vh, 26px); color: #2f3b52; }
.colophon { display: flex; flex-direction: column; gap: 7px; margin-top: auto; }
.colophon-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding-bottom: 4px; border-bottom: 1px solid rgba(60, 48, 30, 0.13);
  font-size: clamp(10.5px, 1.45vh, 12.5px);
}
.colophon-row span { color: var(--paper-ink-2); }
.colophon-row b { font-weight: 600; }
.margin-note { margin: 12px 0 0; font-family: 'Caveat', cursive; font-size: clamp(13px, 1.9vh, 17px); color: var(--paper-ink-2); }

/* diary page */
.diary-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--paper-ink-2);
  border-bottom: 1px solid var(--paper-line);
  padding-bottom: 10px;
  margin-bottom: 12px;
}
.sketch-holder svg { width: 100%; height: 100%; max-height: 100%; }
.sketch-holder svg path, .sketch-holder svg circle, .sketch-holder svg line, .sketch-holder svg rect, .sketch-holder svg polyline, .sketch-holder svg ellipse {
  stroke: var(--paper-ink);
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sketch-holder svg .accent { stroke: #b23a1a; }
.sketch-holder svg .accent-2 { stroke: #0f7a53; }
/* fern drawing page */
.fern-svg path { stroke: var(--paper-ink); fill: none; stroke-linecap: round; }
.fern-svg .accent-2 { stroke: #0f7a53; fill: #0f7a53; }

#diaryText {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(13.5px, 2.1vh, 17px);
  line-height: 1.75;
  color: var(--paper-ink);
  margin: 0;
}
#diaryText .tw {
  opacity: 0;
}
#diaryText .tw.on { opacity: 1; }
#diaryText .cursor {
  display: inline-block;
  width: 8px;
  height: 1em;
  background: var(--paper-ink);
  vertical-align: -0.15em;
  animation: blink 0.9s steps(1) infinite;
  margin-left: 1px;
}
#diaryText .cursor.off { display: none; }
@keyframes blink { 50% { opacity: 0; } }

/* fern page (back page) */
#fernPage .page-content { padding: 16px 18px; }
#fernSvg { width: 100%; height: 100%; display: block; }
.fern-caption {
  position: absolute;
  left: 18px;
  bottom: 14px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 11px;
  color: var(--paper-ink-2);
  border-top: 1px solid var(--paper-line);
  padding-top: 8px;
}
.fern-caption b { color: var(--paper-ink); font-size: 12.5px; }

/* book nav */
.book-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  z-index: 6;
  /* the strip spans the frame and sat ON TOP of the ✕ in match mode: the close button was there but
   * nothing could reach it (Playwright: "<div class="book-nav"> intercepts pointer events"). The strip
   * itself is now transparent to the pointer; only its own controls take clicks. */
  pointer-events: none;
  padding: 0 64px;
}
.book-nav > * { pointer-events: auto; }
.bnav-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(12, 14, 20, 0.72);
  color: #cfd4e2;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s, transform 0.2s;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.bnav-btn:hover:not(:disabled) { background: rgba(124, 92, 255, 0.25); transform: scale(1.06); }
.bnav-btn:disabled { opacity: 0.28; cursor: default; }
.bnav-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.bnav-label { color: rgba(232, 236, 244, 0.5); font-size: 11.5px; letter-spacing: 0.1em; min-width: 110px; text-align: center; }

/* ================= LAPTOP OS ================= */
#osFrame { background: #0b0d13; }
.os-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #0a0c11;
  overflow: hidden;
  font-feature-settings: "tnum" 1;
}

/* ---------- the wallpaper: gradients and glows live in one inline SVG, because the painter that
   copies this screen onto the laptop's 3D surface understands linear gradients and <svg>, but not
   radial-gradient or filter — a CSS radial glow simply disappears on the object. ---------- */
.os-wall { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.os-wall svg { position: absolute; inset: -6%; width: 112%; height: 112%; animation: osDrift 48s ease-in-out infinite alternate; }
@keyframes osDrift {
  from { transform: translate3d(-1.4%, -1%, 0) scale(1.02); }
  to   { transform: translate3d(1.6%, 1.2%, 0) scale(1.07); }
}

/* ---------- the menu bar ---------- */
.os-bar {
  position: relative;
  z-index: 3;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 56px 8px 14px;   /* right padding clears the floating close button */
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: linear-gradient(180deg, rgba(16, 18, 28, 0.92), rgba(12, 14, 22, 0.72));
  font-size: 11px;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
}
.os-mark { font-weight: 800; letter-spacing: 0.16em; color: var(--ink); text-transform: uppercase; font-size: 10.5px; }
.os-mark em { font-style: normal; color: var(--accent); }
.os-sep { width: 1px; height: 13px; background: rgba(255, 255, 255, 0.13); }
.os-now { color: var(--ink); font-weight: 600; letter-spacing: 0.02em; }
.os-bar .grow { flex: 1; }
.os-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.16), rgba(16, 185, 129, 0.05));
  color: #9ff0cd;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.os-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-2); }
.os-glyph { width: 34px; height: 12px; }
.os-clock { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); letter-spacing: 0.04em; min-width: 42px; text-align: right; }

/* ---------- the desktop: icon grid + widget ---------- */
.os-body { flex: 1; position: relative; z-index: 1; overflow: hidden; }
.os-desktop {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  align-items: flex-start;
}
.os-icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
  align-content: start;
  max-width: 424px;
  flex: 1;
}
.os-app {
  appearance: none;
  padding: 9px 6px 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  transition: background 0.18s, border-color 0.18s, transform 0.18s var(--ease);
  animation: iconIn 0.42s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 34ms);
}
@keyframes iconIn { from { opacity: 0; transform: translateY(8px) scale(0.96); } }
.os-app:hover, .os-app:focus-visible { background: rgba(124, 92, 255, 0.14); border-color: rgba(124, 92, 255, 0.34); transform: translateY(-2px); }
.os-app:active { transform: translateY(0) scale(0.985); }
.os-app:focus-visible { outline: none; }
.os-app .ic {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  position: relative;
}
.os-app .ic .run { position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px; border-radius: 50%; background: var(--accent-2); border: 2px solid #0a0c11; }
.os-app .nm { font-size: 10.5px; font-weight: 600; line-height: 1.25; text-align: center; color: rgba(238, 242, 250, 0.95); }
.os-app .dg { font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(238, 242, 250, 0.78); }
.os-app .dg.live { color: #9ff0cd; }
.os-app.live .ic { border-color: rgba(16, 185, 129, 0.5); }
.os-app.warm { background: rgba(124, 92, 255, 0.16); border-color: rgba(124, 92, 255, 0.45); }

.os-widget {
  flex: none;
  width: 208px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(28, 30, 46, 0.85), rgba(14, 16, 26, 0.7));
  display: flex;
  flex-direction: column;
  gap: 5px;
  animation: iconIn 0.5s var(--ease) both;
  animation-delay: 0.1s;
}
.os-widget b { font-size: 13px; color: var(--ink); letter-spacing: 0.01em; }
.os-widget .wsub { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }
.os-widget .wstat { font-size: 11px; color: var(--ink-dim); margin-top: 6px; }
.os-widget .wrow { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #9ff0cd; margin-top: 2px; }
.os-widget .wrow i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-2); }
.os-widget .wcv {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(124, 92, 255, 0.5);
  background: linear-gradient(180deg, rgba(124, 92, 255, 0.28), rgba(124, 92, 255, 0.12));
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}
.os-widget .wcv:hover { border-color: rgba(124, 92, 255, 0.85); }

/* ---------- a window ---------- */
.os-win {
  position: absolute;
  inset: 14px 14px 74px;
  z-index: 4;
  display: none;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  background: #10131b;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.6);
}
.os-win.on { display: flex; animation: winIn 0.3s var(--ease); }
/* the CV is a panel, not a browser: it hugs its content in the top-left of the desktop instead of
 * stretching to the frame and leaving a dead half underneath */
.os-win.native { inset: 14px auto auto 14px; width: min(600px, calc(100% - 28px)); max-height: calc(100% - 88px); }
.os-win.zoom { inset: 8px 8px 8px; }
.os-win.closing { animation: winOut 0.22s ease-in forwards; }
@keyframes winIn { from { transform: translateY(16px) scale(0.985); opacity: 0; } }
@keyframes winOut { to { transform: translateY(10px) scale(0.99); opacity: 0; } }
.os-win-bar { touch-action: none; cursor: grab;
  flex: none;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 11px;
  color: var(--ink-dim);
}
.os-dots { display: inline-flex; gap: 5px; }
.os-dots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); }
.os-dots i:first-child { background: #ff5f57; }
.os-dots i:nth-child(2) { background: #febc2e; }
.os-dots i:last-child { background: #28c840; }
.os-win-bar .ttl { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.os-win-bar .start { font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.os-win-bar .grow { flex: 1; }
.os-win-bar button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-dim);
  border-radius: 7px;
  font-size: 10.5px;
  padding: 4px 9px;
  cursor: pointer;
  white-space: nowrap;
}
.os-win-bar button:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.34); }
.os-win-bar button:focus-visible { outline: none; box-shadow: var(--focus); }
.os-win-body { flex: 1; position: relative; background: #fff; }
.os-win-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.os-native { position: absolute; inset: 0; overflow: auto; background: linear-gradient(160deg, #0f1220, #0b0d15); padding: 18px 20px; }
.os-native[hidden] { display: none; }

/* the CV app's window: a card you can download from */
.cv-head { display: flex; align-items: center; gap: 12px; }
.cv-mark {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  font-weight: 800; font-size: 15px; color: #efeaff;
  border: 1px solid rgba(124, 92, 255, 0.45);
  background: linear-gradient(135deg, #2b2350, #4b3a8f);
}
.cv-head h3 { margin: 0; font-size: 15px; color: var(--ink); }
.cv-head p { margin: 2px 0 0; font-size: 11px; color: var(--ink-dim); }
.cv-line { margin: 14px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--ink-dim); }
.cv-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.cv-chips span {
  font-size: 10px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  color: var(--ink-dim);
}
.cv-mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.cv-mini > div {
  padding: 10px 11px; border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015));
  display: flex; flex-direction: column; gap: 3px;
}
.cv-mini b { font-size: 15px; color: var(--ink); letter-spacing: 0.01em; }
.cv-mini span { font-size: 10px; color: var(--ink-faint); line-height: 1.35; }
.cv-list { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; }
.cv-list > div { display: flex; gap: 10px; align-items: baseline; font-size: 11px; }
.cv-list span { flex: none; width: 78px; font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.cv-list b { color: var(--ink-dim); font-weight: 500; line-height: 1.45; }
.cv-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.cv-actions a {
  font-size: 11px; padding: 8px 12px; border-radius: 9px; text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.14); color: var(--ink-dim);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
}
.cv-actions a:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.34); }
.cv-actions a.dl {
  border-color: rgba(124, 92, 255, 0.55); color: var(--ink); font-weight: 600;
  background: linear-gradient(180deg, rgba(124, 92, 255, 0.32), rgba(124, 92, 255, 0.14));
}

.os-waking {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  gap: 12px;
  background: #0d1017;
  color: var(--ink-faint);
  font-size: 12px;
  letter-spacing: 0.1em;
  transition: opacity 0.4s;
}
.os-waking.gone { opacity: 0; pointer-events: none; }
.os-waking .spin { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.12); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- the dock ---------- */
.os-dock {
  position: relative;
  z-index: 5;
  flex: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px 9px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(12, 14, 22, 0.72), rgba(9, 10, 16, 0.95));
}
.os-dock button {
  appearance: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--ink);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  position: relative;
  transition: transform 0.16s var(--ease), border-color 0.16s;
}
.os-dock button:hover { transform: translateY(-7px) scale(1.22); border-color: rgba(255, 255, 255, 0.4); z-index: 2; }
.os-dock button.on::after { content: ""; position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--accent-2); }
.os-dock .dsep { width: 1px; height: 24px; margin: 0 4px; background: rgba(255, 255, 255, 0.14); align-self: center; }

/* ---------- a toast when an app opens ---------- */
.os-toast {
  position: absolute;
  z-index: 8;
  right: 16px;
  bottom: 62px;
  max-width: 240px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(22, 25, 38, 0.97), rgba(14, 16, 26, 0.97));
  color: var(--ink-dim);
  font-size: 11px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.28s, transform 0.28s var(--ease);
  pointer-events: none;
}
.os-toast.on { opacity: 1; transform: translateY(0); }
.os-toast b { color: var(--ink); }

/* ================= PHONE ================= */
#phoneFrame {
  max-width: 380px;
  max-height: min(760px, 92vh);
  background: #060709;
  border-radius: 34px;
  padding: 10px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 70px rgba(124, 92, 255, 0.1);
}
.phone-screen {
  position: relative;
  height: 100%;
  border-radius: 26px;
  overflow: hidden;
  /* solid + an inline-SVG glow instead of a radial-gradient: the painter that copies this screen onto
   * the phone's 3D surface understands linear gradients and <svg>, not radial ones — which is why the
   * phone used to be flat black on the desk and glowing inside. */
  background: #08090d;
  display: flex;
  flex-direction: column;
}
.phone-glow { position: absolute; inset: 0; pointer-events: none; }
.phone-glow svg { width: 100%; height: 100%; display: block; }
.phone-notch {
  flex: none;
  height: 34px;
  display: grid;
  place-items: center;
}
.phone-notch i { width: 86px; height: 22px; border-radius: 12px; background: #04050a; border: 1px solid rgba(255,255,255,0.05); }
.phone-clock { text-align: center; font-size: 40px; font-weight: 200; letter-spacing: 0.01em; margin-top: 8px; }
.phone-date { text-align: center; font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-faint); margin: 6px 0 4px; }
.phone-owner {
  text-align: center;
  font-size: 12px;
  color: var(--ink-dim);
  margin: 10px auto 16px;
  max-width: 260px;
  line-height: 1.5;
}
.phone-owner b { color: var(--ink); font-weight: 600; }
.phone-dock-label {
  text-align: center;
  font-size: 9.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: auto 0 8px;
}
.phone-dock {
  flex: none;
  margin: 0 12px calc(12px + env(safe-area-inset-bottom, 0px));
  padding: 14px 10px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.papp {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  border-radius: 12px;
  font-family: inherit;
}
.papp:hover, .papp:focus-visible { background: rgba(255, 255, 255, 0.07); }
.papp:focus-visible { outline: none; box-shadow: var(--focus); }
.papp .ic {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition: transform 0.16s var(--ease);
}
.papp:active .ic { transform: scale(0.92); }
.papp .nm { font-size: 9.5px; color: rgba(232, 236, 244, 0.75); letter-spacing: 0.02em; }
.phone-homebar { flex: none; height: 18px; display: grid; place-items: center; }
.phone-homebar i { width: 100px; height: 4px; border-radius: 3px; background: rgba(255, 255, 255, 0.25); }

/* ================= THE NOTE ================= */
#noteFrame { background: #14120d; max-width: 700px; }
.note-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(40px, 6vh, 66px) clamp(16px, 5vw, 56px);
  background:
    radial-gradient(90% 70% at 50% 0%, rgba(124, 92, 255, 0.08), transparent 60%),
    radial-gradient(120% 100% at 50% 110%, rgba(255, 195, 122, 0.06), transparent 55%);
}
.note-paper {
  position: relative;
  width: min(560px, 100%);
  /* the sheet's own shape (0.17 m × 0.22 m): the painted surface is that same box, so a different
   * ratio here would stretch the picture on the paper */
  aspect-ratio: 0.7727;
  background: var(--paper);
  border-radius: 2px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  padding: clamp(22px, 5.6%, 44px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--paper-ink);
}
.note-paper::after { /* the same warm falloff the drawn sheet carries, so both states match */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.35), rgba(186, 176, 152, 0.2));
  pointer-events: none;
}
.note-kicker {
  position: relative;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(28, 26, 20, 0.42);
}
.note-text {
  position: relative;
  font-family: 'Caveat', 'Segoe Script', cursive;
  font-size: clamp(26px, 3.4vw, 44px);
  line-height: 1.28;
  color: var(--paper-ink);
  margin: clamp(14px, 6%, 40px) 0 0;
  transform: rotate(-0.9deg); /* nobody writes level on a loose sheet */
}
.note-sign {
  position: relative;
  font-family: 'Dancing Script', 'Caveat', cursive;
  font-size: clamp(24px, 2.9vw, 38px);
  color: rgba(28, 26, 20, 0.9);
  margin-top: auto;
  text-align: right;
  transform: rotate(-1.2deg);
}
.note-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(9px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  z-index: 6;
  pointer-events: none; /* never swallow a click meant for the ✕ beside it */
}
.note-nav > * { pointer-events: auto; }
.nnav-btn {
  appearance: none;
  height: 36px;
  padding: 0 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(12, 14, 20, 0.72);
  color: #cfd4e2;
  font-family: inherit;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.nnav-btn:hover { background: rgba(124, 92, 255, 0.25); color: var(--ink); }
.nnav-btn:focus-visible { outline: none; box-shadow: var(--focus); }

/* ================= reduced motion ================= */
@media (prefers-reduced-motion: reduce) {
  .sheet { transition-duration: 0.05s; }
  .shell.on, .shell.on > .frame, .shell.leave > .frame, .os-win.on { animation-duration: 0.01s; }
  #veil { transition-duration: 0.1s; }
  .cover .open-hint { animation: none; }
  #diaryText .tw { transition: opacity 0.01s; }
}


/* ================= small phones ================= */
@media (max-width: 560px) {
  .book { height: min(560px, 100%); }
  .cover .stats { grid-template-columns: repeat(2, 1fr); gap: 8px 10px; }
  .os-app { width: 100px; }
  #hud { left: 12px; bottom: 12px; gap: 8px; font-size: 10px; }
  .bnav-label { min-width: 84px; font-size: 10.5px; }
  /* the desk book pages carry full story text; on narrow phones the type scales down
     and the sketch plate hides so the diary text always fits its half-page */
  .page-content { padding: 12px 12px; }
  .sketch-holder { display: none; }
  .diary-type { font-size: 11.5px !important; line-height: 1.6 !important; overflow: hidden; }
  .diary-head { font-size: 9px; padding-bottom: 6px; margin-bottom: 8px; }
  .cover h1 { font-size: 19px; }
  .cover .sub { font-size: 11px; }
  .cover .stat b { font-size: 16px; }
  .phone-dock { grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 10px 6px; }
  .papp .ic { width: 42px; height: 42px; }
  .phone-clock { font-size: 32px; }
}


/* ============ the guide: the room's four moves, told in pictures ============
 * Shown the moment the visitor steps in (app.js → showGuide). pointer-events are off on the card so
 * the guide never steals the very drag it is teaching: the first pointerdown anywhere dismisses it,
 * and the gesture that caused it still reaches the room. */
#guide {
  position: fixed;
  inset: auto 0 max(18px, env(safe-area-inset-bottom, 0px)) 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  padding: 0 14px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.34s ease, transform 0.34s ease;
}
#guide.on { opacity: 1; transform: none; }
.gd-card {
  width: min(680px, 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding: 13px 15px 14px;
  color: var(--ink);
  font-size: 13px;
}
.gd-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.gd-title { font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); }
.gd-ok {
  pointer-events: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.14);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  padding: 5px 13px;
  cursor: pointer;
}
.gd-ok:hover { background: rgba(124, 92, 255, 0.24); border-color: rgba(124, 92, 255, 0.5); }
.gd-ok:focus-visible { outline: none; box-shadow: var(--focus); }
.gd-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 18px; }
.gd-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.gd-art { width: 34px; height: 34px; flex: none; color: var(--accent); }
.gd-text { color: var(--ink-dim); line-height: 1.35; }
.gd-text b { color: var(--ink); font-weight: 600; }
@media (max-width: 620px) {
  .gd-rows { grid-template-columns: 1fr; }
  .gd-art { width: 30px; height: 30px; }
}

/* ============ the controls say what they are ============
 * "make the visitor SEE the diary's page-turn and the close inside every object": on any screen with
 * room for it the two round buttons become labelled pills. The circles stay on small screens. */
@media (min-width: 760px) {
  .shell-close {
    width: auto;
    border-radius: 999px;
    padding: 0 15px;
    gap: 8px;
    grid-auto-flow: column;
  }
  .shell-close::after { content: 'back to the room'; font-size: 12.5px; letter-spacing: 0.01em; }
  .shell-close:hover { transform: none; }
  .bnav-btn {
    width: auto;
    border-radius: 999px;
    padding: 0 16px;
    gap: 7px;
    grid-auto-flow: column;
  }
  .book-nav #bprev::after { content: 'previous'; font-size: 12.5px; }
  .book-nav #bnext::before { content: 'next'; font-size: 12.5px; }
}

/* first time a shell opens, its controls ask to be noticed once (app.js adds .pulse) */
@keyframes shellPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 92, 255, 0); }
  22% { box-shadow: 0 0 0 7px rgba(124, 92, 255, 0.22); }
  60% { box-shadow: 0 0 0 12px rgba(124, 92, 255, 0); }
}
.shell.pulse .shell-close, .shell.pulse .bnav-btn { animation: shellPulse 1.5s ease-out 2; }
