/* ── Air-style centered popup PDF viewer ── */
.pdf-viewer-modal {
  --pv-bg: #0d0d0d;
  --pv-main: #141414;
  --pv-sidebar: #141414;
  --pv-surface: #1f1f1f;
  --pv-surface-hover: #282828;
  --pv-border: rgba(255, 255, 255, 0.07);
  --pv-text: #ffffff;
  --pv-muted: rgba(255, 255, 255, 0.42);
  --pv-toolbar: #1c1c1c;
  z-index: 10050 !important;
}

.pdf-viewer-modal .pdf-viewer-dialog,
.pdf-viewer-modal .modal-dialog.pdf-viewer-dialog {
  width: min(1520px, calc(100vw - 40px)) !important;
  max-width: min(1520px, calc(100vw - 40px)) !important;
  height: min(
    828px,
    90dvh,
    calc(min(1520px, calc(100vw - 40px)) * 828 / 1520)
  ) !important;
  margin: 1.25rem auto !important;
}

.pdf-viewer-modal .pdf-viewer-content {
  background: var(--pv-bg);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  overflow: hidden;
  height: 100%;
  color: var(--pv-text);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.65);
}

.pdf-viewer-modal .modal-body {
  padding: 0;
  overflow: hidden;
  height: 100%;
}

body:has(.pdf-viewer-modal.show) .modal-backdrop {
  z-index: 10040 !important;
  background: #050505;
  opacity: 0.88 !important;
}

body.pdf-viewer-open {
  overflow: hidden !important;
}

/* ── Shell ── */
.pdf-viewer-shell {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--pv-bg);
}

.pdf-viewer-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--pv-main);
  border-radius: 14px 0 0 14px;
  --pv-page-max-width: 300px;
}

/* ── Light mode (entire popup) ── */
.pdf-viewer-shell.is-light {
  --pv-bg: #e5e5e5;
  --pv-main: #d4d4d4;
  --pv-sidebar: #f0f0f0;
  --pv-surface: #e8e8e8;
  --pv-surface-hover: #dedede;
  --pv-border: rgba(0, 0, 0, 0.1);
  --pv-text: #1a1a1a;
  --pv-muted: rgba(0, 0, 0, 0.45);
  --pv-toolbar: #ebebeb;
}

.pdf-viewer-shell.is-light .pdf-viewer-content {
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.18);
}

.pdf-viewer-shell.is-light .pdf-viewer-search-btn {
  color: rgba(0, 0, 0, 0.45);
}

.pdf-viewer-shell.is-light .pdf-viewer-search-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.85);
}

.pdf-viewer-shell.is-light .pdf-viewer-header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

.pdf-viewer-shell.is-light .pdf-viewer-canvas-wrap::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
}

.pdf-viewer-shell.is-light .pdf-viewer-btn {
  color: rgba(0, 0, 0, 0.65);
}

.pdf-viewer-shell.is-light .pdf-viewer-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.9);
}

.pdf-viewer-shell.is-light .pdf-viewer-zoom-label {
  color: rgba(0, 0, 0, 0.65);
}

.pdf-viewer-shell.is-light .pdf-viewer-zoom-slider {
  background: rgba(0, 0, 0, 0.15);
}

.pdf-viewer-shell.is-light .pdf-viewer-zoom-slider::-webkit-slider-thumb,
.pdf-viewer-shell.is-light .pdf-viewer-zoom-slider::-moz-range-thumb {
  background: #333;
}

.pdf-viewer-shell.is-light .pdf-viewer-page-box {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
}

.pdf-viewer-shell.is-light .pdf-viewer-page-label {
  color: rgba(0, 0, 0, 0.75);
}

.pdf-viewer-shell.is-light .pdf-viewer-page-current {
  color: #111;
  border-color: rgba(0, 0, 0, 0.15);
  background: rgba(255, 255, 255, 0.6);
}

