/* The reader (#/read/<id>): the whole screen, a quiet bar on top with the way back, contents, search and
   reading settings, the page in the middle, and a progress line underneath. Colours follow the app's
   light/dark unless the reader picks a colour scheme (then reader.js sets the colour variables on .rd). */
body.reading { overflow: hidden; overscroll-behavior: none; }
body.reading .side, body.reading .dtop, body.reading .tabs { display: none !important; }
body.reading::before { display: none; }
.rd { position: fixed; inset: 0; z-index: 40; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--bg); color: var(--ink);
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
.rd-top { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 6px 10px; border-bottom: 1px solid var(--line-soft); min-width: 0; }
.rd-head { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.rd-head b, .rd-head small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-head b { font-weight: 600; font-size: 15px; }
.rd-head small { color: var(--muted); font-size: 12.5px; min-height: 1.25em; }
.rd-icon, .rd-a { flex: none; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; display: grid; place-items: center; color: var(--ink); }
.rd-icon:hover, .rd-a:hover:not(:disabled) { background: var(--line-soft); }
.rd-fonts { flex: none; display: flex; gap: 2px; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.rd-a { width: 42px; height: 38px; border-radius: 999px; font-family: Georgia, "Times New Roman", serif; line-height: 1; }
.rd-a-s { font-size: 14px; }
.rd-a-b { font-size: 21px; }
.rd-stage { position: relative; min-height: 0; overflow: hidden; touch-action: pan-y pinch-zoom; }
.rd-page { position: absolute; inset: 14px 16px 6px; }
.rd-turn { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 72px; border: 0; border-radius: 14px; background: transparent; color: var(--muted);
  display: none; place-items: center; }
.rd-turn:hover:not(:disabled) { background: var(--line-soft); color: var(--ink); }
.rd-turn:disabled { opacity: .25; }
.rd-prev { left: 8px; }
.rd-next { right: 8px; }
.rd-foot { padding: 6px 16px 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rd-bar { height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.rd-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.rd-line { font-size: 12.5px; color: var(--muted); text-align: center; min-height: 1.4em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; background: var(--bg); }
.rd-msg[hidden] { display: none; }
.rd-msg p { margin: 0 0 4px; max-width: 34ch; font-size: 16px; }
.rd-pill { border: 0; border-radius: 999px; min-height: 44px; padding: 0 20px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.rd-pill.rd-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
@media (min-width: 700px) {
  .rd-top { padding: 8px 18px; }
  .rd-page { inset: 22px 72px 10px; }
  .rd-turn { display: grid; }
}
@media (min-width: 1300px) {
  .rd-page { left: calc((100% - 1150px) / 2); right: calc((100% - 1150px) / 2); }
}
@media (prefers-reduced-motion: reduce) { .rd-bar i { transition: none; } }
/* comics: one picture a page, fitted to the screen; pinch, double-tap or the +/- buttons zoom in */
.rd-zoom[hidden], .rd-fonts[hidden] { display: none; }
.rd-zoom .rd-a svg { width: 20px; height: 20px; }
.rd-comicmode .rd-stage { touch-action: none; }
.rd-comicmode .rd-page { inset: 6px 6px 2px; }
.rd-cview { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; cursor: zoom-in; }
.rd-cview.zoomed { cursor: grab; }
.rd-cview.zoomed:active { cursor: grabbing; }
.rd-cview.pannable { cursor: ns-resize; }
.rd-cpics { position: absolute; display: flex; transform-origin: 50% 50%; }
.rd-rtl .rd-cpics { flex-direction: row-reverse; }
.rd-cimg { display: block; flex: none; height: 100%; width: auto; -webkit-user-drag: none; pointer-events: none; }
.rd-cimg[hidden] { display: none; }
.rd-cblack .rd-stage, .rd-cblack .rd-msg { background: #000; }
.rd-rtl .rd-bar { transform: scaleX(-1); }
@media (min-width: 700px) {
  .rd-comicmode .rd-page { inset: 10px 72px 4px; }
}
@media (min-width: 1300px) {
  .rd-comicmode .rd-page { left: 72px; right: 72px; }
}

/* the bar's tools: contents, search, reading settings */
.rd-icon[hidden] { display: none; }
.rd-aa { font-family: Georgia, "Times New Roman", serif; font-size: 19px; letter-spacing: -.02em; }
/* margins and scrolling */
.rd-m-narrow .rd-page { inset: 10px 8px 4px; }
.rd-m-wide .rd-page { inset: 16px 30px 8px; }
.rd-scroll .rd-turn { display: none !important; }
.rd-scroll .rd-page { inset: 0 6px 0; }
.rd-scroll.rd-m-narrow .rd-page { inset: 0 2px 0; }
.rd-scroll.rd-m-wide .rd-page { inset: 0 24px 0; }
@media (min-width: 700px) {
  .rd-m-narrow .rd-page { inset: 16px 60px 8px; }
  .rd-m-wide .rd-page { inset: 26px 120px 12px; }
  .rd-scroll .rd-page { inset: 0 72px 0; }
  .rd-scroll.rd-m-narrow .rd-page { inset: 0 60px 0; }
  .rd-scroll.rd-m-wide .rd-page { inset: 0 120px 0; }
}
@media (min-width: 1300px) {
  .rd-m-narrow .rd-page, .rd-scroll.rd-m-narrow .rd-page { left: calc((100% - 1300px) / 2); right: calc((100% - 1300px) / 2); }
  .rd-m-wide .rd-page, .rd-scroll.rd-m-wide .rd-page { left: calc((100% - 900px) / 2); right: calc((100% - 900px) / 2); }
  .rd-scroll .rd-page { left: calc((100% - 1150px) / 2); right: calc((100% - 1150px) / 2); }
}
/* panels: a sheet from the bottom on a phone, a column on the right on a wide screen */
.rd-sheetwrap { position: absolute; inset: 0; z-index: 5; }
.rd-sheetwrap[hidden] { display: none; }
.rd-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.32); }
.rd-looks .rd-scrim { background: transparent; }
.rd-sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 72%; display: flex; flex-direction: column; background: var(--surface); color: var(--ink);
  border-radius: 18px 18px 0 0; box-shadow: 0 -8px 32px rgba(0,0,0,.22); padding-bottom: env(safe-area-inset-bottom, 0px); min-width: 0; }
.rd-tall .rd-sheet { height: 86%; max-height: none; }
.rd-looks .rd-sheet { max-height: 58%; }
.rd-sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 6px 20px; border-bottom: 1px solid var(--line-soft); }
.rd-sheet-head h2 { margin: 0; font-size: 17px; font-weight: 650; min-width: 0; overflow-wrap: anywhere; }
.rd-sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 10px 16px; }
.rd-list { display: flex; flex-direction: column; }
.rd-row { width: 100%; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 15px; text-align: left; display: flex; flex-direction: column; align-items: stretch; gap: 3px;
  min-height: 48px; justify-content: center; padding: 10px 12px; border-radius: 12px; cursor: pointer; }
.rd-row:hover { background: var(--line-soft); }
.rd-row[aria-current="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.rd-row.rd-sub { font-size: 14px; }
.rd-row-t { overflow-wrap: anywhere; line-height: 1.4; }
.rd-row-s { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-hit .rd-row-t { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rd-hit mark { background: #F2B70566; color: inherit; border-radius: 3px; padding: 0 1px; }
.rd-find { display: flex; gap: 8px; padding: 4px 2px 8px; }
.rd-input { flex: 1; min-width: 0; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; background: var(--bg); color: var(--ink); font: inherit; font-size: 16px; }
.rd-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.rd-status { margin: 4px 12px 8px; color: var(--muted); font-size: 14px; min-height: 1.2em; }
.rd-status:empty { display: none; }
.rd-set { border: 0; margin: 0 0 14px; padding: 0 6px; min-width: 0; }
.rd-set legend { padding: 0; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.rd-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.rd-opt { border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; border-radius: 999px; min-height: 40px; padding: 0 14px; cursor: pointer; max-width: 100%; }
.rd-opt:hover { border-color: var(--muted); }
.rd-opt[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.rd-swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.rd-steps { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 999px; padding: 2px; width: max-content; }
.rd-step-t { min-width: 56px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.rd-a:disabled { opacity: .35; }
.rd-note { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.rd-note[hidden] { display: none; }
@media (min-width: 700px) {
  .rd-sheet, .rd-tall .rd-sheet, .rd-looks .rd-sheet { left: auto; top: 0; bottom: 0; width: 400px; height: auto; max-height: none; border-radius: 0; box-shadow: -8px 0 32px rgba(0,0,0,.18); }
}

/* bookmarks and highlights: the ribbon in the bar, the colour bar over picked words, the tabs in Contents */
.rd-bm[aria-pressed="true"] { color: var(--accent); }
.rd-bm[aria-pressed="true"] svg { fill: currentColor; }
@media (max-width: 420px) { .rd-top { gap: 2px; padding-left: 4px; padding-right: 4px; } .rd-top .rd-icon { width: 40px; } }
.rd-pop { position: absolute; z-index: 4; display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 999px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); box-shadow: 0 8px 28px rgba(0,0,0,.22); max-width: calc(100% - 16px); }
.rd-pop[hidden] { display: none; }
.rd-dot { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--surface); background: var(--mk); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.rd-dot:hover { transform: scale(1.08); }
.rd-dot-l { width: 38px; height: 38px; }
.rd-dot[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.rd-pop-sep { flex: none; width: 1px; align-self: stretch; margin: 2px 2px; background: var(--line); }
.rd-pop-b { flex: none; height: 36px; border: 0; border-radius: 999px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px; padding: 0 10px 0 8px; cursor: pointer; }
.rd-pop-b svg { width: 18px; height: 18px; }
.rd-pop-b:hover { background: var(--line-soft); }
.rd-pop-i { width: 36px; padding: 0; justify-content: center; }
.rd-toast { position: absolute; z-index: 6; left: 50%; bottom: calc(56px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 8px); max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center; }
.rd-toast.on { opacity: 1; transform: translate(-50%, 0); }
.rd-tabs { display: flex; gap: 4px; padding: 2px 2px 10px; position: sticky; top: -8px; background: var(--surface); z-index: 1; }
.rd-tab { flex: 1; min-width: 0; min-height: 40px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; padding: 0 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.rd-tab[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.rd-mrow { display: flex; align-items: flex-start; gap: 2px; min-width: 0; }
.rd-mrow .rd-row { flex: 1; min-width: 0; }
.rd-mrow .rd-mx { margin-top: 2px; color: var(--muted); }
.rd-hlrow { border-left: 4px solid var(--mk); border-radius: 4px 12px 12px 4px; padding-left: 12px; }
.rd-quote-t { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rd-row-n { font-size: 14px; color: var(--muted); font-style: italic; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rd-mrow .rd-row-s { white-space: normal; }
.rd-addmark { display: inline-flex; align-items: center; gap: 8px; margin: 2px 2px 8px; }
.rd-addmark svg { width: 18px; height: 18px; }
.rd-addmark:disabled { opacity: .6; }
.rd-linkb { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); font-weight: 600; text-decoration: underline; cursor: pointer; }
.rd-quote { margin: 4px 6px 4px; padding: 10px 14px; border-left: 4px solid var(--mk); background: var(--bg); border-radius: 4px 12px 12px 4px; font-family: Georgia, "Iowan Old Style", serif;
  font-size: 15.5px; line-height: 1.5; overflow-wrap: anywhere; max-height: 9.5em; overflow-y: auto; }
.rd-quote.rd-q-underline, .rd-quote.rd-q-squiggly, .rd-quote.rd-q-strikethrough { text-decoration-color: var(--mk); text-decoration-thickness: 2px; }
.rd-quote.rd-q-underline { text-decoration-line: underline; }
.rd-quote.rd-q-squiggly { text-decoration-line: underline; text-decoration-style: wavy; text-decoration-thickness: 1.5px; }
.rd-quote.rd-q-strikethrough { text-decoration-line: line-through; }
.rd-quote-s { margin: 0 6px 14px; font-size: 13px; color: var(--muted); }
.rd-marksheet .rd-quote + .rd-set { margin-top: 14px; }
.rd-colors { gap: 12px; padding: 4px 2px; }
.rd-notefield { display: flex; flex-direction: column; }
.rd-legend { margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.rd-text { min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.rd-acts { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 6px 8px; }
.rd-danger { color: var(--danger) !important; }
.rd-sheet button:focus-visible, .rd-pop button:focus-visible, .rd-top button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* with a sheet open, messages show at the top so they never cover it */
.rd-sheetwrap:not([hidden]) ~ .rd-toast { bottom: auto; top: calc(64px + env(safe-area-inset-top, 0px)); }
@media (min-width: 700px) { .rd-sheetwrap:not([hidden]) ~ .rd-toast { left: calc((100% - 400px) / 2); } }
/* "On your Kobo you're at X% · Go there": over the top of the page, out of the way of the text */
.rd-offer { position: absolute; z-index: 5; top: 10px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 16px; border-radius: 999px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); box-shadow: 0 4px 18px rgba(0,0,0,.18); font-size: 15px; }
.rd-offer[hidden] { display: none; }
.rd-offer-t { min-width: 0; overflow-wrap: anywhere; }
.rd-offer .rd-pill { min-height: 40px; padding: 0 16px; white-space: nowrap; flex: none; }
.rd-offer .rd-icon { flex: none; }
@media (max-width: 480px) { .rd-offer { gap: 4px; padding-left: 14px; font-size: 14px; } .rd-offer .rd-pill { padding: 0 12px; } .rd-offer .rd-icon { width: 40px; height: 40px; } }
@media (max-width: 340px) { .rd-offer { flex-wrap: wrap; justify-content: center; border-radius: 18px; padding: 8px 10px; } }
