/* Luminous Insights PDF viewer chrome
   Brand UI stack matches JSMjoya-full.html (system Gill Sans / Gill Sans MT).
   PDF page glyphs come from embedded fonts inside the PDF — not this stack.
   Color system: 60% soft canvas + white panels, 30% navy/teal chrome, 10% coral CTA
   (Sage archetype; analogous navy–teal + complementary coral — article hero). */

@font-face {
  font-family: "Gill Sans";
  src:
    local("Gill Sans"),
    local("GillSans"),
    local("Gill Sans MT"),
    local("GillSansMT");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Gill Sans";
  src:
    local("Gill Sans Italic"),
    local("GillSans-Italic"),
    local("Gill Sans MT Italic"),
    local("GillSansMT-Italic");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Gill Sans";
  src:
    local("Gill Sans Bold"),
    local("GillSans-Bold"),
    local("Gill Sans MT Bold"),
    local("GillSansMT-Bold");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Gill Sans";
  src:
    local("Gill Sans Bold Italic"),
    local("GillSans-BoldItalic"),
    local("Gill Sans MT Bold Italic"),
    local("GillSansMT-BoldItalic");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

:root {
  /* —— LI primitives (article hero / Sage palette) ——
     Analogous navy→teal chrome; coral as complementary 10% CTA.
     Sage archetype: trust/wisdom. No purple glow; no dual-charcoal chrome.
     Pass 4: clearer canvas/page separation; theme-safe text tokens. */
  --navy-deep: #0f3a4a;
  --navy-mid: #1a5568;
  --navy-light: #246b80;
  --teal: #378f9b;
  --teal-deep: #2a6f79;
  --teal-soft: #e4f3f6;
  --coral: #e98c7b;
  --coral-deep: #e07865;
  --page: #fafcfc;
  --soft: #eaf2f4;
  /* 60% field: deepen vs white PDF pages (Albers — neighbors define contrast) */
  --soft-deep: #cfdce0;
  /* Panel edges: hairline that reads on soft-deep without shouting */
  --line: #bcd0d5;
  --line-brand: #aec8d0;
  --on-navy: #f7fbfc;
  /* Toolbar glyphs: pure white for max clarity; muted labels stay --on-navy-muted */
  --on-navy-icon: #ffffff;
  /* Chrome muted text ≠ panel --line (was identical #d5e3e6 → hierarchy mush) */
  --on-navy-muted: #c8d9de;
  /* Gray wordmark on navy (inline SVG currentColor); AA UI (≥3:1) */
  --logo-gray: #aebdc4;
  --logo-gray-hover: #d0dce0;
  /* Ink tuned for AA+ on near-white panels (≥7:1 on #fff) */
  --ink: #0f3a4a;
  --ink-soft: #1f4452;
  --muted: #2f4a54;
  /* Deeper than --ink so coral CTA text/icons hold AA on coral + coral-deep */
  --ink-on-coral: #0c2f3c;

  /* Sidebar open/close motion */
  --sidebar-w: 280px;
  --sidebar-duration: 280ms;
  --sidebar-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --toolbar-h: 64px;
  --stage-pad-x: 56px;

  /* —— Semantic roles (60 / 30 / 10) —— */
  /* 60% — soft reading field; white panels sit above canvas */
  --bg-canvas: var(--soft-deep);
  --bg-page: #ffffff;
  --bg-panel: #ffffff;
  --bg-panel-elevated: #fafcfc;
  /* Float tools: between canvas and pure PDF white (doesn't compete with pages) */
  --bg-float: var(--page);
  --text-panel: var(--ink);
  --text-panel-secondary: var(--ink-soft);
  --text-panel-muted: var(--muted);
  --border-panel: var(--line);
  --border-float: var(--line);

  /* 30% — fixed dark header chrome (both themes). Matches dark --bg-panel
     (#314850) so header joins the dark DETAILS sidebar; light mode keeps
     this dark bar while sidebars stay theme-dependent (white). */
  --bg-chrome: #314850;
  --bg-chrome-elevated: #3d5760;
  --bg-chrome-chip: #3d5760;
  --text-on-chrome: var(--on-navy);
  --text-on-chrome-icon: var(--on-navy-icon);
  --text-on-chrome-muted: var(--on-navy-muted);
  --border-chrome: rgba(247, 251, 252, 0.2);
  --chrome-inset: rgba(8, 36, 46, 0.42);
  --chrome-hover-wash: rgba(247, 251, 252, 0.14);
  --chrome-divider: rgba(247, 251, 252, 0.16);
  --navy: var(--navy-deep);
  --logo-on-chrome: var(--logo-gray);
  --logo-on-chrome-hover: var(--logo-gray-hover);
  /* Soft teal focus on dark chrome (≥3:1) — both themes */
  --focus-ring-on-chrome: #a3d0d6;
  --focus-ring-glow-on-chrome: rgba(163, 208, 214, 0.35);

  /* 10% — coral CTAs; links stay navy/teal (accessible on white) */
  --accent-cta: var(--coral);
  --accent-cta-hover: var(--coral-deep);
  --accent-cta-ink: var(--ink-on-coral);
  --accent-link: var(--navy-mid);
  --accent-link-hover: var(--teal-deep);
  --accent-interactive: var(--teal);
  /* Open-access status — teal trust signal, not a second CTA */
  --status-open: var(--teal-deep);
  /* Focus: teal-deep on light panels/header (≥3:1); dark theme remaps chrome focus */
  --focus-ring: var(--teal-deep);
  --focus-ring-glow: rgba(55, 143, 155, 0.28);
  --overlay-scrim: rgba(15, 58, 74, 0.4);
  --status-bg: rgba(15, 58, 74, 0.92);

  /* Compat aliases (existing class references) */
  --charcoal: var(--bg-chrome);
  --charcoal-2: var(--bg-chrome-elevated);
  --charcoal-3: var(--bg-chrome-chip);
  --bar-text: var(--text-on-chrome);
  --bar-muted: var(--text-on-chrome-muted);
  --canvas-bg: var(--bg-canvas);
  /* Hairline + soft shadow so pages lift off deepened canvas */
  --page-shadow:
    0 0 0 1px rgba(15, 58, 74, 0.05),
    0 2px 16px rgba(15, 58, 74, 0.14);
  --font-ui: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif;
}

/*
 * Canvas theme (dark): soft charcoal-teal surround — not inverted black.
 * 60% --bg-canvas supports white PDF pages (Albers: relative contrast, not max).
 * 30% header chrome stays fixed dark (#314850) — same as dark --bg-panel.
 * 10% coral CTAs unchanged; links lighten + desaturate for AA on dark panels.
 * Sage/academic: muted brand hue (~200–210), low chroma — no purple glow.
 * OKLCH refs: canvas oklch(32% 0.022 205); panel oklch(36% 0.024 205).
 */
html[data-canvas-theme="dark"] {
  --soft-deep: #2a3e46;
  --page: #243840;
  --soft: #334a52;
  --line: #4a636c;
  --line-brand: #56747e;
  /* Soft teal wash for accent chips on dark float (not light --teal-soft) */
  --teal-soft: #2f4f57;
  --bg-canvas: #2a3e46; /* soft charcoal-teal stage (not near-black) */
  --canvas-bg: #2a3e46;
  --bg-page: #ffffff;
  --bg-panel: #314850; /* elevated vs canvas — matches fixed --bg-chrome */
  --bg-panel-elevated: #3d5760; /* clearer dp step above panel */
  --bg-float: #314850;
  --text-panel: #eef5f6;
  --text-panel-secondary: #c8d9de;
  --text-panel-muted: #aebfc6; /* ≥4.5:1 on --bg-panel */
  --border-panel: #4a636c;
  --border-float: #56747e;
  --ink: #eef5f6;
  --ink-soft: #c8d9de;
  --muted: #aebfc6;
  /* Interactive accents: lift + desaturate for dark surfaces (saturation burn) */
  --accent-link: #8ec4ce;
  --accent-link-hover: #b3d9e0;
  --accent-interactive: #6aa8b4;
  --status-open: #7eb8c2;
  --focus-ring: #8ec4ce;
  --focus-ring-glow: rgba(142, 196, 206, 0.28);
  --page-shadow:
    0 0 0 1px rgba(15, 58, 74, 0.12),
    0 2px 18px rgba(15, 58, 74, 0.28);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  overflow: hidden; /* no body/app horizontal scrollbar; scroll lives in .viewer-shell */
  font-family: var(--font-ui);
  background: var(--canvas-bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button,
input,
a {
  font-family: inherit;
}

.app {
  display: grid;
  grid-template-rows: var(--toolbar-h) 1fr;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden; /* full viewport; float-strip straddle stays inside grid tracks */
}

/* —— Top toolbar —— */
.toolbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--toolbar-h);
  padding: 0 16px;
  background: var(--bg-chrome);
  color: var(--bar-text);
  /* Hairline under header — same family as panel edge; no navy/panel color break */
  border-bottom: 1px solid var(--border-panel);
  z-index: 30;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 0;
  min-width: 0;
  z-index: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  min-width: 0;
  max-width: 200px;
  padding: 6px 0;
  text-decoration: none;
  line-height: 0;
}

.brand-logo {
  display: block;
  /* Color stacked wordmark PNG (294×150). Fixed height; width follows aspect. */
  height: 30px;
  width: auto;
  max-width: 160px;
  flex-shrink: 0;
  object-fit: contain;
  object-position: left center;
}

/* Left journal name: immediately after LI logo, before tools */
.toolbar-journal {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 1;
  min-width: 0;
  max-width: min(220px, 26vw);
}

.toolbar-journal-divider {
  flex-shrink: 0;
  width: 1px;
  height: 28px;
  background: var(--chrome-divider);
}

.toolbar-journal:has(.header-journal.is-stacked) .toolbar-journal-divider {
  height: 34px;
  align-self: center;
}

.header-journal {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: var(--text-on-chrome);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-journal.is-stacked {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.15;
}

.header-journal-line {
  display: block;
  color: var(--text-on-chrome);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-journal-line--prefix {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.92;
}

.header-journal-line--rest {
  font-size: 13px;
  font-weight: 600;
}

.header-journal:hover,
.header-journal:focus-visible {
  color: var(--text-on-chrome);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.header-journal.is-stacked:hover .header-journal-line,
.header-journal.is-stacked:focus-visible .header-journal-line {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* PDF | Video — visually centered in the header */
.view-mode-toggle {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 0;
  padding: 3px;
  border-radius: 999px;
  background: var(--chrome-inset);
  border: 1px solid var(--chrome-divider);
  z-index: 2;
}

.view-mode-btn {
  appearance: none;
  margin: 0;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-on-chrome-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.2;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.view-mode-btn:hover {
  color: var(--text-on-chrome);
  background: var(--chrome-hover-wash);
}

.view-mode-btn:focus-visible {
  outline: 2px solid var(--focus-ring-on-chrome);
  outline-offset: 1px;
}

.view-mode-btn.is-active {
  background: var(--bg-chrome-elevated);
  color: var(--text-on-chrome);
  box-shadow: 0 0 0 1px var(--border-chrome);
}

/* Desktop (>900px): inline toolbar; hamburger hidden.
   Use .tb-icon.toolbar-menu-toggle so display:none beats .tb-icon { display: inline-flex }. */
.tb-icon.toolbar-menu-toggle {
  display: none;
  flex-shrink: 0;
}

.toolbar-menu {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 0;
  min-width: 0;
  gap: 10px;
  z-index: 1;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.page-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 4px 0 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--bar-text);
  font-size: 12px;
  font-weight: 500;
}

.page-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--bar-text);
}

.page-prefix {
  color: var(--bar-text);
}

.page-input {
  width: 40px;
  height: 24px;
  border: 1px solid var(--border-chrome);
  border-radius: 4px;
  background: var(--chrome-inset);
  color: var(--text-on-chrome);
  text-align: center;
  font: inherit;
  font-size: 12px;
}

.page-input::-webkit-outer-spin-button,
.page-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.page-input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.page-total {
  color: var(--bar-text);
  min-width: 2.2em;
}

.tb-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-on-chrome-icon);
  cursor: pointer;
}

.tb-icon svg {
  width: 18px;
  height: 18px;
}

.tb-icon:hover:not(:disabled) {
  background: var(--chrome-hover-wash);
  color: var(--text-on-chrome-icon);
}

.tb-icon:focus-visible {
  outline: 2px solid var(--focus-ring-on-chrome);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-ring-glow-on-chrome);
}