.pdf-viewer-shell.is-light .pdf-viewer-page-nav {
  color: rgba(0, 0, 0, 0.45);
}

.pdf-viewer-shell.is-light .pdf-viewer-page-nav:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.8);
}

.pdf-viewer-shell.is-light .pdf-viewer-download-btn {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.85);
}

.pdf-viewer-shell.is-light .pdf-viewer-download-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}

.pdf-viewer-shell.is-light .pdf-viewer-thumbs-panel {
  background: var(--pv-toolbar);
  border-color: rgba(0, 0, 0, 0.1);
}

.pdf-viewer-shell.is-light .pdf-viewer-thumb-label {
  color: rgba(0, 0, 0, 0.85);
}

.pdf-viewer-shell.is-light .pdf-viewer-thumb-label.is-active {
  background: rgba(0, 0, 0, 0.08);
}

.pdf-viewer-shell.is-light .pdf-viewer-thumb.is-active,
.pdf-viewer-shell.is-light .pdf-viewer-thumb:hover {
  border-color: rgba(0, 0, 0, 0.35);
}

.pdf-viewer-shell.is-light .pdf-viewer-thumbs-collapse {
  color: rgba(0, 0, 0, 0.45);
}

.pdf-viewer-shell.is-light .pdf-viewer-thumbs-collapse:hover {
  color: rgba(0, 0, 0, 0.85);
}

.pdf-viewer-shell.is-light .pdf-viewer-sidebar-collapse {
  color: rgba(0, 0, 0, 0.45);
}

.pdf-viewer-shell.is-light .pdf-viewer-sidebar-collapse:hover {
  color: rgba(0, 0, 0, 0.85);
}

.pdf-viewer-shell.is-light .pdf-viewer-sidebar-expand {
  background: rgba(0, 0, 0, 0.05);
  color: rgba(0, 0, 0, 0.55);
}

.pdf-viewer-shell.is-light .pdf-viewer-close-btn {
  color: rgba(0, 0, 0, 0.45);
}

.pdf-viewer-shell.is-light .pdf-viewer-close-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.85);
}

.pdf-viewer-shell.is-light .pdf-viewer-settings-menu {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
}

.pdf-viewer-shell.is-light .pdf-viewer-settings-item {
  color: rgba(0, 0, 0, 0.88);
}

.pdf-viewer-shell.is-light .pdf-viewer-settings-item.is-active .pdf-viewer-settings-check {
  color: #2563eb;
}

/* Top bar – search stays above scrollable PDF */
.pdf-viewer-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 12px;
  background: var(--pv-main);
  border-bottom: 1px solid var(--pv-border);
  z-index: 12;
}

.pdf-viewer-search-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: background 0.15s, color 0.15s;
}

.pdf-viewer-search-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.9);
}

.pdf-viewer-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.pdf-viewer-close-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.pdf-viewer-close-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.9);
}

.pdf-viewer-header.is-search-open .pdf-viewer-search-btn {
  display: none;
}

.pdf-viewer-header.is-search-open .pdf-viewer-search-bar {
  display: flex;
}

.pdf-viewer-search-bar {
  flex: 1;
  max-width: 420px;
  display: none;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 8px 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

.pdf-viewer-search-bar-icon {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.45);
  flex-shrink: 0;
}

.pdf-viewer-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
  outline: none;
}

.pdf-viewer-search-input::-webkit-search-cancel-button {
  display: none;
}

.pdf-viewer-search-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.pdf-viewer-search-count,
.pdf-viewer-search-nav {
  display: none;
}

.pdf-viewer-search-bar.has-query .pdf-viewer-search-count,
.pdf-viewer-search-bar.has-query .pdf-viewer-search-nav {
  display: inline-flex;
}

.pdf-viewer-search-count {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
  padding: 0 2px;
}

.pdf-viewer-search-nav,
.pdf-viewer-search-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.pdf-viewer-search-nav:hover,
.pdf-viewer-search-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.pdf-viewer-shell.is-light .pdf-viewer-search-bar {
  border-color: rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.04);
}

