/* ── Neo FlipBook — injected once per document; dist/neo-flipbook.css for CSP-strict sites ── */

.neo-flipbook {
  --neo-bg: #e9e9ee;
  --neo-surface: #ffffff;
  --neo-text: #1b1b20;
  --neo-toolbar-bg: rgba(255, 255, 255, 0.94);
  --neo-btn-fg: #37373f;
  --neo-btn-hover: rgba(0, 0, 0, 0.07);
  --neo-border: rgba(0, 0, 0, 0.12);
  --neo-panel-bg: #ffffff;
  --neo-primary: #2563eb;
  --neo-accent: #f59e0b;
  --neo-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
  --neo-dock-h: 56px;
  --neo-sidenav-inset: 12px;

  position: relative;
  width: 100%;
  height: 100%;
  min-height: 240px;
  overflow: hidden;
  background: var(--neo-bg);
  color: var(--neo-text);
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}

.neo-flipbook[data-neo-theme="dark"] {
  --neo-bg: #17171d;
  --neo-surface: #22222a;
  --neo-text: #e7e7ee;
  --neo-toolbar-bg: rgba(32, 32, 40, 0.94);
  --neo-btn-fg: #d6d6df;
  --neo-btn-hover: rgba(255, 255, 255, 0.1);
  --neo-border: rgba(255, 255, 255, 0.14);
  --neo-panel-bg: #1e1e26;
  --neo-primary: #60a5fa;
  --neo-accent: #fbbf24;
  --neo-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.neo-flipbook[data-neo-theme="sepia"] {
  --neo-bg: #efe6d5;
  --neo-surface: #faf4e8;
  --neo-text: #453a28;
  --neo-toolbar-bg: rgba(250, 244, 232, 0.95);
  --neo-btn-fg: #5d4e36;
  --neo-btn-hover: rgba(90, 70, 40, 0.1);
  --neo-border: rgba(90, 70, 40, 0.2);
  --neo-panel-bg: #f7efdf;
  --neo-primary: #92400e;
  --neo-accent: #b45309;
  --neo-shadow: 0 4px 16px rgba(80, 60, 30, 0.25);
}

/* backgroundImage: the inline image sits over --neo-bg, which shows while it loads */
.neo-flipbook[data-neo-bg-image] {
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.neo-flipbook:focus-visible {
  outline: 2px solid var(--neo-primary);
  outline-offset: -2px;
}

/* ── layers ── */
.neo-stage,
.neo-overlay {
  position: absolute;
  /* ends above the toolbar: ChromeReserve writes the chrome layer's height */
  inset: 0 0 var(--neo-chrome-reserve, 0px) 0;
}
.neo-stage {
  touch-action: none;
  cursor: grab;
}
.neo-stage.neo-peek {
  cursor: pointer;
}
.neo-overlay {
  /* links on a zoomed page stay with it through the floating band */
  bottom: calc(var(--neo-chrome-reserve, 0px) - var(--neo-stage-bleed, 0px));
  pointer-events: none;
  overflow: hidden;
}
.neo-overlay--hidden {
  visibility: hidden;
}
.neo-overlay-page {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  pointer-events: none;
}
.neo-overlay-slot {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.neo-link {
  position: absolute;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  pointer-events: auto;
}
.neo-link:hover,
.neo-link:focus-visible {
  outline: 2px solid var(--neo-primary, #4f7cff);
  outline-offset: 1px;
  background: color-mix(in srgb, var(--neo-primary, #4f7cff) 12%, transparent);
}

/* ── outline (TOC) panel ── */
.neo-outline,
.neo-outline-children {
  margin: 0;
  padding: 0;
  list-style: none;
}
.neo-outline-children {
  padding-left: 18px;
}
.neo-outline-row {
  display: flex;
  align-items: center;
  gap: 2px;
}
.neo-outline-chevron {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
}
.neo-outline-chevron svg {
  transition: transform 0.15s ease;
}
.neo-outline-chevron-open svg {
  transform: rotate(90deg);
}
.neo-outline-chevron-space {
  flex: 0 0 22px;
}
.neo-outline-link {
  display: block;
  flex: 1;
  padding: 6px 8px;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  text-decoration: none;
  color: var(--neo-text);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
button.neo-outline-link:hover,
a.neo-outline-link:hover,
.neo-outline-link:focus-visible {
  background: rgba(128, 128, 128, 0.16);
}
.neo-outline-inert {
  cursor: default;
  opacity: 0.7;
}
@media (prefers-reduced-motion: reduce) {
  .neo-outline-chevron svg {
    transition: none;
  }
}
.neo-panels {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 6;
  pointer-events: none;
}
.neo-chrome {
  position: absolute;
  /* Padding, not a 14px bottom offset: the box reaches the root's edge, so its
     height is the whole band ChromeReserve keeps the page out of. */
  inset: auto 0 0 0;
  padding-bottom: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  z-index: 7;
  /* Lets the toolbar size itself by the BOOK's width: an embed in a narrow
     column on a wide screen never trips a viewport media query. */
  container-type: inline-size;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.neo-chrome > * {
  pointer-events: auto;
}
/* toolbar and page indicator both off: nothing to keep the page clear of */
.neo-chrome:empty {
  display: none;
}

.neo-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 15px;
  letter-spacing: 0.4px;
  color: var(--neo-text);
  opacity: 0.65;
  pointer-events: none;
}

.neo-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  color: var(--neo-text);
}
.neo-password {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 24px;
  font-size: 14px;
  text-align: center;
  color: var(--neo-text);
}
.neo-password-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.neo-password-input {
  padding: 8px 10px;
  font-size: 14px;
  color: var(--neo-text);
  background: var(--neo-surface, rgba(255, 255, 255, 0.06));
  border: 1px solid var(--neo-border, rgba(128, 128, 128, 0.4));
  border-radius: 6px;
  min-width: 180px;
}
.neo-password-submit,
.neo-password-cancel {
  width: auto;
  padding: 0 14px;
}
.neo-password-error {
  color: #e5484d;
}
.neo-error strong {
  font-size: 15px;
}
.neo-error span {
  max-width: 46em;
  opacity: 0.7;
}

.neo-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── buttons / toolbar ── */
.neo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--neo-btn-fg);
  cursor: pointer;
  transition: background 0.15s ease;
}
.neo-btn:hover:not(:disabled) {
  background: var(--neo-btn-hover);
}
.neo-btn:focus-visible {
  outline: 2px solid var(--neo-primary);
  outline-offset: 1px;
}
.neo-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.neo-btn[aria-pressed="true"] {
  color: var(--neo-primary);
  background: var(--neo-btn-hover);
}

/* Same shape as the side-nav pills: rounded rectangle, 44px buttons. */
.neo-toolbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--neo-border);
  background: var(--neo-toolbar-bg);
  box-shadow: var(--neo-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.neo-toolbar .neo-btn {
  width: 44px;
  height: 44px;
  border-radius: 11px;
}
.neo-toolbar .neo-btn svg {
  width: 24px;
  height: 24px;
}
.neo-toolbar-sep {
  width: 1px;
  height: 24px;
  margin: 0 5px;
  background: var(--neo-border);
}

.neo-toolbar-more-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  min-width: 184px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--neo-border);
  background: var(--neo-toolbar-bg);
  box-shadow: var(--neo-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.neo-toolbar-more-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.neo-toolbar-more-item:hover:not(:disabled) {
  background: var(--neo-btn-hover);
}
.neo-toolbar-more-item:disabled {
  opacity: 0.45;
  cursor: default;
}
.neo-toolbar-more-icon {
  display: flex;
  flex: none;
}

/* Matches the toolbar beside it: same corner radius, same 58px outer height. */
.neo-page-indicator {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 0 18px;
  border-radius: 16px;
  border: 1px solid var(--neo-border);
  background: var(--neo-toolbar-bg);
  box-shadow: var(--neo-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  /* Reads at a glance: the pages lead, the total and its slash step back. */
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* Mid-width containers: the 44px bar needs ~810px with the default buttons and
   would overflow long before the phone tier collapses it below 560px, so it
   drops back to the denser 36px buttons, same shape. */
@container (max-width: 899px) {
  .neo-toolbar {
    gap: 2px;
    padding: 5px;
    border-radius: 14px;
  }
  .neo-toolbar .neo-btn {
    width: 36px;
    height: 36px;
    border-radius: 9px;
  }
  .neo-toolbar .neo-btn svg {
    width: 20px;
    height: 20px;
  }
  .neo-page-indicator {
    min-height: 46px;
    padding: 0 12px;
    border-radius: 14px;
    gap: 6px;
    font-size: 15px;
  }
}
/* Padded at rest as well as on focus, so clicking in never shifts the pill;
   the inline width (in ch) sizes the text, the padding sits around it. */
.neo-goto-input {
  padding: 6px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 22px;
  text-align: right;
  transition: background 0.15s ease;
}
.neo-goto-input:hover {
  background: var(--neo-btn-hover);
}
/* Same ring as the toolbar buttons' focus. */
.neo-goto-input:focus {
  outline: 2px solid var(--neo-primary);
  outline-offset: 0;
  background: var(--neo-btn-hover);
}
.neo-goto-sep {
  font-weight: 400;
  opacity: 0.4;
}
.neo-goto-total {
  font-weight: 500;
  opacity: 0.65;
}
/* After the base input rule so it wins; pairs with the mid-width tier above. */
@container (max-width: 899px) {
  .neo-goto-input {
    padding: 5px 7px;
    border-radius: 8px;
  }
}

/* ── toolbar placement: fixed (docked bottom bar) ── */
.neo-flipbook[data-neo-toolbar="fixed"] .neo-chrome {
  inset: auto 0 0 0;
  gap: 0;
  min-height: var(--neo-dock-h);
  padding: 0 10px;
  background: var(--neo-toolbar-bg);
  border-top: 1px solid var(--neo-border);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: auto;
}
/* the pills flatten into the bar — two stacked blur layers otherwise */
.neo-flipbook[data-neo-toolbar="fixed"] .neo-toolbar,
.neo-flipbook[data-neo-toolbar="fixed"] .neo-page-indicator {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.neo-flipbook[data-neo-toolbar="fixed"] .neo-page-indicator {
  margin-left: 12px;
  padding: 0 6px;
}
/* keep drawers clear of the bar — panels never feed Viewport, so this is free */
.neo-flipbook[data-neo-toolbar="fixed"] .neo-panel {
  bottom: var(--neo-dock-h);
}

/* ── navigation: buttonsPlacement 'sides' ──
   One long pill per edge with its two buttons stacked, in reading order:
   first over prev on the left, next over last on the right. */
.neo-sidenav {
  position: absolute;
  /* the stage's middle, which sits above the toolbar band */
  top: calc((100% - var(--neo-chrome-reserve, 0px)) / 2);
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--neo-border);
  background: var(--neo-toolbar-bg);
  box-shadow: var(--neo-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  /* under .neo-panels (6): an open drawer covers the left cluster */
  z-index: 5;
  transition: opacity 0.25s ease;
}
.neo-sidenav--start {
  left: var(--neo-sidenav-inset);
}
.neo-sidenav--end {
  right: var(--neo-sidenav-inset);
}
.neo-sidenav--hidden {
  display: none;
}
/* Tall targets: the whole half of the pill turns the page, not just the icon. */
.neo-sidenav-btn {
  width: 44px;
  height: 76px;
  border-radius: 11px;
}
.neo-sidenav-btn svg {
  width: 28px;
  height: 28px;
}

/* ── navigation: scroll mode reads top to bottom ──
   The arrow paths point sideways; a quarter turn clockwise makes first and
   prev point up, next and last down. Both pills move to the right edge,
   first+prev stacked over next+last, like a scroll control. */
.neo-flipbook[data-neo-nav-axis="vertical"] :is([data-neo-tool^="nav-"], .neo-sidenav-btn) svg {
  transform: rotate(90deg);
}
.neo-flipbook[data-neo-nav-axis="vertical"] .neo-sidenav--start {
  left: auto;
  right: var(--neo-sidenav-inset);
  transform: translateY(calc(-100% - 4px));
}
.neo-flipbook[data-neo-nav-axis="vertical"] .neo-sidenav--end {
  transform: translateY(4px);
}

/* ── panels ── */
.neo-panel {
  position: absolute;
  inset: 0 auto 0 0;
  width: min(300px, 88vw);
  display: flex;
  flex-direction: column;
  background: var(--neo-panel-bg);
  border-right: 1px solid var(--neo-border);
  box-shadow: var(--neo-shadow);
  transform: translateX(-102%);
  transition: transform 0.24s ease;
  pointer-events: auto;
  z-index: 6;
}
.neo-panel--open {
  transform: translateX(0);
}
.neo-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 10px 16px;
  border-bottom: 1px solid var(--neo-border);
}
.neo-panel-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.neo-panel-body {
  position: relative;
  flex: 1;
  min-height: 0;
}

/* ── thumbnails ── */
.neo-thumb-scroller {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 10px 0;
}
.neo-thumb-list {
  position: relative;
}
.neo-thumb {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: inherit;
}
.neo-thumb:focus-visible {
  outline: 2px solid var(--neo-primary);
}
.neo-thumb-canvas {
  width: 100%;
  flex: 1;
  min-height: 0;
  object-fit: contain;
  background: var(--neo-surface);
  border: 1px solid var(--neo-border);
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.neo-thumb-ready .neo-thumb-canvas {
  opacity: 1;
}
.neo-thumb-current .neo-thumb-canvas {
  outline: 2px solid var(--neo-primary);
  outline-offset: 1px;
}
.neo-thumb-label {
  font-size: 11px;
  opacity: 0.7;
}

/* ── search ── */
.neo-search-bar {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--neo-border);
}
.neo-search-input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--neo-border);
  border-radius: 8px;
  background: var(--neo-surface);
  color: inherit;
  font: inherit;
}
.neo-search-input:focus {
  outline: 2px solid var(--neo-primary);
  outline-offset: -1px;
}
.neo-search-status {
  padding: 6px 14px;
  font-size: 12px;
  opacity: 0.75;
}
.neo-search-results {
  position: absolute;
  inset: 88px 0 0 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 4px 8px 10px;
  gap: 2px;
}
.neo-search-hit {
  display: flex;
  gap: 8px;
  align-items: baseline;
  text-align: left;
  border: 0;
  border-radius: 8px;
  padding: 7px 9px;
  background: transparent;
  color: inherit;
  font-size: 12.5px;
  line-height: 1.35;
  cursor: pointer;
}
.neo-search-hit:hover {
  background: var(--neo-btn-hover);
}
.neo-search-hit:focus-visible {
  outline: 2px solid var(--neo-primary);
}
.neo-search-hit-current {
  background: var(--neo-btn-hover);
  box-shadow: inset 2px 0 0 var(--neo-primary);
}
.neo-search-hit-page {
  flex: none;
  font-weight: 600;
  color: var(--neo-primary);
  font-variant-numeric: tabular-nums;
}
.neo-search-snippet {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.neo-search-snippet mark {
  background: var(--neo-accent);
  color: #1b1b20;
  border-radius: 2px;
  padding: 0 1px;
}

/* ── bookmarks ── */
.neo-bm-root {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.neo-bm-actions {
  flex: none;
  display: grid;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--neo-border);
}
.neo-bm-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--neo-border);
  border-radius: 10px;
  background: var(--neo-surface);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}
.neo-bm-add:hover:not(:disabled) {
  background: var(--neo-btn-hover);
}
.neo-bm-add:focus-visible {
  outline: 2px solid var(--neo-primary);
  outline-offset: 1px;
}
.neo-bm-add:disabled {
  opacity: 0.4;
  cursor: default;
}
.neo-bm-add[aria-pressed="true"] {
  border-color: var(--neo-primary);
  color: var(--neo-primary);
}
.neo-bm-scroller {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.neo-bm-grid {
  display: grid;
  gap: 10px;
  padding: 12px;
  grid-template-columns: repeat(auto-fill, minmax(var(--neo-bm-w, 96px), 1fr));
}
.neo-bm-item {
  position: relative;
}
.neo-bm-goto {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--neo-border);
  border-radius: 8px;
  background: var(--neo-surface);
  cursor: pointer;
}
.neo-bm-goto:focus-visible {
  outline: 2px solid var(--neo-primary);
  outline-offset: 1px;
}
.neo-bm-current .neo-bm-goto {
  border-color: var(--neo-primary);
  outline: 2px solid var(--neo-primary);
  outline-offset: 1px;
}
.neo-bm-canvas {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.neo-bm-ready .neo-bm-canvas {
  opacity: 1;
}
.neo-bm-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: var(--neo-primary);
  color: #fff;
  pointer-events: none;
}
/* sibling of .neo-bm-goto — a button inside a button is invalid HTML */
.neo-bm-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.neo-bm-remove:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.75);
}
.neo-bm-remove svg {
  width: 14px;
  height: 14px;
}
.neo-bm-item:hover .neo-bm-remove,
.neo-bm-item:focus-within .neo-bm-remove {
  opacity: 1;
}
/* touch has no hover — the control must always be reachable */
@media (hover: none) {
  .neo-bm-remove {
    opacity: 1;
  }
}
/* `display` on these beats the [hidden] attribute's UA rule — restore it */
.neo-bm-empty[hidden],
.neo-bm-grid[hidden] {
  display: none;
}
.neo-bm-empty {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 30px 22px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}
.neo-bm-empty strong {
  font-size: 14px;
}
.neo-bm-empty span {
  opacity: 0.65;
}

/* ── 2D renderer ── */
.neo-r2d {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.neo-r2d-view {
  will-change: transform;
}
.neo-r2d-book {
  position: relative;
  perspective: 2600px;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.3));
  transition: transform 0.32s ease;
}
.neo-r2d-book.neo-r2d-noanim {
  transition: none;
}
/* Flat 2D fold: the same rotateY leaf, projected without perspective, reads
   as a flat squash-and-mirror. backface-visibility still swaps the faces
   because the transform is still 3D. */