.tb-icon:disabled {
  opacity: 0.4;
  cursor: default;
}

.zoom-label {
  min-width: 44px;
  text-align: center;
  font-size: 12px;
  color: var(--bar-text);
}

.btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--accent-cta);
  color: var(--accent-cta-ink);
  text-decoration: none;
}

.btn-download svg {
  width: 18px;
  height: 18px;
}

.btn-download:hover {
  background: var(--accent-cta-hover);
}

.btn-download:focus-visible {
  outline: 2px solid var(--focus-ring-on-chrome);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-ring-glow-on-chrome);
}

.page-input:focus {
  outline: 2px solid var(--focus-ring-on-chrome);
  outline-offset: 1px;
  box-shadow: 0 0 0 3px var(--focus-ring-glow-on-chrome);
  border-color: var(--focus-ring-on-chrome);
}

.btn-ghost {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-chrome);
  border-radius: 6px;
  background: var(--bg-chrome-chip);
  color: var(--bar-text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost:hover {
  background: var(--chrome-hover-wash);
}

.btn-ghost:focus-visible {
  outline: 2px solid var(--focus-ring-on-chrome);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-ring-glow-on-chrome);
}

/* Cite dialog ghost sits on light panel — use panel focus tokens */
.cite-dialog .btn-ghost:focus-visible,
.cite-copy:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-ring-glow);
}

/* Compact light search popover (anchored to #btnSearch) */
.search-anchor {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.search-bar {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 252px;
  max-width: min(252px, calc(100vw - 24px));
  padding: 10px 10px 9px;
  background: var(--bg-panel);
  color: var(--text-panel);
  border: 1px solid var(--border-panel);
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(15, 58, 74, 0.04),
    0 8px 24px rgba(15, 58, 74, 0.14);
}

.search-label {
  margin: 0;
  padding: 0 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  /* Remapped token — --navy-mid stays dark on dark panels */
  color: var(--text-panel-secondary);
  line-height: 1.2;
}

.search-input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--page);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  box-sizing: border-box;
}