.pdf-viewer-shell.is-light .pdf-viewer-search-bar-icon {
  color: rgba(0, 0, 0, 0.4);
}

.pdf-viewer-shell.is-light .pdf-viewer-search-input {
  color: rgba(0, 0, 0, 0.88);
}

.pdf-viewer-shell.is-light .pdf-viewer-search-input::placeholder {
  color: rgba(0, 0, 0, 0.38);
}

.pdf-viewer-shell.is-light .pdf-viewer-search-count {
  color: rgba(0, 0, 0, 0.45);
}

.pdf-viewer-shell.is-light .pdf-viewer-search-nav,
.pdf-viewer-shell.is-light .pdf-viewer-search-close {
  color: rgba(0, 0, 0, 0.5);
}

.pdf-viewer-shell.is-light .pdf-viewer-search-nav:hover,
.pdf-viewer-shell.is-light .pdf-viewer-search-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.85);
}

/* Canvas – scrolls only between header and toolbar */
.pdf-viewer-content-area .pdf-viewer-canvas-wrap {
  flex: 1;
  min-width: 0;
}

.pdf-viewer-canvas-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--pv-main);
  scroll-behavior: smooth;
}

.pdf-viewer-canvas-wrap::-webkit-scrollbar {
  width: 4px;
}

.pdf-viewer-canvas-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

.pdf-viewer-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 24px;
  min-height: min-content;
  width: 100%;
  margin: 0 auto;
}

.pdf-viewer-page {
  position: relative;
  flex-shrink: 0;
  background: #fff;
  line-height: 0;
  border-radius: 2px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

.pdf-viewer-page canvas {
  display: block;
}

.pdf-viewer-text-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  line-height: 1;
  pointer-events: none;
}

.pdf-viewer-text-layer span {
  position: absolute;
  color: transparent;
  white-space: pre;
  transform-origin: 0 0;
}

.pdf-viewer-text-layer mark.pdf-search-match {
  background: rgba(255, 213, 0, 0.6);
  color: transparent;
  border-radius: 2px;
  padding: 0;
}

.pdf-viewer-text-layer mark.pdf-search-match.is-current {
  background: rgba(255, 120, 0, 0.85);
}

.pdf-viewer-loading,
.pdf-viewer-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--pv-muted);
  font-size: 14px;
}

.pdf-viewer-error {
  color: #f87171;
}

/* Content area – canvas + left thumbs panel */
.pdf-viewer-content-area {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Left thumbnails panel – slides in from left */
.pdf-viewer-thumbs-panel {
  flex-shrink: 0;
  width: 0;
  overflow: hidden;
  background: var(--pv-toolbar);
  border-right: 1px solid transparent;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: width 0.28s ease, border-color 0.28s ease;
  z-index: 10;
}

.pdf-viewer-thumbs-panel.is-open {
  width: 200px;
  border-right-color: var(--pv-border);
}

.pdf-viewer-thumbs-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 12px 10px 48px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.pdf-viewer-thumbs-inner::-webkit-scrollbar {
  width: 4px;
}

.pdf-viewer-thumbs-inner::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

.pdf-viewer-thumb-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  flex-shrink: 0;
}

.pdf-viewer-thumb-label {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  padding: 2px 8px;
  border-radius: 6px;
  line-height: 1.3;
}

.pdf-viewer-thumb-label.is-active {
  background: rgba(255, 255, 255, 0.1);
}

.pdf-viewer-thumb {
  flex: 0 0 auto;
  width: 100%;
  max-width: 160px;
  padding: 0;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  opacity: 0.55;
  background: none;
  transition: opacity 0.2s, border-color 0.2s;
}

.pdf-viewer-thumb.is-active,
.pdf-viewer-thumb:hover {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.65);
}

