/* ILX PDF reader (js/viewer.js): #/view and the result preview overlay. Uses the app.css tokens (light / dark).
   PDF.js layer rules (text selection, links, form fields) come from css/pdfjs-layers.css. */
.ilxv {
  --ilxv-bar: var(--bg2); --ilxv-canvas-bg: #e6e9ef; --ilxv-side-w: 220px;
  position: relative; display: flex; flex-direction: column; min-height: 0; height: 100%; background: var(--ilxv-canvas-bg);
  color: var(--text);
}
:root[data-theme="dark"] .ilxv { --ilxv-canvas-bg: #050912; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ilxv { --ilxv-canvas-bg: #050912; } }

/* toolbar */
.ilxv-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; padding: 0.35rem 0.5rem;
  background: var(--ilxv-bar); border-bottom: 1px solid var(--border); flex: none; min-width: 0;
}
.ilxv-group { display: flex; align-items: center; gap: 0.25rem; min-width: 0; }
.ilxv-group.start { flex: 1 1 0; }
.ilxv-group.end { flex: 1 1 0; justify-content: flex-end; }
.ilxv-name { font-weight: 600; color: var(--heading); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; padding-left: 0.25rem; }
.ilxv-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; min-width: 36px; height: 36px; padding: 0 8px;
  border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--heading); cursor: pointer; font: inherit;
  font-size: 0.84rem; flex: none;
}
.ilxv-btn:hover:not(:disabled) { background: var(--bg3); border-color: var(--border); }
.ilxv-btn[aria-pressed="true"], .ilxv-btn[aria-expanded="true"] { background: var(--blue-soft); border-color: var(--border-2); color: var(--blue-2); }
.ilxv-btn:disabled { opacity: 0.35; cursor: default; }
.ilxv-btn .ic { width: 20px; height: 20px; }
.ilxv .ic svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ilxv-btn.text { padding: 0 10px; border-color: var(--border-2); color: var(--blue-2); }
.ilxv-sep { width: 1px; height: 22px; background: var(--border); margin: 0 0.25rem; }
.ilxv-pagebox { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.88rem; color: var(--muted); white-space: nowrap; }
.ilxv-page, .ilxv-zoom, .ilxv-find-in {
  font: inherit; font-size: 0.88rem; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
  height: 32px; padding: 0 0.45rem;
}
.ilxv-page { width: 3.6em; text-align: center; }
.ilxv-zoom { max-width: 8.5rem; }
.ilxv-page:focus, .ilxv-zoom:focus, .ilxv-find-in:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
.ilxv-menu-wrap { position: relative; display: inline-flex; }
.ilxv-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 16rem; padding: 0.35rem; display: grid;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.ilxv-mi {
  display: flex; align-items: center; gap: 0.5rem; text-align: left; padding: 0.5rem 0.6rem; border-radius: 7px; border: 0;
  background: transparent; color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer;
}
.ilxv-mi:hover, .ilxv-mi:focus-visible { background: var(--blue-soft); outline: none; }
.ilxv-mi-check { width: 1rem; flex: none; text-align: center; color: var(--blue-2); }
.ilxv-mi[aria-checked="true"] .ilxv-mi-check::before { content: "✓"; font-weight: 700; }
.ilxv-mi-sep { height: 1px; background: var(--border); margin: 0.3rem 0.2rem; }

/* find bar */
.ilxv-find {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; padding: 0.35rem 0.6rem; flex: none;
  background: var(--ilxv-bar); border-bottom: 1px solid var(--border);
}
.ilxv-find-in { width: min(20rem, 100%); }
.ilxv-check { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.86rem; cursor: pointer; }
.ilxv-check input { accent-color: var(--blue); width: 16px; height: 16px; }
.ilxv-find-count { font-size: 0.86rem; color: var(--muted); min-width: 5rem; }
.ilxv-find-count.none { color: var(--red); }