.search-input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

.search-input:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
  box-shadow: 0 0 0 3px var(--focus-ring-glow);
  border-color: var(--teal);
}

.search-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--navy-mid);
  border-radius: 6px;
  background: var(--navy-deep);
  color: var(--on-navy);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
}

.search-btn:hover {
  background: var(--navy-mid);
  border-color: var(--navy-light);
}

.search-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-ring-glow);
}

.search-btn--quiet {
  width: 28px;
  padding: 0;
  margin-left: auto;
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.search-btn--quiet:hover {
  background: var(--soft);
  border-color: var(--line-brand);
  color: var(--ink);
}

.search-btn--quiet svg {
  width: 14px;
  height: 14px;
}

.search-bar[hidden],
.details[hidden] {
  display: none !important;
}

/* —— Workspace —— */
.workspace {
  display: grid;
  /* Keep three tracks always so open/close can interpolate (no display:none jump). */
  grid-template-columns: var(--sidebar-w) 1fr var(--sidebar-w);
  min-height: 0;
  height: 100%;
  overflow: visible; /* allow float-strips to straddle sidebar edges */
  transition: grid-template-columns var(--sidebar-duration) var(--sidebar-ease);
}

/* Exclusive sidebars: at most one open — collapse via 0px track (animates). */
.app.details-collapsed .workspace {
  grid-template-columns: 0px 1fr var(--sidebar-w);
}

.app.related-collapsed .workspace {
  grid-template-columns: var(--sidebar-w) 1fr 0px;
}

.app.details-collapsed.related-collapsed .workspace {
  grid-template-columns: 0px 1fr 0px;
}

.details,
.related {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg-panel);
  color: var(--text-panel);
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
  transition:
    opacity 200ms ease,
    transform var(--sidebar-duration) var(--sidebar-ease),
    visibility 0s linear 0s;
}

/* Clip content at full sidebar width so text doesn't reflow while the track shrinks. */
.details > .details-head,
.details > .details-body,
.related > .related-head,
.related > .related-body {
  flex: 0 0 auto;
  width: var(--sidebar-w);
  max-width: none;
  box-sizing: border-box;
}

.details > .details-body,
.related > .related-body {
  flex: 1 1 auto;
  min-height: 0;
}

.app.details-collapsed .details {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-10px);
  transition:
    opacity 180ms ease,
    transform var(--sidebar-duration) var(--sidebar-ease),
    visibility 0s linear var(--sidebar-duration);
}

.app.related-collapsed .related {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(10px);
  transition:
    opacity 180ms ease,
    transform var(--sidebar-duration) var(--sidebar-ease),
    visibility 0s linear var(--sidebar-duration);
}

.details-head,
.related-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  background: var(--bg-panel-elevated);
  border-bottom: 1px solid var(--border-panel);
}

/* Author display:flex would otherwise override the [hidden] UA rule. */
.details-head[hidden] {
  display: none !important;
}

.panel-label {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-panel);
}

.details-body,
.related-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 16px 24px;
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* No DETAILS head: keep a comfortable top inset so content isn't flush to the panel edge. */
.details-head[hidden] + .details-body {
  padding-top: 20px;
}

.details-body::-webkit-scrollbar,
.related-body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.outline-empty {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-panel-muted);
}

.outline-nav {
  margin: 0;
}

.outline-tree {
  margin: 0;
  padding: 0;
  list-style: none;
}

.outline-tree .outline-tree {
  padding-left: 12px;
  margin-top: 2px;
}

.outline-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 7px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-panel);
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.outline-item:hover {
  background: var(--soft);
  color: var(--text-panel);
}

.outline-item:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.related-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.related-item {
  margin: 0 0 14px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--border-panel);
}

.related-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.related-link {
  display: block;
  color: var(--text-panel);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
}

.related-link:hover {
  color: var(--accent-link-hover);
}

.related-meta {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.45;
  /* Muted (not secondary) so titles stay the clear primary in the list */
  color: var(--text-panel-muted);
}

.related-empty {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-panel-muted);
}

.related-videos {
  padding: 0;
}

.related-videos-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.related-video-item {
  margin: 0 0 16px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--border-panel);
}

.related-video-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.related-video-link {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  color: var(--text-panel);
  text-decoration: none;
}

.related-video-link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 8px;
}

.related-video-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(165deg, var(--soft) 0%, var(--bg-page) 48%, var(--teal-soft) 100%);
  border: 1px solid var(--border-panel);
}

.related-video-thumb-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.related-video-thumb-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: rgba(15, 58, 74, 0.06);
  pointer-events: none;
}

.related-video-thumb-play svg {
  width: 14px;
  height: 14px;
  padding: 9px;
  border-radius: 50%;
  background: var(--teal-deep);
  color: #ffffff;
  box-sizing: content-box;
  box-shadow: 0 1px 4px rgba(15, 58, 74, 0.22);
}

.related-video-thumb.has-image .related-video-thumb-play {
  color: #ffffff;
}

.related-video-thumb.is-placeholder .related-video-thumb-play {
  background: transparent;
}

.related-video-thumb.is-placeholder .related-video-thumb-play svg {
  width: 16px;
  height: 16px;
  padding: 10px;
}

.related-video-duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 1;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
  color: var(--text-on-chrome);
  background: rgba(15, 58, 74, 0.82);
}

.related-video-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  width: 100%;
}

.related-video-title {
  display: block;
  color: var(--text-panel);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.related-video-link:hover .related-video-title,
.related-video-link:focus-visible .related-video-title {
  color: var(--accent-link-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.related-video-meta {
  display: block;
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-panel-muted);
}

html[data-canvas-theme="dark"] .related-video-thumb,
.app.canvas-dark .related-video-thumb {
  background:
    linear-gradient(165deg, var(--bg-panel-elevated) 0%, var(--bg-panel) 55%, var(--soft) 100%);
}

html[data-canvas-theme="dark"] .related-video-thumb-play svg,
.app.canvas-dark .related-video-thumb-play svg,
html[data-canvas-theme="dark"] .related-video-thumb.is-placeholder .related-video-thumb-play svg,
.app.canvas-dark .related-video-thumb.is-placeholder .related-video-thumb-play svg {
  background: var(--teal-deep);
  color: #ffffff;
  border-color: transparent;
}

.related-videos-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 12px;
  text-align: center;
  border-radius: 10px;
  background:
    linear-gradient(165deg, var(--soft) 0%, var(--bg-page) 55%, var(--teal-soft) 100%);
  border: 1px solid var(--border-panel);
}

.related-videos-empty-play {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--teal-deep);
  border: 1px solid transparent;
  box-shadow: 0 1px 4px rgba(15, 58, 74, 0.22);
}

.related-videos-empty-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-panel-muted);
}

html[data-canvas-theme="dark"] .related-videos-empty,
.app.canvas-dark .related-videos-empty {
  background:
    linear-gradient(165deg, var(--bg-panel-elevated) 0%, var(--bg-panel) 55%, var(--soft) 100%);
}