.pdf-viewer-thumb canvas {
  width: 100%;
  height: auto;
  display: block;
}

.pdf-viewer-thumbs-collapse {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  z-index: 2;
  transition: color 0.15s, background 0.15s;
}

.pdf-viewer-thumbs-panel.is-open .pdf-viewer-thumbs-collapse {
  display: inline-flex;
}

.pdf-viewer-thumbs-collapse:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
}

/* ── Bottom toolbar (3-column, Air layout) ── */
.pdf-viewer-toolbar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin: 8px 12px 12px;
  padding: 6px 10px;
  background: var(--pv-toolbar);
  border: 1px solid var(--pv-border);
  border-radius: 12px;
}

.pdf-viewer-toolbar-left,
.pdf-viewer-toolbar-center,
.pdf-viewer-toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pdf-viewer-toolbar-left {
  justify-content: flex-start;
}

.pdf-viewer-toolbar-center {
  justify-content: center;
}

.pdf-viewer-toolbar-right {
  justify-content: flex-end;
  gap: 2px;
}

.pdf-viewer-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-size: 18px;
  flex-shrink: 0;
}

.pdf-viewer-btn i {
  line-height: 1;
}

.pdf-viewer-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.pdf-viewer-zoom-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 2px;
}

.pdf-viewer-zoom-label {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
  min-width: 30px;
  text-align: right;
  user-select: none;
  white-space: nowrap;
}

.pdf-viewer-zoom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 88px;
  height: 2px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  margin: 0;
}

.pdf-viewer-zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.pdf-viewer-zoom-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
}

/* Page box – prev/next nav with current page highlight */
.pdf-viewer-page-box {
  display: inline-flex;
  align-items: center;
  height: 32px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  overflow: hidden;
  margin: 0 2px;
}

.pdf-viewer-page-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 32px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.pdf-viewer-page-nav:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
}

.pdf-viewer-page-label {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.88);
  padding: 0 6px;
  white-space: nowrap;
  user-select: none;
  letter-spacing: 0.02em;
}

.pdf-viewer-page-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  color: #fff;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  transition: color 0.15s ease, background 0.15s ease;
}

.pdf-viewer-page-sep {
  color: rgba(255, 255, 255, 0.55);
}

/* Settings menu popup */
.pdf-viewer-settings-wrap {
  position: relative;
  display: inline-flex;
}

.pdf-viewer-settings-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  min-width: 210px;
  padding: 6px 0;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  z-index: 30;
}

.pdf-viewer-settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: rgba(0, 0, 0, 0.88);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.pdf-viewer-settings-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.pdf-viewer-settings-check {
  font-size: 16px;
  color: #2563eb;
  opacity: 0;
  flex-shrink: 0;
}

.pdf-viewer-settings-item.is-active .pdf-viewer-settings-check {
  opacity: 1;
}

.pdf-viewer-btn[data-action="toggle-fullscreen"] i[hidden] {
  display: none !important;
}

/* Download button */
.pdf-viewer-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  margin-left: 6px;
  padding: 0 12px 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}

.pdf-viewer-download-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

/* ── Right sidebar ── */
.pdf-viewer-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--pv-sidebar);
  border-left: 1px solid var(--pv-border);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: width 0.25s ease, opacity 0.25s ease;
  overflow: hidden;
  border-radius: 0 14px 14px 0;
}

.pdf-viewer-sidebar.is-collapsed {
  width: 0;
  opacity: 0;
  border: none;
  pointer-events: none;
}

.pdf-viewer-sidebar-collapse {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  font-size: 14px;
  transition: color 0.15s;
}

.pdf-viewer-sidebar-collapse:hover {
  color: rgba(255, 255, 255, 0.85);
}

.pdf-viewer-collapse-bar {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: currentColor;
  border-radius: 1px;
  margin-left: 1px;
  opacity: 0.7;
}

