/* UP PDF Viewer — everything scoped under .upv so the Salient theme can't leak in. */
.upv {
	--upv-navy: #1f2553;
	--upv-accent: #38bdf8;
	--upv-bg: #e9eef3;
	position: relative;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	width: 100%;
	height: calc(100vh - 160px);
	height: calc(100dvh - 160px);
	min-height: 420px;
	margin: 0 auto;
	background: var(--upv-bg);
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 6px 28px rgba(31, 37, 83, .14);
	outline: none;
	/* Deterrents: no selection, no long-press "save image", no drag. */
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
	-webkit-tap-highlight-color: transparent;
}
.upv *, .upv *::before, .upv *::after { box-sizing: border-box; }

/* Toolbar */
.upv .upv-bar {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
	flex-wrap: wrap;
	padding: 8px 12px;
	background: var(--upv-navy);
	color: #fff;
}
.upv:not(.upv-ready) .upv-bar { opacity: .45; pointer-events: none; }
.upv .upv-group { display: flex; align-items: center; gap: 6px; }
.upv .upv-btn {
	all: unset;
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 38px;
	height: 38px;
	padding: 0 10px;
	border-radius: 8px;
	background: rgba(255, 255, 255, .1);
	color: #fff;
	font: 600 22px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
	cursor: pointer;
	transition: background .15s;
}
.upv .upv-btn:hover { background: rgba(255, 255, 255, .22); }
.upv .upv-btn:focus-visible, .upv .upv-retry:focus-visible, .upv .upv-page:focus-visible { outline: 2px solid var(--upv-accent); outline-offset: 2px; }
.upv .upv-btn[disabled] { opacity: .35; cursor: default; }
.upv .upv-pager { display: inline-flex; align-items: center; gap: 6px; font: 500 15px/1 system-ui, sans-serif; color: #fff; }
.upv .upv-page {
	-webkit-user-select: text; user-select: text; /* the only selectable thing: lets people type a page number */
	width: 3.2em; height: 34px; padding: 0 4px; text-align: center;
	border: 0; border-radius: 6px; background: #fff; color: var(--upv-navy);
	font: 600 15px/1 system-ui, sans-serif;
}
.upv .upv-zoom { cursor: pointer; min-width: 3.6em; text-align: center; font: 500 15px/1 system-ui, sans-serif; color: #fff; }
.upv .upv-fit { font-size: 20px; }

/* Pages */
.upv .upv-main { position: relative; flex: 1 1 auto; min-height: 0; }
.upv .upv-scroll {
	position: absolute;
	inset: 0;
	overflow: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
}
.upv .upv-pages {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	width: max-content;
	min-width: 100%;
	padding: 16px 0 28px;
}
.upv .upv-pagebox {
	position: relative;
	flex: 0 0 auto;
	background: #fff;
	box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}
.upv .upv-pagebox canvas {
	display: block;
	width: 100%;
	height: 100%;
	pointer-events: none; /* long-press / right-click never reach the image */
}

/* Loading / error overlay */
.upv .upv-overlay {
	position: absolute;
	inset: 0;
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 24px;
	background: rgba(233, 238, 243, .96);
	text-align: center;
	color: var(--upv-navy);
	z-index: 5;
}
.upv.upv-busy .upv-overlay, .upv.upv-error .upv-overlay, .upv .upv-overlay.upv-show { display: flex; }
.upv .upv-msg { font: 500 17px/1.4 system-ui, sans-serif; max-width: 32em; }
.upv.upv-busy .upv-msg::before {
	content: "";
	display: block;
	width: 34px; height: 34px; margin: 0 auto 14px;
	border: 3px solid rgba(31, 37, 83, .18);
	border-top-color: var(--upv-accent);
	border-radius: 50%;
	animation: upv-spin .8s linear infinite;
}
.upv .upv-progress { display: none; width: min(260px, 70%); height: 5px; border-radius: 3px; background: rgba(31, 37, 83, .15); overflow: hidden; }
.upv.upv-busy .upv-progress { display: block; }
.upv .upv-progress i { display: block; height: 100%; width: 0; background: var(--upv-accent); transition: width .2s; }
.upv .upv-retry {
	all: unset; box-sizing: border-box; cursor: pointer;
	padding: 10px 22px; border-radius: 8px;
	background: var(--upv-navy); color: #fff;
	font: 600 15px/1 system-ui, sans-serif;
}
.upv .upv-retry[hidden] { display: none; }
@keyframes upv-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .upv.upv-busy .upv-msg::before { animation-duration: 3s; } }

/* Printing the page prints nothing of the document. */
.upv .upv-print-note { display: none; }
@media print {
	.upv .upv-bar, .upv .upv-scroll, .upv .upv-overlay { display: none !important; }
	.upv { height: auto; box-shadow: none; background: none; }
	.upv .upv-print-note { display: block; padding: 24px; font: 16px/1.4 system-ui, sans-serif; }
}

/* Tablet / phone */
@media (max-width: 782px) {
	.upv { height: calc(100vh - 110px); height: calc(100dvh - 110px); border-radius: 0; }
	.upv .upv-bar { justify-content: center; padding: 6px 8px; }
	.upv .upv-btn { min-width: 40px; height: 40px; }
	.upv .upv-pages { padding: 10px 0 20px; gap: 10px; }
}
@media (max-width: 420px) { .upv .upv-fit { display: none; } }