html[data-canvas-theme="dark"] .related-videos-empty-play,
.app.canvas-dark .related-videos-empty-play {
  background: var(--teal-deep);
  color: #ffffff;
  border-color: transparent;
}

.trendmd-host {
  min-height: 0;
}

/* Keep empty host mountable for TrendMD (display:none blocked widget init). */
.trendmd-host:empty {
  min-height: 1px;
}

.related-fallback[hidden] {
  display: none !important;
}

/* Soften TrendMD injected chrome to match panel */
.trendmd-host h2,
.trendmd-host .ceTUj89lX8G {
  margin: 0 0 12px;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-panel) !important;
  font-family: var(--font-ui) !important;
}

html[data-canvas-theme="dark"] .trendmd-host h2,
html[data-canvas-theme="dark"] .trendmd-host .ceTUj89lX8G {
  color: var(--text-panel) !important;
}

/* —— Sidebar skeleton loaders (DETAILS + Related; center keeps wavy loader) —— */
.sidebar-skeleton {
  display: none;
}

.details-body.is-skeleton .sidebar-skeleton,
.related-body.is-skeleton .sidebar-skeleton {
  display: block;
}

.details-body.is-skeleton .details-content,
.related-body.is-skeleton .related-content {
  display: none;
}

.sk {
  /* Brand-aligned shimmer: soft → teal-soft (Sage pulse), not white flash */
  --sk-base: var(--soft);
  --sk-shine: var(--teal-soft);
  display: block;
  border-radius: 3px;
  background: linear-gradient(
    105deg,
    var(--sk-base) 0%,
    var(--sk-base) 38%,
    var(--sk-shine) 50%,
    var(--sk-base) 62%,
    var(--sk-base) 100%
  );
  background-size: 220% 100%;
  animation: sk-shimmer 1.55s ease-in-out infinite;
}

.sk-line {
  height: 11px;
  margin: 0 0 8px;
}

.sk-line:last-child {
  margin-bottom: 0;
}

.sk-type {
  height: 9px;
  margin-bottom: 10px;
}

.sk-heading {
  height: 10px;
  margin-bottom: 18px;
}

.sk-meta {
  height: 9px;
  margin-top: 6px;
  opacity: 0.85;
}

.sk-pill {
  width: 52px;
  height: 28px;
  border-radius: 4px;
  flex: 0 0 auto;
}

.sk-w-30 {
  width: 30%;
}
.sk-w-35 {
  width: 35%;
}
.sk-w-40 {
  width: 40%;
}
.sk-w-45 {
  width: 45%;
}
.sk-w-50 {
  width: 50%;
}
.sk-w-55 {
  width: 55%;
}
.sk-w-60 {
  width: 60%;
}
.sk-w-65 {
  width: 65%;
}
.sk-w-70 {
  width: 70%;
}
.sk-w-75 {
  width: 75%;
}
.sk-w-80 {
  width: 80%;
}
.sk-w-85 {
  width: 85%;
}
.sk-w-90 {
  width: 90%;
}
.sk-w-95 {
  width: 95%;
}
.sk-w-100 {
  width: 100%;
}

.sk-section {
  margin: 0;
  padding: 0 0 16px;
}

.sk-section + .sk-section {
  padding-top: 16px;
  border-top: 1px solid var(--border-panel);
}

.sk-date-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.sk-date-row:last-child {
  margin-bottom: 0;
}

.sk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.sk-related-item {
  padding: 0 0 14px;
  margin: 0 0 14px;
  border-bottom: 1px solid var(--border-panel);
}

.sk-related-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

@keyframes sk-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sk {
    animation: none;
    background: var(--soft);
  }
}

/* DETAILS sidebar sections — consistent rhythm */
.meta-section {
  margin: 0;
  padding: 0 0 16px;
}

.meta-section + .meta-section {
  padding-top: 16px;
  border-top: 1px solid var(--border-panel);
}

.meta-section--footer {
  padding-bottom: 0;
}

/* Compact portrait Lumin Shorts slot (top of DETAILS) */
.meta-section--shorts {
  padding-bottom: 18px;
}

.shorts-label {
  margin: 0 0 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-panel-secondary);
}

.shorts-card {
  position: relative;
  width: min(100%, 168px);
  margin: 0 auto;
  aspect-ratio: 9 / 16;
  max-height: 300px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--soft);
  border: 1px solid var(--border-panel);
  box-shadow: none;
}

.shorts-card.is-empty {
  background:
    linear-gradient(165deg, var(--soft) 0%, var(--bg-page) 48%, var(--teal-soft) 100%);
}

.shorts-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 12px;
  text-align: center;
}

.shorts-empty-play {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  /* Remapped --ink (not --navy-deep) so dark theme stays light */
  color: var(--ink);
  background: color-mix(in srgb, var(--bg-page) 85%, transparent);
  border: 1px solid var(--line-brand);
}

.shorts-empty-mark {
  display: block;
  width: auto;
  height: 22px;
  max-width: 88px;
  object-fit: contain;
  opacity: 0.9;
}

.shorts-empty-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-panel-muted);
}

.shorts-video,
.shorts-embed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0f3a4a;
}

.shorts-video {
  object-fit: cover;
}

/* Theme is on <html data-canvas-theme>; .app.canvas-dark is legacy/compat */
html[data-canvas-theme="dark"] .shorts-card.is-empty,
.app.canvas-dark .shorts-card.is-empty {
  background:
    linear-gradient(165deg, var(--bg-panel-elevated) 0%, var(--bg-panel) 55%, var(--soft) 100%);
}

html[data-canvas-theme="dark"] .shorts-empty-play,
.app.canvas-dark .shorts-empty-play {
  background: color-mix(in srgb, var(--bg-panel) 90%, transparent);
  color: var(--text-panel);
  border-color: var(--border-panel);
}

.meta-type {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-panel-secondary);
}

.meta-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-panel);
}

.meta-authors {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-panel);
}

.meta-authors .aff-marker {
  margin-left: 1px;
  font-size: 0.7em;
  font-weight: 700;
  line-height: 0;
  vertical-align: super;
  color: var(--ink);
}

.meta-affiliations {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-panel-secondary);
}

.meta-affiliations li {
  display: grid;
  grid-template-columns: 1.1em 1fr;
  gap: 6px;
  align-items: start;
}

.meta-affiliations li + li {
  margin-top: 4px;
}

.meta-affiliations .aff-num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  line-height: 1.45;
}

.meta-affiliations .aff-text {
  color: var(--text-panel-secondary);
}

.meta-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.cite-action {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  /* Interactive link role — distinct from OA status and View article */
  color: var(--accent-link);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.cite-action:hover {
  color: var(--accent-link-hover);
  text-decoration: underline;
}

.cite-action:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--focus-ring-glow);
}

.meta-actions-divider {
  display: inline-block;
  width: 1px;
  height: 12px;
  background: var(--line);
}

