/* Gift Guide flipbook. Colors live here as tokens; change them in one place. */
:root {
  /* The table behind the book: one flat colour (Mike, 1.1.2). Change it here only; also
     theme-color in index.html and manifest.webmanifest. UI on the table uses dark ink. */
  --table: #eee2dd;
  --ink-on-wood: rgb(46, 31, 18);
  --ink-on-wood-dim: rgba(46, 31, 18, 0.85);
  --ink-on-dark: rgb(243, 234, 223);
  --chip: rgba(255, 251, 244, 0.55);
  --chip-hover: rgba(255, 251, 244, 0.8);
  --chip-edge: rgba(46, 31, 18, 0.18);
  --chip-solid: rgba(255, 251, 244, 0.88);
  --ink-on-wood-off: rgba(46, 31, 18, 0.32);
  /* Two-tone focus ring: deep rust inside, warm white outside, so one of the two always
     stands out (rust 8.4:1 on cream paper, warm white 11.7:1 on the dark green page). */
  --focus: rgb(122, 42, 28);
  --focus-halo: rgb(255, 249, 238);
  /* The same ring traced around a cutout's silhouette: rust first, then the halo outside it. */
  --ring-filter: drop-shadow(2px 0 0 var(--focus)) drop-shadow(-2px 0 0 var(--focus))
    drop-shadow(0 2px 0 var(--focus)) drop-shadow(0 -2px 0 var(--focus))
    drop-shadow(2px 0 0 var(--focus-halo)) drop-shadow(-2px 0 0 var(--focus-halo))
    drop-shadow(0 2px 0 var(--focus-halo)) drop-shadow(0 -2px 0 var(--focus-halo));
  /* Warm-neutral shadows so the cream pages stand off the blush table without a black halo.
     Quieter than on the old wood: a light table shows a shadow more. The hairline keeps the
     page edge readable where paper and table are close in tone. */
  --book-edge: rgba(92, 52, 40, 0.20);
  --book-contact: rgba(80, 44, 32, 0.24);
  --book-near: rgba(80, 44, 32, 0.15);
  --book-far: rgba(80, 44, 32, 0.26);
  --paper: rgb(251, 248, 242);
  --link-on-paper: rgb(122, 42, 28);
  --paper-ink: rgb(42, 29, 18);
  --lift-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
  --lift-shadow-color: rgba(0, 0, 0, 0.14);
  --glow: rgba(255, 255, 255, 0.35);
  --glow-edge: rgba(255, 255, 255, 0.5);
  --glow-soft: rgba(255, 255, 255, 0.18);
  /* Photo lift presets (config.js hoverPreset, ?debug=hover). "quiet" is the first version. */
  --pop-contact: rgba(0, 0, 0, 0.18);
  --pop-soft: rgba(0, 0, 0, 0.18);
  --pop-glow: rgba(255, 255, 255, 0.42);
  --pop-glow-edge: rgba(255, 255, 255, 0.6);
  --lift-scale: 1.025;
  --lift-y: -2px;
  --lift-ms: 240ms;
  --slow: 1; /* ?debug=slow multiplies every hover transition (app.js) */
  --t-lift: calc(var(--lift-ms) * var(--slow));
  --t-text: calc(200ms * var(--slow));
  --f-shadow: drop-shadow(0 10px 14px var(--lift-shadow-color));
  --f-glow: drop-shadow(0 0 1px var(--glow-edge)) drop-shadow(0 0 18px var(--glow));
  --f-both: drop-shadow(0 0 14px var(--glow-soft)) drop-shadow(0 10px 14px var(--lift-shadow-color));
  --f-shadow-still: brightness(1.02) drop-shadow(0 2px 3px var(--lift-shadow-color)) drop-shadow(0 12px 16px var(--lift-shadow-color));
  --f-glow-soft: drop-shadow(0 0 14px var(--glow-soft));
  --b-shadow: var(--lift-shadow);
  --b-glow: 0 0 18px var(--glow), 0 0 0 1px var(--glow-edge);
  --b-both: var(--lift-shadow), 0 0 14px var(--glow-soft);
  --text-hot: rgba(255, 220, 160, 0.14);
  --text-underline: rgba(42, 29, 18, 0.45);
  --ease-lift: cubic-bezier(0.2, 0.7, 0.2, 1);
  --bar-h: 64px;
  --controls-h: 72px;
  --gutter: 24px;
  color-scheme: light;
}
:root[data-lift="pop"] {
  --lift-scale: 1.04;
  --lift-y: -3px;
  --lift-ms: 260ms;
  --t-lift: calc(var(--lift-ms) * var(--slow));
  --f-shadow: drop-shadow(0 2px 3px var(--pop-contact)) drop-shadow(0 14px 18px var(--pop-soft));
  --f-glow: drop-shadow(0 0 1px var(--pop-glow-edge)) drop-shadow(0 0 22px var(--pop-glow));
  --f-both: drop-shadow(0 0 16px var(--glow-soft)) drop-shadow(0 2px 3px var(--pop-contact)) drop-shadow(0 14px 18px var(--pop-soft));
  --f-shadow-still: brightness(1.03) drop-shadow(0 3px 4px var(--pop-contact)) drop-shadow(0 18px 22px var(--pop-soft));
  --b-shadow: 0 2px 3px var(--pop-contact), 0 14px 18px var(--pop-soft);
  --b-glow: 0 0 22px var(--pop-glow), 0 0 0 1px var(--pop-glow-edge);
  --b-both: 0 2px 3px var(--pop-contact), 0 14px 18px var(--pop-soft), 0 0 16px var(--glow-soft);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--table);
  color: var(--ink-on-wood);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar ---------- */
