body.reader {
  --rd-bg: #2a2e35;
  --rd-bar: rgba(22, 25, 30, .78);
  --rd-fg: #eef0f3;
  --rd-fg-2: #aab1bd;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #3a3f48 0%, var(--rd-bg) 70%);
  color: var(--rd-fg);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  user-select: none;
  -webkit-user-select: none;
}

.rd-top, .rd-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--rd-bar);
  backdrop-filter: blur(8px);
  z-index: 20;
}
.rd-top { justify-content: space-between; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
.rd-title { flex: 1; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rd-actions { display: flex; gap: 2px; flex-shrink: 0; }
.rd-bottom { justify-content: center; padding-bottom: max(8px, env(safe-area-inset-bottom)); }

.rd-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--rd-fg);
  cursor: pointer; text-decoration: none;
}
.rd-btn:hover { background: rgba(255, 255, 255, .1); }
.rd-btn:focus-visible { outline: 2px solid #8fd3bf; outline-offset: 1px; }
.rd-btn[aria-pressed="true"] { background: rgba(255, 255, 255, .16); }

.rd-pageform { display: flex; align-items: center; gap: 6px; margin: 0 6px; font-variant-numeric: tabular-nums; }
.rd-pageform input {
  width: 64px; height: 32px; text-align: center;
  border: 1px solid rgba(255, 255, 255, .2); border-radius: 6px;
  background: rgba(0, 0, 0, .25); color: var(--rd-fg);
}
.rd-of { color: var(--rd-fg-2); white-space: nowrap; }

.rd-stage { position: relative; min-width: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 16px 64px; }
.rd-book-wrap { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; min-width: 0; }
.rd-book { width: 100%; height: 100%; transition: transform .45s ease; }
.rd-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 72px; border: 0; border-radius: 10px;
  background: rgba(0, 0, 0, .25); color: #fff; cursor: pointer; display: grid; place-items: center;
  z-index: 5; transition: opacity .2s, background .2s;
}
.rd-nav .i { width: 28px; height: 28px; }
.rd-nav:hover { background: rgba(0, 0, 0, .45); }
.rd-nav:disabled { opacity: 0; pointer-events: none; }
.rd-prev { left: 8px; }
.rd-next { right: 8px; }

/* Custom background behind the book */
.rd-bg { position: fixed; inset: 0; z-index: -1; background-size: cover; background-position: center; }
.rd-bg-cover { inset: -40px; filter: blur(28px) saturate(1.15) brightness(.72); transform: scale(1.1); }
.rd-bg-image::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, .12); }
body.reader:has(.rd-bg) { background: #2a2e35; isolation: isolate; }

/* Pages */
.page { background: #fff; overflow: hidden; }
.page-inner { position: relative; width: 100%; height: 100%; }
.page img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; -webkit-user-drag: none; pointer-events: none; }
.page.--left .page-inner::after, .page.--right .page-inner::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 6%; pointer-events: none;
}
.page.--left .page-inner::after { right: 0; background: linear-gradient(to left, rgba(0,0,0,.14), transparent); }
.page.--right .page-inner::after { left: 0; background: linear-gradient(to right, rgba(0,0,0,.14), transparent); }

.hs {
  position: absolute; display: block; z-index: 2; border-radius: 3px; cursor: pointer;
  background: rgba(31, 111, 92, 0); transition: background .15s, box-shadow .15s;
}
.hs:hover, .hs:focus-visible { background: rgba(31, 111, 92, .14); box-shadow: inset 0 0 0 2px rgba(31, 111, 92, .55); outline: none; }
.hs-video { background: rgba(0, 0, 0, .04); }
.hs-video .hs-play { position: absolute; right: 4px; bottom: 4px; width: 28px; height: 28px; }
.hs-video.is-large .hs-play { inset: 50% auto auto 50%; transform: translate(-50%, -50%); width: 56px; height: 56px; }
.reader.flash-links .hs { background: rgba(31, 111, 92, .18); box-shadow: inset 0 0 0 2px rgba(31, 111, 92, .5); }