/* body: sidebar + pages */
.ilxv-body { position: relative; display: flex; flex: 1 1 auto; min-height: 0; }
.ilxv-side {
  width: var(--ilxv-side-w); flex: none; display: flex; flex-direction: column; min-height: 0; background: var(--bg2);
  border-right: 1px solid var(--border);
}
.ilxv-tabs { display: flex; gap: 0.25rem; padding: 0.4rem; border-bottom: 1px solid var(--border); flex: none; }
.ilxv-tab {
  flex: 1; padding: 0.4rem 0.5rem; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--muted);
  font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.ilxv-tab[aria-selected="true"] { background: var(--blue-soft); color: var(--blue-2); border-color: var(--border-2); }
.ilxv-thumbs, .ilxv-outline { flex: 1 1 auto; overflow: auto; min-height: 0; overscroll-behavior: contain; }
.ilxv-thumbs { display: flex; flex-direction: column; align-items: center; gap: 0.7rem; padding: 0.8rem 0.5rem; }
.ilxv-thumb {
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem; border: 0; background: transparent; padding: 4px;
  border-radius: 8px; cursor: pointer; color: var(--muted); font: inherit; width: 150px; flex: none;
}
.ilxv-thumb-img {
  display: block; width: 132px; max-height: 190px; background: var(--page); box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  border: 2px solid transparent; border-radius: 3px; overflow: hidden;
}
.ilxv-thumb-img canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.ilxv-thumb:hover .ilxv-thumb-img { border-color: var(--border-2); }
.ilxv-thumb.current .ilxv-thumb-img { border-color: var(--blue); }
.ilxv-thumb.current { color: var(--blue-2); font-weight: 700; }
.ilxv-thumb-no { font-size: 0.78rem; }
.ilxv-outline { padding: 0.4rem 0.3rem 1rem; }
.ilxv-empty { padding: 0.8rem; }
.ilxv-tree { list-style: none; margin: 0; padding: 0; }
.ilxv-tree .ilxv-tree { padding-left: 0.9rem; display: none; }
.ilxv-tree li.open > .ilxv-tree { display: block; }
.ilxv-ol-row { display: flex; align-items: flex-start; gap: 0.1rem; }
.ilxv-ol-tog, .ilxv-ol-pad { width: 22px; height: 26px; flex: none; }
.ilxv-ol-tog { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 5px; border-radius: 5px; }
.ilxv-ol-tog svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .12s; }
li.open > .ilxv-ol-row .ilxv-ol-tog svg { transform: rotate(90deg); }
.ilxv-ol-link {
  flex: 1; text-align: left; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 0.86rem;
  padding: 0.25rem 0.4rem; border-radius: 6px; cursor: pointer; line-height: 1.35; word-break: break-word;
}
.ilxv-ol-link:hover { background: var(--blue-soft); color: var(--heading); }
.ilxv-ol-link.b { font-weight: 700; }
.ilxv-ol-link.i { font-style: italic; }