.bar {
  position: relative; z-index: 2;
  height: var(--bar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 var(--gutter);
}
.bar__title { margin: 0; font-size: 16px; font-weight: 500; letter-spacing: 0.02em; color: var(--ink-on-wood-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__brand { color: var(--ink-on-wood); font-weight: 600; margin-right: 0.35em; }
.bar__actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-size: 16px; color: var(--ink-on-wood);
  background: var(--chip); border: 1px solid var(--chip-edge);
  min-height: 40px; min-width: 40px; border-radius: 999px; cursor: pointer;
  transition: background-color 160ms ease, opacity 160ms ease;
}
@media (hover: hover) and (pointer: fine) { .btn:hover { background: var(--chip-hover); } }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn--text { padding: 0 16px; }
.btn--icon { width: 44px; height: 44px; display: inline-grid; place-items: center; padding: 0; }
.btn--dark { color: var(--paper-ink); background: transparent; border-color: rgba(42, 29, 18, 0.25); }
@media (hover: hover) and (pointer: fine) { .btn--dark:hover { background: rgba(42, 29, 18, 0.06); } }
.btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 0;
  box-shadow: 0 0 0 4px var(--focus-halo);
}

/* ---------- Stage and book ---------- */
.stage {
  position: relative; z-index: 1;
  height: calc(100dvh - var(--bar-h) - var(--controls-h));
  display: grid; place-items: center;
  padding: 0 var(--gutter);
  /* app.js owns every touch gesture here: pinch, double tap and pan zoom the book; a swipe at
     fit turns the page. The browser must not zoom or scroll the page under them. */
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
/* The zoom layer: app.js sets translate(x, y) scale(s) on it (zoom-math.js). It covers the
   stage and centers the book, so at fit (no transform) the book sits exactly as before. */
.zoom {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  transform-origin: 0 0;
}
.zoom.is-moving { will-change: transform; }
html.is-zoomed .stage { overflow: hidden; }
html.is-zoomed .stage, html.is-zoomed .hs { cursor: grab; }
html.is-zoomed.is-panning .stage, html.is-zoomed.is-panning .hs { cursor: grabbing; }
.book-frame { position: relative; width: 300px; }
/* app.js moves the book (and scales its contact shadow) frame by frame in step with the page
   turn when a cover opens or closes (applyShift, driveFrame), so there is no transform transition
   here. will-change is on only while a turn is under way. */
.book-shift { position: relative; transition: opacity 180ms ease; }
.book-shift.is-fading { opacity: 0; }
.book-shift.is-turning, .book-shift.is-turning .book-shadow { will-change: transform; }

/* Soft contact shadow under whatever pages are showing. Full width; app.js scales it to the
   cover's half with scaleX while a cover shows alone. */
.book-shadow {
  position: absolute; top: 0; bottom: 0; left: 0; width: 100%;
  border-radius: 2px;
  box-shadow:
    0 0 0 1px var(--book-edge),
    0 1px 2px var(--book-contact),
    0 6px 16px var(--book-near),
    0 28px 52px -18px var(--book-far);
}

.book { position: relative; }
/* The engine casts a flat gradient box beside a turning cover. On the light table its hard top
   and bottom edges read as a grey rectangle, so soften it into a cast shadow. */
.book .stf__hardShadow { filter: blur(10px); opacity: 0.7; }

.page { background: var(--paper); overflow: hidden; }
.page__img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; object-fit: cover;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
/* A page image shows only once decoded (app.js hydrate); until then the page's tiny blurred
   placeholder shows, and the image fades in over it. */
.page__ph {
  position: absolute; inset: -4%; pointer-events: none;
  background-size: 100% 100%; background-repeat: no-repeat;
  filter: blur(10px);
}
.page__img.is-pending { opacity: 0; }
/* The 3x zoom copy (app.js ensureHi): over the 2x image, faded in once decoded. */
.page__hi {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; object-fit: cover; opacity: 0; transition: opacity 180ms ease;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.page__hi.is-on { opacity: 1; }
.page__img.is-fade { transition: opacity 240ms ease; }

/* Center-fold shadow on spreads, very light. */
.page::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 7%;
  pointer-events: none; z-index: 1;
}
.book-frame:not(.is-portrait) .page--left::after {
  right: 0; background: linear-gradient(270deg, rgba(60, 38, 18, 0.16), rgba(60, 38, 18, 0.05) 35%, transparent);
}
.book-frame:not(.is-portrait) .page--right::after {
  left: 0; background: linear-gradient(90deg, rgba(60, 38, 18, 0.14), rgba(60, 38, 18, 0.04) 35%, transparent);
}
.book-frame:not(.is-portrait) .page--cover::after { display: none; }

/* ---------- Hotspots ---------- */
/* Every item has up to three kinds of region: its name, its URL and its photo.
   They share one destination and react together (app.js setGroup). */
.hs {
  position: absolute; z-index: 2; display: block;
  border-radius: var(--hs-radius, 0);
  -webkit-tap-highlight-color: transparent;
  /* Sideways drags on a link reach app.js (they turn the page); vertical ones still scroll. */
  touch-action: pan-y pinch-zoom;
}

/* Photo: the wrapper lifts and casts the shadow, the link inside is the picture. */
.hs-wrap {
  position: absolute; z-index: 2;
  pointer-events: none;
  border-radius: var(--hs-radius, 0);
  /* Return: the transform and shadow ease back over --t-lift while z-index holds until the
     very end, so the cutout stays above its fill (and nearby photos) the whole way back.
     Then cutout, fill, overlay and z-index all drop in the same frame, at identity, where
     the plain page matches pixel for pixel. Lift (below) zeroes every delay. */
  transition: transform var(--t-lift) var(--ease-lift), filter var(--t-lift) var(--ease-lift), z-index 0s linear var(--t-lift);
  /* Hover treatment. config.js hoverStyle sets data-hover; a region may override it.
     --lift-box is for old crop rectangles (box-shadow), --lift-filter for cutouts (drop-shadow). */
  --lift-box: var(--b-shadow);
  --lift-filter: var(--f-shadow);
  /* Per-cutout lift (app.js setLift, from tools/lift-tune.py). The defaults never win the
     min()/max() below, so a region without its own lift uses the preset. */
  --cut-scale: 9;
  --cut-y: -999px;
  --cut-origin: 50% 50%;
  transform-origin: var(--cut-origin);
}
/* A cutout that cannot move without showing its ghost stays put; its shadow carries the lift. */
.hs-wrap--cut[data-still][data-hover="shadow"] { --lift-filter: var(--f-shadow-still); }
.hs-wrap--cut[data-still][data-hover="both"] { --lift-filter: var(--f-glow-soft) var(--f-shadow-still); }
.hs-wrap[data-hover="glow"] { --lift-box: var(--b-glow); --lift-filter: var(--f-glow); }
.hs-wrap[data-hover="both"] { --lift-box: var(--b-both); --lift-filter: var(--f-both); }

/* True cutout: the product's own transparent image (pages/cutouts/), exactly over its spot.
   Hidden at rest so the page shows untouched; it appears as the lift starts and hides again
   only after the lift has settled back. The link on top is invisible: its clip-path is the
   click area. */
.hs-cut {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; pointer-events: none; user-select: none; -webkit-user-drag: none;
  opacity: 0;
  transition: opacity 0s linear var(--t-lift);
}
.hs-wrap--cut > .hs--photo { right: auto; bottom: auto; }
.hs-wrap--cut > .hs--photo:focus-visible { outline: none; }
.hs-wrap--cut.is-focus .hs-cut { opacity: 1; transition-delay: 0s; }
.hs-wrap--cut.is-focus {
  filter: var(--ring-filter);
  z-index: 5;
}
.hs-wrap > .hs--photo {
  inset: 0; pointer-events: auto;
  background-repeat: no-repeat;
  transition: box-shadow var(--t-lift) var(--ease-lift);
}
/* A cut-out: clip-path on the link shapes the picture, hit area and focus ring. */
.hs-wrap--shaped > .hs--photo:focus-visible { outline: none; }
.hs-wrap--shaped.is-focus {
  filter: var(--ring-filter);
  z-index: 5;
}

/* Clean background under a lifted cutout (tools/hole-fill.py). It follows the cutout: shown
   the moment the lift starts, hidden only after the lift has settled back. Never moves. */
.hs-fill { position: absolute; z-index: 4; pointer-events: none; }
.hs-fill > .hs-fill__img { opacity: 0; transition: opacity 0s linear var(--t-lift); }

/* What the designer drew on top of a photo (tools/occluders.py): page-fixed, above the lifted
   cutout (z-index 5), shown and hidden exactly with it. At rest it matches the page. */
.hs-over { position: absolute; z-index: 6; pointer-events: none; }
.hs-over > .hs-over__img { opacity: 0; transition: opacity 0s linear var(--t-lift); }
.hs-wrap--cut.is-focus + .hs-over > .hs-over__img,
.hs-wrap--cut.is-focus + .hs-fill + .hs-over > .hs-over__img { opacity: 1; transition-delay: 0s; }

/* Name and URL: a soft tint and a hairline underline. */
.hs--text { transition: background-color var(--t-text) ease, box-shadow var(--t-text) ease; }

/* The hover lift and its fill and overlay layers are for a mouse or trackpad only. On touch
   there is no lift, no extra layers, and app.js does not load the cutouts. */
@media (hover: hover) and (pointer: fine) {
  .hs-wrap { will-change: transform; }
  .hs-wrap.is-lift {
    transform: scale(min(var(--cut-scale), var(--lift-scale))) translateY(max(var(--cut-y), var(--lift-y)));
    z-index: 5;
    transition-delay: 0s, 0s, 0s;
  }
  .hs-wrap.is-lift:not(.hs-wrap--shaped):not(.hs-wrap--cut) > .hs--photo { box-shadow: var(--lift-box); }
  .hs-wrap--shaped.is-lift, .hs-wrap--cut.is-lift { filter: var(--lift-filter); }
  .hs-wrap--cut.is-lift .hs-cut, .hs-wrap--cut.is-lift + .hs-fill > .hs-fill__img,
  .hs-wrap--cut.is-lift + .hs-over > .hs-over__img,
  .hs-wrap--cut.is-lift + .hs-fill + .hs-over > .hs-over__img { opacity: 1; transition-delay: 0s; }
  .hs-wrap--shaped.is-lift.is-focus, .hs-wrap--cut.is-lift.is-focus {
    filter: var(--ring-filter) var(--lift-filter);
  }
  .hs--text.is-hot { background-color: var(--text-hot); box-shadow: inset 0 -1.5px 0 var(--text-underline); }
}
/* Keyboard focus on a name or URL keeps the halo even while it is also hot. */
.hs--text:focus-visible, .hs--text.is-hot:focus-visible { box-shadow: 0 0 0 4px var(--focus-halo), inset 0 -1.5px 0 var(--text-underline); }
/* Touch: grow each credit's tap area toward 40px without moving its visible box.
   app.js sets --room-* (how far it may grow before reaching another maker), as a multiple of
   the link's own height (top, bottom) or width (left, right). Larger value = less growth. */
@media (pointer: coarse) {
  .hs--text::before {
    content: '';
    position: absolute;
    /* min(0px, ...) so a box already 40px or more never shrinks. */
    top: max(min(0px, calc((100% - 40px) / 2)), calc(var(--room-t, 0) * -100%));
    bottom: max(min(0px, calc((100% - 40px) / 2)), calc(var(--room-b, 0) * -100%));
    left: max(min(0px, calc((100% - 40px) / 2)), calc(var(--room-l, 0) * -100%));
    right: max(min(0px, calc((100% - 40px) / 2)), calc(var(--room-r, 0) * -100%));
  }
}

/* Only with ?debug=links in the URL. */
.debug-links {
  position: fixed; right: 16px; bottom: 16px; z-index: 50; max-width: min(480px, calc(100vw - 32px));
  max-height: 40vh; overflow: auto; padding: 12px 14px; border-radius: 10px;
  font-size: 16px; line-height: 1.4; color: rgb(255, 255, 255); background: rgba(120, 20, 20, 0.92);
}

/* Only with ?debug=hover in the URL. */
.hover-debug {
  position: fixed; left: 16px; bottom: 16px; z-index: 50;
  display: flex; flex-wrap: wrap; gap: 8px; max-width: calc(100vw - 32px);
}
.hover-debug__group {
  display: flex; gap: 4px; padding: 4px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.78);
}
.hover-debug button {
  min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px;
  font: inherit; font-size: 16px; color: var(--ink-on-desk, rgb(255, 255, 255)); background: transparent; cursor: pointer;
}
.hover-debug button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.2); }