/* Side panels */
.rd-panel {
  position: fixed; top: 56px; bottom: 60px; right: 0; width: min(340px, 100vw);
  background: #1d2026; border-left: 1px solid rgba(255,255,255,.08);
  z-index: 30; display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,.3);
}
.rd-panel-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 8px 16px; font-weight: 600; }
.rd-thumbs { overflow: auto; padding: 8px 12px 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 10px; }
.rd-thumb { border: 0; padding: 0; background: none; color: var(--rd-fg-2); cursor: pointer; text-align: center; font-size: 12px; }
.rd-thumb img { width: 100%; display: block; border-radius: 3px; background: #fff; outline: 2px solid transparent; outline-offset: 2px; aspect-ratio: var(--ar, 0.77); object-fit: contain; }
.rd-thumb.is-current img { outline-color: #8fd3bf; }
.rd-thumb.is-current { color: #fff; }

.rd-search { padding: 0 12px 8px; }
.rd-search input { width: 100%; height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.3); color: #fff; }
.rd-results { overflow: auto; padding: 0 8px 16px; user-select: text; }
.rd-result { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--rd-fg); padding: 10px 8px; border-radius: 8px; cursor: pointer; }
.rd-result:hover { background: rgba(255,255,255,.07); }
.rd-result b { display: block; font-size: 12px; color: var(--rd-fg-2); font-weight: 600; margin-bottom: 2px; }
.rd-result mark { background: #f5d76e; color: #1d2433; border-radius: 2px; padding: 0 1px; }
.rd-results .rd-empty { color: var(--rd-fg-2); padding: 8px; }

/* Zoom */
.rd-zoom { position: fixed; inset: 0; background: #1b1e23; z-index: 40; display: flex; flex-direction: column; }
.rd-zoom-bar { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 8px; background: var(--rd-bar); }
.rd-zoom-bar span { min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }
.rd-zoom-bar [data-close] { position: absolute; right: 12px; }
.rd-zoom-scroll { flex: 1; overflow: auto; cursor: grab; touch-action: pan-x pan-y pinch-zoom; }
.rd-zoom-scroll.is-dragging { cursor: grabbing; }
.rd-zoom-pages { display: flex; justify-content: center; width: max-content; min-width: 100%; padding: 24px; margin: 0 auto; }
.rd-zoom-page { position: relative; background: #fff; box-shadow: 0 6px 30px rgba(0,0,0,.4); }
.rd-zoom-page img { width: 100%; height: 100%; display: block; -webkit-user-drag: none; }

/* Modals */
.rd-modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(10, 12, 16, .7); }
.rd-modal-card {
  position: relative; width: min(460px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: #fff; color: var(--ink); border-radius: 14px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
  user-select: text;
}
.rd-modal-card h2 { margin: 0 0 6px; font-size: 20px; }
.rd-modal-card p { margin: 0 0 16px; color: var(--ink-2); }
.rd-modal-x { position: absolute; top: 8px; right: 8px; color: var(--ink-2); }
.rd-modal-x:hover { background: #f0f2f5; }
.rd-video-card { width: min(960px, 100%); padding: 0; background: #000; overflow: visible; }
.rd-video-card .rd-modal-x { top: -44px; right: 0; color: #fff; }
.rd-video { position: relative; aspect-ratio: 16 / 9; }
.rd-video iframe, .rd-video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 6px; }

.rd-field { display: block; margin-bottom: 12px; }
.rd-field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.rd-field input, .rd-field select {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid #cfd4dc; border-radius: 8px; background: #fff;
}
.rd-field input:focus, .rd-field select:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.rd-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.rd-copy { display: flex; gap: 8px; }
.rd-copy input { flex: 1; min-width: 0; }
.rd-check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-2); }
.rd-primary {
  height: 42px; padding: 0 18px; border: 0; border-radius: 8px; background: var(--brand); color: var(--brand-ink);
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.rd-primary:hover { filter: brightness(1.08); }
.rd-primary:disabled { opacity: .6; cursor: default; }
.rd-link { border: 0; background: none; color: var(--ink-2); text-decoration: underline; cursor: pointer; }
.rd-lead-actions { display: flex; align-items: center; gap: 16px; margin-top: 4px; }
.rd-error { color: var(--danger) !important; font-size: 14px; }

.rd-toast {
  position: fixed; left: 50%; bottom: 76px; transform: translate(-50%, 20px); opacity: 0;
  background: #fff; color: var(--ink); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s; pointer-events: none; z-index: 60; font-size: 14px;
}
.rd-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.rd-noscript { text-align: center; padding: 40px; }

/* Embedded on another site: tighter chrome */
.is-embed .rd-top { padding-top: 4px; padding-bottom: 4px; }
.is-embed .rd-stage { padding: 8px 52px; }

@media (max-width: 720px) {
  .rd-stage { padding: 8px 4px; }
  .rd-nav { display: none; }
  .rd-actions [data-act="fullscreen"] { display: none; }
  .rd-btn { width: 38px; height: 38px; }
  .rd-panel { top: auto; bottom: 0; height: 70dvh; width: 100vw; border-left: 0; border-top: 1px solid rgba(255,255,255,.08); border-radius: 14px 14px 0 0; }
  .rd-thumbs { grid-template-columns: repeat(3, 1fr); }
  .rd-grid2 { grid-template-columns: 1fr; }
}

/* District previews are view only: no printing from the browser. */
@media print { body.is-preview > * { display: none !important; } body.is-preview::after { content: "This preview can't be printed."; } }
.rd-back { margin-right: 4px; }

/* Notes, highlights and bookmarks */
.an-c-yellow { --an: #fde68a; --an-hl: rgba(250, 204, 21, .42); }
.an-c-pink { --an: #fbcfe8; --an-hl: rgba(244, 114, 182, .36); }
.an-c-green { --an: #bbf7d0; --an-hl: rgba(74, 222, 128, .36); }
.an-c-blue { --an: #bfdbfe; --an-hl: rgba(96, 165, 250, .36); }
.an-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.an-layer > * { pointer-events: auto; }
.an-placing .an-layer, .an-highlighting .an-layer { pointer-events: auto; cursor: crosshair; touch-action: none; }
.an-highlighting .an-layer { cursor: text; }
.an-drawing { position: absolute; inset: 0; pointer-events: none; }
.an-highlighting .an-layer > * { pointer-events: none; }
.an-hl { position: absolute; background: var(--an-hl); mix-blend-mode: multiply; border-radius: 2px; cursor: pointer; }
.an-hl.is-drawing { outline: 1px dashed rgba(0, 0, 0, .35); pointer-events: none; }
.an-note {
  position: absolute; width: 26px; height: 26px; margin: -4px 0 0 -4px; padding: 0; border: 0; cursor: grab; touch-action: none;
  background: linear-gradient(225deg, transparent 7px, var(--an) 7px); border-radius: 2px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .35); transition: transform .12s;
}
.an-note::before { content: ""; position: absolute; top: 0; right: 0; width: 10px; height: 10px; background: linear-gradient(225deg, transparent 50%, rgba(0, 0, 0, .18) 50%); }
.an-note::after { content: ""; position: absolute; left: 6px; right: 7px; top: 9px; height: 8px; border-top: 2px solid rgba(0,0,0,.25); border-bottom: 2px solid rgba(0,0,0,.25); }
.an-note:hover, .an-note:focus-visible { transform: scale(1.15); outline: none; }
.an-mark { position: absolute; top: 0; right: 8%; width: 18px; height: 34px; background: #dc2626; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%); box-shadow: 0 1px 3px rgba(0,0,0,.3); }

.an-tools {
  position: fixed; top: 62px; left: 50%; transform: translateX(-50%); z-index: 35;
  display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; width: max-content; max-width: calc(100vw - 16px);
  padding: 6px 6px 6px 8px; border-radius: 12px; background: #1d2026; box-shadow: 0 8px 24px rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.1);
}
.an-tool { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--rd-fg); cursor: pointer; font: inherit; font-size: 14px; }
.an-tool .i { width: 18px; height: 18px; }
.an-tool:hover { background: rgba(255,255,255,.1); }
.an-tool[aria-pressed="true"] { background: #8fd3bf; color: #10231d; }
.an-swatches { display: inline-flex; gap: 4px; padding: 0 4px; }
.an-sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; background: var(--an); cursor: pointer; padding: 0; }
.an-sw[aria-checked="true"], .an-sw.is-on { border-color: #fff; box-shadow: 0 0 0 2px #1d2026 inset; }
.an-close { width: 36px; height: 36px; }
.an-hint { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px); margin: 0; padding: 6px 12px; border-radius: 8px; background: rgba(22,25,30,.9); text-align: center; font-size: 13px; color: var(--rd-fg); }

.an-pop {
  position: fixed; z-index: 65; width: 280px; padding: 10px; border-radius: 12px;
  background: #fff; color: var(--ink); box-shadow: 0 12px 40px rgba(0,0,0,.4); user-select: text;
}
.an-pop textarea { width: 100%; min-height: 110px; resize: vertical; border: 1px solid #d5d9e0; border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px; background: #fffdf3; }
.an-pop textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.an-pop textarea[hidden], .an-quote[hidden] { display: none; }
.an-quote { margin: 0 0 4px; max-height: 140px; overflow: auto; font-size: 14px; line-height: 1.45; color: #39404d; font-style: italic; }
.an-pop-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.an-pop .an-sw.is-on { border-color: #1d2433; box-shadow: none; }
.an-del { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--danger, #b42318); cursor: pointer; font: inherit; font-size: 13px; padding: 6px; border-radius: 6px; }
.an-del .i { width: 15px; height: 15px; }
.an-del:hover { background: #fdecea; }
.an-done { height: 32px; padding: 0 14px; border: 0; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font-weight: 600; cursor: pointer; }

.an-where { margin: 0 16px 8px; font-size: 13px; color: var(--rd-fg-2); }
.an-list { flex: 1; overflow: auto; padding: 0 8px 8px; user-select: text; }
.an-list .rd-empty { color: var(--rd-fg-2); padding: 8px; }
.an-item { display: flex; align-items: flex-start; border-radius: 8px; }
.an-item:hover { background: rgba(255,255,255,.07); }
.an-go { flex: 1; min-width: 0; display: flex; gap: 10px; text-align: left; border: 0; background: none; color: var(--rd-fg); padding: 10px 8px; cursor: pointer; font: inherit; font-size: 14px; }
.an-item-text { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; white-space: pre-wrap; }
.an-item-text b { display: block; font-size: 12px; color: var(--rd-fg-2); font-weight: 600; }
.an-dot { flex: none; width: 14px; height: 14px; margin-top: 3px; border-radius: 3px; background: var(--an); }
.an-dot.an-k-bookmark { background: #dc2626; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }
.an-item-del { width: 34px; height: 34px; margin-top: 4px; color: var(--rd-fg-2); }
.an-item-del .i { width: 16px; height: 16px; }
.an-panel-foot { padding: 8px 16px 12px; border-top: 1px solid rgba(255,255,255,.08); }
.an-export { border: 0; background: none; color: #8fd3bf; cursor: pointer; font: inherit; font-size: 14px; padding: 4px 0; }
.an-export:hover { text-decoration: underline; }
.rd-zoom-page .an-layer { z-index: 3; }

@media (max-width: 720px) {
  .an-tools { top: 54px; }
  .an-tool span { display: none; }
  .an-tool { padding: 0 8px; }
  .an-swatches { gap: 3px; padding: 0 2px; }
  .an-pop { left: 8px !important; right: 8px; width: auto; top: auto !important; bottom: 8px; }
}
.an-drawing .an-hl.is-drawing { outline: none; }
