/* The notebook owns its paper, writing and material treatment in every entry view. */
.notebook { position:relative; z-index:2; width:min(450px,78vw); height:590px; font-family:var(--hand); transform:rotate(-3deg); transition:transform .28s cubic-bezier(.2,.65,.25,1); isolation:isolate; }
body:not(.room-view) .desk-pencil { display:none!important; }
.notebook:not(.is-open):hover { transform:translateY(-6px) rotate(-1deg); }
.notebook::after { content:''; position:absolute; inset:7px -6px -7px 6px; background:repeating-linear-gradient(to bottom,#d7d3c5 0 1px,#f9f5e8 1px 3px); border:1px solid #a7a496; border-radius:4px 15px 15px 4px; z-index:-1; box-shadow:10px 21px 27px #36332328,2px 4px 5px #36332336; }
.notebook::before { content:''; position:absolute; inset:3px -3px -5px 2px; border-radius:3px 12px 12px 3px; background:repeating-linear-gradient(#e6ddcc 0 1px,#fff9eb 1px 3px); box-shadow:2px 5px 6px #251b1940; pointer-events:none; }
.notebook:not(.is-open)::after { opacity:0; }
.room-view .notebook:not(.is-open)::before { display:none; }

/* Preserve the photographic cover and its original live handwriting. */
.cover { position:absolute; inset:0; transform-origin:left center; transform-style:preserve-3d; transition:transform .72s cubic-bezier(.22,.7,.2,1),visibility .72s; z-index:3; border-radius:4px 13px 13px 4px; }
.cover-front,.cover-back { position:absolute; inset:0; backface-visibility:hidden; border-radius:inherit; }
.cover-front { container-type:inline-size; background:transparent; border:0; box-shadow:none; overflow:visible; }
.cover-back { container-type:inline-size; overflow:hidden; transform:rotateY(180deg); background:#fff; border:1px solid #c4c2ba; box-shadow:inset -12px 0 24px #514b3d30,1px 3px 0 #bbb5a6; }
.notebook-photo { position:absolute; inset:0; width:100%; height:100%; object-fit:fill; pointer-events:none; }
.open-cover { position:absolute; inset:0; border:0; background:transparent; color:inherit; cursor:pointer; width:100%; padding:0; }
.name-label { position:absolute; top:24%; left:31%; right:15%; height:23%; padding:0; border:0; background:none; box-shadow:none; border-radius:0; transform:none; display:flex; flex-direction:column; justify-content:center; text-align:center; }
.label-title { display:block; font:900 4.9cqw/1.05 Arial,Helvetica,sans-serif; letter-spacing:.01em; border:0; padding:0; margin-bottom:1.4cqw; }
.label-name,.label-location { display:block; margin:0 8%; border-bottom:1px solid #8d8c86; text-transform:none; letter-spacing:0; white-space:nowrap; font:400 7.2cqw/1.12 var(--hand); }
.label-location { font-size:6.1cqw; margin-top:1.2cqw; }
.label-sub { display:block; font:400 2.1cqw/1.2 Georgia,serif; letter-spacing:0; text-transform:none; text-align:left; margin:1.6cqw 8% 0; }
.work-label { position:absolute; top:47%; left:38%; right:8%; display:flex; gap:0; align-items:center; justify-content:center; z-index:4; pointer-events:none; }
.work-label > span { flex:1; min-width:0; max-width:none; white-space:nowrap; background:#fff6cf; box-shadow:1px 2px 2px #0005; padding:1.8cqw 2cqw; font:4.3cqw/1.05 var(--hand); transform:rotate(-2deg); }
.clay-sticker { display:flex; background:#fffef6; padding:3px 12px; border-radius:12px; box-shadow:2px 4px 3px #0005; transform:rotate(7deg); pointer-events:auto; transition:transform .2s; }
.clay-sticker:hover { transform:rotate(3deg) translateY(-4px); }
.clay-sticker img { width:89px; height:48px; object-fit:contain; }
.work-label .clay-sticker { flex-shrink:0; padding:1cqw 2cqw; border-radius:2.6cqw; }
.work-label .clay-sticker img { width:21cqw; height:11.3cqw; }
.notebook:not(.is-open) .pages,.notebook:not(.is-open) .cover-back { visibility:hidden; }
.notebook:not(.is-open) .cover { transition:none; }
.notebook.is-open { transform:rotate(0); transition:transform .25s cubic-bezier(.16,1,.3,1); }
.notebook.is-open.is-pulling { transition:none; }
.is-open .cover { transform:rotateY(-100deg); pointer-events:none; }
.is-open .cover-front { pointer-events:none; }

/* One 48px ruler carries every wrapped line. Headings use whole rule multiples.
   Writing.js aligns actual font baselines after fonts, resizing and photo loads. */
.pages { --rule-step:48px; --margin-line:48px; container-type:inline-size; position:absolute; inset:0; overflow:auto; border-radius:3px 12px 12px 3px; background:linear-gradient(to right,transparent 0 calc(var(--margin-line) - 1px),#e6a49e calc(var(--margin-line) - 1px) var(--margin-line),transparent var(--margin-line)),repeating-linear-gradient(to bottom,transparent 0 calc(var(--rule-step) - 1px),#94b5ce70 calc(var(--rule-step) - 1px) var(--rule-step)),var(--paper); background-attachment:local; padding:64px 34px 30px 67px; scrollbar-width:thin; rotate:y var(--page-bend,0deg); transform-origin:left center; transition:rotate 160ms ease; box-shadow:inset 13px 0 19px #554d3420,inset -25px 0 35px rgb(51 40 20 / var(--page-shade,0)); }
.notebook .pages [data-ruled-writing] { translate:0 var(--baseline-shift,0px); }
.notebook #page-title { position:relative; font:400 64px/calc(var(--rule-step) * 2) var(--hand); margin:0 0 var(--rule-step); }
#page-title:focus { outline:none; }
.notebook #page-title[hidden] { display:none; }
.notebook #contents:focus { outline:none; }
.notebook .reading-essay #page-title { font-size:42px; line-height:var(--rule-step); }
.notebook .pages:has(#doodle-page:not([hidden])) #page-title { font-size:36px; line-height:var(--rule-step); }
.page-meta { position:relative; line-height:var(--rule-step); font-size:16px; letter-spacing:.13em; text-transform:uppercase; color:#73736a; margin:0 0 var(--rule-step); }
.entry { font:28px/var(--rule-step) var(--hand); }
.entry p { position:relative; margin:0 0 var(--rule-step); }
.entry a { text-decoration-thickness:1px; text-underline-offset:5px; }
.signature { position:relative; font-size:32px; line-height:var(--rule-step); display:block; }
.toc { margin:0; padding:0; list-style:none; font:28px/var(--rule-step) var(--hand); }
.toc li { margin:0 0 var(--rule-step); }
.toc-line { position:relative; display:block; width:100%; min-height:44px; padding:0 0 0 38px; color:#323630; text-decoration:none; font:40px/var(--rule-step) var(--hand); }
.toc-line:is(button) { border:0; background:transparent; text-align:left; cursor:pointer; }
.toc-line .essay-number { position:absolute; left:0; top:0; color:#878a7e; font-size:20px; line-height:var(--rule-step); }
.toc-line:hover { color:#884730; text-decoration:underline; text-decoration-thickness:1px; text-underline-offset:5px; }
.page-bottom { display:flex; align-items:center; justify-content:space-between; gap:20px; margin-top:var(--rule-step); font-size:16px; color:#66665d; }
.page-bottom #page-number { margin-left:auto; }
.close { min-height:44px; border:0; border-bottom:1px solid #aaa99f; padding:5px 0; cursor:pointer; background:transparent; font-size:18px; color:var(--ink); }

/* Essays and their taped photographs scroll with the same paper and ruler. */
.pages.reading-essay { padding-top:calc(var(--rule-step) * 3); }
.reading-essay .page-meta { margin-bottom:0; }
#essay-date { position:absolute; top:calc(var(--rule-step) * 1.5); right:30px; color:#74766b; font:18px/var(--rule-step) var(--hand); }
#essay-subtitle { font:28px/var(--rule-step) var(--hand); margin:0 0 var(--rule-step); }
.essay-body { font:28px/var(--rule-step) var(--hand); overflow-wrap:anywhere; }
.essay-body p,.essay-body h2,.essay-body h3,.essay-body h4,.essay-body h5,.essay-body h6,.essay-body ul,.essay-body ol,.essay-body blockquote { margin:0 0 var(--rule-step); font:inherit; line-height:var(--rule-step); }
.essay-body h2,.essay-body h3,.essay-body h4 { font-weight:700; }
.essay-body blockquote { padding-left:14px; border-left:2px solid #9b9a88; }
.essay-body ul,.essay-body ol { padding-left:24px; }
.essay-body li { margin:0; }
.essay-body hr { height:var(--rule-step); border:0; margin:0 0 var(--rule-step); text-align:center; }
.essay-body hr::after { content:'· · ·'; }
.essay-body a { text-decoration-thickness:1px; text-underline-offset:4px; }
.essay-body figure { position:relative; margin:var(--rule-step) 0; padding:8px; background:#fffefa; box-shadow:1px 3px 5px #453e3529; }
.essay-body figure::before,.essay-body figure::after { content:''; position:absolute; z-index:1; top:-9px; width:58px; height:23px; background:linear-gradient(90deg,#dbc39774,#e8d1a698,#d0bb9380); box-shadow:0 1px 1px #745d3920; }
.essay-body figure::before { left:8%; transform:rotate(-13deg); }
.essay-body figure::after { right:7%; transform:rotate(10deg); }
.essay-body img { display:block; width:100%; height:auto; }
.essay-body figcaption { color:#77766d; font:20px/var(--rule-step) var(--hand); text-align:center; padding-bottom:calc(var(--rule-step) / 2); }
.reading-essay .page-bottom { flex-wrap:wrap; }
#essay-contents,#essay-next { font:20px/var(--rule-step) var(--hand); }
.notebook-nav { position:absolute; top:14px; right:18px; z-index:5; display:flex; gap:7px; }
.notebook:not(.is-open) .notebook-nav { display:none; }
.notebook-nav button,.notebook-nav .home-tab { position:static; min-height:44px; margin:0; padding:4px 11px; border:1px solid #aaa99f; border-radius:999px; background:#fffdf4f5; color:#393a32; font:18px/24px var(--hand); text-decoration:none; box-shadow:0 2px 3px #33291420; cursor:pointer; }
.notebook-room-header[hidden],.notebook-folded-frame[hidden] { display:none; }

/* Printed semester rows stay compact, rather than stretching to fill the cover. */
.semester-learning { margin:0; padding:clamp(32px,5vh,78px) clamp(20px,3vw,36px); color:#454948; }
.semester-learning h2 { margin:0 0 30px; text-align:center; text-transform:uppercase; font:700 clamp(16px,4cqw,23px)/1.2 var(--ui); letter-spacing:.02em; }
.semester-learning h2 span { white-space:nowrap; }
.semester-learning table { border-collapse:collapse; width:100%; }
.semester-learning td { border:1px solid #747974; padding:18px 14px; font:clamp(20px,4.6cqw,28px)/1.4 var(--hand); text-align:left; }

/* Placement differs by scene. The writing rhythm does not. */
.stage .notebook { grid-column:span 2; width:77%; max-width:220px; height:auto; min-height:0; aspect-ratio:3/4; }
.stage .notebook:not(.is-open) { margin:0; transform:rotate(-3deg); }
.stage .notebook:not(.is-open):hover { transform:translateY(-6px) rotate(-1deg); }
.stage .notebook:not(.is-open) .open-cover { cursor:grab; }
.stage:has(.notebook.is-open) { display:flex; min-height:640px; }
.stage:has(.notebook.is-open) .object-rack { display:none; }
.stage .notebook.is-open { margin:0; transform:none; translate:none!important; touch-action:auto; user-select:auto; }
.notebook-view .stage:has(.notebook.is-open) { min-height:0; }
:is(.notebook-view,.monitor-view) .stage .notebook.is-open { --open-page-width:min(61vw,68svh,720px,calc((100vw - 32px)/2)); width:var(--open-page-width); max-width:none; height:auto; min-height:0; aspect-ratio:3/4; }
.notebook-view .stage .notebook.is-open { margin-left:var(--open-page-width); }
.monitor-view .stage .notebook.is-open { left:50vw; top:50svh; transform:translateY(-50%); }
.notebook-view .notebook.is-open .cover,.monitor-view .stage .notebook.is-open .cover { transform:rotateY(-180deg); visibility:visible; }
.notebook-view { background:#79a9cf url("/assets/bliss.jpg") center center / cover no-repeat fixed; background-image:image-set(url("/assets/performance/bliss-w960-8afd0f764001.webp") 1x,url("/assets/performance/bliss-w1920-faa3e73c0bb9.webp") 2x); }
.notebook-view .work-label,.notebook-view .stage > .object-rack { display:none; }
@media(min-width:961px) { .notebook-view { background-image:image-set(url("/assets/performance/bliss-w1440-d748f7939f97.webp") 1x,url("/assets/performance/bliss-w1920-faa3e73c0bb9.webp") 2x); } }
@media(min-width:1441px) { .notebook-view { background-image:url("/assets/performance/bliss-w1920-faa3e73c0bb9.webp"); } }

/* Room reading is one bound, folded-back notebook, never a half-empty spread.
   Nine-slice the blank photograph: preserve its curved binding/corners/page block
   while only the unprinted paper centre adapts to a broad or short viewport. */
.room-view .stage .notebook.is-open {
  --room-page-top:calc(156px + env(safe-area-inset-top));
  --room-page-height:min(760px,calc(100svh - var(--room-page-top) - 16px - env(safe-area-inset-bottom)));
  --folded-top:64px; --folded-right:44px; --folded-bottom:44px; --folded-gutter:76px;
  left:50vw; top:max(var(--room-page-top),calc((100svh - var(--room-page-height)) / 2));
  width:min(860px,calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  height:var(--room-page-height); aspect-ratio:auto; transform:translateX(-50%); transition:none;
}
.room-view .stage .notebook.is-open::before,.room-view .stage .notebook.is-open::after { display:none; }
.room-view .stage .notebook.is-open .cover { display:none; }
.notebook-folded-frame {
  position:absolute; inset:0; z-index:1; pointer-events:none; user-select:none;
  border:solid transparent; border-width:var(--folded-top) var(--folded-right) var(--folded-bottom) var(--folded-gutter);
  border-image-slice:9% 8% 6% 13% fill; border-image-repeat:stretch;
  background:var(--paper); background-clip:padding-box;
  /* Map the photograph's exterior silhouette through the same edge slices.
     Trim stray alpha-edge pixels, not the connected fold or right page stack. */
  clip-path:polygon(
    calc(var(--folded-gutter) * .61538) calc(var(--folded-top) * .5),
    calc(1.26582% + var(--folded-gutter) * .98734 - var(--folded-right) * .01266) calc(var(--folded-top) * .44444),
    calc(34.17722% + var(--folded-gutter) * .65823 - var(--folded-right) * .34177) calc(var(--folded-top) * .61111),
    calc(100% - var(--folded-right)) calc(var(--folded-top) * .72222),
    calc(100% - var(--folded-right) * .25) calc(1.17647% + var(--folded-top) * .98824 - var(--folded-bottom) * .01176),
    calc(100% - var(--folded-right) * .25) calc(100% - var(--folded-bottom) * .91667),
    calc(100% - var(--folded-right) * .5) calc(100% - var(--folded-bottom) * .71667),
    calc(var(--folded-gutter) * .15385) calc(100% - var(--folded-bottom) * .71667),
    calc(var(--folded-gutter) * .10769) calc(5.88235% + var(--folded-top) * .94118 - var(--folded-bottom) * .05882),
    calc(var(--folded-gutter) * .23077) var(--folded-top),
    calc(var(--folded-gutter) * .61538) calc(var(--folded-top) * .96667)
  );
}
.room-view .stage .notebook.is-open .pages {
  inset:48px 26px 30px var(--folded-gutter); z-index:2;
  padding:48px 34px 30px 36px; --margin-line:22px;
  background-color:transparent; border-radius:2px 9px 9px 2px; box-shadow:none;
}
.room-view .stage .notebook.is-open .pages.reading-essay { padding-top:48px; }
.room-view .stage .notebook.is-open .notebook-room-header {
  position:relative; display:grid; grid-template-columns:minmax(0,1fr) auto;
  gap:0 20px; align-items:start; margin:0 0 var(--rule-step);
}
.room-view .stage .notebook.is-open .notebook-room-header[hidden] { display:none; }
.room-view .notebook-room-header .notebook-nav { position:relative; top:auto; right:auto; justify-self:start; }
.room-view .notebook-room-header .notebook-nav button,.room-view .notebook-room-header .home-tab {
  position:relative; min-height:48px; padding:0 8px; border:0; border-radius:999px;
  font:18px/var(--rule-step) var(--hand); background:#fffdf4d9; box-shadow:0 0 0 1px #aaa99f80,0 2px 3px #33291420;
}
.room-view .notebook-room-header #essay-date {
  position:relative; top:auto; right:auto; display:block; min-width:0;
  margin:0; font:18px/var(--rule-step) var(--hand); text-align:right;
}
.room-view .notebook-room-header #essay-date[hidden] { display:none; }
.room-view .stage .notebook.is-open .page-corner { right:26px; bottom:30px; }

/* The marbled cover extends under the photographed paper, with a dark hinge
   and a layered page block instead of a floating paper card. */
.room-view .stage:has(.notebook.is-open)::after { background:#211a1038; backdrop-filter:blur(1px); }
.notebook-room-material { position:absolute; inset:0; z-index:0; pointer-events:none; user-select:none; }
.notebook-room-material[hidden] { display:none; }
.notebook-room-cover { position:absolute; inset:24px 5px 8px 8px; border-radius:8px 17px 19px 8px; background:#191918 url("/assets/notebook-cover.webp") center / 100% 100%; box-shadow:0 4px 0 #11110f,0 10px 4px #1b160f8c,0 25px 28px #17110c72; }
.notebook-room-block { position:absolute; left:34px; right:13px; bottom:12px; height:22px; border-radius:2px 4px 12px 8px; background:repeating-linear-gradient(to bottom,#e6dbc0 0 1px,#cfc0a3 1px 2px,#f9f1df 2px 4px); box-shadow:0 3px 2px #33271888; }
.notebook-room-spine { position:absolute; left:7px; top:30px; bottom:12px; width:26px; border-radius:10px 2px 2px 10px; background:linear-gradient(90deg,#141514 0,#30302b 25%,#161714 63%,#504b40 85%,#111 100%); box-shadow:3px 0 7px #17130d80; }
.notebook-volume-host { position:absolute; inset:0; pointer-events:none; overflow:visible; }
.notebook-volume-host canvas { display:block; width:100%; height:100%; pointer-events:none; }
.notebook-opening-cover { position:absolute; z-index:6; inset:28px 10px 12px 28px; pointer-events:none; transform-origin:left center; transform-style:preserve-3d; animation:notebook-cover-arrive .62s cubic-bezier(.2,.7,.24,1) both; filter:drop-shadow(6px 8px 8px #241b1280); }
.room-view .stage .notebook.is-open .notebook-opening-cover .cover-front { visibility:visible; backface-visibility:hidden; }
@keyframes notebook-cover-arrive { 0%,20% { transform:perspective(1600px) rotateY(0); opacity:1; } 85% { opacity:1; } 100% { transform:perspective(1600px) rotateY(-165deg); opacity:0; } }

/* Keep the material reveal connected to the short phone source movement. */
@media(max-width:650px), (max-height:500px) and (pointer:coarse) {
  .notebook-opening-cover { animation-duration:.22s; }
  .notebook.is-open .cover { transition-duration:.22s; }
}

/* This temporary face is a decorative snapshot of visible DOM, never its
   replacement. Navigation is not delayed by a leaf or optional renderer. */
.notebook-turn-shadow,.notebook-turn-sheet { position:absolute; pointer-events:none; user-select:none; }
.notebook-turn-shadow { z-index:3; opacity:0; background:linear-gradient(90deg,transparent 18%,#261b0f 90%); border-radius:3px 10px 10px 3px; }
.notebook-turn-sheet { z-index:4; transform-style:preserve-3d; transform-origin:left center; transform:perspective(1500px) rotateY(calc(-1 * var(--turn-angle,0deg))); filter:drop-shadow(8px 6px 8px #25190d55); }
.notebook-turn-sheet.is-reverse { transform-origin:right center; transform:perspective(1500px) rotateY(var(--turn-angle,0deg)); }
.room-view .stage .notebook.is-open .notebook-turn-sheet .pages { position:absolute; inset:0; width:100%; height:100%; overflow:hidden; backface-visibility:hidden; background-color:var(--paper); box-shadow:inset 14px 0 20px #554d3425; rotate:none; }
.notebook-turn-back { position:absolute; inset:0; border-radius:3px 10px 10px 3px; backface-visibility:hidden; transform:rotateY(180deg); background:linear-gradient(90deg,#bdb29e 0,#f8f1de 12%,#fffaf0 84%,#c5b9a0 100%); box-shadow:inset 0 -12px 25px #8c7b5b35; }
.notebook-turn-copy .turn-copy-page-title { position:relative; font:400 64px/calc(var(--rule-step) * 2) var(--hand); margin:0 0 var(--rule-step); }
.notebook-turn-copy.reading-essay .turn-copy-page-title { font-size:42px; line-height:var(--rule-step); }
.notebook-turn-copy .turn-copy-essay-date { position:absolute; top:calc(var(--rule-step) * 1.5); right:30px; color:#74766b; font:18px/var(--rule-step) var(--hand); }
.notebook-turn-copy .notebook-room-header .turn-copy-essay-date { position:relative; top:auto; right:auto; text-align:right; }
.notebook-turn-copy .turn-copy-essay-subtitle { font:28px/var(--rule-step) var(--hand); margin:0 0 var(--rule-step); }
.room-view .stage .notebook.is-open .page-corner { z-index:5; }
@media(min-width:1100px) {
  /* At this width the paper clears site chrome horizontally; centre it vertically. */
  .room-view .stage .notebook.is-open { --room-page-top:calc(24px + env(safe-area-inset-top)); }
}

/* Short desktop spreads keep useful page width and scroll instead of shrinking ink. */
@media(min-width:651px) and (max-height:500px) {
  /* A tall chrome reservation would hide even the title in landscape. The blank
     upper paper may sit behind chrome; live writing starts safely below it. */
  .room-view .stage .notebook.is-open {
    --room-page-top:calc(16px + env(safe-area-inset-top));
    --room-page-height:calc(100svh - var(--room-page-top) - 16px - env(safe-area-inset-bottom));
    top:var(--room-page-top);
  }
  .room-view .stage .notebook.is-open .pages:not(.reading-essay) { padding-top:calc(var(--rule-step) * 2); }
  :is(.notebook-view,.monitor-view) .stage .notebook.is-open { --open-page-width:min(430px,calc((100vw - 32px)/2)); height:calc(100svh - 32px); aspect-ratio:auto; }
  :is(.notebook-view,.monitor-view) .notebook .pages { padding-top:48px; }
  :is(.notebook-view,.monitor-view) .notebook #page-title { font-size:38px; line-height:var(--rule-step); }
  :is(.notebook-view,.monitor-view) .notebook .reading-essay #page-title { font-size:32px; }
  :is(.notebook-view,.monitor-view) .notebook .toc-line { font-size:28px; }
  :is(.notebook-view,.monitor-view) .notebook .pages.reading-essay { padding-top:calc(var(--rule-step) * 2); }
  :is(.notebook-view,.monitor-view) .notebook #essay-date { top:var(--rule-step); font-size:16px; }
  .semester-learning { padding:18px; }
  .semester-learning h2 { font-size:18px; margin-bottom:16px; }
  .semester-learning td { padding:10px; font-size:22px; }
}

/* A touch phone in landscape uses the broad folded page above, but its scroll
   window still has to clear site navigation rather than slide ink underneath. */
@media(min-width:651px) and (max-height:500px) and (pointer:coarse) {
  .room-view .stage .notebook.is-open .pages.reading-essay {
    padding-top:calc(var(--rule-step) * 2);
    clip-path:inset(96px 0 0 0);
    scroll-padding-top:96px;
  }
}

/* A narrow facing page must wrap whole words without overflowing its margin. */
@container (max-width:320px) {
  .notebook #page-title { font-size:38px; line-height:var(--rule-step); }
  .notebook .reading-essay #page-title { font-size:32px; }
  .notebook .toc-line { font-size:28px; }
}

/* Phones open one full-width contents page, then a full-screen essay. */
@media(max-width:650px) {
  /* Mobile opens to the right-hand page only; desktop retains its facing cover. */
  .notebook { width:min(390px,84vw); height:550px; }
  .notebook-view .stage:has(.notebook.is-open) { perspective:none; }
  .stage .notebook.is-open:not(:has(.pages.reading-essay)) {
    --mobile-page-top:calc(155px + env(safe-area-inset-top));
    --mobile-page-height:min(540px,calc(100dvh - var(--mobile-page-top) - 12px - env(safe-area-inset-bottom)));
    position:fixed; inset:auto; left:12px;
    top:max(var(--mobile-page-top),calc((100dvh - var(--mobile-page-height)) / 2));
    width:calc(100vw - 24px); max-width:none; height:var(--mobile-page-height);
    min-height:0; margin:0; transform:none;
  }
  .stage .notebook.is-open:has(.pages.reading-essay) { position:fixed; inset:0; z-index:160; width:100%; max-width:none; height:100dvh; min-height:0; margin:0; transform:none; border-radius:0; }
  .notebook.is-open .cover { display:none; }
  .notebook.is-open .cover-front { visibility:hidden!important; }
  .notebook.is-open .pages { padding:48px 24px 24px 44px; --margin-line:28px; }
  .notebook.is-open .pages.reading-essay { padding:calc(var(--rule-step) * 5) 20px 24px; --margin-line:12px; border-radius:0; }
  .notebook .pages:not(.reading-essay) #page-title { font-size:36px; line-height:var(--rule-step); }
  .notebook .reading-essay #page-title { font-size:36px; }
  .notebook .toc-line { padding-left:30px; font-size:28px; }
  .notebook .toc-line .essay-number { font-size:18px; }
  .essay-body,#essay-subtitle { font-size:26px; }
  #essay-date { right:22px; font-size:16px; }
  .notebook-nav { right:10px; }
  .notebook-nav button,.notebook-nav .home-tab { font-size:16px; padding:3px 9px; }
  body:not(.room-view) .stage:has(.notebook.is-open) .desk-pencil { display:none; }
  /* Preserve one full-width phone page and the existing full-screen essay.
     The photo stays stationary; the live rule layers still scroll with the text. */
  .room-view .stage .notebook.is-open { --folded-top:40px; --folded-right:28px; --folded-bottom:28px; --folded-gutter:48px; }
  .room-view .stage .notebook.is-open:has(.pages) { transform:none; }
  .room-view .stage .notebook.is-open .pages { inset:0; padding:48px 24px 24px 44px; --margin-line:28px; clip-path:inset(28px 14px 22px 14px round 10px 20px 12px 0); }
  /* The four-link overview is not the essay reader. A compact shared ruler and
     quieter handwriting expose every complete choice without a scroll gesture. */
  .room-view .stage .notebook.is-open .pages:has(#contents:not([hidden])) {
    --rule-step:32px; padding:32px 28px 28px 42px;
  }
  .room-view .pages:has(#contents:not([hidden])) .toc-line { font-size:22px; line-height:var(--rule-step); padding-left:24px; }
  .room-view .pages:has(#contents:not([hidden])) .toc-line .essay-number { font-size:15px; }
  .room-view .pages:has(#contents:not([hidden])) .toc li { margin-bottom:var(--rule-step); }
  .room-view .pages:has(#contents:not([hidden])) .toc li:last-child { margin-bottom:0; }
  .room-view .pages:has(#contents:not([hidden])) .page-bottom { display:none; }
  .room-view .stage .notebook.is-open .pages.reading-essay {
    padding:calc(var(--rule-step) * 3 + 16px + env(safe-area-inset-top)) 28px 24px 38px;
    --margin-line:30px; border-radius:0;
    /* The paper fills the screen, but scrolling ink stays below site Back. */
    clip-path:inset(calc(156px + env(safe-area-inset-top)) 14px 22px 14px round 10px 20px 12px 0);
    scroll-padding-top:calc(160px + env(safe-area-inset-top));
  }
  .room-view .stage .notebook.is-open .notebook-room-header { grid-template-columns:minmax(0,1fr); }
  .room-view .notebook-room-header #essay-date { justify-self:end; font-size:16px; }
  .room-view .stage .notebook.is-open .page-corner { right:0; bottom:0; }
  .room-view .stage .notebook.is-open .pages { touch-action:pan-y pinch-zoom; }
  .notebook-room-cover { inset:18px 2px 4px 2px; }
  .notebook-room-block { left:20px; right:6px; bottom:6px; height:16px; }
  .notebook-room-spine { left:2px; top:22px; bottom:7px; width:17px; }
  .notebook-turn-copy.reading-essay .turn-copy-page-title { font-size:36px; }
}

@media(max-width:650px) and (max-height:600px), (max-width:360px) {
  .room-view .stage .notebook.is-open .pages:has(#contents:not([hidden])) { --rule-step:24px; }
  .room-view .pages:has(#contents:not([hidden])) .toc-line { font-size:clamp(18px,5.4vw,20px); }
}

/* A woven ribbon marks the essay waiting inside the closed book. */
.notebook-bookmark { position:absolute; z-index:3; top:-17px; right:19%; width:19px; height:74px; pointer-events:none; background:repeating-linear-gradient(90deg,#853528 0 1px,#a54c39 1px 3px,#963d2f 3px 4px); clip-path:polygon(0 0,100% 0,100% 100%,50% 86%,0 100%); filter:drop-shadow(2px 3px 2px #28160855); }
.notebook-bookmark[hidden],.notebook.is-open .notebook-bookmark { display:none; }

/* The page corner lifts and peels, preserving the physical next-page control. */
#essay-next { position:absolute; width:1px; height:1px; padding:0; border:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.page-corner { position:absolute; z-index:4; right:0; bottom:0; width:110px; height:110px; border:0; padding:0; background:transparent; cursor:grab; touch-action:none; }
.page-corner[hidden] { display:none; }
.page-corner:active { cursor:grabbing; }
.page-corner::before { content:''; position:absolute; right:0; bottom:0; width:calc((30px + var(--peel,0) * 110px) * var(--lift,1)); height:calc((30px + var(--peel,0) * 110px) * var(--lift,1)); clip-path:polygon(0 100%,100% 0,100% 100%); background:linear-gradient(45deg,#fffdf4 0%,#f6f0dd 42%,#e2d9bf 55%,#c9bfa2 100%); filter:drop-shadow(-2px -2px 3px #453b1e59); transform-origin:bottom right; transition:width .22s ease,height .22s ease; animation:corner-invite 4.6s ease-in-out 1.4s infinite; }
.page-corner::after { content:''; position:absolute; inset:0; background:linear-gradient(45deg,transparent 55%,#2e2a1850 100%); opacity:calc(var(--peel,0) * .9); pointer-events:none; }
.page-corner:hover::before,.page-corner:focus-visible::before { width:calc((44px + var(--peel,0) * 110px) * var(--lift,1)); height:calc((44px + var(--peel,0) * 110px) * var(--lift,1)); }
.page-corner.is-peeling::before { transition:none; animation:none; }
@keyframes corner-invite { 0%,100% { transform:scale(1); } 7% { transform:scale(1.14); } 14% { transform:scale(1); } }
@media(max-width:650px) { .page-corner { width:96px; height:96px; } }

/* On a room phone, the large fixed corner steals reading drags. Keep the real
   Next button in the scrolling paper instead; desktop retains its physical peel. */
@media(max-width:650px), (max-height:500px) and (pointer:coarse) {
  .room-view .notebook.is-open .page-corner { display:none; }
  .room-view .notebook.is-open #essay-next {
    position:static; width:auto; height:auto; padding:5px 0; border:0;
    border-bottom:1px solid #aaa99f; overflow:visible; clip-path:none; white-space:normal;
  }
}

/* Doodles retain the original introduction and a live drawing sheet. */
.doodle-page { padding:0; display:flex; flex-direction:column; flex:1 0 auto; min-height:min-content; }
.notebook .pages:has(#doodle-page:not([hidden])) { display:flex; flex-direction:column; padding-top:44px; }
.doodle-quote { margin:0 0 var(--rule-step); font:26px/var(--rule-step) var(--hand); color:#36424c; }
.doodle-sheet { position:relative; flex:1; min-height:110px; border:1px dashed #b9b2a0; border-radius:2px; background:#fbfaf6; touch-action:none; overflow:hidden; cursor:crosshair; }
.doodle-canvas { position:absolute; inset:0; width:100%; height:100%; }
@media(max-width:650px) {
  .mobile-swipe-cue { display:none; }
  .notebook.is-open .pages.reading-essay .mobile-swipe-cue { position:fixed; bottom:18px; left:50%; transform:translateX(-50%); z-index:180; display:block; width:max-content; max-width:calc(100% - 10px); margin:0; padding:7px 13px; border:1px solid #b3a98b; border-radius:999px; background:#fffdf0ed; color:#554c3e; box-shadow:0 2px 8px #4035232b; font:15px/1.2 var(--hand); text-align:center; pointer-events:none; }
  .mobile-swipe-cue[hidden] { display:none!important; }
}
@media(prefers-reduced-motion:reduce) {
  .notebook,.notebook.is-open,.notebook .cover { transition:none; }
  .notebook .pages { rotate:none; transition:none; }
  .page-corner::before { animation:none; transition:none; }
}
@media(hover:hover) and (pointer:fine) {
  .notebook:not(.is-open) .open-cover,.notebook.is-open .pages,.notebook .doodle-sheet { cursor:url("/assets/cursors/pencil.png") 3 29,pointer; }
}