/* Touch: a quiet pressed state, no lift. */
.hs:active { filter: brightness(0.96); }

/* ---------- Controls ---------- */
.controls {
  position: relative; z-index: 2;
  height: var(--controls-h);
  display: flex; align-items: center; justify-content: center; gap: 16px;
}
.zoombar { display: flex; gap: 6px; margin-left: 8px; }
.controls__count { margin: 0; min-width: 88px; text-align: center; color: var(--ink-on-wood); font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--controls-h) + 8px); z-index: 10;
  transform: translateX(-50%); margin: 0;
  padding: 8px 16px; border-radius: 999px;
  background: rgba(20, 13, 7, 0.86); color: var(--ink-on-dark);
  opacity: 0; transition: opacity 200ms ease; pointer-events: none;
}
.toast.is-on { opacity: 1; }

.load-error { position: absolute; color: var(--ink-on-wood); }

/* One-time Home Screen hint (iPhone Safari only, app.js a2hs). */
.a2hs {
  position: fixed; z-index: 12; left: 50%; transform: translateX(-50%);
  top: calc(var(--safe-t, 12px) + 52px);
  width: max-content; max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 4px;
  padding: 0 4px 0 16px; border-radius: 999px;
  background: rgba(20, 13, 7, 0.86); color: var(--ink-on-dark);
}
.a2hs[hidden] { display: none; }
.a2hs__text { margin: 0; font-size: 16px; line-height: 1.3; padding: 8px 0; }
.a2hs__close { color: var(--ink-on-dark); background: transparent; border-color: transparent; }
@media (hover: hover) and (pointer: fine) { .a2hs__close:hover { background: rgba(255, 255, 255, 0.12); } }

