/* nivellipso Product Catalogue 2026 - interactive reader
   Design language: the catalogue's own Swiss system - white paper, black ink, one red. */

:root {
  --red: #e30613;
  --red-ink: #c00010;
  --red-wash: rgba(227, 6, 19, .09);
  --red-hl: rgba(227, 6, 19, .22);

  --stage: #ecebe7;
  --chrome: #ffffff;
  --panel: #ffffff;
  --field: #f2f2ef;
  --hover: #f0f0ec;
  --ink: #111111;
  --ink-2: #4c4c4a;
  --ink-3: #8b8b87;
  --line: #e3e3de;
  --line-2: #d3d3cd;
  --numeral: #e2e1dc;
  --sheet: #ffffff;
  --tip: #111111;
  --tip-ink: #ffffff;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 1px rgba(0, 0, 0, .04);
  --shadow-2: 0 6px 18px -6px rgba(0, 0, 0, .18), 0 2px 6px -2px rgba(0, 0, 0, .08);
  --shadow-3: 0 24px 60px -18px rgba(0, 0, 0, .35), 0 8px 20px -8px rgba(0, 0, 0, .18);
  --book-shadow: 0 34px 70px -26px rgba(0, 0, 0, .42), 0 10px 24px -10px rgba(0, 0, 0, .22);

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --t: 200ms;

  --bar-h: 60px;
  --dock-h: 64px;
  --panel-w: 372px;
  --r: 6px;

  --font: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --stage: #151516;
  --chrome: #0e0e0f;
  --panel: #111112;
  --field: #1d1d1f;
  --hover: #1f1f21;
  --ink: #f2f2ef;
  --ink-2: #b9b9b4;
  --ink-3: #7d7d79;
  --line: #262628;
  --line-2: #333336;
  --numeral: #1e1e20;
  --tip: #f2f2ef;
  --tip-ink: #111;
  --red-wash: rgba(227, 6, 19, .16);
  --book-shadow: 0 34px 80px -24px rgba(0, 0, 0, .8), 0 10px 26px -10px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --stage: #151516;
    --chrome: #0e0e0f;
    --panel: #111112;
    --field: #1d1d1f;
    --hover: #1f1f21;
    --ink: #f2f2ef;
    --ink-2: #b9b9b4;
    --ink-3: #7d7d79;
    --line: #262628;
    --line-2: #333336;
    --numeral: #1e1e20;
    --tip: #f2f2ef;
    --tip-ink: #111;
    --red-wash: rgba(227, 6, 19, .16);
    --book-shadow: 0 34px 80px -24px rgba(0, 0, 0, .8), 0 10px 26px -10px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 var(--font);
  font-feature-settings: "cv11", "ss01";
  color: var(--ink);
  background: var(--stage);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
kbd {
  font: 600 11px/1 var(--font); display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 4px;
  border: 1px solid var(--line-2); border-bottom-width: 2px; color: var(--ink-2); background: var(--chrome);
}
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.search input:focus-visible, .field input:focus-visible, .pager__goto input:focus-visible { outline: none; }
[hidden] { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- app frame ---------- */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: var(--bar-h) 1fr var(--dock-h);
  grid-template-areas: "bar" "stage" "dock";
}

/* ---------- top bar ---------- */
.bar {
  grid-area: bar;
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px 0 10px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 30;
  min-width: 0;
}
.brand { display: flex; align-items: center; height: 100%; padding: 0 4px; flex: none; }
.brand__logo { height: 30px; width: auto; display: block; }
.brand__logo--dark { display: none; }
:root[data-theme="dark"] .brand__logo--light { display: none; }
:root[data-theme="dark"] .brand__logo--dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand__logo--light { display: none; }
  :root:not([data-theme="light"]) .brand__logo--dark { display: block; }
}
.bar__title {
  flex: none; padding-left: 14px; border-left: 1px solid var(--line);
  font-size: 13px; font-weight: 600; letter-spacing: .01em; color: var(--ink); white-space: nowrap;
}
.bar__title b { color: var(--red); font-weight: 700; }

