/* Reader: in-browser PDF reading with private highlights and notes.
   Only reader-specific layout lives here; colours come from the site variables
   in style.css, so the reader follows the site's light and dark themes. */

:root {
  /* Marker colours, chosen to read well when multiplied over a white page. */
  --rd-hl-yellow: #ffe169;
  --rd-hl-green: #b2eaa6;
  --rd-hl-blue: #a9d6ff;
  --rd-hl-pink: #ffbcdc;
  /* Stronger tones for swatches, list accents and focus rings. */
  --rd-dot-yellow: #e9b500;
  --rd-dot-green: #3ca24a;
  --rd-dot-blue: #2f86d8;
  --rd-dot-pink: #d9468e;
}

[data-color="yellow"] { --rd-c: var(--rd-hl-yellow); --rd-d: var(--rd-dot-yellow); }
[data-color="green"]  { --rd-c: var(--rd-hl-green);  --rd-d: var(--rd-dot-green); }
[data-color="blue"]   { --rd-c: var(--rd-hl-blue);   --rd-d: var(--rd-dot-blue); }
[data-color="pink"]   { --rd-c: var(--rd-hl-pink);   --rd-d: var(--rd-dot-pink); }

/* ---------- The reader fills the window below the site header ---------- */

.reader-app {
  --rd-stage: color-mix(in srgb, var(--ink) 9%, var(--bg));
  --rd-hover: color-mix(in srgb, var(--ink) 8%, transparent);
  --rd-active: color-mix(in srgb, var(--primary) 15%, transparent);
  --rd-ring: color-mix(in srgb, var(--primary) 30%, transparent);
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: calc(100vh - 64px);
  background: var(--card);
  color: var(--ink);
}
@supports selector(body:has(.x)) {
  body:has(> main .reader-app) { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  body:has(> main .reader-app) > main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  body:has(> main .reader-app) > .site-footer { display: none; }
  .reader-app { height: auto; }
}
.reader-app [hidden] { display: none !important; }
.reader-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.reader-sr {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.ri {
  width: 18px; height: 18px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.ri-lg { width: 34px; height: 34px; stroke-width: 1.6; }

/* ---------- Header: breadcrumbs, toolbar, find bar ---------- */

.reader-head { flex: 0 0 auto; position: relative; z-index: 6; background: var(--card); border-bottom: 1px solid var(--border); }
.reader-crumbs {
  margin: 0; padding: 6px 16px 0; font-size: .78rem; line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reader-banner {
  margin: 4px 16px 0; padding: 4px 10px; border-radius: 6px; font-size: .82rem;
  background: color-mix(in srgb, var(--danger) 12%, var(--card)); color: var(--danger);
}
.reader-toolbar { display: flex; align-items: center; gap: 6px; padding: 4px 8px 6px; min-height: 48px; }
.rt-group { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.rt-title { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.rt-title-text {
  margin: 0; min-width: 0; font-family: var(--font-body); font-size: .92rem; font-weight: 600; line-height: 1.3;
  color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rt-file select { max-width: 200px; }

.rt-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 36px; height: 36px; padding: 0 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-soft); font: inherit; font-size: .88rem; cursor: pointer;
  text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.rt-btn:hover { background: var(--rd-hover); color: var(--ink); text-decoration: none; }
.rt-btn[aria-expanded="true"], .rt-btn[aria-pressed="true"] { background: var(--rd-active); color: var(--primary); }
.rt-btn:disabled { opacity: .38; cursor: default; background: transparent; }
.reader-app :is(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
.rt-badge {
  position: absolute; top: 1px; right: -1px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--primary); color: var(--on-primary, #fff); box-shadow: 0 0 0 2px var(--card);
  font-size: .66rem; font-weight: 700; line-height: 17px; text-align: center; font-variant-numeric: tabular-nums;
}
.rt-page, .rt-select {
  height: 32px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); color: var(--ink);
  font: inherit; font-size: .88rem;
}
.rt-page { width: 3.4em; padding: 0 4px; text-align: center; font-variant-numeric: tabular-nums; }
.rt-select { padding: 0 6px; max-width: 132px; cursor: pointer; }
.rt-of { padding: 0 4px 0 2px; color: var(--muted); font-size: .86rem; white-space: nowrap; font-variant-numeric: tabular-nums; }

.reader-more { position: relative; }
.reader-menu {
  position: absolute; left: auto; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 236px; padding: 6px;
  background: var(--card); color: var(--ink); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 14px 36px rgb(0 0 0 / .18);
}
.reader-menu > button, .reader-menu > a {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--ink); font: inherit; font-size: .9rem; text-align: left; text-decoration: none; cursor: pointer;
}
.reader-menu > button:hover, .reader-menu > a:hover, .reader-menu > :focus-visible { background: var(--rd-hover); text-decoration: none; }
.reader-menu .ri { color: var(--ink-soft); }
.reader-menu [aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--primary); font-weight: 700; }
.reader-menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.reader-menu .rm-sm { display: none; }

.reader-findbar { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; padding: 6px 10px 8px; border-top: 1px solid var(--border); }
.rf-field {
  display: flex; align-items: center; gap: 6px; flex: 1 1 200px; max-width: 420px; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--muted);
}
.rf-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--rd-ring); }
.rf-field input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: .92rem; }
.rf-field input:focus-visible { outline: none; }
.rf-status { min-width: 7.5em; padding: 0 4px; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.rf-status.is-miss { color: var(--danger); }
.rf-opt { display: inline-flex; align-items: center; gap: 5px; padding: 0 4px; font-size: .82rem; color: var(--ink-soft); white-space: nowrap; cursor: pointer; }

/* ---------- Body: sidebars around the page stage ---------- */

.reader-body { position: relative; display: flex; flex: 1 1 auto; min-height: 0; }
.reader-side { position: relative; display: flex; flex-direction: column; flex: 0 0 auto; min-height: 0; background: var(--card); }
.reader-left { width: 200px; border-right: 1px solid var(--border); }
.reader-right { order: 3; width: 340px; border-left: 1px solid var(--border); }
.reader-app[data-left="closed"] .reader-left, .reader-app[data-right="closed"] .reader-right { display: none; }

.reader-stage { position: relative; flex: 1 1 auto; min-width: 0; background: var(--rd-stage); }
.reader-viewer { position: absolute; inset: 0; overflow: auto; touch-action: pan-x pan-y; overscroll-behavior: contain; }
.reader-viewer:focus { outline: none; }
.reader-viewer:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); }
/* PDF.js sizes its boxes for the browser default (content-box). The site's global
   "* { box-sizing: border-box }" would make each page's 9px border eat into the
   page: the canvas lost 18px at the right and bottom, and the highlight layer sat
   on a box 1.8% smaller than the text layer. :where() keeps this at the lowest
   specificity, so PDF.js's own explicit box-sizing rules still apply. */