.pdf-viewer-sidebar-inner {
  padding: 44px 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.pdf-viewer-modal .pdf-viewer-sidebar-title {
  font-size: 16px !important;
  font-weight: 600 !important;
  line-height: 1.45 !important;
  color: var(--pv-text);
  margin: 0 0 8px !important;
  padding-right: 28px;
  word-break: break-word;
  letter-spacing: -0.01em;
}

.pdf-viewer-sidebar-meta {
  font-size: 11px;
  color: var(--pv-muted);
  margin-bottom: 18px;
  letter-spacing: 0.01em;
}

/* Expand sidebar button */
.pdf-viewer-sidebar-expand {
  display: none;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.pdf-viewer-shell:has(.pdf-viewer-sidebar.is-collapsed) .pdf-viewer-sidebar-expand {
  display: inline-flex;
}

.pdf-viewer-sidebar-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 14;
  border-radius: 14px;
}

/* Hide mobile-only elements on desktop */
.pdf-viewer-mobile-title-row,
.pdf-viewer-mobile-bar {
  display: none;
}

.pdf-viewer-search-wrap {
  display: contents;
}

/* ── Responsive (mobile only – desktop unchanged) ── */
@media (max-width: 767.98px) {
  /* Full-screen page takeover (not a modal) */
  .pdf-viewer-modal.is-mobile-screen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 10050 !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    background: var(--pv-bg);
  }

  .pdf-viewer-modal.is-mobile-screen .modal-dialog,
  .pdf-viewer-modal.is-mobile-screen .pdf-viewer-dialog {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    transform: none !important;
  }

  .pdf-viewer-modal.is-mobile-screen .modal-content,
  .pdf-viewer-modal.is-mobile-screen .pdf-viewer-content {
    height: 100% !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  body.pdf-viewer-mobile-active {
    overflow: hidden !important;
  }

  .pdf-viewer-modal.is-mobile-screen .modal-body {
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  body.pdf-viewer-mobile-active .modal-backdrop {
    display: none !important;
  }

  .pdf-viewer-modal .pdf-viewer-dialog,
  .pdf-viewer-modal .modal-dialog.pdf-viewer-dialog {
    max-width: 100vw !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    margin: 0 !important;
  }

  .pdf-viewer-modal .pdf-viewer-content {
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  .pdf-viewer-shell {
    flex-direction: column;
    height: 100%;
  }

  .pdf-viewer-main {
    border-radius: 0;
    flex: 1;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    --pv-page-max-width: none;
  }

  /* Header: title row + search row below */
  .pdf-viewer-header {
    flex-wrap: wrap;
    align-items: stretch;
    height: auto;
    min-height: 0;
    padding: 0;
    gap: 0;
    border-bottom: none;
    background: var(--pv-bg);
  }

  .pdf-viewer-mobile-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    order: 1;
    flex-basis: 100%;
    width: 100%;
    padding: 10px 12px;
    background: var(--pv-main);
    border-bottom: 1px solid var(--pv-border);
  }

  .pdf-viewer-modal .pdf-viewer-mobile-title {
    display: block;
    flex: 1;
    min-width: 0;
    margin: 0 !important;
    padding: 0;
    font-size: 11px !important;
    font-weight: 500 !important;
    line-height: 1.3;
    color: var(--pv-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0;
  }

  .pdf-viewer-mobile-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    font-size: 18px;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
  }

  .pdf-viewer-mobile-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.95);
  }

  .pdf-viewer-shell.is-light .pdf-viewer-mobile-close-btn {
    color: rgba(0, 0, 0, 0.45);
  }

  .pdf-viewer-shell.is-light .pdf-viewer-mobile-close-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: rgba(0, 0, 0, 0.85);
  }

  .pdf-viewer-mobile-title {
    display: block;
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--pv-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0;
  }

  .pdf-viewer-search-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    order: 2;
    flex-basis: 100%;
    width: 100%;
    min-height: 40px;
    padding: 6px 14px 8px;
    background: var(--pv-bg);
    border-bottom: 1px solid var(--pv-border);
  }

  .pdf-viewer-search-btn {
    margin-left: auto;
    flex-shrink: 0;
  }

  .pdf-viewer-header.is-search-open .pdf-viewer-mobile-title-row {
    display: none;
  }

  .pdf-viewer-header.is-search-open .pdf-viewer-search-wrap {
    justify-content: stretch;
    padding: 8px 12px 10px;
  }

  .pdf-viewer-header.is-search-open .pdf-viewer-search-btn {
    display: none;
  }

  .pdf-viewer-header.is-search-open .pdf-viewer-search-bar {
    display: flex;
    flex: 1;
    max-width: none;
  }

  .pdf-viewer-header-actions {
    display: none;
  }

  /* Hide desktop sidebar – info is inline below pages */
  .pdf-viewer-sidebar,
  .pdf-viewer-sidebar-backdrop {
    display: none !important;
  }

  /* Canvas: full-width pages + bottom padding for fixed bars */
  .pdf-viewer-content-area {
    flex: 1;
    min-height: 0;
  }

  .pdf-viewer-canvas-wrap {
    padding-bottom: 0;
  }

  /* Hide desktop toolbar */
  .pdf-viewer-toolbar {
    display: none;
  }

  /* Mobile bottom bar – pinned in flex layout (not fixed) */
  .pdf-viewer-mobile-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: 100%;
    position: relative;
    z-index: 30;
    margin-top: auto;
    padding: 44px 0 0;
    pointer-events: auto;
    background: var(--pv-toolbar);
    border-top: 1px solid var(--pv-border);
  }

  .pdf-viewer-mobile-page-pill {
    display: inline-flex;
    align-items: center;
    position: absolute;
    top: -17px;
    left: 50%;
    transform: translateX(-50%);
    height: 34px;
    padding: 0 4px;
    background: rgba(28, 28, 28, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
    z-index: 2;
  }

  .pdf-viewer-shell.is-light .pdf-viewer-mobile-page-pill {
    background: rgba(235, 235, 235, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  }

  .pdf-viewer-mobile-page-pill .pdf-viewer-page-nav {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }

  .pdf-viewer-mobile-page-pill .pdf-viewer-page-label {
    font-size: 13px;
    padding: 0 4px;
    min-width: 64px;
    justify-content: center;
  }

  .pdf-viewer-mobile-page-pill .pdf-viewer-page-current {
    min-width: auto;
    height: auto;
    padding: 0;
    border: none;
    background: transparent;
    font-weight: 600;
  }

  .pdf-viewer-mobile-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 52px;
    padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--pv-toolbar);
    pointer-events: auto;
  }

  .pdf-viewer-mobile-download {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    min-width: 132px;
    height: 40px;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.14);
    color: #fff !important;
    text-decoration: none;
    visibility: visible;
    opacity: 1;
  }

  .pdf-viewer-mobile-download:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff !important;
  }

  .pdf-viewer-shell.is-light .pdf-viewer-mobile-download {
    border-color: rgba(0, 0, 0, 0.14);
    background: rgba(0, 0, 0, 0.08);
    color: rgba(0, 0, 0, 0.88) !important;
  }

  .pdf-viewer-mobile-download span {
    display: inline !important;
  }

  .pdf-viewer-mobile-download i {
    font-size: 16px;
  }

  .pdf-viewer-pages {
    gap: 8px;
    padding: 4px 0 12px;
    align-items: stretch;
  }

  .pdf-viewer-page {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.28);
  }

  .pdf-viewer-page canvas {
    display: block;
    max-width: 100%;
  }

  .pdf-viewer-thumbs-panel.is-open {
    width: min(200px, 72vw);
  }

  .pdf-viewer-mobile-title-row {
    display: flex;
  }

  .pdf-viewer-mobile-bar {
    display: flex;
  }
}