.neo-r2d--flat .neo-r2d-book {
  perspective: none;
}
.neo-r2d-half {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  overflow: hidden;
  background: var(--neo-surface);
}
.neo-r2d-left {
  left: 0;
  border-radius: 4px 0 0 4px;
}
.neo-r2d-right {
  right: 0;
  border-radius: 0 4px 4px 0;
}
.neo-r2d-single .neo-r2d-half {
  width: 100%;
  border-radius: 4px;
}
.neo-r2d-single .neo-r2d-right {
  display: none;
}
.neo-r2d-half.neo-r2d-empty {
  background: transparent;
}
.neo-r2d-half canvas,
.neo-r2d-face canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.neo-r2d-blankface {
  width: 100%;
  height: 100%;
}
.neo-r2d-loading {
  width: 100%;
  height: 100%;
  background: linear-gradient(
      100deg,
      transparent 30%,
      rgba(0, 0, 0, 0.05) 50%,
      transparent 70%
    )
    var(--neo-surface);
  background-size: 240% 100%;
  animation: neo-shimmer 1.1s linear infinite;
}
@keyframes neo-shimmer {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}
.neo-r2d-fliphost {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform-style: preserve-3d;
}
.neo-r2d-leaf {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  transform-style: preserve-3d;
  will-change: transform;
}
.neo-r2d-single .neo-r2d-leaf {
  width: 100%;
}
.neo-r2d-fwd {
  left: 50%;
  transform-origin: left center;
}
.neo-r2d-single .neo-r2d-fwd {
  left: 0;
}
.neo-r2d-bwd {
  left: 0;
  transform-origin: right center;
}
.neo-r2d-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--neo-surface);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.neo-r2d-back {
  transform: rotateY(180deg);
}
.neo-r2d-shade {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.5),
    rgba(0, 0, 0, 0) 55%
  );
  pointer-events: none;
}