.access-label {
  /* OA = trust/open status (teal), not a second ink-weight label */
  color: var(--status-open);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.meta-link {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 4px;
  color: var(--accent-link);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.meta-link:hover {
  color: var(--accent-link-hover);
  text-decoration: underline;
}

.meta-dates {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 6px 12px;
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}

.meta-dates dt {
  margin: 0;
  color: var(--text-panel-secondary);
  font-weight: 700;
}

.meta-dates dd {
  margin: 0;
  color: var(--text-panel);
}

.meta-doi {
  display: block;
  margin: 0 0 10px;
  color: var(--accent-link);
  font-size: 12px;
  font-weight: 700;
  word-break: break-all;
  text-decoration: none;
}

.meta-doi:hover {
  color: var(--accent-link-hover);
  text-decoration: underline;
}

.meta-copyright {
  margin: 0 0 12px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-panel-secondary);
}

.cite-dialog {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--overlay-scrim);
}

.cite-dialog[hidden] {
  display: none !important;
}

.cite-dialog-card {
  width: min(440px, 100%);
  padding: 16px;
  border-radius: 10px;
  background: var(--bg-panel-elevated);
  border: 1px solid var(--border-panel);
  box-shadow: 0 16px 40px rgba(15, 58, 74, 0.28);
  color: var(--text-panel);
}

.cite-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cite-dialog-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-panel);
}

.cite-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-panel-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.cite-close:hover {
  background: var(--soft);
  color: var(--text-panel);
}

.cite-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-panel-muted);
}

.cite-select,
.cite-output {
  width: 100%;
  margin-bottom: 12px;
  border: 1px solid var(--line-brand);
  border-radius: 6px;
  background: var(--page);
  color: var(--ink);
  font: inherit;
}

.cite-select {
  height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.cite-output {
  padding: 10px;
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
}

.cite-copy {
  width: 100%;
  border-color: var(--line-brand);
  background: var(--accent-cta);
  color: var(--accent-cta-ink);
}

.cite-copy:hover {
  background: var(--accent-cta-hover);
  border-color: var(--accent-cta-hover);
}

.load-error code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 10.5px;
  word-break: break-all;
}

.viewer-area {
  position: relative;
  z-index: 5; /* above sidebars so straddling float-strips stay clickable */
  /* Own stacking root: PDF canvas layers cannot escape above float tools */
  isolation: isolate;
  display: flex;
  align-items: stretch;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  background: var(--canvas-bg);
}

/* Overlay tools — out of flow so the PDF can truly center in the canvas.
   Must sit above .viewer-shell (z-index:1) so page/canvas/loader never cover the
   straddling half on first paint / refresh (canvas often promotes a compositor layer). */
.float-strip {
  position: absolute;
  top: 18px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin: 0;
  padding: 4px;
  width: auto;
  border-radius: 999px;
  /* Near-white tool chrome — not pure PDF white (Albers neighbor effect) */
  background: var(--bg-float);
  border: 1px solid var(--border-float);
  box-shadow: 0 2px 8px rgba(15, 58, 74, 0.12);
  /* translate3d keeps a stable compositor layer above PDF canvases */
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  /* Tracks canvas edge as sidebar grid columns interpolate */
  transition:
    left var(--sidebar-duration) var(--sidebar-ease),
    right var(--sidebar-duration) var(--sidebar-ease),
    transform var(--sidebar-duration) var(--sidebar-ease);
}

/* Default: fully inset on the canvas. Straddle only while that sidebar is open
   so collapsed 0px tracks / off-canvas drawers never leave half-pills past the viewport. */
.float-strip--left {
  left: 10px;
}

.float-strip--right {
  right: 10px;
}

.app:not(.details-collapsed) .float-strip--left {
  left: 0;
  transform: translate3d(-50%, 0, 0);
}

.app:not(.related-collapsed) .float-strip--right {
  right: 0;
  transform: translate3d(50%, 0, 0);
}

.fs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.fs-btn svg {
  width: 14px;
  height: 14px;
}

.fs-btn:hover:not(:disabled) {
  background: var(--soft);
  color: var(--ink);
}

.fs-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
  box-shadow: 0 0 0 3px var(--focus-ring-glow);
}

.fs-btn.accent,
.fs-btn.active {
  background: var(--teal-soft);
  color: var(--teal-deep);
}

/* Dark: teal-soft remaps to a wash; use light link ink for AA on that wash */
html[data-canvas-theme="dark"] .fs-btn.accent,
html[data-canvas-theme="dark"] .fs-btn.active,
.app.canvas-dark .fs-btn.accent,
.app.canvas-dark .fs-btn.active {
  color: var(--accent-link);
}

.fs-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.viewer-shell {
  position: relative;
  /* Stacking context below .float-strip: traps .page-wrap / canvas / .li-loader
     so they cannot paint over the straddling half of the float tools. */
  z-index: 1;
  flex: 1 1 auto;
  /* Confine page overflow here (not body/app). Hide bars; input still scrolls. */
  overflow: auto;
  overscroll-behavior: contain;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  background: var(--canvas-bg);
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* Legacy Edge / IE */
}

.viewer-shell.is-loading {
  overflow: hidden;
}

.viewer-shell::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
  background: transparent;
}

.viewer-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Pages pack from the top; do not center on the cross/main axis (that creates
     empty scrollable space above page 1 when content is shorter than the shell). */
  justify-content: flex-start;
  gap: 16px;
  /* Modest top padding; sides clear the overlay float-strip; bottom keeps last page reachable */
  padding: 16px var(--stage-pad-x) 96px;
  min-height: 100%;
  width: 100%;
  box-sizing: border-box;
}

/* —— Video mode: Article in Video main stage —— */
.app.view-mode-video .viewer-stage,
.app.view-mode-video .canvas-page-indicator,
.app.view-mode-video .status,
.app.view-mode-video .viewer-error,
.app.view-mode-video .li-loader {
  display: none !important;
}

.app.view-mode-video .toolbar-right .page-chip,
.app.view-mode-video .toolbar-right #btnFitWidth,
.app.view-mode-video .toolbar-right #btnZoomOut,
.app.view-mode-video .toolbar-right #btnZoomIn,
.app.view-mode-video .toolbar-right .zoom-label,
.app.view-mode-video .toolbar-right #btnRotate,
.app.view-mode-video .toolbar-right .search-anchor,
.app.view-mode-video .toolbar-right #btnPrint {
  display: none;
}

.app.view-mode-pdf .video-stage {
  display: none !important;
}

.video-stage {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  min-height: 100%;
  padding: 24px var(--stage-pad-x) 48px;
  box-sizing: border-box;
}

.video-stage-inner {
  display: flex;
  flex-direction: column;
  gap: 28px;
  width: min(100%, 920px);
}

.article-video-player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: var(--soft);
  border: 1px solid var(--border-panel);
  box-shadow: var(--page-shadow);
  flex-shrink: 0;
}