/* Only with ?debug=fullscreen: what the browser said about full screen. */
.fs-debug {
  position: fixed; z-index: 50; left: 8px; right: 8px; bottom: calc(var(--safe-b, 8px) + 56px);
  margin: 0; padding: 8px 12px; border-radius: 10px;
  font: 16px/1.4 ui-monospace, Menlo, monospace; color: rgb(255, 255, 255); background: rgba(0, 0, 0, 0.8);
  white-space: pre-wrap;
}

/* ---------- Text version ---------- */
.textver {
  width: min(720px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 0; border-radius: 12px;
  background: var(--paper); color: var(--paper-ink);
  font-size: 16px; line-height: 1.55;
}
.textver::backdrop { background: rgba(10, 6, 3, 0.6); }
.textver__head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; background: var(--paper); border-bottom: 1px solid rgba(42, 29, 18, 0.12);
}
.textver__head h2 { margin: 0; font-size: 18px; }
#textver-body { padding: 8px 20px 24px; }
.textver section { padding: 12px 0; border-bottom: 1px solid rgba(42, 29, 18, 0.08); }
.textver h3 { margin: 0 0 4px; font-size: 16px; }
.textver p { margin: 0 0 6px; }
.textver ul { margin: 0; padding-left: 20px; }
.textver li { margin: 4px 0; }
.textver a { color: var(--link-on-paper); min-height: 40px; display: inline-flex; align-items: center; }

