/* ==========================================================================
   A.M.A.D.E.U.S — PDF reader (amadeus-reader.js)
   Full-screen overlay #am-reader. Chrome uses the studio tokens (site.css /
   amadeus.css) so it flips with the app theme; the reading theme
   (data-read-theme = light | sepia | dark) only touches the page bitmaps.
   Layers inside a page (bottom -> top): canvas, sepia tint, search hits,
   text layer, links, plugin overlay.
   ========================================================================== */

html.amr-lock, html.amr-lock body { overflow: hidden; }

#am-reader {
  --amr-bar-h: 52px;
  --amr-btn: 36px;
  --amr-desk: color-mix(in srgb, var(--ink) 7%, var(--page));
  --amr-page-shadow: 0 1px 2px rgba(11,11,11,.10), 0 4px 16px rgba(11,11,11,.07);
  --amr-hit: rgba(255, 200, 0, .38);
  --amr-hit-cur: rgba(255, 128, 0, .55);
  position: fixed;
  inset: 0;
  z-index: 240;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
  animation: amr-in .16s var(--am-ease, ease) both;
}
:root[data-theme="dark"] #am-reader {
  --amr-desk: #111110;
  --amr-page-shadow: 0 1px 2px rgba(0,0,0,.5), 0 6px 20px rgba(0,0,0,.35);
}
@keyframes amr-in { from { opacity: 0; } to { opacity: 1; } }
#am-reader *, #am-reader *::before, #am-reader *::after { box-sizing: border-box; }
#am-reader [hidden] { display: none !important; }

/* ---- Top bar --------------------------------------------------------------- */
.amr-bar {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: calc(var(--amr-bar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) calc(8px + env(safe-area-inset-right, 0px)) 0 calc(8px + env(safe-area-inset-left, 0px));
  background: var(--surface-raised);
  border-bottom: 1px solid var(--hairline);
  position: relative;
  z-index: 30;
  -webkit-user-select: none;
  user-select: none;
}
.amr-bar-l, .amr-bar-r, .amr-bar-c { display: flex; align-items: center; gap: 4px; min-width: 0; }
.amr-bar-c { gap: 10px; }
.amr-bar-r { justify-content: flex-end; }
.amr-title { min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 6px 0 4px; line-height: 1.2; }
.amr-title-main { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amr-title-sub { font-size: .74rem; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amr-title-sub:empty { display: none; }
.amr-slot { display: flex; align-items: center; gap: 4px; }
.amr-slot:empty { display: none; }

/* Icon buttons (same language as .am-tinybtn / .am-iconbtn) */
.amr-btn {
  width: var(--amr-btn);
  height: var(--amr-btn);
  flex: none;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-secondary);
  cursor: pointer;
  touch-action: manipulation;
  transition: color .15s, background .15s, opacity .15s;
}
.amr-btn:hover { color: var(--ink); background: var(--accent-wash); }
.amr-btn:active { transform: scale(.96); }
.amr-btn[aria-pressed="true"] { color: var(--accent-strong); background: var(--accent-wash); }
.amr-btn:disabled { opacity: .35; cursor: default; background: transparent; transform: none; }
.amr-btn:focus-visible, .amr-zoom-val:focus-visible, .amr-pagechip:focus-visible,
.amr-menu-item:focus-visible, .amr-ol-item:focus-visible, .amr-tab:focus-visible, .amr-chip button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.amr-close { color: var(--ink); }
/* Page/zoom/search controls mean nothing until a document is showing. */
#am-reader.amr-has-state .amr-bar-c, #am-reader.amr-has-state .amr-pagechip,
#am-reader.amr-has-state .amr-search-btn { visibility: hidden; }

/* Page field + zoom: pill groups */
.amr-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
}
.amr-group .amr-btn { border-radius: 999px; width: 32px; height: 32px; }
.amr-page-field { display: inline-flex; align-items: baseline; gap: 5px; padding: 0 6px; font-size: .86rem; color: var(--ink-muted); cursor: text; font-variant-numeric: tabular-nums; }
.amr-page-input {
  width: 3.4ch;
  min-width: 2.4ch;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: 600 .88rem/1.6 var(--sans);
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 0 3px;
}
.amr-page-input:focus { outline: none; background: var(--surface-raised); box-shadow: 0 0 0 2px var(--accent-wash), 0 0 0 1px var(--accent) inset; }
.amr-page-total { white-space: nowrap; }
.amr-zoom-val {
  min-width: 58px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 600 .84rem var(--sans);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.amr-zoom-val:hover { background: var(--accent-wash); }
.amr-pagechip {
  display: none;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 600 .82rem var(--sans);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
}

/* ---- Search bar (floats under the top bar) --------------------------------- */
.amr-searchbar {
  position: absolute;
  top: calc(var(--amr-bar-h) + env(safe-area-inset-top, 0px) + 8px);
  right: calc(12px + env(safe-area-inset-right, 0px));
  z-index: 28;
  width: min(440px, calc(100% - 24px));
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 4px 4px 12px;
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  /* Tight shadow: a wide soft one reads as a grey smear over a white page. */
  box-shadow: 0 1px 3px rgba(11,11,11,.10), 0 6px 18px rgba(11,11,11,.12);
  animation: amr-pop .14s var(--am-ease, ease) both;
}
:root[data-theme="dark"] .amr-searchbar { box-shadow: 0 1px 3px rgba(0,0,0,.5), 0 6px 18px rgba(0,0,0,.35); }
.amr-search-ico { display: inline-flex; color: var(--ink-muted); flex: none; margin-right: 6px; }
.amr-search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: .92rem var(--sans);
  padding: 7px 0;
  outline: none;
}
.amr-search-input::-webkit-search-cancel-button { display: none; }
.amr-search-count { flex: none; font-size: .78rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; padding: 0 6px; white-space: nowrap; }
.amr-searchbar .amr-btn { width: 32px; height: 32px; }

/* ---- Body: sidebar + main ---------------------------------------------------- */
.amr-body { flex: 1; min-height: 0; display: flex; position: relative; }
.amr-side {
  flex: none;
  width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
  border-right: 1px solid transparent;
  /* Closed: hidden once collapsed, so Tab can't reach its controls. */
  visibility: hidden;
  transition: width .2s var(--am-ease, ease), border-color .2s, visibility 0s .2s;
  z-index: 12;
}
.amr-side > * { width: 288px; }
#am-reader.amr-side-open .amr-side { width: 288px; border-right-color: var(--hairline); visibility: visible; transition-delay: 0s; }
.amr-side-head { flex: none; display: flex; align-items: center; gap: 6px; padding: 10px 8px 8px 12px; border-bottom: 1px solid var(--hairline); }
.amr-tabs { flex: 1; display: flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--hairline); border-radius: 999px; }
.amr-tab {
  flex: 1;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  font: 600 .8rem var(--sans);
  cursor: pointer;
}
.amr-tab[aria-selected="true"] { background: var(--surface-raised); color: var(--ink); box-shadow: 0 1px 2px rgba(11,11,11,.12); }
.amr-side-x { display: none; }
.amr-side-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 6px 6px 20px; }
.amr-side-empty { padding: 18px 12px; font-size: .84rem; color: var(--ink-muted); line-height: 1.5; }

