.odf-wrap { margin: 1.5em 0; }
.odf-title { margin: 0 0 .6em; }
.odf-notice { padding: 12px 16px; background: #f3f4f6; border-radius: 8px; }

.odf-viewer {
	--odf-bg: #2b3a55;
	--odf-d: 900ms;
	position: relative;
	background: var(--odf-bg);
	border-radius: 10px;
	overflow: hidden;
	color: #fff;
	outline: none;
	-webkit-user-select: none;
	user-select: none;
	min-height: 220px;
}
.odf-viewer:focus-visible { box-shadow: 0 0 0 3px rgba(255, 255, 255, .6) inset; }
.odf-viewer.odf-isfs { display: flex; flex-direction: column; width: 100%; height: 100%; border-radius: 0; }
.odf-viewer.odf-pseudo { position: fixed; inset: 0; z-index: 999999; }
.odf-isfs .odf-stage { flex: 1 1 auto; }

.odf-stage { position: relative; overflow: hidden; touch-action: pan-y; cursor: pointer; }
.odf-stage.is-zoomed { touch-action: none; cursor: grab; }
.odf-pan { position: absolute; inset: 0; transform-origin: 50% 50%; transition: transform .25s ease; }
.odf-pan.is-dragging { transition: none; }
.odf-persp { position: absolute; inset: 0; perspective: 2600px; }
.odf-book { position: absolute; left: 50%; top: 50%; transform-style: preserve-3d; transition: transform var(--odf-d) ease; }

.odf-leaf {
	position: absolute; top: 0; height: 100%;
	transform-style: preserve-3d; transform-origin: left center;
	transition: transform var(--odf-d) cubic-bezier(.45, .05, .25, 1), opacity 1ms linear;
}
.odf-leaf.is-flipped { transform: rotateY(-180deg); }
.odf-single .odf-leaf.is-flipped {
	opacity: 0;
	transition: transform var(--odf-d) cubic-bezier(.45, .05, .25, 1), opacity 1ms linear calc(var(--odf-d) * .85);
}

.odf-face {
	position: absolute; inset: 0; overflow: hidden; background: #fff;
	backface-visibility: hidden; -webkit-backface-visibility: hidden;
	box-shadow: 0 6px 22px rgba(0, 0, 0, .35);
}
.odf-back { transform: rotateY(180deg); }
.odf-face canvas { display: block; width: 100%; height: 100%; object-fit: contain; }

.odf-shade { position: absolute; inset: 0; pointer-events: none; }
.odf-front .odf-shade { background: linear-gradient(to right, rgba(0, 0, 0, .28), rgba(0, 0, 0, 0) 8%, rgba(0, 0, 0, 0) 94%, rgba(0, 0, 0, .06)); }
.odf-back .odf-shade { background: linear-gradient(to left, rgba(0, 0, 0, .28), rgba(0, 0, 0, 0) 8%, rgba(0, 0, 0, 0) 94%, rgba(0, 0, 0, .06)); }
.odf-shade::after { content: ""; position: absolute; inset: 0; background: #000; opacity: 0; }
.odf-leaf.is-flipping .odf-shade::after { animation: odf-dim var(--odf-d) ease; }
@keyframes odf-dim { 0%, 100% { opacity: 0; } 50% { opacity: .35; } }

.odf-toolbar {
	display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
	gap: 4px; padding: 8px 10px; background: rgba(0, 0, 0, .3);
}
.odf-btn {
	appearance: none; border: 0; background: transparent; color: #fff;
	width: 38px; height: 38px; border-radius: 8px; padding: 0; cursor: pointer;
	display: inline-flex; align-items: center; justify-content: center;
}
.odf-btn:hover, .odf-btn:focus-visible { background: rgba(255, 255, 255, .2); outline: none; }
.odf-btn[disabled] { opacity: .35; cursor: default; background: transparent; }
.odf-btn svg { width: 22px; height: 22px; fill: currentColor; }
.odf-btn.is-on { background: rgba(255, 255, 255, .28); }
.odf-sep { width: 1px; height: 22px; margin: 0 6px; background: rgba(255, 255, 255, .28); }
.odf-pageinfo { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px; font-size: 14px; font-variant-numeric: tabular-nums; }
.odf-pageinput {
	width: 58px; height: 30px; padding: 0 4px; text-align: center; font: inherit;
	color: #fff; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .35); border-radius: 6px;
}
.odf-pageinput:focus { outline: 2px solid #fff; outline-offset: 1px; }
.odf-credit { margin-left: 8px; font-size: 12px; color: rgba(255, 255, 255, .75); text-decoration: none; }
.odf-credit:hover { color: #fff; text-decoration: underline; }

.odf-loading, .odf-error {
	position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column;
	align-items: center; justify-content: center; gap: 12px; padding: 20px;
	background: var(--odf-bg); text-align: center; font-size: 15px;
}
.odf-viewer:not(.odf-ready) { min-height: 320px; }
.odf-spinner { width: 34px; height: 34px; border: 3px solid rgba(255, 255, 255, .3); border-top-color: #fff; border-radius: 50%; animation: odf-spin .9s linear infinite; }
@keyframes odf-spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
	.odf-btn { width: 34px; height: 34px; }
	.odf-sep { display: none; }
}
@media (prefers-reduced-motion: reduce) {
	.odf-leaf, .odf-book, .odf-pan { transition-duration: 1ms !important; }
	.odf-leaf.is-flipping .odf-shade::after, .odf-spinner { animation: none; }
}

/* Hotspots */
.odf-hs {
	position: absolute; z-index: 3; padding: 0; cursor: pointer; color: #fff;
	width: var(--odf-hs, 34px); height: var(--odf-hs, 34px);
	margin: calc(var(--odf-hs, 34px) / -2) 0 0 calc(var(--odf-hs, 34px) / -2);
	border: 2px solid #fff; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .45); transition: transform .15s ease;
}
.odf-hs svg { width: 56%; height: 56%; fill: currentColor; pointer-events: none; }
.odf-hs:hover, .odf-hs:focus-visible { transform: scale(1.14); outline: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, .75), 0 2px 8px rgba(0, 0, 0, .45); }
.odf-hs-image { background: #0f766e; }
.odf-hs-audio { background: #b45309; }
.odf-hs-video { background: #be123c; }
.odf-hs-link { background: #4338ca; }

.odf-modal {
	position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
	padding: clamp(8px, 3vw, 32px); background: rgba(6, 10, 18, .86);
}
.odf-modal-card {
	display: flex; flex-direction: column; max-width: min(980px, 100%); max-height: 100%;
	min-width: min(340px, 100%); background: #0f1522; border-radius: 12px; overflow: hidden;
	box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
}
.odf-modal-head { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 4px 6px 4px 16px; }
.odf-modal-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.odf-modal-body { display: flex; align-items: center; justify-content: center; min-height: 0; }
.odf-modal-body img { display: block; max-width: 100%; max-height: calc(100vh - 130px); object-fit: contain; }
.odf-modal-body video { display: block; width: 100%; max-height: calc(100vh - 130px); background: #000; }
.odf-modal-body audio { width: min(520px, 84vw); margin: 18px 16px 24px; }
.odf-ratio { position: relative; width: min(900px, 92vw, calc((100vh - 130px) * 16 / 9)); aspect-ratio: 16 / 9; }
.odf-ratio iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Inline audio: progress ring while playing */
.odf-hs.is-audio-active { box-shadow: 0 0 0 3px rgba(255, 255, 255, .55), 0 2px 8px rgba(0, 0, 0, .45); }
.odf-hs.is-audio-active::before {
	content: ""; position: absolute; inset: -8px; border-radius: 50%; pointer-events: none;
	background: conic-gradient(#f59e0b calc(var(--odf-p, 0) * 360deg), rgba(15, 23, 42, .28) 0);
	-webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
	mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
}
.odf-hs.is-error { outline: 2px solid #ef4444; outline-offset: 2px; }

/* Floating window for image / video */
.odf-win {
	position: absolute; z-index: 8; display: flex; flex-direction: column; color: #fff;
	max-width: calc(100% - 16px); max-height: calc(100% - 16px);
	background: #0f1522; border-radius: 10px; overflow: hidden; box-shadow: 0 12px 40px rgba(0, 0, 0, .55);
}
.odf-win-bar { display: flex; align-items: center; gap: 2px; min-height: 42px; padding: 2px 4px 2px 12px; background: rgba(255, 255, 255, .08); cursor: move; touch-action: none; }
.odf-win-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.odf-win .odf-btn { width: 34px; height: 34px; }
.odf-win-body { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; background: #000; }
.odf-win-body img { display: block; width: 100%; height: auto; max-height: calc(100vh - 140px); object-fit: contain; }
.odf-win-body video { display: block; width: 100%; max-height: calc(100vh - 140px); background: #000; }
.odf-win .odf-ratio { width: 100%; max-height: none; }
.odf-win.is-dragging iframe, .odf-win.is-dragging video { pointer-events: none; }
.odf-win.is-sheet { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto !important; max-width: none; border-radius: 12px 12px 0 0; }
.odf-win.is-sheet .odf-win-bar { cursor: default; }
.odf-win.odf-win-max { position: fixed; inset: 0; z-index: 999999; }
.odf-win.is-max { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; max-width: none; max-height: none; border-radius: 0; }
.odf-win.is-max .odf-win-bar { cursor: default; }
.odf-win.is-max .odf-win-body img, .odf-win.is-max .odf-win-body video { height: 100%; max-height: none; object-fit: contain; }
.odf-win.is-max .odf-ratio { height: 100%; aspect-ratio: auto; }