.reader-viewer :where(.pdfViewer, .pdfViewer *) { box-sizing: content-box; }
.reader-viewer .pdfViewer { padding: 10px 0 40px; }
.reader-viewer .pdfViewer .page { background-color: #fff; }
.reader-viewer .pdfViewer .canvasWrapper { box-shadow: 0 1px 2px rgb(0 0 0 / .16), 0 6px 18px rgb(0 0 0 / .07); }
.reader-viewer.is-over-hl, .reader-viewer.is-over-hl .textLayer, .reader-viewer.is-over-hl .textLayer span { cursor: pointer; }

/* Search matches: the site's accent instead of PDF.js's magenta. The text layer
   sits above the page image, so the tints stay translucent enough to read through. */
.reader-viewer .textLayer .highlight {
  --highlight-bg-color: color-mix(in srgb, var(--accent) 30%, transparent);
  --highlight-selected-bg-color: color-mix(in srgb, var(--gold) 55%, transparent);
}
.reader-viewer .textLayer .highlight.selected { box-shadow: 0 0 0 1px color-mix(in srgb, var(--gold) 90%, #000); }

.reader-loading {
  position: absolute; left: 50%; top: 42%; z-index: 2; transform: translate(-50%, -50%);
  width: 260px; text-align: center; color: var(--muted); font-size: .9rem; pointer-events: none;
}
.reader-loading p { margin: 0; }
.reader-app:not([data-state="loading"]) .reader-loading { display: none; }
.reader-progress { height: 4px; margin: 0 auto 10px; border-radius: 2px; overflow: hidden; background: color-mix(in srgb, var(--ink) 12%, transparent); }
.reader-progress span { display: block; width: 4%; height: 100%; border-radius: 2px; background: var(--primary); transition: width .2s ease-out; }
.reader-error { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 24px; background: var(--rd-stage); }
.reader-error .empty-state { max-width: 480px; background: var(--card); }
.reader-error h2 { margin-top: 0; }

/* ---------- Highlights drawn over the pages ---------- */

.reader-hl-layer { position: absolute; inset: 0; z-index: 1; pointer-events: none; mix-blend-mode: multiply; }
.reader-hl { position: absolute; border-radius: 2px; background: var(--rd-c, var(--rd-hl-yellow)); }
.reader-hl.is-pending { opacity: .55; }
.reader-hl.is-active { box-shadow: 0 0 0 2px var(--rd-d); }
.reader-hl.is-flash { animation: rd-flash 1.1s ease-out 2; }
.reader-hl-pin {
  position: absolute; width: 12px; height: 12px; margin: -7px 0 0 -3px; border-radius: 50% 50% 50% 2px;
  background: var(--rd-d, var(--rd-dot-yellow));
}
@keyframes rd-flash { 0%, 100% { filter: none; } 40% { filter: saturate(2.4) brightness(.82); } }

.is-dark-pages .reader-viewer .pdfViewer { --page-bg-color: #202226; }
.is-dark-pages .reader-viewer .pdfViewer .page { background-color: #202226; }
.is-dark-pages .reader-viewer .canvasWrapper,
.is-dark-pages .reader-thumb-img canvas { filter: invert(.88) hue-rotate(180deg); }
.is-dark-pages .reader-hl-layer { mix-blend-mode: normal; opacity: .4; }

/* ---------- Selection and highlight popover ---------- */

.reader-pop {
  position: fixed; z-index: 40; display: flex; align-items: center; gap: 2px; padding: 5px;
  background: var(--card); color: var(--ink); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px rgb(0 0 0 / .2);
}
.rp-color {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px;
  background: none; cursor: pointer;
}
.rp-color:hover { background: var(--rd-hover); }
.rp-color[aria-pressed="true"] .rn-dot { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--rd-d); }
.rp-sep { width: 1px; height: 22px; margin: 0 4px; background: var(--border); }
.rp-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border: 0; border-radius: 8px;
  background: none; color: var(--ink); font: inherit; font-size: .85rem; font-weight: 500; white-space: nowrap;
  text-decoration: none; cursor: pointer;
}
.rp-btn:hover { background: var(--rd-hover); text-decoration: none; }
.rp-btn .ri { width: 16px; height: 16px; color: var(--ink-soft); }
.rp-danger, .rp-danger .ri { color: var(--danger); }
.rn-dot { display: inline-block; flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; background: var(--rd-d); }

/* ---------- Left sidebar: thumbnails and contents ---------- */

/* The tabs are the site's shared .tabs/.tab component. Here they only get their
   place in the sidebar; the fallback look below sits in a cascade layer, so the
   shared component's own styling wins wherever it defines one. */
.reader-tabs { display: flex; flex: 0 0 auto; gap: 2px; margin: 0; padding: 6px 8px 0; overflow: visible; border-bottom: 1px solid var(--border); }
.reader-tabs [role="tab"] { flex: 1 1 0; min-width: 0; justify-content: center; padding-inline: 6px; }
@layer reader-fallback {
  .reader-tabs [role="tab"] {
    padding: 7px 8px 8px; border: 0; border-bottom: 2px solid transparent; background: none;
    color: var(--muted); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
  }
  .reader-tabs [role="tab"][aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
}
.reader-thumbs, .reader-outline { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.reader-thumbs { padding: 14px 0 24px; }
.reader-thumb {
  display: block; width: 140px; margin: 0 auto 12px; padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: .74rem; line-height: 1.6; text-align: center; font-variant-numeric: tabular-nums;
}
.reader-thumb-img {
  position: relative; display: block; width: 112px; margin: 0 auto 3px; aspect-ratio: var(--ar, .7727);
  overflow: hidden; border-radius: 2px; background: #fff;
  box-shadow: 0 0 0 1px var(--border), 0 1px 3px rgb(0 0 0 / .12);
}
.reader-thumb-img canvas { display: block; width: 100%; height: 100%; }
.reader-thumb:hover .reader-thumb-img { box-shadow: 0 0 0 2px var(--rd-ring); }
.reader-thumb[aria-current="page"] { color: var(--primary); font-weight: 700; }
.reader-thumb[aria-current="page"] .reader-thumb-img { box-shadow: 0 0 0 3px var(--primary); }
.reader-thumb.has-notes .reader-thumb-img::after {
  content: ""; position: absolute; top: 5px; right: 5px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--rd-dot-yellow); box-shadow: 0 0 0 2px #fff;
}
.is-dark-pages .reader-thumb-img { background: #202226; }
.reader-outline { padding: 8px 6px 24px; font-size: .84rem; }
.reader-outline ul { list-style: none; margin: 0; padding: 0; }
.reader-outline ul ul { padding-left: 12px; }
.reader-outline button {
  display: block; width: 100%; padding: 5px 8px; border: 0; border-radius: 6px; background: none;
  color: var(--ink-soft); font: inherit; line-height: 1.35; text-align: left; cursor: pointer;
}
.reader-outline button:hover { background: var(--rd-hover); color: var(--ink); }

/* ---------- Right sidebar: my notes ---------- */

.rn-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 2px 16px; }
.rn-head h2 { margin: 0; font-family: var(--font-body); font-size: .98rem; font-weight: 700; }
.rn-count { color: var(--muted); font-weight: 500; font-size: .85rem; }
.rn-private { margin: 0 0 8px; padding: 0 16px; font-size: .78rem; color: var(--muted); }
.rn-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 12px 10px 16px; border-bottom: 1px solid var(--border); }
.rn-filter {
  flex: 1 1 100%; height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--ink); font: inherit; font-size: .88rem;
}
.rn-colors { display: flex; gap: 4px; }
.rn-cf {
  display: inline-grid; place-items: center; height: 28px; min-width: 30px; padding: 0 9px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--card); color: var(--ink-soft); font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer;
}
.rn-cf .rn-dot { width: 12px; height: 12px; }
.rn-cf[aria-pressed="true"] { border-color: var(--primary); background: var(--rd-active); color: var(--primary); }
.rn-list { flex: 1 1 auto; min-height: 0; margin: 0; padding: 4px 10px 16px; overflow: auto; list-style: none; overscroll-behavior: contain; }
.rn-page {
  padding: 12px 4px 4px; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.rn-item {
  position: relative; margin: 0 0 8px; border: 1px solid var(--border); border-left: 4px solid var(--rd-d);
  border-radius: 8px; background: var(--card);
}
.rn-item:hover { border-color: color-mix(in srgb, var(--ink) 22%, var(--border)); border-left-color: var(--rd-d); }
.rn-item.is-active { border-color: var(--primary); border-left-color: var(--rd-d); box-shadow: 0 0 0 3px var(--rd-ring); }
.rn-item.is-pending { opacity: .6; }
.rn-main {
  display: block; width: 100%; padding: 8px 10px 4px; border: 0; border-radius: 8px; background: none;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.rn-quote {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden;
  font-size: .84rem; line-height: 1.45; color: var(--ink); overflow-wrap: anywhere;
}
.rn-note {
  display: block; margin-top: 6px; padding: 6px 8px; border-radius: 6px; font-size: .84rem; line-height: 1.45;
  color: var(--ink); background: color-mix(in srgb, var(--rd-d) 13%, transparent); white-space: pre-wrap; overflow-wrap: anywhere;
}
.rn-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 4px 3px 10px; font-size: .74rem; color: var(--muted); }
.rn-actions { display: flex; gap: 0; }
.rn-actions .rt-btn { min-width: 30px; height: 30px; padding: 0 6px; }
.rn-actions .ri { width: 15px; height: 15px; }
.rn-empty, .rn-signin { padding: 28px 24px; text-align: center; color: var(--muted); font-size: .88rem; }
.rn-empty p, .rn-signin p { margin: 6px 0; }
.rn-empty strong { color: var(--ink); }
.rn-signin { color: var(--ink-soft); }
.rn-signin h3 { margin: 10px 0 6px; color: var(--ink); }
.rn-signin .btn { margin: 6px 2px 0; }
.rn-empty .ri-lg, .rn-signin .ri-lg { color: var(--rd-dot-yellow); }
.rn-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 10px 16px; border-top: 1px solid var(--border); }
.rn-foot .btn { display: inline-flex; align-items: center; gap: 6px; }
.rn-foot .ri { width: 16px; height: 16px; }
.rn-all { font-size: .85rem; }

/* ---------- Dialogs and toast ---------- */

.reader-modal {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); margin: auto; padding: 0;
  border: 1px solid var(--border); border-radius: 14px; background: var(--card); color: var(--ink);
  box-shadow: 0 24px 64px rgb(0 0 0 / .3);
}
.reader-modal::backdrop { background: rgb(12 18 28 / .5); }
.reader-modal form { padding: 14px 20px 18px; }
.rm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.rm-head h2 { margin: 0; font-size: 1.15rem; }
.rnd-quote {
  margin: 0 0 14px; padding: 8px 12px; max-height: 8.6em; overflow: auto; border-left: 4px solid var(--rd-d, var(--rd-dot-yellow));
  border-radius: 0 6px 6px 0; background: color-mix(in srgb, var(--ink) 5%, transparent);
  font-size: .88rem; line-height: 1.5; color: var(--ink-soft); white-space: pre-wrap; overflow-wrap: anywhere;
}
.rnd-colors { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; padding: 0; border: 0; }
.rnd-colors legend { margin-bottom: 6px; font-size: .85rem; font-weight: 600; }
.rnd-color {
  position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 6px;
  border: 1px solid var(--border); border-radius: 999px; font-size: .85rem; cursor: pointer;
}
.rnd-color input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.rnd-color:has(input:checked) { border-color: var(--rd-d); background: color-mix(in srgb, var(--rd-d) 14%, transparent); font-weight: 600; }
.rnd-color:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 1px; }
.rnd-color .rn-dot { width: 16px; height: 16px; }
.rnd-field { display: block; }
.rnd-field > span:first-child { display: block; margin-bottom: 6px; font-size: .85rem; font-weight: 600; }
.rnd-field textarea {
  display: block; width: 100%; min-height: 128px; padding: 10px 12px; resize: vertical; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; font-size: .92rem; line-height: 1.5;
}
.rnd-left { display: block; margin-top: 4px; text-align: right; }
.rnd-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.rnd-spacer { flex: 1; }
.rcd-label { margin: 12px 0 6px; font-family: var(--font-body); font-size: .74rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.rcd-text {
  margin: 0 0 8px; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--ink) 5%, transparent);
  font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere;
}
.rcd-pre { max-height: 14em; overflow: auto; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; }
.rcd-more { margin-left: 8px; font-size: .88rem; }
.rkd-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.rkd-table th { padding: 7px 12px 7px 0; border-bottom: 1px solid var(--border); font-weight: 500; text-align: left; color: var(--ink-soft); }
.rkd-table td { padding: 7px 0; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.reader-modal kbd {
  display: inline-block; min-width: 1.7em; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; background: var(--bg); color: var(--ink); font: 600 .76rem/1.5 var(--font-body); text-align: center;
}
.reader-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px); padding: 10px 16px;
  border-radius: 10px; background: var(--ink); color: var(--card); font-size: .9rem; box-shadow: 0 10px 30px rgb(0 0 0 / .28);
}
.reader-toast-action {
  padding: 2px 4px; border: 0; background: none; color: inherit; font: inherit; font-weight: 700;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

/* ---------- Narrow screens: sidebars float over the page ---------- */

@media (max-width: 1099px) {
  .reader-left {
    position: absolute; top: 0; bottom: 0; left: 0; z-index: 8; width: 188px;
    box-shadow: 10px 0 30px rgb(0 0 0 / .16);
  }
}
@media (max-width: 1239px) {
  .reader-right {
    position: absolute; top: 0; bottom: 0; right: 0; z-index: 9; width: min(360px, 94vw);
    box-shadow: -10px 0 30px rgb(0 0 0 / .16);
  }
}
@media (max-width: 900px) {
  .rt-title { display: none; }
  .reader-toolbar { justify-content: space-between; }
}
@media (max-width: 760px) {
  .rt-opt, .rt-wide { display: none; }
  .reader-menu .rm-sm { display: flex; }
  .reader-toolbar { gap: 2px; padding: 2px 4px 4px; }
  .reader-crumbs { padding: 4px 12px 0; }
  .rf-opt { display: none; }
  .rf-status { min-width: 0; }
}
@media (max-width: 440px) {
  .rt-zoom { display: none; }
  .rt-btn { min-width: 38px; height: 38px; }
  .reader-pop { max-width: calc(100vw - 16px); flex-wrap: wrap; }
  .rp-btn span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .reader-hl.is-flash { animation: none; }
  .reader-progress span { transition: none; }
}

/* ---------- Dashboard "Continue reading", reading list, listing chips ---------- */

.reader-continue { margin: 0 0 1.8rem; }
.reader-continue .section-head h2 { font-size: 1.2rem; }
.reader-continue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.reader-continue-card {
  display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; color: var(--ink);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
.reader-continue-card:hover { border-color: var(--primary); text-decoration: none; }
.rc-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-weight: 600; line-height: 1.35; }
.rc-authors { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-bar { width: 100%; height: 6px; accent-color: var(--primary); }
.rc-meta { margin-top: auto; }
/* The reading list uses the shared .result-list/.result-item component; this
   layered fallback only fills in where the site stylesheet has no such layout. */
@layer reader-fallback {
  .reader-lib-list { list-style: none; }
  .reader-lib-list .result-item { display: flex; gap: 20px; }
  .reader-lib-list .result-main { flex: 1; min-width: 0; }
  .reader-lib-list .result-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
  .reader-lib-list .result-title { margin: .4em 0 .2em; font-size: 1.12rem; }
  .reader-lib-list .result-side { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
  @media (max-width: 640px) {
    .reader-lib-list .result-item { flex-direction: column; gap: 10px; }
    .reader-lib-list .result-side { flex-direction: row; align-items: center; }
  }
}
.reader-lib-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 8px; }
.reader-lib-meta .rc-bar { width: 120px; }
.reader-lib-file { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-chip::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%;
  background: var(--rd-dot-yellow); vertical-align: 1px;
}