/* Outline tree */
.amr-ol-list { display: flex; flex-direction: column; }
.amr-ol-node > .amr-ol-list { display: none; }
.amr-ol-node.is-open > .amr-ol-list { display: flex; }
.amr-ol-row { display: flex; align-items: flex-start; gap: 0; }
.amr-ol-tog {
  flex: none;
  width: 24px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
}
.amr-ol-tog svg { transition: transform .15s; }
.amr-ol-tog[aria-expanded="true"] svg { transform: rotate(90deg); }
.amr-ol-tog.is-leaf { cursor: default; }
.amr-ol-item {
  flex: 1;
  min-width: 0;
  min-height: 30px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-secondary);
  font: .84rem/1.35 var(--sans);
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.amr-ol-item:hover { background: var(--accent-wash); color: var(--ink); }
.amr-ol-item.is-bold { font-weight: 600; color: var(--ink); }
.amr-ol-item.is-italic { font-style: italic; }

/* Page thumbnails (Pages tab) */
.amr-thumbs { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; }
.amr-thumbs[hidden] { display: none; }
.amr-thumb {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 10px 4px;
  border: 0; border-radius: 10px;
  background: transparent;
  color: var(--ink-muted);
  font: 600 .72rem var(--sans);
  cursor: pointer;
}
.amr-thumb:hover { background: var(--accent-wash); color: var(--ink); }
.amr-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.amr-thumb-img { display: block; width: 120px; background: #fff; box-shadow: 0 0 0 1px var(--hairline), 0 1px 3px rgba(11,11,11,.12); border-radius: 2px; overflow: hidden; }
.amr-thumb-img img { display: block; width: 100%; height: 100%; }
.amr-thumb.is-current { color: var(--accent-strong); }
.amr-thumb.is-current .amr-thumb-img { box-shadow: 0 0 0 2px var(--accent), 0 1px 3px rgba(11,11,11,.12); }
/* Pages carrying annotations (ctx.setPageMarks). */
.amr-thumb.has-marks::after {
  content: ""; position: absolute; top: 2px; right: 4px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--surface-raised);
}

.amr-scrim { display: none; }
.amr-main { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }

/* ---- Scroller + pages ------------------------------------------------------- */
.amr-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
  background: var(--amr-desk);
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  outline: none;
  scrollbar-gutter: auto;
}
.amr-pages { position: relative; margin: 0; transform-origin: 0 0; }
.amr-pages.is-live { will-change: transform; }
.amr-page {
  position: absolute;
  background: #fff;
  box-shadow: var(--amr-page-shadow);
  overflow: hidden;
  contain: layout paint;
  --scale-factor: 1;
  --user-unit: 1;
  --total-scale-factor: calc(var(--scale-factor) * var(--user-unit));
  --scale-round-x: 1px;
  --scale-round-y: 1px;
}
/* Placeholder shimmer until the first bitmap lands. */
.amr-page:not(:has(> .amr-canvas))::before {
  content: "";
  position: absolute;
  inset: 8% 10%;
  background: repeating-linear-gradient(to bottom, rgba(11,11,11,.05) 0 10px, transparent 10px 22px);
  border-radius: 4px;
  opacity: .8;
}
.amr-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.amr-tint, .amr-hits, .amr-links, .amr-overlay { position: absolute; inset: 0; }
.amr-tint { pointer-events: none; display: none; }
.amr-hits { pointer-events: none; z-index: 1; }
.amr-text { z-index: 2; }
.amr-links { z-index: 3; pointer-events: none; }
.amr-overlay { z-index: 4; pointer-events: none; }
.amr-overlay > * { pointer-events: auto; }
.amr-hit { position: absolute; background: var(--amr-hit); border-radius: 2px; mix-blend-mode: multiply; }
.amr-hit.is-current { background: var(--amr-hit-cur); box-shadow: 0 0 0 1px rgba(255, 110, 0, .6); }
.amr-link {
  position: absolute;
  display: block;
  pointer-events: auto;
  border-radius: 2px;
  cursor: pointer;
}
.amr-link:hover { background: rgba(58, 110, 255, .12); box-shadow: 0 0 0 1px rgba(58, 110, 255, .35); }
.amr-link:focus-visible { outline: 2px solid var(--accent); }
/* While a text drag is in progress, links must not steal the selection. */
.amr-text.selecting ~ .amr-links { display: none; }