.article-video-player.is-empty {
  background:
    var(--article-video-poster, none),
    linear-gradient(165deg, var(--soft) 0%, var(--bg-page) 48%, var(--teal-soft) 100%);
  background-size: cover, auto;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

/* Poster already carries brand frame — keep a light “coming soon” cue only */
.article-video-player.is-empty.has-poster .article-video-empty-play,
.article-video-player.is-empty.has-poster .article-video-empty-mark,
.article-video-player.is-empty.has-poster .article-video-empty-label {
  display: none;
}

.article-video-player.is-empty.has-poster .article-video-empty {
  justify-content: flex-end;
  padding-bottom: 18px;
  background: linear-gradient(180deg, transparent 58%, rgba(15, 58, 74, 0.08) 100%);
}

.article-video-player.is-empty.has-poster .article-video-empty-hint {
  color: var(--ink-soft, #3d5760);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(174, 200, 208, 0.55);
}

.article-video-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 24px;
  text-align: center;
}

.article-video-empty-play {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--teal-deep);
  border: 1px solid transparent;
  box-shadow: 0 2px 8px rgba(15, 58, 74, 0.22);
}

.article-video-empty-mark {
  display: block;
  width: auto;
  height: 28px;
  max-width: 140px;
  object-fit: contain;
  opacity: 0.92;
}

.article-video-empty-label {
  margin: 4px 0 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-panel);
}

.article-video-empty-hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-panel-muted);
}

.article-video,
.article-video-embed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0f3a4a;
}

.article-video {
  object-fit: contain;
}

/* Dark canvas empty player without a poster — keep panel gradient.
   When .has-poster is set, prefer the shared light abstract poster. */
html[data-canvas-theme="dark"] .article-video-player.is-empty:not(.has-poster),
.app.canvas-dark .article-video-player.is-empty:not(.has-poster) {
  background:
    linear-gradient(165deg, var(--bg-panel-elevated) 0%, var(--bg-panel) 55%, var(--soft) 100%);
}

html[data-canvas-theme="dark"] .article-video-player.is-empty.has-poster,
.app.canvas-dark .article-video-player.is-empty.has-poster {
  background:
    var(--article-video-poster, none),
    linear-gradient(165deg, var(--bg-panel-elevated) 0%, var(--bg-panel) 55%, var(--soft) 100%);
  background-size: cover, auto;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

html[data-canvas-theme="dark"] .article-video-empty-play,
.app.canvas-dark .article-video-empty-play {
  background: var(--teal-deep);
  color: #ffffff;
  border-color: transparent;
}

.app.view-mode-video .viewer-shell {
  overflow: auto;
}

.app.view-mode-video .related-content {
  display: none !important;
}

.app.view-mode-pdf .related-videos {
  display: none !important;
}

/* Related Lumin Shorts — portrait cards under Article in Video */
.related-shorts {
  width: 100%;
  margin: 0;
  padding: 0;
}

.related-shorts-label {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-panel-secondary);
}

.related-shorts-grid {
  --shorts-cols: 5;
  display: grid;
  grid-template-columns: repeat(var(--shorts-cols), minmax(0, 1fr));
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(163, 208, 214, 0.35) transparent;
}

.related-shorts-grid::-webkit-scrollbar {
  height: 6px;
}

.related-shorts-grid::-webkit-scrollbar-thumb {
  background: rgba(163, 208, 214, 0.35);
  border-radius: 999px;
}

.related-shorts-grid.is-empty {
  display: block;
  overflow: visible;
}

.related-short-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: none;
  width: auto;
  padding: 0 12px;
  text-decoration: none;
  color: inherit;
  box-sizing: border-box;
}

.related-short-card:first-child {
  padding-left: 0;
}

.related-short-card:last-child {
  padding-right: 0;
}

/* Mist divider between Shorts — not a full card border */
.related-short-card + .related-short-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 36px;
  width: 1px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(163, 208, 214, 0.18) 12%,
    rgba(174, 200, 208, 0.42) 50%,
    rgba(163, 208, 214, 0.18) 88%,
    transparent 100%
  );
  pointer-events: none;
}

/* True Shorts frame: 9:16 portrait. Centered in equal columns so wide cells
   pillarbox rather than squashing the frame to landscape/square. */
.related-short-thumb {
  --shorts-frame-max-h: 260px;
  position: relative;
  display: block;
  width: min(100%, calc(var(--shorts-frame-max-h) * 9 / 16));
  max-width: 100%;
  aspect-ratio: 9 / 16;
  height: auto;
  max-height: var(--shorts-frame-max-h);
  margin-inline: auto;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background:
    linear-gradient(165deg, var(--soft) 0%, var(--bg-page) 48%, var(--teal-soft) 100%);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border-panel);
}

.related-short-thumb.has-image {
  background-color: #f7faf8;
}

.related-short-thumb-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: rgba(15, 58, 74, 0.06);
}

.related-short-thumb.has-image .related-short-thumb-play {
  color: #ffffff;
  background: rgba(15, 58, 74, 0.06);
}

.related-short-thumb-play span {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--teal-deep);
  border: 1px solid transparent;
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(15, 58, 74, 0.22);
}

.related-short-thumb.has-image .related-short-thumb-play span {
  background: var(--teal-deep);
  border-color: transparent;
  color: #ffffff;
}

.related-short-duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-on-chrome);
  background: rgba(15, 58, 74, 0.78);
}

.related-short-title {
  margin: 0;
  width: 100%;
  max-width: min(100%, calc(var(--shorts-frame-max-h, 260px) * 9 / 16));
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-panel);
  text-align: left;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.related-short-card:hover .related-short-title,
.related-short-card:focus-visible .related-short-title {
  color: var(--accent-link-hover);
}

.related-short-card:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 10px;
}

.related-shorts-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px 16px;
  text-align: center;
  border-radius: 10px;
  background:
    linear-gradient(165deg, var(--soft) 0%, var(--bg-page) 55%, var(--teal-soft) 100%);
  border: 1px solid var(--border-panel);
}

.related-shorts-empty-play {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--teal-deep);
  border: 1px solid transparent;
  box-shadow: 0 1px 4px rgba(15, 58, 74, 0.22);
}

.related-shorts-empty-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-panel-muted);
}

html[data-canvas-theme="dark"] .related-short-thumb,
.app.canvas-dark .related-short-thumb,
html[data-canvas-theme="dark"] .related-shorts-empty,
.app.canvas-dark .related-shorts-empty {
  background:
    linear-gradient(165deg, var(--bg-panel-elevated) 0%, var(--bg-panel) 55%, var(--soft) 100%);
}

html[data-canvas-theme="dark"] .related-short-thumb-play span,
.app.canvas-dark .related-short-thumb-play span {
  background: var(--teal-deep);
  color: #ffffff;
  border-color: transparent;
}

html[data-canvas-theme="dark"] .related-shorts-empty-play,
.app.canvas-dark .related-shorts-empty-play {
  background: var(--teal-deep);
  color: #ffffff;
  border-color: transparent;
}

.page-wrap {
  flex: 0 0 auto;
  /* Horizontal center via .viewer-stage align-items; no margin-block:auto — that ate
     free space between pages / clipped continuous scroll when only one page was shown. */
  margin: 0 auto;
  background: var(--bg-page);
  box-shadow: var(--page-shadow);
  line-height: 0;
  position: relative;
}

.page-wrap.is-placeholder {
  /* Reserved height from inline style; faint pulse so empty slots aren't a hard flash */
  background: linear-gradient(
    180deg,
    var(--bg-page) 0%,
    color-mix(in srgb, var(--bg-page) 88%, var(--soft-deep)) 50%,
    var(--bg-page) 100%
  );
}

