* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  overflow-x: clip;
  background:
    radial-gradient(ellipse at 80% 0, oklch(.52 .065 80 / .06), transparent 52rem),
    linear-gradient(145deg, var(--page-bg-start), var(--page-bg-middle) 55%, var(--page-bg-end));
  color: var(--page-text);
  font-family: var(--font-ui);
  font-size: var(--type-body);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grain-opacity);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.3'/%3E%3C/svg%3E");
  mix-blend-mode: var(--grain-blend);
}
/* The pool is rasterized once and follows the pointer through transform only.
   It sits behind the books/text, preserving legibility and the 3D ancestor chain. */
.room-light { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: clip; }
.room-light::before {
  content: "";
  position: absolute;
  width: clamp(28rem, 60vw, 54rem);
  aspect-ratio: 1;
  background: radial-gradient(ellipse, oklch(.85 .09 80 / .1), oklch(.7 .075 80 / .025) 42%, transparent 70%);
  transform: translate3d(calc(var(--lamp-x) - 50%), calc(var(--lamp-y) - 50%), 0);
}
html[data-theme="light"] body {
  background:
    linear-gradient(120deg, transparent 18%, oklch(1 .02 90 / .36) 28%, oklch(1 .02 90 / .12) 38%, transparent 49%),
    linear-gradient(145deg, var(--page-bg-start), var(--page-bg-middle) 60%, var(--page-bg-end));
}
html[data-theme="light"] .room-light { display: none; }
html[data-theme="dark"] .book__front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 15%, oklch(.9 .07 85 / .16), transparent 75%);
  opacity: var(--book-illumination, .3);
  pointer-events: none;
}
button, a { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
body.has-open-bookplate { overflow: hidden; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 5px; }
::selection { background: var(--focus-ring); color: var(--ink-deep); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.admin-page::before { display: none; }
html[data-theme] .admin-page { background: var(--page-bg-start); }
@media (prefers-reduced-motion: reduce) {
  body::before { display: none; }
  .room-light { --lamp-x: 58vw !important; --lamp-y: 14vh !important; }
  .book__front::after { display: none; }
}