.amr-flash {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  border-radius: 3px;
  background: rgba(255, 190, 40, .35);
  box-shadow: 0 0 0 2px rgba(255, 150, 0, .55);
  animation: amr-flash 1.4s ease-out both;
}
.amr-flash.is-page { inset: 0; background: transparent; box-shadow: inset 0 0 0 3px var(--accent); }
@keyframes amr-flash { 0% { opacity: 0; } 12% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }

/* ---- pdf.js text layer (from pdfjs-dist 6.3.289 web/pdf_viewer.css) --------- */
#am-reader .textLayer {
  color-scheme: only light;
  position: absolute;
  text-align: initial;
  inset: 0;
  overflow: clip;
  opacity: 1;
  line-height: 1;
  letter-spacing: normal;
  word-spacing: normal;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  caret-color: CanvasText;
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));
}
/* Pages with /Rotate: pdf.js lays the text out unrotated and tags the layer. */
#am-reader .textLayer[data-main-rotation="90"] { transform: rotate(90deg) translateY(-100%); }
#am-reader .textLayer[data-main-rotation="180"] { transform: rotate(180deg) translate(-100%, -100%); }
#am-reader .textLayer[data-main-rotation="270"] { transform: rotate(270deg) translateX(-100%); }
#am-reader .textLayer :is(span, br) {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
  -webkit-user-select: text;
  user-select: text;
}
#am-reader .textLayer > :not(.markedContent),
#am-reader .textLayer .markedContent span:not(.markedContent) {
  z-index: 1;
  --font-height: 0;
  font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1;
  --rotate: 0deg;
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
#am-reader .textLayer .markedContent { display: contents; }
#am-reader .textLayer span[role="img"] { -webkit-user-select: none; user-select: none; cursor: default; }
#am-reader .textLayer ::selection { background: rgba(38, 99, 235, .28); color: transparent; }
#am-reader .textLayer br::selection { background: transparent; }
#am-reader .textLayer .endOfContent {
  display: block;
  position: absolute;
  inset: 100% 0 0;
  z-index: 0;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}
#am-reader .textLayer.selecting .endOfContent { top: 0; }

/* ---- Reading themes: only the page bitmap is filtered, never the chrome ------ */
#am-reader[data-read-theme="sepia"] .amr-page { background: #f4ecd8; }
#am-reader[data-read-theme="sepia"] .amr-tint { display: block; background: #f4ecd8; mix-blend-mode: multiply; }
#am-reader[data-read-theme="sepia"] .amr-canvas { filter: sepia(.12) contrast(.96); }
#am-reader[data-read-theme="dark"] .amr-page { background: #1e1e1d; }
#am-reader[data-read-theme="dark"] .amr-canvas { filter: invert(.88) hue-rotate(180deg) contrast(.95); }
#am-reader[data-read-theme="dark"] .amr-thumb-img { background: #1e1e1d; }
#am-reader[data-read-theme="dark"] .amr-thumb-img img { filter: invert(.88) hue-rotate(180deg) contrast(.95); }
#am-reader[data-read-theme="dark"] .amr-page:not(:has(> .amr-canvas))::before {
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.06) 0 10px, transparent 10px 22px);
}
#am-reader[data-read-theme="dark"] .amr-hit { mix-blend-mode: normal; background: rgba(255, 200, 0, .32); }
#am-reader[data-read-theme="dark"] .amr-hit.is-current { background: rgba(255, 140, 0, .5); }
#am-reader[data-read-theme="dark"] .textLayer ::selection { background: rgba(120, 160, 255, .38); }