/* ── 3D renderer ── */
.neo-r3d-canvas {
  display: block;
  width: 100% !important;
  /* runs on under a floating toolbar; the renderer sizes its buffer to match */
  height: calc(100% + var(--neo-stage-bleed, 0px)) !important;
}

/* ── fullscreen ── */
.neo-fullscreen-fallback {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483000;
}
.neo-fullscreen .neo-chrome,
.neo-fullscreen .neo-sidenav {
  opacity: 0;
  pointer-events: none;
}
.neo-fullscreen:hover .neo-chrome,
.neo-fullscreen:focus-within .neo-chrome,
.neo-fullscreen:hover .neo-sidenav,
.neo-fullscreen:focus-within .neo-sidenav {
  opacity: 1;
}
.neo-fullscreen:hover .neo-chrome > *,
.neo-fullscreen:focus-within .neo-chrome > *,
.neo-fullscreen:hover .neo-sidenav,
.neo-fullscreen:focus-within .neo-sidenav {
  pointer-events: auto;
}

/* ── scroll view mode ── */
/* Both scrollers run on under a floating toolbar. The padding keeps their
   content box on the stage, so pages fit and centre above the band but scroll
   (or zoom) on through it. */
.neo-scroll {
  position: absolute;
  inset: 0 0 calc(var(--neo-stage-bleed, 0px) * -1) 0;
  padding-bottom: var(--neo-stage-bleed, 0px);
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
.neo-scroll-list {
  position: relative;
  margin: 0 auto;
}
.neo-scroll-page {
  position: absolute;
  left: 0;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.28);
}
.neo-scroll-page canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.neo-scroll-loading {
  background: linear-gradient(110deg, #ececec 30%, #f7f7f7 45%, #ececec 60%);
  background-size: 200% 100%;
  animation: neo-shimmer 1.2s linear infinite;
}

/* ── swipe (horizontal snap carousel) ── */
.neo-swipe {
  position: absolute;
  inset: 0 0 calc(var(--neo-stage-bleed, 0px) * -1) 0;
  padding-bottom: var(--neo-stage-bleed, 0px);
  overflow-x: auto;
  overflow-y: hidden;
  touch-action: pan-x;
  overscroll-behavior: contain;
  scroll-snap-type: x mandatory;
  display: flex;
  align-items: center;
}
.neo-swipe--nosnap {
  scroll-snap-type: none;
}
.neo-swipe-list {
  position: relative;
  flex: none;
}
.neo-swipe-spread {
  position: absolute;
  top: 0;
  display: flex;
  scroll-snap-align: center;
  border-radius: 2px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.28);
  background: #fff;
}
.neo-swipe-half {
  flex: 1 1 50%;
  min-width: 0;
}
.neo-swipe-half canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.neo-swipe-empty {
  background: transparent;
  box-shadow: none;
}
.neo-swipe-loading {
  background: linear-gradient(110deg, #ececec 30%, #f7f7f7 45%, #ececec 60%);
  background-size: 200% 100%;
  animation: neo-shimmer 1.2s linear infinite;
}


/* ── liquid controls (controlStyle: 'liquid') ──
   Apple-style liquid glass for the floating controls only; drawers stay solid.
   A thin tint of the theme's toolbar colour over a heavy blur with boosted
   colour, a bright rim along the top edge, an inner glow, and a light that
   follows the pointer (--neo-glass-x/-y/-light, set by ui/liquidControls.ts).
   [data-neo-refract] is only set where the engine can draw the SVG lens. */
.neo-flipbook[data-neo-controls="liquid"] {
  --neo-glass-tint: color-mix(in srgb, var(--neo-toolbar-bg) 42%, transparent);
  --neo-glass-edge: rgba(255, 255, 255, 0.55);
  --neo-glass-rim: rgba(255, 255, 255, 0.9);
  --neo-glass-glow: rgba(255, 255, 255, 0.2);
  --neo-glass-hover: rgba(255, 255, 255, 0.5);
  --neo-glass-light-color: rgba(255, 255, 255, 0.45);
  --neo-glass-filter: blur(16px) saturate(190%) brightness(1.05);
}
.neo-flipbook[data-neo-controls="liquid"][data-neo-theme="dark"] {
  --neo-glass-tint: color-mix(in srgb, var(--neo-toolbar-bg) 50%, transparent);
  --neo-glass-edge: rgba(255, 255, 255, 0.16);
  --neo-glass-rim: rgba(255, 255, 255, 0.4);
  --neo-glass-glow: rgba(255, 255, 255, 0.07);
  --neo-glass-hover: rgba(255, 255, 255, 0.14);
  --neo-glass-light-color: rgba(255, 255, 255, 0.18);
  --neo-glass-filter: blur(16px) saturate(170%) brightness(0.9);
}
.neo-flipbook[data-neo-controls="liquid"][data-neo-refract] {
  /* frost first, then bend the frosted result: lensing raw content behind
     the icons would leave it sharp enough to compete with them */
  --neo-glass-filter: blur(14px) saturate(190%) brightness(1.05) url(#neo-liquid-refract);
}
.neo-flipbook[data-neo-controls="liquid"][data-neo-refract][data-neo-theme="dark"] {
  --neo-glass-filter: blur(14px) saturate(170%) brightness(0.9) url(#neo-liquid-refract);
}
/* The docked bar is one surface; its pills flatten into it, so they stay out. */
.neo-flipbook[data-neo-controls="liquid"]:not([data-neo-toolbar="fixed"]) :is(.neo-toolbar, .neo-page-indicator),
.neo-flipbook[data-neo-controls="liquid"] :is(.neo-sidenav, .neo-toolbar-more-menu) {
  isolation: isolate;
  border-color: var(--neo-glass-edge);
  background: var(--neo-glass-tint);
  box-shadow:
    inset 0 1px 0 var(--neo-glass-rim),
    inset 0 -1px 0 var(--neo-glass-glow),
    inset 0 0 18px var(--neo-glass-glow),
    0 12px 32px rgba(0, 0, 0, 0.18),
    0 2px 6px rgba(0, 0, 0, 0.08);
  backdrop-filter: var(--neo-glass-filter);
  -webkit-backdrop-filter: var(--neo-glass-filter);
}
.neo-flipbook[data-neo-controls="liquid"][data-neo-toolbar="fixed"] .neo-chrome {
  border-top-color: var(--neo-glass-edge);
  background: var(--neo-glass-tint);
  box-shadow:
    inset 0 1px 0 var(--neo-glass-rim),
    0 -8px 24px rgba(0, 0, 0, 0.12);
  backdrop-filter: var(--neo-glass-filter);
  -webkit-backdrop-filter: var(--neo-glass-filter);
}
.neo-flipbook[data-neo-controls="liquid"] .neo-page-indicator {
  position: relative;
}
/* The pointer light: behind the buttons (z-index -1 inside the isolated
   surface), above the glass itself. */
.neo-flipbook[data-neo-controls="liquid"] :is(.neo-toolbar, .neo-sidenav, .neo-page-indicator, .neo-toolbar-more-menu)::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    140px circle at var(--neo-glass-x, 50%) var(--neo-glass-y, 0%),
    var(--neo-glass-light-color),
    transparent 65%
  );
  opacity: var(--neo-glass-light, 0);
  transition: opacity 0.25s ease;
}
/* Squish on press, spring back on release: the press is quick, the release
   overshoots slightly on the base transition. */
.neo-flipbook[data-neo-controls="liquid"] :is(.neo-toolbar, .neo-sidenav) .neo-btn {
  transition:
    background 0.2s ease,
    transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.neo-flipbook[data-neo-controls="liquid"] :is(.neo-toolbar, .neo-sidenav) .neo-btn:hover:not(:disabled),
.neo-flipbook[data-neo-controls="liquid"] .neo-toolbar-more-item:hover:not(:disabled) {
  background: var(--neo-glass-hover);
}
.neo-flipbook[data-neo-controls="liquid"] :is(.neo-toolbar, .neo-sidenav) .neo-btn:active:not(:disabled) {
  transform: scale(0.88);
  transition-duration: 0.2s, 0.08s;
}

/* ── responsive ── */
@media (max-width: 560px) {
  .neo-flipbook {
    --neo-dock-h: 44px;
    --neo-sidenav-inset: 4px;
  }
  .neo-toolbar {
    gap: 2px;
    padding: 4px;
    border-radius: 12px;
  }
  .neo-toolbar .neo-btn {
    width: 34px;
    height: 34px;
    border-radius: 9px;
  }
  .neo-btn {
    width: 32px;
    height: 32px;
  }
  .neo-page-indicator {
    min-height: 42px;
    padding: 0 8px;
    border-radius: 12px;
    gap: 5px;
    font-size: 14px;
  }
  .neo-goto-input {
    padding: 4px 6px;
    border-radius: 7px;
    line-height: 20px;
  }
  .neo-panel {
    width: 100vw;
    border-right: 0;
  }
  .neo-flipbook[data-neo-toolbar="fixed"] .neo-chrome {
    padding: 0 4px;
  }
  .neo-flipbook[data-neo-toolbar="fixed"] .neo-page-indicator {
    margin-left: 4px;
  }
  .neo-sidenav {
    gap: 2px;
    padding: 4px;
    border-radius: 12px;
  }
  .neo-sidenav-btn {
    width: 34px;
    height: 56px;
    border-radius: 9px;
  }
  .neo-sidenav-btn svg {
    width: 24px;
    height: 24px;
  }
  .neo-bm-grid {
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  }
}

/* ── reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .neo-flipbook[data-neo-controls="liquid"] .neo-btn:active:not(:disabled) {
    transform: none;
  }
  .neo-panel,
  .neo-chrome,
  .neo-btn,
  .neo-r2d-book,
  .neo-thumb-canvas,
  .neo-sidenav,
  .neo-bm-add,
  .neo-bm-canvas,
  .neo-bm-remove {
    transition: none !important;
  }
  .neo-r2d-loading {
    animation: none;
  }
}
