/* Shared application chrome; paper colours remain independently adjustable. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #191b20; --ink: #f2eee8; --quiet: #aaa6a0; --line: #393b42; --warm: #24262d;
  --brand: #e7755b; --brand-hover: #d65b41;
  --background: #191b20; --foreground: #f2eee8; --card: #24262d; --card-foreground: #f2eee8;
  --popover: #292c33; --popover-foreground: #f2eee8; --elevated: #292c33;
  --primary: #e7755b; --primary-foreground: #17191e; --secondary: #292c33;
  --secondary-foreground: #f2eee8; --muted: #292c33; --muted-foreground: #aaa6a0;
  --accent: #343139; --accent-foreground: #f2eee8; --border: #393b42; --input: #454751; --ring: #e7755b;
  --reader-paper: #191b20; --reader-card: #24262d; --reader-warm: #202229;
  --reader-ink: #f2eee8; --reader-quiet: #aaa6a0; --reader-line: #393b42;
  --reader-accent: #e7755b; --reader-accent-deep: #d65b41;
  --reader-glass: #191b20ed; --reader-glass-strong: #24262df5; --reader-hairline: #393b42;
  --m-surface: #191b20; --m-surface-container-low: #191b20; --m-surface-container: #24262d; --m-surface-container-high: #292c33;
  --m-surface-container-highest: #30333c; --m-on-surface: #f2eee8; --m-on-surface-variant: #aaa6a0;
  --m-outline-variant: #393b42; --m-primary: #e7755b;
}
:root[data-theme="light"] { color-scheme: light; }
[data-theme="dark"] .bs-card { background: var(--card); color: var(--foreground); }
[data-theme="dark"] .toc-link { color: #bbb6ae; }
/* The light chapter highlight is a pale peach; under the grey dark-theme text it
   left the current chapter the one line you couldn't read. */
[data-theme="dark"] .toc-link.active { background: color-mix(in srgb, var(--reader-accent) 18%, transparent); color: #f6b8a6; }
.bookmark-panel { padding: 10px 16px 16px; border-bottom: 1px solid var(--reader-line); }
.bookmark-panel h3 { font: 600 12px/1.4 system-ui; color: var(--reader-quiet); }
.bookmark-panel button { border: 1px solid var(--reader-line); border-radius: 9px; background: var(--reader-card); color: var(--reader-ink); padding: 9px 12px; margin: 3px; cursor: pointer; }
#bookmarkBtn[aria-pressed="true"] { color: var(--reader-accent); background: color-mix(in srgb,var(--reader-accent) 15%,transparent); }
.flip-zone .curl { display: none!important; }
.flip-zone { background: transparent!important; }
body.immersive #bar { visibility: hidden; pointer-events: none; transform: translateY(-110%); }
body.immersive.bar-peek #bar { visibility: visible; pointer-events: auto; transform: none; }
body.immersive .bar-right { visibility: hidden; pointer-events: none; opacity: 0; }
body.immersive.bar-peek .bar-right { visibility: visible; pointer-events: auto; opacity: 1; }
body.immersive #scroller { top: 0; bottom: 0; }
body.immersive .bpage { border: 0; border-radius: 0; box-shadow: none; }
body.immersive #barPeek {
  display: flex !important;
  align-items: center;
  justify-content: center;
  z-index: 80;
}
[data-theme="dark"] body.immersive .bar-handle {
  color: #ddd8d0;
  background: color-mix(in srgb, #2a2d34 35%, transparent);
  border: 1px solid color-mix(in srgb, #fff 10%, transparent);
  box-shadow: none;
}
.bpage.dragging { user-select: none; cursor: grabbing; }
body.mode-kindle .bpage { touch-action: none; }
[data-theme="dark"] .bar-right { box-shadow: 0 12px 32px #0005; }
/* Bounded visual mesh: only the active turning sheet is subdivided. */
.paper-mesh { position: fixed; z-index: 9; pointer-events: none; transform-style: preserve-3d; background: transparent; overflow: visible; }
.paper-mesh-tile { position: absolute; inset: 0; transform-origin: 0 0; transform-style: preserve-3d; will-change: transform; }
.paper-mesh-image { position:absolute; inset:0; width:100%; height:100%; }
.paper-mesh-tile.paper-verso { background:var(--page-bg); }
.paper-mesh-tile.paper-verso .paper-mesh-image { opacity:.06; }
.paper-mesh .paper-mesh-content { display: block!important; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0; transform: none; opacity: 1!important; visibility: visible!important; box-shadow: none; }
.paper-mesh .bp-inner, .paper-mesh .page-num, .paper-mesh .page-bookmark { backface-visibility: visible; }
.paper-mesh .paper-verso .bp-inner, .paper-mesh .paper-verso .page-num, .paper-mesh .paper-verso .page-bookmark { opacity: .08; }
.paper-mesh-light { display: none; }
/* Shadows the turning sheet casts on the page it uncovers — clipped to the page,
   so they never smudge the desk. Positioned and sized per frame in viewer.js. */
.paper-mesh-shadow-clip { position: absolute; inset: 0; overflow: hidden; pointer-events: none; border-radius: inherit; }
.paper-mesh-shadow {
  position: absolute;
  background: linear-gradient(90deg, rgba(26, 16, 6, .62), rgba(26, 16, 6, .26) 38%, rgba(26, 16, 6, 0));
  filter: blur(3px);
}
.paper-mesh-lift {
  position: absolute;
  background: linear-gradient(90deg, rgba(26, 16, 6, .30), rgba(26, 16, 6, .12) 40%, rgba(26, 16, 6, 0));
  filter: blur(12px);
  pointer-events: none;
}
.page-bookmark, #bookmarkBtn { position: absolute; top: 0; right: 20px; z-index: 8; width: 38px; min-width: 38px; height: 42px; min-height: 42px; padding: 7px 9px 11px; border: 0; border-radius: 0; color: #8a6547; background: transparent; cursor: pointer; }
.page-bookmark svg { width: 20px; height: 24px; flex: none; }
.page-bookmark[aria-pressed="true"], #bookmarkBtn[aria-pressed="true"] { color: #bf4932; background: transparent; }
.page-bookmark:focus-visible { outline: 2px solid #c75137; outline-offset: -2px; border-radius: 4px; }
body.mode-kindle .bpage > .page-num, body.immersive.mode-kindle .bpage > .page-num { position: absolute; top: auto; bottom: max(10px,var(--sa-bottom)); left: 0; right: 0; text-align: center; background: transparent; color: var(--ink); opacity: .6; font: 12px/1.2 Georgia,serif; z-index: 7; pointer-events: none; }
.bpage .bp-inner { padding-top: 46px; padding-bottom: max(40px,calc(26px + var(--sa-bottom))); }
body.mode-kindle .bpage.current > .flip-zone { top: auto; bottom: 0; height: 96px; width: 96px; }
@media (pointer: coarse) {
  body.mode-kindle .bpage.current > .flip-zone { width: 96px; height: 96px; }
}
@media(prefers-reduced-motion:reduce) { .paper-mesh { display:none; } }