.page-wrap.is-rendering::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: color-mix(in srgb, var(--bg-page) 70%, transparent);
  opacity: 0.35;
}

.page-wrap canvas {
  display: block;
  max-width: none;
  height: auto;
  /* Text layer sits above; canvas stays non-interactive for selection. */
  pointer-events: none;
  user-select: none;
}

/* PDF.js text layer — transparent selectable glyphs over the page canvas.
   Must stay inside .viewer-shell (z-index:1) so float strips (z-index:40) stay on top. */
.page-wrap .textLayer {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  opacity: 1;
  line-height: 1;
  text-align: initial;
  -webkit-text-size-adjust: none;
  -moz-text-size-adjust: none;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  pointer-events: auto;
  cursor: text;
}

.page-wrap .textLayer span,
.page-wrap .textLayer br {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}

.page-wrap .textLayer span.markedContent {
  top: 0;
  height: 0;
}

.page-wrap .textLayer .endOfContent {
  display: block;
  position: absolute;
  left: 0;
  top: 100%;
  right: 0;
  bottom: 0;
  z-index: -1;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

.page-wrap .textLayer .endOfContent.active {
  top: 0;
}

.page-wrap .textLayer ::selection {
  background: color-mix(in srgb, var(--teal) 35%, transparent);
}

.page-wrap .textLayer ::-moz-selection {
  background: color-mix(in srgb, var(--teal) 35%, transparent);
}

.load-error {
  margin: 0;
  max-width: 40rem;
  padding: 2rem;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-panel-muted);
  text-align: center;
}

.status {
  position: absolute;
  left: 50%;
  top: 24px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--status-bg);
  color: var(--on-navy);
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 5;
}

.status.visible {
  opacity: 1;
}

.canvas-page-indicator {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 6;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--navy-deep) 78%, transparent);
  color: var(--on-navy);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  pointer-events: none;
  opacity: 0.72;
  transition: opacity 0.2s ease;
}

.canvas-page-indicator[hidden] {
  display: none !important;
}

.viewer-shell:hover .canvas-page-indicator:not([hidden]) {
  opacity: 0.92;
}

.viewer-error {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  background: var(--canvas-bg);
  text-align: center;
}

.viewer-error[hidden] {
  display: none !important;
}

.viewer-error__msg {
  margin: 0;
  max-width: 28rem;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-panel-muted);
}

.viewer-error__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 18px;
}

.viewer-error__retry {
  border-color: var(--line-brand);
  background: var(--accent-cta);
  color: var(--accent-cta-ink);
}

.viewer-error__retry:hover {
  background: var(--accent-cta-hover);
  border-color: var(--accent-cta-hover);
}

.viewer-error .btn-ghost:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-ring-glow);
}

@media print {
  .toolbar,
  .search-bar,
  .details,
  .related,
  .float-strip,
  .sidebar-scrim,
  .status,
  .li-loader,
  .canvas-page-indicator,
  .viewer-error,
  .cite-dialog {
    display: none !important;
  }

  html,
  body,
  .app,
  .workspace,
  .viewer-area,
  .viewer-shell {
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
  }

  .workspace {
    display: block !important;
  }

  .viewer-stage {
    padding: 0 !important;
    gap: 0 !important;
  }

  .page-wrap {
    box-shadow: none !important;
    break-after: page;
    page-break-after: always;
  }
}

/* —— Branded document loader (scoped to .viewer-shell canvas) —— */
.li-loader {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  /* Match the PDF canvas backdrop exactly */
  background: var(--canvas-bg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.55s ease,
    visibility 0.55s ease;
}

.li-loader.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.li-loader.is-leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.li-loader__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  width: min(380px, 78%);
  transform: translateY(0);
  transition: transform 0.45s ease, opacity 0.45s ease;
}

.li-loader.is-leaving .li-loader__inner {
  transform: translateY(-6px);
  opacity: 0;
}

.li-loader__mark {
  position: relative;
  width: 100%;
  aspect-ratio: 1024 / 581;
  --fill: 8;
}

.li-loader__ghost,
.li-loader__brand {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.li-loader__ghost {
  opacity: 0.28;
  filter: saturate(0.9) brightness(0.98);
}

.li-loader__brand-clip {
  position: absolute;
  inset: 0;
  clip-path: inset(calc((100 - var(--fill)) * 1%) 0 0 0);
  filter: brightness(1.05) saturate(1.06);
}

.li-loader__liquid-mask {
  position: absolute;
  inset: 0;
  -webkit-mask-image: url("./assets/li-wordmark-loading.png");
  mask-image: url("./assets/li-wordmark-loading.png");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-mode: alpha;
  mask-mode: alpha;
  pointer-events: none;
  mix-blend-mode: soft-light;
  opacity: 0.88;
}

.li-loader__liquid {
  position: absolute;
  left: -8%;
  width: 116%;
  bottom: 0;
  height: calc(var(--fill) * 1% + 22px);
  overflow: hidden;
}

.li-loader__glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 40% at 50% 18%, rgba(255, 248, 242, 0.65), transparent 70%),
    linear-gradient(
      180deg,
      rgba(240, 160, 144, 0.4) 0%,
      rgba(55, 143, 155, 0.26) 55%,
      rgba(36, 107, 128, 0.3) 100%
    );
}

.li-loader__waves {
  position: absolute;
  left: 0;
  top: 0;
  width: 200%;
  height: 42px;
  animation: li-wave-drift 4.8s linear infinite;
}

.li-loader__wave--b {
  animation: li-wave-drift 6.4s linear infinite reverse;
  opacity: 0.9;
}

@keyframes li-wave-drift {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

/* Mission line — secondary to the mark; academic, quiet confidence */
.li-loader__tagline {
  margin: 0.55rem 0 0.05rem;
  max-width: 24em;
  font-family: var(--font-ui);
  font-size: 1.5rem; /* 24px — clear step up from prior ~18px */
  font-weight: 400;
  font-style: normal;
  letter-spacing: 0.045em;
  line-height: 1.3;
  /* Use remapped ink (not --navy-deep primitive) so dark canvas gets light text */
  color: var(--ink);
  text-align: center;
  opacity: 0.88;
}

html[data-canvas-theme="dark"] .li-loader__tagline {
  color: var(--text-panel);
  opacity: 0.95;
}

.li-loader__label {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-panel-muted);
  text-align: center;
}

.li-loader.is-fail .li-loader__label {
  color: var(--coral-deep);
  letter-spacing: 0.08em;
  text-transform: none;
  font-size: 0.9rem;
}

.li-loader.is-fail .li-loader__liquid-mask {
  opacity: 0.35;
  animation: none;
}

.li-loader.is-fail .li-loader__waves {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .workspace,
  .details,
  .related,
  .float-strip {
    transition: none !important;
  }

  /* Desktop only: skip the 10px nudge. Mobile drawers still translate fully off-canvas. */
  @media (min-width: 901px) {
    .app.details-collapsed .details,
    .app.related-collapsed .related {
      transform: none;
    }
  }

  .li-loader,
  .li-loader__inner {
    transition-duration: 0.2s;
  }

  .li-loader__waves,
  .li-loader__wave--b {
    animation: none;
  }

  .li-loader.is-active .li-loader__mark {
    --fill: 100;
  }
}

