        /* === SacredWP PDF Viewer === */
        .sacredpdf-wrapper {
            --cpdf-bg: #1a1a2e;
            --cpdf-toolbar: #16213e;
            --cpdf-accent: #0f3460;
            --cpdf-highlight: #e94560;
            --cpdf-text: #eee;
            --cpdf-text-dim: #8892a4;
            --cpdf-radius: 12px;
            --cpdf-shadow: 0 8px 32px rgba(0,0,0,0.35);
            position: relative;
            border-radius: var(--cpdf-radius);
            overflow: hidden;
            box-shadow: var(--cpdf-shadow);
            margin: 1.5em 0;
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            background: var(--cpdf-bg);
            transition: all 0.3s ease;
        }
        .sacredpdf-wrapper.sacredpdf-fullscreen {
            position: fixed !important;
            top: 0; left: 0; right: 0; bottom: 0;
            z-index: 999999;
            border-radius: 0;
            margin: 0;
            width: 100vw !important;
            height: 100vh !important;
        }

        /* Toolbar */
        .sacredpdf-toolbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 8px 16px;
            background: var(--cpdf-toolbar);
            border-bottom: 1px solid rgba(255,255,255,0.06);
            gap: 8px;
            flex-wrap: wrap;
            min-height: 48px;
        }
        .sacredpdf-toolbar-left,
        .sacredpdf-toolbar-center,
        .sacredpdf-toolbar-right {
            display: flex;
            align-items: center;
            gap: 6px;
            position: relative; /* anchor for the download chooser */
        }
        /* Download chooser (with / without highlights) */
        .sacredpdf-dlmenu {
            position: absolute;
            top: calc(100% + 6px);
            right: 0;
            z-index: 40;
            min-width: 210px;
            background: #fff;
            border: 1px solid #d0d5dd;
            border-radius: 8px;
            box-shadow: 0 8px 24px rgba(16,24,40,0.18);
            overflow: hidden;
        }
        .sacredpdf-dlmenu button {
            display: block;
            width: 100%;
            text-align: left;
            padding: 10px 14px;
            background: none;
            border: none;
            border-radius: 0;
            cursor: pointer;
            font-size: 13px;
            line-height: 1.3;
            color: #1d2939;
            white-space: nowrap;
        }
        .sacredpdf-dlmenu button + button { border-top: 1px solid #eaecf0; }
        .sacredpdf-dlmenu button:hover { background: #f2f4f7; color: #1d2939; }
        .sacredpdf-dlmenu button:disabled { opacity: .6; cursor: default; background: none; }
        .sacredpdf-icon-pdf { opacity: 0.7; flex-shrink: 0; }
        .sacredpdf-title {
            color: var(--cpdf-text-dim);
            font-size: 13px;
            font-weight: 500;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 180px;
        }

        /* Buttons */
        .sacredpdf-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 34px; height: 34px;
            border: none;
            border-radius: 8px;
            background: transparent;
            color: var(--cpdf-text);
            cursor: pointer;
            transition: all 0.2s ease;
            padding: 0;
        }
        /* Download button starts hidden when downloads are role-restricted; the
           per-user AJAX check reveals it only for allowed visitors. */
        .sacredpdf-dl-pending { display: none !important; }
        .sacredpdf-btn:hover {
            background: rgba(255,255,255,0.1);
            transform: scale(1.08);
        }
        .sacredpdf-btn:active { transform: scale(0.95); }
        .sacredpdf-btn[disabled] {
            opacity: 0.3;
            pointer-events: none;
        }
        .sacredpdf-btn-fullscreen:hover {
            background: var(--cpdf-highlight);
        }

        /* Page Info */
        .sacredpdf-page-info {
            display: flex;
            align-items: center;
            gap: 4px;
            color: var(--cpdf-text);
            font-size: 13px;
            font-weight: 600;
            min-width: 50px;
            justify-content: center;
            padding: 4px 10px;
            background: rgba(255,255,255,0.06);
            border-radius: 6px;
        }
        .sacredpdf-page-sep { color: var(--cpdf-text-dim); }
        .sacredpdf-zoom-level {
            color: var(--cpdf-text-dim);
            font-size: 12px;
            font-weight: 500;
            min-width: 40px;
            text-align: center;
        }
        .sacredpdf-divider {
            width: 1px; height: 20px;
            background: rgba(255,255,255,0.1);
            margin: 0 4px;
        }

        /* Canvas Container */
        .sacredpdf-canvas-container {
            position: relative;
            overflow: auto;
            display: flex;
            justify-content: center;
            align-items: flex-start;
            background: var(--cpdf-bg);
            height: 650px;
            scrollbar-width: thin;
            scrollbar-color: rgba(255,255,255,0.15) transparent;
        }
        .sacredpdf-fullscreen .sacredpdf-canvas-container {
            height: calc(100vh - 48px);
        }
        .sacredpdf-canvas-container::-webkit-scrollbar { width: 8px; height: 8px; }
        .sacredpdf-canvas-container::-webkit-scrollbar-track { background: transparent; }
        .sacredpdf-canvas-container::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.15);
            border-radius: 4px;
        }

        .sacredpdf-canvas {
            display: block;
            margin: 20px auto;
            box-shadow: 0 4px 24px rgba(0,0,0,0.5);
            border-radius: 4px;
            transition: opacity 0.2s ease;
        }

        /* Loading */
        .sacredpdf-loading {
            position: absolute;
            top: 50%; left: 50%;
            transform: translate(-50%, -50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 16px;
            color: var(--cpdf-text-dim);
            font-size: 14px;
            z-index: 2;
        }
        .sacredpdf-loading.sacredpdf-hidden { display: none; }
        .sacredpdf-spinner {
            width: 36px; height: 36px;
            border: 3px solid rgba(255,255,255,0.08);
            border-top-color: var(--cpdf-highlight);
            border-radius: 50%;
            animation: sacredpdf-spin 0.8s linear infinite;
        }
        @keyframes sacredpdf-spin { to { transform: rotate(360deg); } }

        /* Thumbnail bar in fullscreen */
        .sacredpdf-thumbnail-bar {
            display: none;
        }

        /* Responsive */
        @media (max-width: 600px) {
            .sacredpdf-toolbar { padding: 6px 10px; }
            .sacredpdf-toolbar-left { display: none; }
            .sacredpdf-canvas-container { height: 450px; }
            .sacredpdf-continuous .sacredpdf-pages-scroll { height: 520px; }
            .sacredpdf-btn { width: 30px; height: 30px; }
        }

        /* ===== Continuous-scroll + selectable text layer (highlighting mode) ===== */
        .sacredpdf-continuous .sacredpdf-pages-scroll {
            position: relative; overflow: auto; background: var(--cpdf-bg);
            height: 720px; scrollbar-width: thin;
            scrollbar-color: rgba(255,255,255,0.15) transparent;
        }
        .sacredpdf-continuous.sacredpdf-fullscreen .sacredpdf-pages-scroll { height: 100%; }
        .sacredpdf-pages {
            display: flex; flex-direction: column; align-items: center;
            gap: 16px; padding: 18px 10px;
        }
        .sacredpdf-page {
            position: relative; background: #fff; flex: 0 0 auto;
            box-shadow: 0 3px 14px rgba(0,0,0,0.4);
        }
        .sacredpdf-page-canvas { display: block; }
        /* pdf.js text layer */
        .sacredpdf-page .textLayer {
            position: absolute; inset: 0; overflow: clip; opacity: 1; line-height: 1;
            text-align: initial; text-size-adjust: none; forced-color-adjust: none;
            transform-origin: 0 0; z-index: 2; caret-color: transparent;
            user-select: none; -webkit-user-select: none;
        }
        .sacredpdf-page .textLayer span,
        .sacredpdf-page .textLayer br {
            color: transparent; position: absolute; white-space: pre; cursor: text;
            transform-origin: 0% 0%;
        }
        .sacredpdf-page .textLayer ::selection { background: rgba(43,124,255,0.35); }
        .sacredpdf-page .textLayer br::selection { background: transparent; }
        /* selection enabled only for permitted roles (unlocked via AJAX) */
        .sacredpdf-continuous.sacredpdf-hl-on .textLayer { user-select: text; -webkit-user-select: text; cursor: text; }
        /* Highlite Pro's highlight wrappers live inside the transparent text layer (which
           sits above the canvas). The highlight's background is made translucent in JS
           (opaque rgb -> rgba) so the PDF text on the canvas underneath reads through it,
           like a real marker — WITHOUT element opacity, which would also fade the child
           note/colour/delete icons. */
        .sacredpdf-page .textLayer .user-highlight { color: transparent !important; border-radius: 2px; }
        /* Highlite Pro's floating UI (highlight button, colour picker, note modal) is
           appended to <body>; raise it above the fullscreen viewer (z-index 999999) so it
           stays visible when the PDF is in fullscreen. */
        #highlight-action-btn, #hl-color-picker { z-index: 1000001 !important; }
        body .swal2-container { z-index: 1000001 !important; }
        .sacredpdf-continuous .sacredpdf-page-info { min-width: 60px; }

.sacredpdf-error {
    color: #e74c3c;
}