/* ---- Floating chips ("Back to p. 4", "Finished? Mark as read") --------------- */
.amr-chips {
  position: absolute;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100% - 24px);
}
.amr-chip {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--page);
  box-shadow: var(--am-shadow-pop);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s, transform .18s var(--am-ease, ease);
  max-width: 100%;
}
.amr-chip.is-in { opacity: 1; transform: none; }
.amr-chip-main {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: 600 .84rem var(--sans);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.amr-chip-main > span { display: inline-flex; align-items: center; gap: 7px; }
.amr-chip-main:hover { background: rgba(255,255,255,.12); }
:root[data-theme="dark"] .amr-chip-main:hover { background: rgba(0,0,0,.08); }
.amr-chip-ico { display: inline-flex; }
.amr-chip-x {
  width: 30px; height: 30px;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 999px;
  background: transparent; color: inherit; opacity: .7;
  cursor: pointer;
}
.amr-chip-x:hover { opacity: 1; background: rgba(255,255,255,.12); }
.amr-chip.is-accent { background: var(--accent-strong); color: #fff; }

/* ---- Plugin tool rail (annotation tools live here) --------------------------- */
.amr-tools {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 18;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.amr-tools:empty { display: none; }
#am-reader.amr-has-state .amr-tools, #am-reader.amr-has-state .amr-chip:not([data-chip="reading"]) { display: none; }
/* A file picked from the error / no-link card: its "Reading the file…" chip (and ×) shows over the card. */
#am-reader.amr-has-state .amr-chips { z-index: 26; }

/* ---- Loading / error card ------------------------------------------------------ */
.amr-state {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 24px calc(16px + env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
  background: var(--amr-desk);
  overflow: auto;
}
.amr-state-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 24px 22px;
  text-align: center;
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--am-radius-lg, 16px);
  box-shadow: var(--shadow, 0 1px 2px rgba(0,0,0,.06));
  animation: amr-pop .18s var(--am-ease, ease) both;
}
.amr-state-ico {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--accent-wash);
  color: var(--accent-strong);
}
.amr-state-ico.is-spin svg { animation: amr-bob 1.2s ease-in-out infinite; }
.amr-state-card.is-error .amr-state-ico { background: color-mix(in srgb, var(--error, #d2483f) 12%, transparent); color: var(--error, #d2483f); }
.amr-state-title { font-size: 1.02rem; font-weight: 650; color: var(--ink); }
.amr-state-msg { font-size: .86rem; line-height: 1.5; color: var(--ink-muted); max-width: 36ch; overflow-wrap: anywhere; }
.amr-state-field { width: 100%; }
.amr-state-field .am-input { width: 100%; }
.amr-state-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.amr-state-acts .btn { display: inline-flex; align-items: center; gap: 7px; }
.amr-prog { width: 100%; max-width: 260px; height: 4px; margin-top: 4px; border-radius: 999px; background: var(--hairline); overflow: hidden; position: relative; }
.amr-prog-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .2s; }
.amr-prog.is-indet .amr-prog-fill { width: 34%; position: absolute; animation: amr-indet 1.1s ease-in-out infinite; }
@keyframes amr-indet { 0% { left: -34%; } 100% { left: 100%; } }
@keyframes amr-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes amr-pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---- Popovers + menus --------------------------------------------------------- */
.amr-pop {
  position: fixed;
  z-index: 60;
  min-width: 200px;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--surface-raised);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--am-shadow-pop);
  animation: amr-pop .12s var(--am-ease, ease) both;
}
.amr-menu { display: flex; flex-direction: column; padding: 6px; min-width: 232px; }
.amr-zoom-menu .amr-menu { min-width: 200px; }
.amr-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font: .88rem var(--sans);
  text-align: left;
  cursor: pointer;
}
.amr-menu-item svg { flex: none; color: var(--ink-muted); }
.amr-menu-item.is-checked svg { color: var(--accent-strong); }
.amr-menu-item:hover:not(:disabled) { background: var(--accent-wash); }
.amr-menu-item:disabled { opacity: .45; cursor: default; }
.amr-menu-item.is-danger, .amr-menu-item.is-danger svg { color: var(--error, #d2483f); }
.amr-menu-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amr-menu-hint { flex: none; font-size: .76rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.amr-menu-sep { height: 1px; margin: 5px 4px; background: var(--hairline); }
.amr-menu-head { padding: 8px 10px 4px; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.amr-menu-pad { padding: 2px 4px 6px; }
.amr-theme-seg { display: flex; width: 100%; }
.amr-theme-seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: .4rem .5rem; }

/* Go-to-page popover */
.amr-goto { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.amr-goto-row { display: flex; align-items: center; gap: 8px; font-size: .88rem; }
.amr-goto-row .btn { flex: 1; justify-content: center; }
.amr-goto-row .amr-goto-input { width: 76px; text-align: center; }
.amr-goto-row .btn-primary { flex: none; }
.amr-muted { color: var(--ink-muted); white-space: nowrap; }

/* ---- Narrow (phones, small windows): class set by JS below 760px ------------- */
#am-reader.amr-narrow { --amr-bar-h: 52px; }
#am-reader.amr-narrow .amr-hide-narrow { display: none; }
#am-reader.amr-narrow .amr-bar { grid-template-columns: minmax(0, 1fr) auto; gap: 4px; padding-left: calc(4px + env(safe-area-inset-left, 0px)); padding-right: calc(4px + env(safe-area-inset-right, 0px)); }
#am-reader.amr-narrow .amr-bar-c { display: none; }
#am-reader.amr-narrow .amr-pagechip { display: inline-flex; align-items: center; }
#am-reader.amr-narrow .amr-title { padding: 0 2px; }
#am-reader.amr-narrow .amr-searchbar { left: 8px; right: 8px; width: auto; top: calc(var(--amr-bar-h) + env(safe-area-inset-top, 0px) + 6px); }
/* Sidebar becomes a sheet over the page with a scrim. */
#am-reader.amr-narrow .amr-side {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: min(86vw, 340px);
  border-right: 1px solid var(--hairline);
  box-shadow: var(--am-shadow-pop);
  transform: translateX(-104%);
  transition: transform .22s var(--am-ease, ease), visibility 0s .22s;
  z-index: 26;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
}
#am-reader.amr-narrow .amr-side > * { width: auto; }
#am-reader.amr-narrow.amr-side-open .amr-side { transform: none; width: min(86vw, 340px); transition-delay: 0s; }
#am-reader.amr-narrow .amr-side-x { display: inline-grid; }
#am-reader.amr-narrow .amr-scrim {
  display: block;
  position: absolute; inset: 0;
  z-index: 24;
  background: rgba(11,11,11,.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
#am-reader.amr-narrow.amr-side-open .amr-scrim { opacity: 1; pointer-events: auto; }
#am-reader.amr-narrow .amr-chips { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }

/* ---- Coarse pointers (tablets / phones / stylus): 44px targets --------------- */
#am-reader.amr-coarse { --amr-btn: 44px; --amr-bar-h: 58px; }
#am-reader.amr-coarse .amr-group .amr-btn { width: 40px; height: 40px; }
#am-reader.amr-coarse .amr-zoom-val, #am-reader.amr-coarse .amr-pagechip { height: 40px; }
#am-reader.amr-coarse .amr-page-input { font-size: 1rem; }
#am-reader.amr-coarse .amr-search-input { font-size: 16px; }
#am-reader.amr-coarse .amr-searchbar .amr-btn { width: 40px; height: 40px; }
#am-reader.amr-coarse .amr-menu-item { min-height: 44px; }
#am-reader.amr-coarse .amr-ol-item { min-height: 40px; padding-top: 10px; padding-bottom: 10px; }
#am-reader.amr-coarse .amr-ol-tog { width: 32px; height: 40px; }
#am-reader.amr-coarse .amr-tab { height: 36px; }
#am-reader.amr-coarse .amr-chip-main { min-height: 40px; }
#am-reader.amr-coarse .amr-chip-x { width: 36px; height: 36px; }
#am-reader.amr-coarse .amr-goto-input { font-size: 16px; }
/* Tools move to a bottom-centre dock where thumbs and pens reach them. */
#am-reader.amr-narrow .amr-tools, #am-reader.amr-coarse .amr-tools {
  left: 50%;
  top: auto;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  flex-direction: row;
  max-width: calc(100% - 16px);
}
#am-reader.amr-has-plugin.amr-narrow .amr-chips,
#am-reader.amr-has-plugin.amr-coarse .amr-chips { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
#am-reader.amr-has-plugin .amr-tools:empty ~ .amr-chips { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }

/* Very small phones: drop the subtitle so the title keeps its room. */
@media (max-width: 420px) {
  #am-reader.amr-narrow .amr-title-sub { display: none; }
}
/* Short landscape phones: slimmer bar. */
@media (max-height: 480px) and (orientation: landscape) {
  #am-reader.amr-coarse { --amr-bar-h: 48px; }
}

/* ---- Motion + print ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  #am-reader, #am-reader * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
/* Printing goes through Print… (amadeus-reader.js printPdf): a blob in a hidden iframe
   (.amr-print-frame), or, on Safari/iPadOS/Android, page images in #amr-print printed with
   everything else hidden (html.amr-printing). A browser-menu print while the reader is open
   would otherwise print the studio behind it, so it prints a pointer to Print… instead. */
.amr-print-frame { position: fixed; right: 0; bottom: 0; width: 0; height: 0; border: 0; opacity: 0; pointer-events: none; }
#amr-print { display: none; }
@media print {
  html.amr-lock:not(.amr-printing) body > * { display: none !important; }
  html.amr-lock:not(.amr-printing) body::before {
    content: "To print this paper, use Print\2026  in the reader\2019 s menu (Ctrl+P / \2318 P).";
    display: block;
    padding: 24px;
    font: 14px/1.5 -apple-system, "Segoe UI", sans-serif;
    color: #000;
  }
  html.amr-printing, html.amr-printing body {
    overflow: visible !important;
    height: auto !important;
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  html.amr-printing body > :not(#amr-print) { display: none !important; }
  html.amr-printing #amr-print { display: block !important; }
  #amr-print .amr-print-page { break-after: page; page-break-after: always; break-inside: avoid; page-break-inside: avoid; }
  #amr-print .amr-print-page:last-child { break-after: auto; page-break-after: auto; }
  #amr-print img { display: block; margin: 0 auto; width: 100%; height: auto; max-height: 100vh; object-fit: contain; }
}

/* ---- Annotation tools ---- (amadeus-reader-annot.js) ---------------------------
   One SVG per page inside .amr-overlay; its viewBox is the page's scale-1
   viewport, so zooming only changes the CSS size (never a re-render).
   The layer is pointer-events:none: text selection keeps working and taps are
   hit-tested geometrically by the plugin. */
#am-reader .amr-overlay > .amra-svg {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
}
/* Light + sepia: markup multiplies with the page like ink on paper (same as the
   exported PDF's /BM /Multiply). The overlay is its own stacking context, so the
   blend has to be on the overlay itself to reach the canvas below. */
#am-reader:not([data-read-theme="dark"]) .amr-overlay:has(> .amra-svg) { mix-blend-mode: multiply; }
.amra-hl { fill-opacity: 1; }
.amra-hl-live { fill-opacity: .7; }
.amra-line { stroke-linecap: butt; }
.amra-note { filter: none; }
.amra-note-bg { stroke: rgba(0, 0, 0, .38); stroke-width: .8; }
.amra-note-ico { stroke: #1d1d1b; stroke-width: 1.35; stroke-linecap: round; }
.amra-note.is-empty .amra-note-bg { stroke-dasharray: 2.2 1.6; }
.amra-selbox {
  fill: none;
  stroke: var(--accent, #3a6eff);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  vector-effect: non-scaling-stroke;
}
/* Dark reading theme: the page bitmap is inverted, multiply would black
   everything out. Translucent fills instead; ink colours are lifted in JS. */
#am-reader[data-read-theme="dark"] .amra-hl { fill-opacity: .38; }
#am-reader[data-read-theme="dark"] .amra-hl-live { fill-opacity: .3; }
#am-reader[data-read-theme="dark"] .amra-ink.is-marker { opacity: .3; }
#am-reader[data-read-theme="dark"] .amra-note-bg { stroke: rgba(255, 255, 255, .45); }

/* Tool cursors + no text selection while drawing tools are active */
#am-reader.amra-tool-pen .amr-page, #am-reader.amra-tool-pen .amr-page .textLayer,
#am-reader.amra-tool-pen .amr-page .textLayer span, #am-reader.amra-tool-pen .amr-link,
#am-reader.amra-tool-note .amr-page, #am-reader.amra-tool-note .amr-page .textLayer,
#am-reader.amra-tool-note .amr-page .textLayer span, #am-reader.amra-tool-note .amr-link { cursor: crosshair; }
#am-reader.amra-tool-eraser .amr-page, #am-reader.amra-tool-eraser .amr-page .textLayer,
#am-reader.amra-tool-eraser .amr-page .textLayer span, #am-reader.amra-tool-eraser .amr-link {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Ccircle cx='10' cy='10' r='7' fill='white' fill-opacity='.6' stroke='%23222' stroke-width='1.5'/%3E%3C/svg%3E") 10 10, cell;
}
#am-reader.amra-tool-highlight .amr-page, #am-reader.amra-tool-highlight .amr-page .textLayer { cursor: text; }
#am-reader.amra-tool-pen .amr-page .textLayer, #am-reader.amra-tool-eraser .amr-page .textLayer,
#am-reader.amra-tool-note .amr-page .textLayer { -webkit-user-select: none; user-select: none; }
#am-reader.amra-tool-pen .amr-link:hover, #am-reader.amra-tool-eraser .amr-link:hover,
#am-reader.amra-tool-note .amr-link:hover, #am-reader.amra-tool-highlight .amr-link:hover { background: none; box-shadow: none; }
/* "Draw with finger": the page no longer pans for one finger (the viewer's own
   two-finger pinch still works, it listens to touch events). */
#am-reader.amra-fingerdraw .amr-page { touch-action: none; }
/* A pen hovering over the pages (and about to draw) while they may still be flinging:
   touch-action is read at touch-down, so this keeps an Android fling from turning the
   pen's contact into a pan (a finger that lands meanwhile is panned by the plugin). */
#am-reader.amra-penhover .amr-page { touch-action: none; }
/* Moving a note: "Move" armed (next tap places it) / a note being dragged. */
#am-reader.amra-moving .amr-page, #am-reader.amra-moving .amr-page .textLayer { cursor: crosshair; }
#am-reader.amra-dragging .amr-page, #am-reader.amra-dragging .amr-page .textLayer { cursor: grabbing; }
.amra-note.is-dragging { opacity: .85; }

/* Palette: left rail on wide screens, bottom dock on touch / narrow */
.amra-palette {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px;
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  box-shadow: var(--am-shadow-pop, 0 8px 28px rgba(11,11,11,.16));
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.amra-palette .amra-btn {
  width: var(--amr-btn, 36px);
  height: var(--amr-btn, 36px);
  flex: none;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-secondary, var(--ink-muted));
  cursor: pointer;
  position: relative;
  transition: color .15s, background .15s, opacity .15s;
}
.amra-palette .amra-btn:hover:not(:disabled) { color: var(--ink); background: var(--accent-wash); }
.amra-palette .amra-btn:active:not(:disabled) { transform: scale(.95); }
.amra-palette .amra-btn[aria-pressed="true"] { color: var(--accent-strong); background: var(--accent-wash); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.amra-palette .amra-btn:disabled { opacity: .32; cursor: default; }
.amra-palette .amra-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Tiny chevron on the active tool: tap it again for options */
.amra-palette .amra-tool[aria-pressed="true"]:not(.amra-tool-select)::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-bottom: 4px solid currentColor;
  opacity: .7;
}
.amra-sep { flex: none; width: 22px; height: 1px; margin: 3px 0; background: var(--hairline); }
.amra-sep[hidden] { display: none; }
.amra-dot {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  box-shadow: 0 0 0 1.5px var(--surface-raised), 0 0 0 2.5px color-mix(in srgb, var(--ink) 30%, transparent);
}
.amra-dot.is-w0 { width: 10px; height: 10px; }
.amra-dot.is-w1 { width: 14px; height: 14px; }
.amra-dot.is-w2 { width: 19px; height: 19px; }
.amra-dot.is-underline, .amra-dot.is-strike { width: 20px; height: 4px; border-radius: 2px; }
#am-reader.amr-narrow .amra-palette, #am-reader.amr-coarse .amra-palette {
  flex-direction: row;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  border-radius: 18px;
}
#am-reader.amr-narrow .amra-palette::-webkit-scrollbar, #am-reader.amr-coarse .amra-palette::-webkit-scrollbar { display: none; }
#am-reader.amr-narrow .amra-sep, #am-reader.amr-coarse .amra-sep { width: 1px; height: 22px; margin: 0 3px; }
@media (max-width: 400px) {
  #am-reader.amr-narrow .amra-palette { padding: 4px; gap: 0; }
  #am-reader.amr-narrow .amra-palette .amra-btn { width: 40px; height: 40px; }
  #am-reader.amr-narrow .amra-sep { margin: 0 1px; }
}
/* Top-bar buttons (palette toggle, download) */
.amra-dl.is-busy { pointer-events: none; }
.amra-dl.is-busy svg { animation: amra-pulse 1s ease-in-out infinite; }
@keyframes amra-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* Tool options popover */
.amra-opts { display: flex; flex-direction: column; gap: 10px; width: 272px; max-width: calc(100vw - 32px); padding: 12px; }
.amra-opts-h { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.amra-opts-tip { margin: 0; font-size: .8rem; line-height: 1.45; color: var(--ink-muted); }
.amra-opts-sep { height: 1px; margin: 2px -12px; background: var(--hairline); }
.amra-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.amra-swatch {
  width: 28px;
  height: 28px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.amra-swatch:hover { transform: scale(1.08); }
.amra-swatch.is-on { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18), 0 0 0 2px var(--surface-raised), 0 0 0 4px var(--accent); }
.amra-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.amra-swatch.is-sm { width: 22px; height: 22px; }
.amra-swatch.is-sm.is-on { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18), 0 0 0 2px var(--surface-raised), 0 0 0 3.5px var(--ink-muted); }
.amra-seg { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface, var(--page)); border: 1px solid var(--hairline); }
.amra-seg-btn {
  flex: 1 1 auto; /* size by content so a long label can't spill into its neighbour */
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-muted);
  font: 600 .78rem var(--sans);
  cursor: pointer;
  white-space: nowrap;
}
.amra-seg-btn svg { flex: none; }
.amra-seg-btn.is-on { background: var(--surface-raised); color: var(--ink); box-shadow: 0 1px 2px rgba(11, 11, 11, .14); }
.amra-seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.amra-widths { display: flex; gap: 6px; margin-top: 10px; }
.amra-width {
  flex: 1;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}
.amra-width.is-on { border-color: var(--accent); background: var(--accent-wash); }
.amra-width-bar { display: block; width: 60%; border-radius: 999px; background: var(--ink); }
.amra-toggle-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.amra-toggle-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; font-size: .86rem; color: var(--ink); }
.amra-toggle-txt small { font-size: .74rem; line-height: 1.35; color: var(--ink-muted); }
.amra-switch {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 36px;
  height: 22px;
  margin: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 22%, transparent);
  position: relative;
  cursor: pointer;
  transition: background .15s;
}
.amra-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  transition: transform .15s;
}
.amra-switch:checked { background: var(--accent-strong, var(--accent)); }
.amra-switch:checked::after { transform: translateX(14px); }
.amra-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Selection mini popover */
.amr-pop.amra-pop-sel { min-width: 0; border-radius: 999px; }
.amra-selpop { display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; }
.amra-selpop .amra-sep { width: 1px; height: 22px; margin: 0 2px; }
.amra-selpop .amra-btn, .amra-apop .amra-btn {
  width: 34px; height: 34px;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-secondary, var(--ink-muted));
  cursor: pointer;
}
.amra-selpop .amra-btn:hover { color: var(--ink); background: var(--accent-wash); }
#am-reader.amr-coarse .amra-selpop .amra-btn { width: 40px; height: 40px; }
#am-reader.amr-coarse .amra-selpop .amra-swatch.is-sm { width: 26px; height: 26px; }