.ilxv-main { position: relative; flex: 1 1 auto; min-width: 0; }
.ilxv-container {
  position: absolute; inset: 0; overflow: auto; outline: none; touch-action: pan-x pan-y; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.ilxv-container:focus-visible { box-shadow: inset 0 0 0 2px var(--border-2); }
.ilxv .pdfViewer { padding: 12px 0 24px; }
.ilxv .pdfViewer .page { box-shadow: 0 1px 3px rgba(0,0,0,0.22), 0 6px 18px rgba(0,0,0,0.10); margin: 0 auto 14px; }
.ilxv .pdfViewer.singlePageView, .ilxv .pdfViewer:has(.spread) { padding-left: 8px; padding-right: 8px; }
.ilxv .pdfViewer .spread .page { margin: 0 4px 14px; }
.ilxv .canvasWrapper canvas.ilxv-detail { position: absolute; width: auto; height: auto; pointer-events: none; }
.ilxv.dark-pages .canvasWrapper, .ilxv.dark-pages .ilxv-thumb-img canvas { filter: invert(1) hue-rotate(180deg); }
.ilxv.dark-pages .pdfViewer .page { background-color: #000; }
.ilxv .textLayer .highlight { background-color: rgba(255, 196, 0, 0.45); }
.ilxv .textLayer .highlight.selected { background-color: rgba(26, 112, 255, 0.45); }

/* presentation / full screen */
.ilxv.fullscreen, .ilxv.presenting { height: 100%; width: 100%; }
.ilxv.presenting { background: #000; }
.ilxv.presenting .ilxv-bar, .ilxv.presenting .ilxv-find, .ilxv.presenting .ilxv-side { display: none !important; }
.ilxv.presenting .ilxv-container { overflow: hidden; cursor: pointer; }
.ilxv.presenting .pdfViewer { padding: 0; }
.ilxv.presenting .pdfViewer .page { box-shadow: none; margin: 0 auto; }
.ilxv.presenting:not(:fullscreen) { position: fixed; inset: 0; z-index: 3000; }
.ilxv-present-hint {
  position: absolute; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: rgba(0,0,0,0.75); color: #fff;
  padding: 0.5rem 0.9rem; border-radius: 8px; font-size: 0.88rem; pointer-events: none; z-index: 10;
}

/* dialogs */
.ilxv-dialog.wide { width: min(34rem, calc(100vw - 2rem)); }
.ilxv-props { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; font-size: 0.9rem; max-height: 60vh; overflow: auto; }
.ilxv-props dt { color: var(--muted); }
.ilxv-props dd { margin: 0; color: var(--heading); word-break: break-word; }
.ilxv-props.keys dt { white-space: nowrap; }
.ilxv kbd, .ilxv-dialog kbd {
  font: inherit; font-size: 0.82rem; padding: 0.1rem 0.4rem; border-radius: 5px; border: 1px solid var(--border);
  background: var(--bg3); color: var(--heading);
}

/* the #/view page: open screen, then the reader fills the window under the nav */
.ilxv-start .ilxv-drop { min-height: 260px; }
.ilxv-private { margin-top: 0.9rem; }
body.ilxv-reading { overflow: hidden; }
body.ilxv-reading .site-footer { display: none; }
.ilxv-page-host { position: fixed; left: 0; right: 0; bottom: 0; top: var(--ilxv-top, 56px); z-index: 30; }
.ilxv-page-host > .ilxv { height: 100%; }

/* overlay preview (tool results) */
body.ilxv-noscroll { overflow: hidden; }
.ilxv-layer { position: fixed; inset: 0; z-index: 1500; background: rgba(5, 9, 18, 0.6); padding: 2vh 2vw; display: flex; }
.ilxv-layer > .ilxv { flex: 1; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-lg); }
@media (max-width: 700px) { .ilxv-layer { padding: 0; } .ilxv-layer > .ilxv { border-radius: 0; } }

/* home card, result "View" button */
.result-actions .btn.view-btn { flex: 0 1 auto; }

.ilxv-mi.sm-only { display: none; }

/* phones / tablets */
@media (max-width: 900px) {
  .ilxv-zoom { max-width: 6.5rem; }
  .ilxv-name { display: none; }
}
@media (max-width: 700px) {
  .hide-sm { display: none !important; }
  .ilxv-mi.sm-only:not([hidden]) { display: flex; }
  .ilxv-bar { padding: 0.3rem; gap: 0.15rem; }
  .ilxv-btn { min-width: 34px; padding: 0 5px; }
  .ilxv-zoom-out, .ilxv-zoom-in, .ilxv-zoom, .ilxv-prev, .ilxv-next { display: none; } /* pinch to zoom; zoom presets in the menu */
  .ilxv-group.start, .ilxv-group.end { flex: none; }
  .ilxv-group.mid { flex: 1 1 auto; justify-content: center; }
  .ilxv-entries span:not(.ic) { display: none; }
  .ilxv-side { position: absolute; left: 0; top: 0; bottom: 0; z-index: 20; width: min(78vw, 260px); box-shadow: var(--shadow-lg); }
  .ilxv-page { width: 3em; }
}

/* printing (Print button): only the prepared page images */
#ilxv-print { display: none; }
@media print {
  body.ilxv-printing > *:not(#ilxv-print) { display: none !important; }
  body.ilxv-printing #ilxv-print { display: block; }
  body.ilxv-printing { background: #fff; }
  .ilxv-pp { break-after: page; page-break-after: always; height: 100vh; display: flex; align-items: center; justify-content: center; overflow: hidden; }
  .ilxv-pp:last-child { break-after: auto; page-break-after: auto; }
  .ilxv-pp img { max-width: 100%; max-height: 100%; display: block; }
  @page { margin: 0.2in; }
}