@media (max-width: 1100px) {
  :root {
    --sidebar-w: 260px;
  }

  .workspace,
  .app.related-collapsed .workspace {
    grid-template-columns: var(--sidebar-w) 1fr 0px;
  }

  .app:not(.related-collapsed) .workspace,
  .app.details-collapsed:not(.related-collapsed) .workspace {
    grid-template-columns: 0px 1fr var(--sidebar-w);
  }

  .app.details-collapsed.related-collapsed .workspace {
    grid-template-columns: 0px 1fr 0px;
  }
}

/* Scrim sits idle on desktop; mobile rules activate it when a drawer is open */
.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--overlay-scrim);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/*
 * ≤900px: sidebars become overlay drawers (canvas keeps full width).
 * Prior rule used display:none and made DETAILS / Related unreachable.
 */
@media (max-width: 900px) {
  :root {
    --sidebar-w: min(360px, calc(100vw - 40px));
    --stage-pad-x: 16px;
    --toolbar-h: auto;
  }

  .app {
    grid-template-rows: auto 1fr;
  }

  .toolbar {
    height: auto;
    min-height: 52px;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
  }

  .brand {
    max-width: 80px;
  }

  .brand-logo {
    height: 24px;
    width: auto;
    max-width: 80px;
  }

  /* Compact: LI logo | journal | PDF/Video | hamburger; tools in panel */
  .toolbar-left {
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
  }

  .toolbar-journal {
    flex: 1 1 auto;
    max-width: none;
    gap: 8px;
    min-width: 0;
  }

  .toolbar-journal-divider {
    display: none;
  }

  .header-journal {
    font-size: 11px;
  }

  .header-journal-line--prefix {
    font-size: 10px;
  }

  .header-journal-line--rest {
    font-size: 11px;
  }

  .view-mode-toggle {
    position: static;
    left: auto;
    transform: none;
    flex-shrink: 0;
    padding: 2px;
  }

  .view-mode-btn {
    padding: 6px 10px;
    font-size: 11px;
    min-height: 32px;
  }

  .tb-icon.toolbar-menu-toggle {
    display: inline-flex;
    width: 44px;
    height: 44px;
    margin-left: 0;
  }

  .video-stage {
    padding: 16px var(--stage-pad-x) 32px;
  }

  .video-stage-inner {
    gap: 22px;
  }

  .article-video-player {
    border-radius: 10px;
  }

  .article-video-empty-play {
    width: 52px;
    height: 52px;
  }

  .article-video-empty-label {
    font-size: 14px;
  }

  .related-short-card {
    min-width: 0;
    max-width: none;
    padding: 0 8px;
  }

  .related-short-card + .related-short-card::before {
    bottom: 32px;
  }

  .related-short-thumb {
    --shorts-frame-max-h: 200px;
  }

  .toolbar-menu {
    display: none;
    position: absolute;
    top: calc(100% + 1px);
    left: 8px;
    right: 8px;
    flex: none;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
    background: var(--bg-chrome-elevated);
    border: 1px solid var(--border-chrome);
    border-radius: 0 0 10px 10px;
    box-shadow: 0 12px 28px rgba(15, 58, 74, 0.35);
    z-index: 36;
  }

  .toolbar.is-menu-open .toolbar-menu {
    display: flex;
  }

  .toolbar-right {
    flex: none;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
    margin-left: 0;
    width: 100%;
  }

  .page-prefix {
    display: inline;
  }

  .page-chip {
    height: 44px;
    gap: 4px;
  }

  .page-input {
    width: 44px;
    height: 36px;
    font-size: 14px;
  }

  .toolbar-menu .tb-icon {
    width: 44px;
    height: 44px;
  }

  .btn-download {
    width: 44px;
    height: 44px;
    margin-left: 2px;
  }

  .zoom-label {
    min-width: 44px;
    font-size: 12px;
  }

  .search-bar {
    width: 240px;
    max-width: min(240px, calc(100vw - 16px));
    right: -4px;
  }

  .workspace,
  .app.details-collapsed .workspace,
  .app.related-collapsed .workspace,
  .app.details-collapsed.related-collapsed .workspace,
  .app:not(.related-collapsed) .workspace {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    transition: none;
    min-height: 0;
    height: 100%;
  }

  .viewer-area {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
  }

  .app:not(.details-collapsed) .sidebar-scrim,
  .app:not(.related-collapsed) .sidebar-scrim {
    display: block;
  }

  .details,
  .related {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 50;
    width: var(--sidebar-w);
    max-width: 100vw;
    display: flex;
    box-shadow: 0 8px 32px rgba(15, 58, 74, 0.28);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .details {
    left: 0;
    right: auto;
  }

  .related {
    right: 0;
    left: auto;
  }

  /* Explicit open/closed so desktop collapsed transforms cannot stick */
  .app:not(.details-collapsed) .details {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
  }

  .app:not(.related-collapsed) .related {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
  }

  .details > .details-head,
  .details > .details-body,
  .related > .related-head,
  .related > .related-body {
    width: 100%;
  }

  .app.details-collapsed .details {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-110%);
    box-shadow: none;
  }

  .app.related-collapsed .related {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(110%);
    box-shadow: none;
  }

  /* Clip any off-canvas drawer / straddle remnants at the viewport edge */
  .app,
  .workspace,
  .viewer-area {
    overflow-x: hidden;
  }

  .float-strip,
  .float-strip.float-strip--left,
  .float-strip.float-strip--right,
  .app:not(.details-collapsed) .float-strip--left,
  .app:not(.related-collapsed) .float-strip--right {
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    left: auto;
    right: auto;
    flex-direction: row;
    padding: 4px;
    gap: 4px;
    z-index: 55;
    /* Never straddle on compact; keep translate3d so the layer stays above PDF */
    transform: translate3d(0, 0, 0);
  }

  .float-strip--left,
  .float-strip.float-strip--left,
  .app:not(.details-collapsed) .float-strip--left {
    left: 10px;
    right: auto;
  }

  .float-strip--right,
  .float-strip.float-strip--right,
  .app:not(.related-collapsed) .float-strip--right {
    right: 10px;
    left: auto;
  }

  .fs-btn {
    width: 44px;
    height: 44px;
  }

  .fs-btn svg {
    width: 16px;
    height: 16px;
  }

  .viewer-stage {
    padding: 12px var(--stage-pad-x) 88px;
  }

  .viewer-shell {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .li-loader {
    padding: 16px;
  }

  .li-loader__inner {
    width: min(280px, 86%);
    gap: 0.85rem;
  }

  .li-loader__tagline {
    margin-top: 0.4rem;
    font-size: 1.2rem; /* ~19px — readable on small screens */
    letter-spacing: 0.035em;
    max-width: 18em;
  }

  .li-loader__label {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
  }

}

/* Phones: near-full sheet drawers (48px scrim peek to dismiss) + tighter chrome */
@media (max-width: 480px) {
  :root {
    --sidebar-w: calc(100vw - 48px);
    --stage-pad-x: 12px;
  }

  .page-total {
    min-width: 1.6em;
  }
}
