/* HP Thailand ONE Catalogue — flipbook viewer
   HP corporate identity (HP Blue #024AD8, HP Forma DJR) on a quiet, glassy interaction layer. */

/* HP Forma DJR Thai Office — the Thai cut also carries the Latin set (subset WOFF2, scripts/fonts.py) */
@font-face { font-family: "HP Forma DJR"; src: url("../fonts/HPFormaDJRThai-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HP Forma DJR"; src: url("../fonts/HPFormaDJRThai-Medium.woff2") format("woff2"); font-weight: 500 600; font-style: normal; font-display: swap; }
@font-face { font-family: "HP Forma DJR"; src: url("../fonts/HPFormaDJRThai-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --hp-blue: #024ad8;
  --hp-blue-strong: #0039b0;
  --accent-text: #024ad8;
  --bg: #f5f5f7;
  --bg-spot: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --fill: rgba(0, 0, 0, .05);
  --fill-2: rgba(0, 0, 0, .09);
  --glass: rgba(251, 251, 253, .74);
  --glass-line: rgba(0, 0, 0, .07);
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --seg-ind: #ffffff;
  --tab-bg: #ffffff;
  --tab-fg: #3a3a3c;
  --book-shadow: rgba(10, 14, 30, .26);
  --scrim: rgba(0, 0, 0, .3);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-sheet: cubic-bezier(.32, .72, 0, 1);
  --topbar-h: 52px;
  --font: "HP Forma DJR", -apple-system, BlinkMacSystemFont, "Segoe UI", "Leelawadee UI", Tahoma, sans-serif;
  color-scheme: light;
}

/* Dark palette: follows the system unless the viewer picked a theme (data-theme on <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-text: #5b8cff;
    --bg: #0a0a0b;
    --bg-spot: #1d1d21;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --fill: rgba(255, 255, 255, .07);
    --fill-2: rgba(255, 255, 255, .13);
    --glass: rgba(24, 24, 27, .72);
    --glass-line: rgba(255, 255, 255, .09);
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --seg-ind: #636366;
    --tab-bg: #2c2c2e;
    --tab-fg: #e5e5ea;
    --book-shadow: rgba(0, 0, 0, .7);
    --scrim: rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent-text: #5b8cff;
  --bg: #0a0a0b;
  --bg-spot: #1d1d21;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --fill: rgba(255, 255, 255, .07);
  --fill-2: rgba(255, 255, 255, .13);
  --glass: rgba(24, 24, 27, .72);
  --glass-line: rgba(255, 255, 255, .09);
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --seg-ind: #636366;
  --tab-bg: #2c2c2e;
  --tab-fg: #e5e5ea;
  --book-shadow: rgba(0, 0, 0, .7);
  --scrim: rgba(0, 0, 0, .55);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--hp-blue); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

svg.i {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

/* ───────────── Top bar ───────────── */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  border-bottom: .5px solid var(--glass-line);
  transition: transform .5s var(--ease-sheet);
}
.brand { justify-self: start; display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: var(--text); border-radius: 8px; }
.brand img { width: 30px; height: 30px; display: block; flex: none; }
.brand-text { font-size: 15px; letter-spacing: -.012em; white-space: nowrap; color: var(--text-2); line-height: 1.15; }
.brand-text b { font-weight: 600; color: var(--text); }
.bt-1 { font-weight: 500; color: var(--text); }
@media (max-width: 640px) {
  /* stacked lockup on phones */
  .brand-text { display: flex; flex-direction: column; }
  .bt-1 { font-size: 11px; font-weight: 500; color: var(--text-2); letter-spacing: .01em; }
  .bt-2 { font-size: 14.5px; }
}
.now { justify-self: center; font-size: 13px; font-weight: 500; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
.now span { display: inline-block; transition: opacity .25s, transform .35s var(--ease-out); }
.now span.swap { opacity: 0; transform: translateY(4px); }
.actions { justify-self: end; display: flex; align-items: center; gap: 2px; }
.icon-btn {
  height: 36px; min-width: 36px; padding: 0 8px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13px; font-weight: 500; text-decoration: none; color: var(--text);
  transition: background-color .2s, transform .15s;
}
.icon-btn:hover { background: var(--fill); }
.icon-btn:active { background: var(--fill-2); transform: scale(.96); }
.icon-btn[aria-pressed="true"] { color: var(--accent-text); }
.btn-text { padding-right: 4px; }
@media (max-width: 899px) { .btn-text { display: none; } }
@media (max-width: 640px) {
  .topbar { grid-template-columns: 1fr auto; }
  .now { display: none; }
}
@media (hover: none), (pointer: coarse) { .only-fine { display: none; } }

/* ───────────── Stage & book ───────────── */
.stage {
  position: fixed; inset: 0; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none;
  background: radial-gradient(1100px 760px at 50% 46%, var(--bg-spot), var(--bg) 72%);
}
.stage[data-cursor="next"], .stage[data-cursor="prev"] { cursor: pointer; }
.stage[data-cursor="zoom"] { cursor: zoom-in; }
.app.zoomed .stage { cursor: grab; }
.app.zoomed .stage.panning { cursor: grabbing; }

.zoom { position: absolute; inset: 0; transform-origin: 0 0; }
.zoom.animating { transition: transform .55s var(--ease-sheet); }
.lift { position: absolute; inset: 0; transition: opacity .9s ease, transform 1.2s var(--ease-out); }
.app:not(.ready) .lift { opacity: 0; transform: translateY(28px) scale(.96); }

.book { position: absolute; }

.b-shadow { position: absolute; top: 0; width: 50%; height: 100%; border-radius: 2px;
  box-shadow: 0 34px 60px -24px var(--book-shadow), 0 10px 22px -10px var(--book-shadow); }
.b-shadow.l { left: 0; }
.b-shadow.r { left: 50%; }

.stack { position: absolute; top: 3px; bottom: 3px; width: 0;
  background: repeating-linear-gradient(to right, #fdfdfd 0 1px, #d9d9de 1px 2px); }
.stack.r { left: 100%; border-radius: 0 3px 3px 0; box-shadow: 1px 0 2px rgba(0, 0, 0, .12); }
.stack.l { right: 100%; border-radius: 3px 0 0 3px; box-shadow: -1px 0 2px rgba(0, 0, 0, .12);
  background: repeating-linear-gradient(to left, #fdfdfd 0 1px, #d9d9de 1px 2px); }
.book[data-mode="single"] .stack, .book[data-mode="single"] .b-shadow.l { display: none; }

/* A leaf sits on the right half; its back face rests on the left half (translateX(-100%)).
   While turning, the engine clips the flat part and reflects the folded flap with a matrix. */
.leaf { position: absolute; top: 0; left: 50%; width: 50%; height: 100%; }
.face {
  position: absolute; inset: 0; transform-origin: 0 0;
  background-color: #fff; background-size: 100% 100%; background-repeat: no-repeat;
}
.face.back { transform: translateX(-100%); }
.face.off { display: none; }
.face.blank { background: #fbfbfb; }
/* single-page mode: the reverse of a page shows its print faintly through the paper */
.face.paper { background: #f4f4f2; }
.face.paper > img, .face.paper > img.loaded { opacity: .1; transform: scaleX(-1); }
.fw { position: absolute; inset: 0; }
.fw.lifted { filter: drop-shadow(0 3px 9px rgba(0, 0, 0, .28)); }
.fold-shadow { position: absolute; top: 0; left: -100%; width: 200%; height: 100%; z-index: 2; pointer-events: none; display: none; }
.face > img {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  opacity: 0; transition: opacity .4s ease;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.face > img.loaded { opacity: 1; }
/* gutter: soft binding shadow near the spine */
.face::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.face.front::after { background: linear-gradient(to right, rgba(0,0,0,.16), rgba(0,0,0,.05) 2.5%, rgba(0,0,0,0) 7%); }
.face.back::after { background: linear-gradient(to left, rgba(0,0,0,.16), rgba(0,0,0,.05) 2.5%, rgba(0,0,0,0) 7%); }
.face.cover::after { background: linear-gradient(to right, rgba(0,0,0,.08), rgba(0,0,0,0) 2%); }
.face.back.cover::after { background: linear-gradient(to left, rgba(0,0,0,.08), rgba(0,0,0,0) 2%); }
.book[data-mode="single"] .face.front::after { background: linear-gradient(to right, rgba(0,0,0,.07), rgba(0,0,0,0) 2.5%); }
/* curl lighting painted by the engine onto the folded flap */
.shade { position: absolute; inset: 0; pointer-events: none; z-index: 1; }

.leaf.far .face { visibility: hidden; }
.leaf.gone { display: none; }

/* ───────────── Category bookmarks (index tabs on the page edge) ───────────── */
.tab {
  position: absolute; z-index: 2; visibility: visible;
  top: calc(var(--tab-top0) + var(--i) * var(--tab-slot));
  height: var(--tab-h); min-width: 34px;
  display: flex; align-items: center; gap: 7px;
  padding: 0 10px 0 8px;
  background: var(--tab-bg); color: var(--tab-fg);
  font-size: 12.5px; font-weight: 500; letter-spacing: -.005em; white-space: nowrap;
  box-shadow: 0 0 0 .5px rgba(0,0,0,.1), 0 3px 10px -2px rgba(0,0,0,.14);
  transition: background-color .35s, color .35s, box-shadow .3s;
}
.face.front .tab { left: calc(100% + var(--stack-r, 0px)); border-radius: 0 10px 10px 0; }
.face.back .tab { right: calc(100% + var(--stack-l, 0px)); border-radius: 10px 0 0 10px; flex-direction: row-reverse; padding: 0 8px 0 10px; }
.tab svg.i { width: 17px; height: 17px; }
.tab-label { max-width: 0; opacity: 0; overflow: hidden; transition: max-width .45s var(--ease-out), opacity .25s; }
.tab:hover .tab-label { max-width: 240px; opacity: 1; }
.tab:hover { box-shadow: 0 0 0 .5px rgba(0,0,0,.12), 0 6px 18px -4px rgba(0,0,0,.22); }
.tab.active { background: var(--hp-blue); color: #fff; }
.tab::before { /* widen the hit area toward the page without covering it visually */
  content: ""; position: absolute; inset: 0 -6px;
}

/* ───────────── Floating controls ───────────── */
.nav-btn {
  position: absolute; z-index: 5; top: 50%; width: 46px; height: 46px; margin-top: -23px;
  display: grid; place-items: center; border-radius: 50%; color: var(--text);
  box-shadow: 0 0 0 .5px var(--glass-line), 0 6px 18px -6px rgba(0,0,0,.18);
  transition: opacity .35s, transform .2s var(--ease-out), background-color .2s;
}
.nav-btn.prev { left: max(18px, env(safe-area-inset-left)); }
.nav-btn.next { right: max(18px, env(safe-area-inset-right)); }
.nav-btn:hover { transform: scale(1.06); }
.nav-btn:active { transform: scale(.95); }
.nav-btn[disabled] { opacity: 0; pointer-events: none; }
.nav-btn svg.i { width: 22px; height: 22px; stroke-width: 2; }
.app[data-mode="single"] .nav-btn, .app.zoomed .nav-btn { opacity: 0; pointer-events: none; }
@media (hover: none), (pointer: coarse) { .nav-btn { display: none; } }

.hint, .page-pill {
  position: absolute; z-index: 6; left: 50%; transform: translate(-50%, 8px);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--text);
  box-shadow: 0 0 0 .5px var(--glass-line), 0 8px 24px -8px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; white-space: nowrap;
  transition: opacity .45s, transform .6s var(--ease-out);
}
.hint { bottom: calc(var(--bottom-h, 80px) + 14px); }
.page-pill { bottom: calc(var(--bottom-h, 80px) + 12px); font-variant-numeric: tabular-nums; padding: 6px 13px; font-size: 12.5px; }
.hint.show, .page-pill.show { opacity: 1; transform: translate(-50%, 0); }

/* desktop scrubber capsule */
.capsule {
  position: fixed; z-index: 10; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom));
  width: min(760px, calc(100% - 32px)); height: 48px; padding: 0 20px 0 18px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px; border-radius: 24px;
  box-shadow: 0 0 0 .5px var(--glass-line), 0 10px 30px -10px rgba(0,0,0,.22);
  transition: transform .5s var(--ease-sheet), opacity .3s;
}
.capsule > .pager, .capsule > .scrubber { transition: opacity .35s; }
.capsule-hint {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 0 20px;
  font-size: 13.5px; font-weight: 500; color: var(--text); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .35s;
}
.capsule.hinting .capsule-hint { opacity: 1; }
.capsule.hinting > .pager, .capsule.hinting > .scrubber { opacity: 0; }
.pager { font-size: 13px; font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 62px; }
.scrubber { position: relative; flex: 1; height: 32px; display: flex; align-items: center; cursor: pointer; touch-action: none; border-radius: 6px; }
.segs { display: flex; width: 100%; height: 6px; transition: height .25s var(--ease-out); }
.scrubber:hover .segs, .scrubber.dragging .segs { height: 8px; }
.seg { height: 100%; padding-left: 3px; background-clip: content-box; background-color: var(--fill-2); transition: background-color .35s; }
.seg:first-child { padding-left: 0; }
.seg:first-child { border-radius: 4px 0 0 4px; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.seg.chapter { border-radius: 4px; }
.seg.active { background-color: var(--hp-blue); }
.scrub-pos {
  position: absolute; top: 50%; height: 16px; margin-top: -8px; min-width: 16px; border-radius: 8px;
  background: #fff; box-shadow: 0 0 0 .5px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.22);
  transition: left .55s var(--ease-sheet), width .35s var(--ease-sheet);
  pointer-events: none;
}
.scrubber.dragging .scrub-pos { transition: none; }
.scrub-tip {
  position: absolute; bottom: calc(100% + 14px); left: 0; z-index: 2;
  padding: 7px; border-radius: 14px; background: var(--surface); text-align: center;
  box-shadow: 0 0 0 .5px var(--glass-line), 0 18px 40px -12px rgba(0,0,0,.35);
  opacity: 0; transform: translate(-50%, 6px) scale(.97); transform-origin: 50% 100%;
  transition: opacity .2s, transform .3s var(--ease-out); pointer-events: none;
}
.scrub-tip.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.tip-imgs { display: flex; justify-content: center; }
.tip-imgs img { width: 92px; height: 130px; display: block; background: var(--fill); object-fit: cover; }
.tip-imgs img:first-child { border-radius: 5px 0 0 5px; }
.tip-imgs img:last-child { border-radius: 0 5px 5px 0; }
.tip-imgs img:only-of-type, .tip-imgs img[hidden] + img, .tip-imgs.one img { border-radius: 5px; }
.tip-imgs img[hidden] { display: none; }
.tip-t1 { margin-top: 7px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.tip-t2 { font-size: 11.5px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* phone / portrait chip bar */
.chipbar {
  position: fixed; z-index: 10; inset: auto 0 0 0;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  border-top: .5px solid var(--glass-line);
  transition: transform .5s var(--ease-sheet);
}
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 0 16px; scroll-padding: 0 16px;
  scrollbar-width: none; overscroll-behavior-x: contain; touch-action: pan-x;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 15px 0 12px; border-radius: 19px;
  background: var(--fill); color: var(--text); font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background-color .35s, color .35s, transform .15s;
}
.chip svg.i { width: 18px; height: 18px; }
.chip:active { transform: scale(.96); }
.chip.active { background: var(--hp-blue); color: #fff; }
.chip.all { background: transparent; box-shadow: inset 0 0 0 1px var(--fill-2); }

.app[data-mode="spread"] .chipbar,
.app[data-mode="single"] .capsule { display: none; }
.app.chrome-hidden .topbar { transform: translateY(-110%); }
.app.chrome-hidden .chipbar { transform: translateY(110%); }
.app.chrome-hidden .capsule { transform: translate(-50%, 160%); }

/* ───────────── Contents sheet ───────────── */
.scrim { position: fixed; inset: 0; z-index: 20; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .45s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 21; left: 50%; top: 50%;
  width: min(1000px, calc(100% - 48px)); height: min(780px, calc(100% - 96px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border-radius: 22px;
  box-shadow: 0 0 0 .5px var(--glass-line), 0 40px 100px -20px rgba(0,0,0,.45);
  opacity: 0; transform: translate(-50%, -47%) scale(.965); pointer-events: none;
  /* hidden once closed, so a breakpoint change (e.g. rotating a phone) can't animate a ghost sheet into view */
  visibility: hidden;
  transition: opacity .3s, transform .55s var(--ease-sheet), visibility 0s linear .55s;
}
.sheet.open { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; visibility: visible; transition-delay: 0s; }
.sheet-grabber { display: none; }
.sheet-head { display: flex; align-items: center; gap: 16px; padding: 22px 20px 16px 28px; }
.sheet-head h2 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.02em; flex: 1; }
.sheet-close { background: var(--fill); }
.segmented { position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 2px; border-radius: 9px; background: var(--fill); }
.segmented button { position: relative; z-index: 1; height: 30px; padding: 0 18px; border-radius: 7px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.seg-ind { position: absolute; top: 2px; bottom: 2px; left: 2px; width: calc(50% - 2px); border-radius: 7px; background: var(--seg-ind);
  box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.04); transition: transform .4s var(--ease-sheet); }
.segmented[data-v="pages"] .seg-ind { transform: translateX(100%); }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 28px 32px; -webkit-overflow-scrolling: touch; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.cat-card {
  display: flex; flex-direction: column; text-align: left; overflow: hidden;
  border-radius: 18px; background: var(--surface-2);
  transition: transform .35s var(--ease-out), box-shadow .35s;
}
.cat-card:hover { transform: translateY(-3px); box-shadow: 0 16px 34px -14px rgba(0,0,0,.3); }
.cat-card.current { box-shadow: inset 0 0 0 2px var(--hp-blue); }
.cat-thumb { position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden; }
.cat-thumb img {
  position: absolute; left: 50%; top: 16px; width: 54%; height: auto; aspect-ratio: 2480 / 3508;
  transform: translateX(-50%); object-fit: cover; background: #fff; border-radius: 4px;
  box-shadow: 0 10px 24px -10px rgba(0,0,0,.4); transition: transform .45s var(--ease-out);
}
.cat-card:hover .cat-thumb img { transform: translateX(-50%) translateY(-4px) scale(1.02); }
.cat-meta { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 14px 16px 16px; }
.cat-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--hp-blue); color: #fff; }
.cat-icon svg.i { width: 19px; height: 19px; }
.cat-name { display: block; font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; }
.cat-desc { display: block; font-size: 12.5px; color: var(--text-2); }
.cat-pages { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; align-self: start; padding-top: 2px; }

.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 26px 18px; }
.spread-thumb { display: flex; flex-direction: column; align-items: center; gap: 9px; border-radius: 8px; }
.spread-imgs { display: flex; justify-content: center; width: 100%; aspect-ratio: 1.414; }
.page-grid.single .spread-imgs { aspect-ratio: 2480 / 3508; }
.spread-imgs img { height: 100%; width: auto; min-width: 0; max-width: 50%; aspect-ratio: 2480 / 3508; object-fit: cover; background: #fff; box-shadow: 0 6px 16px -8px rgba(0,0,0,.35); transition: transform .35s var(--ease-out); }
.spread-imgs img:only-child { max-width: 100%; }
.page-grid.single .spread-imgs img { border-radius: 3px; }
.spread-thumb:hover .spread-imgs img { transform: translateY(-3px); }
.spread-thumb.current .spread-imgs { outline: 2px solid var(--hp-blue); outline-offset: 5px; border-radius: 3px; }
.spread-label { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.spread-thumb.current .spread-label { color: var(--accent-text); font-weight: 600; }

@media (max-width: 640px) {
  .sheet {
    left: 0; top: auto; bottom: 0; width: 100%; height: 90%;
    border-radius: 22px 22px 0 0; opacity: 1; transform: translateY(105%);
  }
  .sheet.open { transform: translateY(0); }
  .sheet.dragging { transition: none; }
  .sheet-grabber { display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--fill-2); margin: 8px auto 0; flex: none; }
  .sheet-head { flex-wrap: wrap; padding: 10px 16px 12px 20px; gap: 12px; }
  .sheet-head h2 { font-size: 22px; }
  .segmented { order: 3; width: 100%; }
  .sheet-body { padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); }
  .cat-grid { grid-template-columns: 1fr; gap: 12px; }
  .cat-card { flex-direction: row; align-items: center; }
  .cat-thumb { width: 96px; flex: none; aspect-ratio: auto; height: 124px; overflow: visible; }
  .cat-thumb img { top: 12px; left: 14px; width: 72px; transform: none; }
  .cat-card:hover .cat-thumb img { transform: none; }
  .cat-meta { grid-template-columns: 1fr; align-content: center; gap: 6px; padding: 12px 14px 12px 10px; }
  .cat-icon { width: 28px; height: 28px; border-radius: 8px; }
  .cat-icon svg.i { width: 16px; height: 16px; }
  .cat-pages { padding: 0; }
  .page-grid { grid-template-columns: repeat(2, 1fr); gap: 20px 12px; }
  .page-grid.single { grid-template-columns: repeat(3, 1fr); gap: 18px 12px; }
}

/* ───────────── Toast & splash ───────────── */
.toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(var(--bottom-h, 80px) + 20px);
  padding: 10px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  background: rgba(29, 29, 31, .92); color: #fff;
  opacity: 0; transform: translate(-50%, 10px); pointer-events: none;
  transition: opacity .3s, transform .45s var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.splash { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 28px; background: var(--bg); transition: opacity .7s ease .1s, visibility .8s; }
.app.ready .splash { opacity: 0; visibility: hidden; }
.splash img { display: block; animation: breathe 1.8s ease-in-out infinite; }
.splash-bar { width: 120px; height: 3px; border-radius: 2px; background: var(--fill-2); overflow: hidden; }
.splash-bar i { display: block; height: 100%; width: 8%; background: var(--hp-blue); border-radius: inherit; transition: width .5s var(--ease-out); }
@keyframes breathe { 50% { transform: scale(.94); opacity: .82; } }

::view-transition-old(root), ::view-transition-new(root) { animation-duration: .45s; animation-timing-function: cubic-bezier(.22, 1, .36, 1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