/* Annotation popover (tap an annotation) */
.amr-pop.amra-pop-annot { min-width: 0; }
.amra-apop { display: flex; flex-direction: column; gap: 10px; width: 292px; max-width: calc(100vw - 32px); padding: 12px; }
.amra-apop-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.amra-apop-kind { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.amra-apop-page { font-size: .74rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.amra-apop-quote {
  margin: 0;
  padding: 6px 10px;
  max-height: 7.5em;
  overflow: auto;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-wash);
  font-size: .8rem;
  line-height: 1.45;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.amra-note-ta {
  width: 100%;
  min-height: 44px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--page);
  color: var(--ink);
  font: .88rem/1.45 var(--sans);
}
.amra-note-ta:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
#am-reader.amr-coarse .amra-note-ta { font-size: 16px; }
.amra-apop-acts, .amra-item-edit-acts { display: flex; align-items: center; gap: 6px; }
.amra-grow { flex: 1; }
.amra-act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 600 .8rem var(--sans);
  cursor: pointer;
  white-space: nowrap;
}
.amra-act:hover { background: var(--accent-wash); }
.amra-act.is-danger { color: var(--error, #d2483f); }
.amra-act.is-danger:hover { background: color-mix(in srgb, var(--error, #d2483f) 10%, transparent); }
.amra-act.is-primary { border-color: transparent; background: var(--accent-strong, var(--accent)); color: #fff; }
.amra-act.is-primary:hover { filter: brightness(1.06); background: var(--accent-strong, var(--accent)); }
.amra-act:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#am-reader.amr-coarse .amra-act { height: 40px; padding: 0 14px; }

/* Download menu */
.amra-menu-item .amra-mi-ico { display: inline-grid; flex: none; color: var(--ink-muted); }
.amra-dl-menu .amr-menu { min-width: 280px; }

/* Sidebar "Annotations" tab */
.amra-side { display: flex; flex-direction: column; }
.amra-side-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 8px 8px; }
.amra-side-count { flex: 1; min-width: 0; font-size: .78rem; font-weight: 600; color: var(--ink-muted); }
.amra-side-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border: 1px solid var(--hairline); border-radius: 999px;
  background: transparent; color: var(--ink);
  font: 600 .74rem var(--sans);
  cursor: pointer; white-space: nowrap;
}
.amra-side-btn:hover:not(:disabled) { background: var(--accent-wash); }
.amra-side-btn:disabled { opacity: .45; cursor: default; }
.amra-side-empty b { color: var(--ink); font-weight: 600; }
.amra-side-page { padding: 10px 8px 4px; font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.amra-side-group { display: flex; flex-direction: column; gap: 2px; }
.amra-item { position: relative; display: flex; flex-wrap: wrap; align-items: flex-start; border-radius: 10px; }
.amra-item:hover, .amra-item:focus-within { background: var(--accent-wash); }
.amra-item-main {
  flex: 1; min-width: 0;
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 4px 7px 8px;
  border: 0; background: transparent; color: var(--ink);
  font: .82rem/1.4 var(--sans); text-align: left;
  cursor: pointer;
}
.amra-item-main:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 10px; }
.amra-item-ico { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; margin-top: -1px; border-radius: 7px; color: var(--ink); background: color-mix(in srgb, var(--c) 45%, transparent); }
.amra-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.amra-item-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.amra-item-text.is-quote.is-highlight { background: linear-gradient(color-mix(in srgb, var(--c) 30%, transparent), color-mix(in srgb, var(--c) 30%, transparent)); border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.amra-item-text.is-underline { text-decoration: underline 1.5px var(--c); text-underline-offset: 2px; }
.amra-item-text.is-strike { text-decoration: line-through 1.5px var(--c); }
.amra-item-text.is-muted { color: var(--ink-muted); font-style: italic; }
.amra-item-note { font-size: .78rem; color: var(--ink-secondary, var(--ink-muted)); white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.amra-item-note::before { content: "\201C"; }
.amra-item-note::after { content: "\201D"; }
.amra-item-acts { flex: none; display: flex; gap: 0; padding: 4px 4px 0 0; opacity: 0; transition: opacity .12s; }
.amra-item:hover .amra-item-acts, .amra-item:focus-within .amra-item-acts, #am-reader.amr-coarse .amra-item-acts { opacity: 1; }
.amra-item-act { width: 28px; height: 28px; display: inline-grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--ink-muted); cursor: pointer; }
.amra-item-act:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.amra-item-act.is-danger:hover { color: var(--error, #d2483f); }
.amra-item-act:focus-visible { outline: 2px solid var(--accent); }
#am-reader.amr-coarse .amra-item-act { width: 36px; height: 36px; }
.amra-item-edit { flex: 1 0 100%; display: flex; flex-direction: column; gap: 6px; padding: 0 8px 8px 38px; }
.amra-item-edit-acts { justify-content: flex-end; }
.amra-item.is-editing { background: var(--accent-wash); }
/* ---- /Annotation tools ---- */

/* ---- PDF library sync pill (amadeus-reader.js applyPdfStatus / openPillMenu) --------------
   Where this paper's PDF stands in your library: a dot (saved, waiting), a spinning ring
   (uploading, downloading) or an amber glyph ("Only on this device …"). flex: none and a
   capped width, so a changing label never moves the other bar buttons or the bar's height.
   Narrow: the icon alone, as a 32 px button (the aria-label keeps the full message). */
.amr-pdfsync {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-secondary);
  font: 500 12px var(--sans);
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, color .15s;
}
.amr-pdfsync[hidden] { display: none; }
.amr-pdfsync:hover { background: var(--accent-wash); color: var(--ink); }
.amr-pdfsync:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.amr-pdfsync-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.amr-pdfsync-ico {
  flex: none;
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.amr-pdfsync[data-state="synced"] { color: var(--ink-muted); }
.amr-pdfsync[data-state="synced"] .amr-pdfsync-ico { background: #2f9e63; }
.amr-pdfsync[data-ico="spin"] .amr-pdfsync-ico {
  width: 11px;
  height: 11px;
  background: transparent;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  animation: amr-pdfsync-spin .9s linear infinite;
}
.amr-pdfsync[data-ico="alert"] .amr-pdfsync-ico { width: 13px; height: 13px; border-radius: 0; background: transparent; color: #b7791f; }
.amr-pdfsync[data-ico="alert"] .amr-pdfsync-ico svg { display: block; }
@keyframes amr-pdfsync-spin { to { transform: rotate(360deg); } }
:root[data-theme="dark"] .amr-pdfsync[data-state="synced"] .amr-pdfsync-ico { background: #4cc38a; }
:root[data-theme="dark"] .amr-pdfsync[data-ico="alert"] .amr-pdfsync-ico { color: #e3a33b; }
#am-reader.amr-narrow .amr-pdfsync-txt { display: none; }
#am-reader.amr-narrow .amr-pdfsync { width: 32px; height: 32px; padding: 0; justify-content: center; }
/* Touch: a finger-sized target (the bar is 58px tall there). */
#am-reader.amr-coarse .amr-pdfsync { height: 36px; }
#am-reader.amr-coarse.amr-narrow .amr-pdfsync { width: 36px; }
/* Reduced motion: a still, closed ring (the global rule would only make it flicker). */
@media (prefers-reduced-motion: reduce) {
  #am-reader .amr-pdfsync[data-ico="spin"] .amr-pdfsync-ico { animation: none; border-right-color: var(--accent); opacity: .75; }
}
/* The pill's menu (and the "only on this device" confirm): the full status as a sentence,
   not the uppercase section heading, then its detail. */
.amr-pdfsync-head { max-width: 300px; padding: 9px 10px 3px; font-size: .86rem; font-weight: 600; line-height: 1.35; color: var(--ink); }
.amr-pdfsync-detail { max-width: 300px; padding: 0 10px 6px; font-size: .8rem; line-height: 1.4; color: var(--ink-muted); }
.amr-pdfsync-head + .amr-menu-sep, .amr-pdfsync-detail + .amr-menu-sep { margin-top: 4px; }
/* "A newer PDF … is in your library" / "… now uses the original PDF" chips: their Reload. */
.amr-chip-act { margin-left: 3px; text-decoration: underline; text-underline-offset: 2px; }
/* ---- /PDF library sync pill ---- */