.crumb {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: baseline; justify-content: center; gap: 8px;
  font-size: 13px; color: var(--ink-2); white-space: nowrap;
}
.crumb__no { color: var(--red); font-weight: 700; font-variant-numeric: tabular-nums; }
.crumb__ch { color: var(--ink); font-weight: 600; }
.crumb__sep { color: var(--line-2); }
.crumb__sec { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumb > * { animation: crumbIn 260ms var(--ease) both; }
@keyframes crumbIn { from { opacity: 0; transform: translateY(3px); } }

.bar__tools { display: flex; align-items: center; gap: 4px; flex: none; }

.btn-icon {
  position: relative;
  width: 38px; height: 38px; border-radius: var(--r);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2);
  transition: background var(--t) var(--ease), color var(--t) var(--ease), transform 120ms var(--ease);
}
.btn-icon:hover { background: var(--hover); color: var(--ink); }
.btn-icon:active { transform: scale(.94); }
.btn-icon[aria-pressed="true"] { color: var(--red); }
.btn-icon[aria-pressed="true"] svg { fill: var(--red); }
.btn-icon:disabled { opacity: .3; pointer-events: none; }

.search {
  position: relative; display: flex; align-items: center;
  width: clamp(220px, 22vw, 320px); height: 38px; margin-right: 6px;
  background: var(--field); border: 1px solid transparent; border-radius: var(--r);
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.search:focus-within { background: var(--chrome); border-color: var(--ink); box-shadow: 0 0 0 3px var(--red-wash); }
.search__icon { position: absolute; left: 10px; width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.search input {
  width: 100%; height: 100%; border: 0; background: none; padding: 0 34px 0 36px; font-size: 13.5px;
}
.search input::placeholder { color: var(--ink-3); }
.search input::-webkit-search-cancel-button { display: none; }
.search__kbd { position: absolute; right: 9px; pointer-events: none; }
.search:focus-within .search__kbd { opacity: 0; }

.only-narrow { display: none !important; }

/* ---------- panel ---------- */
/* The panel always slides OVER the stage (transform only): the stage, and with it the book, is never
   resized when it opens or closes, so nothing is re-measured or rebuilt. On wide screens the book
   glides aside with a transform instead (JS sideShift). */
.panel {
  position: fixed; left: 0; top: var(--bar-h); bottom: var(--dock-h); z-index: 28;
  width: var(--panel-w); overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  transform: translate3d(-100%, 0, 0); visibility: hidden;
  transition: transform 320ms var(--ease), visibility 0s linear 320ms, box-shadow 320ms var(--ease);
}
.app.panel-open .panel {
  transform: none; visibility: visible; box-shadow: var(--shadow-3);
  transition: transform 320ms var(--ease), visibility 0s, box-shadow 320ms var(--ease);
}
.app.panel-open.panel-side .panel { box-shadow: 14px 0 34px -22px rgba(0, 0, 0, .35); }
.book-host, .scroll__col { transition: transform 320ms var(--ease); }
.app.panel-side .turn--prev { translate: var(--panel-w) 0; }   /* own property: keeps the :active scale */
.app.panel-side .grid { padding-left: calc(var(--panel-w) + clamp(16px, 4vw, 56px)); }
.panel__head {
  flex: none; display: flex; align-items: center; gap: 4px;
  width: var(--panel-w); padding: 10px 8px 0 16px; border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 2px; flex: 1; min-width: 0; }
.tab {
  position: relative; height: 40px; padding: 0 9px; font-size: 13px; font-weight: 600; color: var(--ink-3);
  white-space: nowrap; transition: color var(--t) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab::after {
  content: ""; position: absolute; left: 9px; right: 9px; bottom: -1px; height: 2px; background: var(--red);
  transform: scaleX(0); transition: transform 260ms var(--ease);
}
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tab__n { color: var(--red); font-variant-numeric: tabular-nums; }
.tab__n:empty { display: none; }
.panel__close { flex: none; margin-bottom: 1px; }
.panel__body { flex: 1; min-height: 0; overflow-y: auto; width: var(--panel-w); overscroll-behavior: contain; }
.pane { padding: 14px 10px 28px 16px; }

.field {
  position: relative; display: flex; align-items: center; height: 38px; margin: 0 6px 12px 0;
  background: var(--field); border-radius: var(--r); border: 1px solid transparent;
}
.field:focus-within { border-color: var(--ink); background: var(--chrome); }
.field svg { position: absolute; left: 10px; width: 17px; height: 17px; color: var(--ink-3); }
.field input { width: 100%; height: 100%; border: 0; background: none; padding: 0 12px 0 34px; font-size: 13.5px; }
.field input::placeholder { color: var(--ink-3); }

/* contents */
.toc { list-style: none; margin: 0; padding: 0; }
.toc__group { margin: 0 0 2px; }
.toc__group--front { margin-bottom: 10px; }
.toc__ch {
  width: 100%; display: grid; grid-template-columns: 30px 1fr auto; align-items: baseline; gap: 4px;
  padding: 9px 8px 9px 8px; border-radius: var(--r); text-align: left;
  transition: background var(--t) var(--ease);
}
.toc__ch:hover { background: var(--hover); }
.toc__no { font-weight: 700; color: var(--red); font-variant-numeric: tabular-nums; font-size: 13px; }
.toc__title { font-weight: 600; font-size: 14px; color: var(--ink); }
.toc__pg { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; padding-left: 8px; }
.toc__secs { list-style: none; margin: 0 0 6px; padding: 0; display: none; }
.toc__group.open .toc__secs { display: block; }
.toc__sec {
  width: 100%; display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 8px;
  padding: 6px 8px 6px 42px; border-radius: var(--r); text-align: left; font-size: 13px; color: var(--ink-2);
  position: relative; transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.toc__sec:hover { background: var(--hover); color: var(--ink); }
.toc__sec .toc__pg { padding: 0; }
.toc__sec.current, .toc__ch.current .toc__title { color: var(--ink); font-weight: 600; }
.toc__sec.current::before {
  content: ""; position: absolute; left: 30px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px;
  border-radius: 50%; background: var(--red);
}
.toc__sec.current .toc__pg, .toc__ch.current .toc__pg { color: var(--red); }
.toc__empty { color: var(--ink-3); padding: 12px 8px; font-size: 13px; }
.toc mark { background: none; color: var(--red); font-weight: 700; }

/* search results */
.results__meta { font-size: 12px; color: var(--ink-3); margin: 0 6px 10px 2px; display: flex; justify-content: space-between; gap: 8px; }
.result {
  width: 100%; display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start;
  padding: 10px 8px; border-radius: var(--r); text-align: left;
  transition: background var(--t) var(--ease);
}
.result:hover, .result.focus { background: var(--hover); }
.result img { width: 44px; height: 62px; object-fit: cover; border-radius: 2px; background: var(--field); box-shadow: var(--shadow-1); }
.result__head { display: flex; gap: 6px; align-items: baseline; font-size: 13px; margin-bottom: 3px; }
.result__pg { font-weight: 700; color: var(--red); font-variant-numeric: tabular-nums; white-space: nowrap; }
.result__title { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result__snip { font-size: 12.5px; line-height: 1.45; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.result__snip mark, .partcard mark { background: var(--red-wash); color: var(--ink); font-weight: 600; border-radius: 2px; padding: 0 1px; }
.result__n { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }

.partcard {
  margin: 0 6px 14px 0; padding: 14px; border-radius: 8px; background: var(--field);
  display: grid; gap: 10px;
}
.partcard__code { font-size: 20px; font-weight: 700; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.partcard__where { font-size: 12.5px; color: var(--ink-2); }
.partcard__where button { color: var(--red); font-weight: 600; }
.partcard__where button:hover { text-decoration: underline; }
.partcard__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { color: var(--ink-3); font-size: 13px; padding: 18px 8px; line-height: 1.6; }
.empty b { color: var(--ink); font-weight: 600; }
.empty__title { font-size: 15px; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.hint-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 28px; padding: 0 10px; border-radius: 14px; background: var(--field); font-size: 12.5px; color: var(--ink-2);
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.chip:hover { background: var(--hover); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }

/* saved */
.saved { list-style: none; margin: 0; padding: 0; }
.saved li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px; }
.saved .result { grid-template-columns: 44px 1fr; }
.label-sm { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin: 2px 0 8px; }


/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 13px;
  border-radius: var(--r); font-size: 13px; font-weight: 600;
  background: var(--chrome); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2);
  transition: background var(--t) var(--ease), box-shadow var(--t) var(--ease), transform 120ms var(--ease), color var(--t) var(--ease);
  white-space: nowrap;
}
.btn:hover { box-shadow: inset 0 0 0 1px var(--ink-3); }
.btn:active { transform: scale(.97); }
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: var(--red); color: #fff; box-shadow: none; }
.btn--primary:hover { background: var(--red-ink); box-shadow: none; }
.btn--quiet { box-shadow: none; background: transparent; color: var(--red); padding: 0 8px; }
.btn--quiet:hover { box-shadow: none; background: var(--red-wash); }
.btn:disabled { opacity: .4; pointer-events: none; }

/* ---------- stage ---------- */
.stage {
  grid-area: stage; position: relative; overflow: hidden; min-width: 0; min-height: 0;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, .045) 100%),
    var(--stage);
}
.stage__numeral {
  position: absolute; left: clamp(12px, 2.4vw, 40px); bottom: -.16em;
  font-size: clamp(160px, 44vh, 520px); font-weight: 800; line-height: 1; letter-spacing: -.055em;
  color: var(--numeral); font-variant-numeric: tabular-nums; pointer-events: none; user-select: none;
  transition: opacity 500ms var(--ease), transform 600ms var(--ease);
}
.stage__numeral.swap { opacity: 0; transform: translateY(.06em); }
.stage__spine {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl; font-size: 10px; font-weight: 600; letter-spacing: .32em; text-transform: uppercase;
  color: var(--ink-3); opacity: .7; pointer-events: none; white-space: nowrap;
}

.view { position: absolute; inset: 0; }

/* book */
.view--book { padding: 26px 76px 30px; }
.book-host { position: relative; width: 100%; height: 100%; }
.book-host > .book-root.stf__parent {
  position: absolute; inset: 0; width: 100%; height: 100%;
  will-change: transform;          /* centring is driven per frame from the flip progress - no CSS transition */
}
.book-root .stf__wrapper { position: relative; width: 100%; height: 100%; }
.book-root.jump .stf__block { animation: jumpIn 300ms var(--ease) both; }
@keyframes jumpIn { from { opacity: .25; } }
.book-shadow {
  position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none;
  box-shadow: var(--book-shadow);
  opacity: 0; transition: opacity 300ms var(--ease);
  will-change: transform;
}
.book-shadow.on { opacity: 1; }

.page { background: var(--sheet); overflow: hidden; }
.page__img {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.page__shade { position: absolute; inset: 0; pointer-events: none; }
.stf__wrapper.--landscape .page.--left .page__shade {
  background: linear-gradient(to left, rgba(0, 0, 0, .13) 0, rgba(0, 0, 0, .05) 1.6%, rgba(0, 0, 0, 0) 6%);
}
.stf__wrapper.--landscape .page.--right .page__shade {
  background: linear-gradient(to right, rgba(0, 0, 0, .14) 0, rgba(255, 255, 255, .25) .6%, rgba(0, 0, 0, .04) 2%, rgba(0, 0, 0, 0) 7%);
}
.view--book .book-host { cursor: default; touch-action: pan-y; }
.view--book .book-host.over-page { cursor: zoom-in; }
.view--book .book-host.over-target { cursor: pointer; }
.view--book .book-host.grabbing { cursor: grabbing; }

/* click / hover overlay above the book: never blocks a drag (pointer-events: none), hidden while a page moves */
.book-ui { position: absolute; inset: 0; z-index: 4; pointer-events: none; transition: opacity 160ms var(--ease); }
.book-ui.off { opacity: 0; transition: none; }
.book-ui__page { position: absolute; }
.hs-mark { position: absolute; border-bottom: 1.5px solid rgba(227, 6, 19, .6); }
.hover-box {
  position: absolute; border-radius: 2px;
  background: rgba(227, 6, 19, .08); box-shadow: inset 0 0 0 1.5px rgba(227, 6, 19, .6);
}

/* first-load screen + background page loading */
.loader {
  position: absolute; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--stage); transition: opacity 420ms var(--ease);
}
.loader.gone { opacity: 0; pointer-events: none; }
.loader__logo { height: 56px; width: auto; display: block; }
.loader .brand__logo--dark { display: none; }
:root[data-theme="dark"] .loader .brand__logo--light { display: none; }
:root[data-theme="dark"] .loader .brand__logo--dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .loader .brand__logo--light { display: none; }
  :root:not([data-theme="light"]) .loader .brand__logo--dark { display: block; }
}
.loader__bar { width: 160px; height: 2px; background: var(--line-2); overflow: hidden; border-radius: 1px; }
.loader__bar i { display: block; height: 100%; background: var(--red); transform-origin: 0 50%; transform: scaleX(0); transition: transform 240ms var(--ease); }
.loader p { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.loader p b { color: var(--red); }
.preload { position: absolute; left: 0; right: 0; top: 0; height: 2px; z-index: 6; pointer-events: none; transition: opacity 500ms 400ms var(--ease); }
.preload i { display: block; height: 100%; background: var(--red); transform-origin: 0 50%; transform: scaleX(0); transition: transform 300ms var(--ease); }
.preload.done { opacity: 0; }

/* layers shared by book, scroll and zoom pages */
.layer { position: absolute; inset: 0; pointer-events: none; }
.hl {
  position: absolute; background: var(--red-hl); border-radius: 1px;
  box-shadow: 0 1.5px 0 0 var(--red);
  animation: hlIn 520ms var(--ease) both;
}
@keyframes hlIn { from { opacity: 0; transform: scale(1.6); } }
.hs {
  position: absolute; pointer-events: auto; display: block; border-radius: 2px;
  cursor: pointer; background: transparent;
  transition: background 160ms var(--ease), box-shadow 160ms var(--ease);
}
.hs:hover, .hs:focus-visible { background: rgba(227, 6, 19, .07); box-shadow: inset 0 0 0 1.5px rgba(227, 6, 19, .55); }
.hs--link { box-shadow: inset 0 -1.5px 0 rgba(227, 6, 19, .55); }
.textlayer { position: absolute; inset: 0; line-height: 1; color: transparent; pointer-events: none; }
.textlayer span {
  position: absolute; white-space: pre; transform-origin: 0 0; cursor: text;
  font-family: var(--font); font-weight: 500;
}
.textlayer span::selection { background: rgba(227, 6, 19, .28); color: transparent; }
.sel-text .textlayer { pointer-events: auto; user-select: text; }
.sel-text .textlayer span { pointer-events: auto; }

/* page-turn buttons */
.turn {
  position: absolute; top: 50%; width: 44px; height: 64px; margin-top: -32px; border-radius: var(--r);
  display: grid; place-items: center; color: var(--ink-2); z-index: 5;
  transition: background var(--t) var(--ease), color var(--t) var(--ease), opacity var(--t) var(--ease), transform 140ms var(--ease), translate 320ms var(--ease);
}
.turn svg { width: 26px; height: 26px; stroke-width: 1.4; }
.turn:hover { background: var(--chrome); color: var(--ink); box-shadow: var(--shadow-2); }
.turn:active { transform: scale(.95); }
.turn--prev { left: 16px; }
.turn--next { right: 16px; }
.turn:disabled { opacity: 0; pointer-events: none; }

/* scroll */
.scroll { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; scroll-padding-top: 16px; }
.scroll__col { width: min(900px, calc(100% - 48px)); margin: 0 auto; padding: 22px 0 60px; }
.spage { margin: 0 0 30px; }
.spage__label {
  display: flex; align-items: baseline; gap: 10px; margin: 0 2px 8px; font-size: 12.5px; color: var(--ink-3);
}
.spage__label b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.spage__label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spage__label i { font-style: normal; color: var(--red); font-weight: 700; margin-left: auto; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.sheet {
  position: relative; width: 100%; aspect-ratio: 596 / 842; background: var(--sheet);
  box-shadow: var(--shadow-2); container-type: inline-size; overflow: hidden;
}
.sheet .page__img { opacity: 1; }
.scroll .textlayer { pointer-events: auto; user-select: text; }
.scroll .textlayer span { pointer-events: auto; }

/* grid */
.grid { position: absolute; inset: 0; overflow-y: auto; padding: 26px clamp(16px, 4vw, 56px) 60px; overscroll-behavior: contain; }
.gsec { max-width: 1320px; margin: 0 auto 34px; }
.gsec__head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line-2); }
.gsec__no { font-size: 28px; font-weight: 800; letter-spacing: -.03em; color: var(--red); font-variant-numeric: tabular-nums; line-height: 1; }
.gsec__title { font-size: 17px; font-weight: 700; }
.gsec__range { margin-left: auto; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.gsec__tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 22px 16px; }
.tile { text-align: left; display: block; align-self: start; }
.tile__img {
  position: relative; display: block; aspect-ratio: 596 / 842; background: var(--sheet); overflow: hidden;
  box-shadow: var(--shadow-1); transition: transform 260ms var(--ease), box-shadow 260ms var(--ease);
}
.tile__img img { width: 100%; height: 100%; display: block; object-fit: cover; }
.tile:hover .tile__img { transform: translateY(-3px); box-shadow: var(--shadow-3); }
.tile.current .tile__img { box-shadow: 0 0 0 2px var(--red), var(--shadow-2); }
.tile__mark { position: absolute; top: 0; right: 10px; width: 12px; height: 18px; background: var(--red); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }
.tile__cap { display: flex; gap: 6px; margin-top: 8px; font-size: 12px; line-height: 1.35; }
.tile__cap b { color: var(--ink); font-variant-numeric: tabular-nums; flex: none; }
.tile__cap span { color: var(--ink-3); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* zoom */
.zoom { position: absolute; inset: 0; z-index: 12; background: var(--stage); animation: fadeIn 200ms var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
.zoom__viewport { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
.zoom__viewport.dragging { cursor: grabbing; }
.zoom.sel-text .zoom__viewport { cursor: default; }
.zoom__content { position: absolute; left: 0; top: 0; display: flex; transform-origin: 0 0; will-change: transform; }
.zpage { position: relative; background: var(--sheet); container-type: inline-size; overflow: hidden; flex: none; }
.zpage .page__img { opacity: 1; }
.zoom__content { box-shadow: var(--book-shadow); }
.zoom__label {
  position: absolute; left: 18px; top: 14px; z-index: 2; font-size: 12.5px; color: var(--ink-2);
  background: var(--chrome); padding: 6px 10px; border-radius: var(--r); box-shadow: var(--shadow-1);
}
.zoom__label b { color: var(--ink); font-variant-numeric: tabular-nums; }
.zoom__tools {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 2;
  display: flex; align-items: center; gap: 2px; padding: 5px; border-radius: 10px;
  background: var(--chrome); box-shadow: var(--shadow-3);
  animation: toolsIn 320ms var(--ease) both;
}
@keyframes toolsIn { from { opacity: 0; transform: translate(-50%, 12px); } }
.zoom__sep { width: 1px; height: 22px; background: var(--line); margin: 0 5px; }
.zoom__pct { min-width: 56px; height: 38px; border-radius: var(--r); font-weight: 600; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.zoom__pct:hover { background: var(--hover); }

/* ---------- dock ---------- */
.dock {
  grid-area: dock; position: relative; z-index: 30;
  display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 18px;
  padding: 0 14px; background: var(--chrome); border-top: 1px solid var(--line);
}
.seg { display: inline-flex; padding: 3px; border-radius: 8px; background: var(--field); gap: 2px; }
.seg__btn {
  height: 32px; padding: 0 11px; border-radius: 6px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-3);
  transition: background var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.seg__btn svg { width: 18px; height: 18px; }
.seg__btn:hover { color: var(--ink); }
.seg__btn[aria-checked="true"] { background: var(--chrome); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.seg--sm .seg__btn { height: 32px; width: 34px; padding: 0; justify-content: center; }
.seg--full { display: flex; }
.seg--full .seg__btn { flex: 1; justify-content: center; }

.pager { display: flex; align-items: center; gap: 2px; }
/* one line box: "1" and "/ 91" share a baseline and sit centred with the arrows */
.pager__count {
  height: 38px; min-width: 92px; padding: 0 10px; border-radius: var(--r);
  display: inline-block; line-height: 38px; text-align: center; white-space: nowrap;
  font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums;
}
.pager__count:hover { background: var(--hover); }
.pager__of { color: var(--ink-3); font-weight: 500; font-size: 12.5px; margin-left: 5px; }
.pager__goto input {
  width: 92px; height: 38px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums;
  border: 1px solid var(--ink); border-radius: var(--r); background: var(--chrome); box-shadow: 0 0 0 3px var(--red-wash);
}

.rail { position: relative; height: 44px; min-width: 0; cursor: pointer; touch-action: none; }
.rail__track { position: absolute; left: 0; right: 0; top: 0; bottom: 0; display: flex; gap: 3px; }
.rseg { position: relative; height: 100%; min-width: 0; }
/* reading progress: --fill is animatable so the bar fills in step with the sliding marker */
@property --fill { syntax: "<percentage>"; inherits: true; initial-value: 0%; }
.rseg::before {
  content: ""; position: absolute; left: 0; right: 0; top: 24px; height: 4px; border-radius: 1px;
  background: linear-gradient(to right, var(--ink-2) var(--fill), var(--line-2) var(--fill));
  transition: height 160ms var(--ease), top 160ms var(--ease);
}
.rseg { --fill: 0%; transition: --fill 420ms var(--ease); }
.rail.scrubbing .rseg { transition: none; }
.rseg__no {
  position: absolute; left: 0; top: 6px; font-size: 10.5px; font-weight: 700; color: var(--ink-3);
  font-variant-numeric: tabular-nums; letter-spacing: .02em; transition: color var(--t) var(--ease);
  white-space: nowrap;
}
.rseg.narrow .rseg__no { display: none; }
.rseg.active .rseg__no { color: var(--red); }
.rail:hover .rseg::before { top: 23px; height: 6px; }
.rseg__mark { position: absolute; top: 31px; width: 3px; height: 3px; border-radius: 50%; background: var(--red); transform: translateX(-50%); }
.rail__marker {
  position: absolute; top: 18px; width: 4px; height: 16px; margin-left: -2px; border-radius: 1px;
  background: var(--red); box-shadow: 0 0 0 2px var(--chrome); pointer-events: none;
  transition: left 420ms var(--ease);
}
.rail.scrubbing .rail__marker { transition: none; }
.rail__tip {
  position: absolute; bottom: 52px; width: 232px; display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center;
  padding: 8px; border-radius: 8px; background: var(--tip); color: var(--tip-ink); box-shadow: var(--shadow-3);
  pointer-events: none; transform: translateX(-50%);
  animation: tipIn 160ms var(--ease) both;
}
@keyframes tipIn { from { opacity: 0; transform: translate(-50%, 4px); } }
.rail__tip img { width: 64px; height: 90px; object-fit: cover; background: #fff; border-radius: 2px; }
.rail__tip b { display: block; font-size: 12px; font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.rail__tip b em { font-style: normal; color: var(--red); }
.rail__tip span { display: block; font-size: 12px; line-height: 1.35; opacity: .8; }

.btn--zoom { box-shadow: none; background: var(--field); }
.btn--zoom:hover { box-shadow: none; background: var(--hover); }

/* ---------- popovers / overlays ---------- */
.popover {
  position: fixed; z-index: 60; background: var(--chrome); border-radius: 10px; box-shadow: var(--shadow-3), 0 0 0 1px var(--line);
  animation: popIn 200ms var(--ease) both;
}
@keyframes popIn { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.settings { top: calc(var(--bar-h) - 4px); right: 12px; width: 300px; padding: 6px 16px 14px; max-height: calc(100% - var(--bar-h) - 20px); overflow-y: auto; }
.settings__group { padding: 12px 0; border-bottom: 1px solid var(--line); }
.settings__group:last-of-type { border-bottom: 0; }
.settings h3 { margin: 0 0 9px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.settings__row--btns { display: flex; gap: 8px; }
.settings__row--btns .btn { flex: 1; justify-content: center; }
.switch { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 6px 0; font-size: 13.5px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { position: relative; flex: none; width: 36px; height: 21px; border-radius: 11px; background: var(--line-2); transition: background var(--t) var(--ease); }
.switch i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform 240ms var(--ease); }
.switch input:checked + i { background: var(--red); }
.switch input:checked + i::after { transform: translateX(15px); }
.switch input:focus-visible + i { outline: 2px solid var(--red); outline-offset: 2px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; margin: 0; font-size: 13px; align-items: center; }
.keys dt { display: flex; gap: 3px; }
.keys dd { margin: 0; color: var(--ink-2); }
.settings__about { margin: 12px 0 0; font-size: 12px; line-height: 1.55; color: var(--ink-3); }
.settings__about a { color: var(--ink-2); }


.toast {
  position: absolute; left: 50%; bottom: 22px; z-index: 40; transform: translate(-50%, 16px);
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px);
  padding: 10px 12px 10px 16px; border-radius: 8px; background: var(--tip); color: var(--tip-ink);
  font-size: 13px; box-shadow: var(--shadow-3); opacity: 0; pointer-events: none;
  transition: opacity 220ms var(--ease), transform 320ms var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { color: var(--red); font-weight: 700; padding: 4px 6px; border-radius: 4px; white-space: nowrap; }
:root[data-theme="dark"] .toast button { color: var(--red-ink); }

.coach {
  position: absolute; left: 50%; bottom: 22px; z-index: 41; transform: translateX(-50%);
  width: min(560px, calc(100% - 32px)); display: flex; align-items: center; gap: 14px;
  padding: 12px 12px 12px 16px; border-radius: 10px; background: var(--chrome); box-shadow: var(--shadow-3), 0 0 0 1px var(--line);
  animation: toolsIn 420ms 600ms var(--ease) both;
}
.coach p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.55; }
.coach b { color: var(--ink); font-weight: 600; }
.coach kbd { transform: translateY(-1px); }

.scrim { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .32); animation: fadeIn 220ms var(--ease); }

.modal { border: 0; border-radius: 12px; padding: 0; background: var(--chrome); color: var(--ink); box-shadow: var(--shadow-3); max-width: min(960px, 92vw); width: max-content; }
.modal::backdrop { background: rgba(0, 0, 0, .55); }
.modal__close { position: absolute; top: 8px; right: 8px; z-index: 2; }
.modal__close .btn-icon { background: var(--chrome); }
.modal__body { padding: 20px; }
.modal__body video, .modal__body iframe, .modal__body img { display: block; max-width: 100%; max-height: 78vh; border: 0; }
.modal__body iframe { width: min(880px, 86vw); aspect-ratio: 16 / 9; height: auto; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .crumb { justify-content: flex-start; }
}
@media (max-width: 980px) {
  .bar__title { display: none; }
  .search { width: 210px; }
  .seg.modes .seg__btn span { display: none; }
  .seg.modes .seg__btn { padding: 0 9px; }
  .btn--zoom span { display: none; }
  .btn--zoom { padding: 0 10px; }
}
@media (max-width: 760px) {
  :root { --bar-h: 54px; --dock-h: 104px; --panel-w: 100vw; }
  .bar { gap: 6px; padding: 0 6px; }
  .brand__logo { height: 26px; }
  .crumb { display: none; }
  .bar__tools { margin-left: auto; gap: 0; }
  .search { display: none; }
  .only-narrow { display: inline-flex !important; }
  .settings__group.only-narrow { display: block !important; }
  .hide-narrow { display: none !important; }
  .panel {
    top: auto; bottom: 0; right: 0; width: 100vw; height: min(86vh, calc(100% - 40px));
    border-radius: 14px 14px 0 0; border: 0; z-index: 50;
    transform: translate3d(0, 100%, 0);
  }
  .panel__head { padding-top: 8px; }
  .panel__head::before {
    content: ""; position: absolute; left: 50%; top: 6px; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line-2);
  }
  .tab { padding: 0 8px; }
  .view--book { padding: 14px 10px 16px; }
  .turn { display: none; }
  .stage__spine { display: none; }
  .stage__numeral { font-size: 34vh; }
  .dock {
    grid-template-columns: auto 1fr auto; grid-template-rows: 40px 1fr; gap: 0 8px; padding: 0 8px 4px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }
  .rail { grid-column: 1 / -1; grid-row: 1; height: 40px; margin: 0 4px; }
  .rseg__no { display: none; }
  .rseg::before { top: 18px; }
  .rail:hover .rseg::before { top: 17px; }
  .rail__marker { top: 12px; }
  .rseg__mark { top: 25px; }
  .rail__tip { bottom: 46px; }
  .pager { justify-self: center; }
  .settings { left: 8px; right: 8px; width: auto; }
  .scroll__col { width: calc(100% - 20px); padding-top: 12px; }
  .zoom__tools { bottom: 10px; max-width: calc(100% - 16px); overflow-x: auto; }
  .zoom__label { left: 10px; top: 10px; }
  .coach { bottom: 12px; flex-direction: column; align-items: stretch; }
  .gsec__tiles { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 16px 12px; }
}
@media (hover: none) {
  .hide-touch { display: none; }
  .search__kbd { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
@media print {
  .bar, .dock, .panel, .turn, .zoom__tools { display: none !important; }
}