.skip {
  position: absolute; left: 16px; top: -100px; z-index: 20;
  padding: 10px 16px; background: var(--paper); color: var(--paper-ink); border-radius: 8px;
}
.skip:focus { top: 12px; }

.noscript { position: relative; z-index: 3; text-align: center; padding: 24px; }

/* ---------- Phone ---------- */
@media (max-width: 760px) {
  :root { --gutter: 16px; --bar-h: 56px; --controls-h: 68px; }
  .bar__brand { display: none; }
  .btn--text { padding: 0 14px; }
}

/* Phones, either way up (narrow, or a short landscape screen): the book gets the whole visible
   screen, inside the notch and home-bar safe areas, and the controls float over it on chips.
   On a touch screen they fade after 2.5 s without input and come back on any touch, key or
   wheel (app.js poke). app.js sizes the book from the stage, so it fits the real visible size.
   The same query is PHONE_MQ in app.js. */
@media (max-width: 760px), (max-height: 500px) {
  :root {
    --edge: 8px;
    --safe-t: calc(env(safe-area-inset-top, 0px) + var(--edge));
    --safe-r: calc(env(safe-area-inset-right, 0px) + var(--edge));
    --safe-b: calc(env(safe-area-inset-bottom, 0px) + var(--edge));
    --safe-l: calc(env(safe-area-inset-left, 0px) + var(--edge));
  }
  .stage {
    position: fixed; inset: 0; height: auto;
    padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  }
  .bar, .controls {
    position: fixed; left: 0; right: 0; z-index: 3; height: auto;
    pointer-events: none;
    transition: opacity 220ms ease;
  }
  .bar > *, .controls > * { pointer-events: auto; }
  .bar { top: 0; padding: var(--safe-t) var(--safe-r) 0 var(--safe-l); align-items: flex-start; }
  .controls { bottom: 0; padding: 0 var(--safe-r) var(--safe-b) var(--safe-l); gap: 6px; }
  .bar__title, .controls__count {
    min-height: 40px; display: flex; align-items: center; justify-content: center;
    padding: 0 12px; border-radius: 999px;
    background: var(--chip); border: 1px solid var(--chip-edge);
  }
  .bar__title { flex-shrink: 1; min-width: 0; display: block; line-height: 38px; }
  .controls__count { min-width: 72px; }
  /* Chips sit over the pages too (dark covers, photos), so they are nearly solid here. */
  .bar__title, .controls__count, .bar .btn, .controls .btn { background: var(--chip-solid); }
  .controls .btn:disabled { opacity: 1; color: var(--ink-on-wood-off); }
  .zoombar { gap: 6px; margin-left: 6px; }
  .bar__actions { gap: 6px; }
  .toast { bottom: calc(var(--safe-b) + 56px); }
  /* Faded out: still in the page for screen readers (focus brings them back), never tappable. */
  html.chrome-hidden .bar, html.chrome-hidden .controls { opacity: 0; }
  html.chrome-hidden .bar > *, html.chrome-hidden .controls > * { pointer-events: none; }
}
/* Landscape phone: the arrows sit on the table beside the spread, at mid-height. */
@media (max-height: 500px) and (orientation: landscape) {
  #btn-prev, #btn-next { position: fixed; top: 50%; transform: translateY(-50%); }
  #btn-prev { left: var(--safe-l); }
  #btn-next { right: var(--safe-r); }
}
@media (prefers-reduced-motion: reduce) {
  .bar, .controls { transition: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .book-shift { transition: opacity 180ms ease; }
  .hs-wrap { transition: filter var(--t-lift) var(--ease-lift), z-index 0s linear var(--t-lift); }
  .hs-wrap.is-lift { transform: none; }
}
