/* ═══════════════════════════════════════════════════════════════════════
   PDF HTML Viewer — Scribd-style (ported from PDFViewer.scss)
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Main viewer container ── */
.pdftopost-viewer {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto !important;
    margin: 0 auto;
    padding: 0;
    display: block;
    box-sizing: border-box;
    background: transparent !important;
    background-color: transparent !important;
    overflow: visible !important;
    /* Prevent iOS from auto-enlarging text — breaks pdf2htmlEX absolute positioning.
       Must be 'none' not '100%' — Chrome iOS ignores '100%' when CSS zoom is applied. */
    -webkit-text-size-adjust: none;
    -moz-text-size-adjust: none;
    text-size-adjust: none;
}

/* ── Fullscreen mode (each prefix in own block — browsers drop entire block if one selector invalid) ── */
.pdftopost-viewer:fullscreen {
    background: #f7f8f9 !important;
    background-color: #f7f8f9 !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    padding: 0 !important;
}
.pdftopost-viewer:-webkit-full-screen {
    background: #f7f8f9 !important;
    background-color: #f7f8f9 !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    padding: 0 !important;
}
.pdftopost-viewer:-moz-full-screen {
    background: #f7f8f9 !important;
    background-color: #f7f8f9 !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    padding: 0 !important;
}

/* Class-based fallback (JS adds this) */
.pdftopost-viewer.pdftopost-is-fullscreen {
    background: #f7f8f9 !important;
    background-color: #f7f8f9 !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    padding: 0 !important;
}

.pdftopost-viewer:fullscreen .pdftopost-toolbar-container {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
    background: #f7f8f9 !important;
}
.pdftopost-viewer:-webkit-full-screen .pdftopost-toolbar-container {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
    background: #f7f8f9 !important;
}
.pdftopost-viewer.pdftopost-is-fullscreen .pdftopost-toolbar-container {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
    background: #f7f8f9 !important;
}

/* ── Sticky horizontal scrollbar (PC/tablet, visible when zoomed) ── */
.pdftopost-hscroll-bar {
    display: none; /* hidden by default, JS shows when zoomed */
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-top: 1px solid #e0e0e0;
    height: 16px;
    cursor: grab;
}

.pdftopost-hscroll-bar:active {
    cursor: grabbing;
}

/* Inner element sets the scrollable width */
.pdftopost-hscroll-inner {
    height: 1px;
}

@media (max-width: 768px) {
    .pdftopost-hscroll-bar {
        display: none !important; /* mobile uses native touch scroll */
    }
}

/* ── Toolbar container (sticky) ── */
.pdftopost-toolbar-container {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 0;
    z-index: 1000;
    padding: 12px 0;
    background: #f7f8f9;
    width: 100%;
    box-sizing: border-box;
    /* When WP admin bar is showing */
}

.admin-bar .pdftopost-toolbar-container {
    top: 32px;
}

@media screen and (max-width: 782px) {
    .admin-bar .pdftopost-toolbar-container {
        top: 46px;
    }
}

/* ── Toolbar bar (white rounded, hardened) ── */
.pdftopost-viewer-toolbar {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 8px 12px !important;
    background: white !important;
    border-radius: 10px !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06) !important;
    gap: 8px !important;
    min-height: 50px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    border: none !important;
}

/* ── Toolbar sections ── */
.pdftopost-toolbar-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pdftopost-toolbar-left {
    flex-shrink: 0;
}

.pdftopost-toolbar-center {
    flex: 1;
    justify-content: center;
}

.pdftopost-toolbar-right {
    flex-shrink: 0;
}

/* ── Download button (green) ── */
.pdftopost-download-btn {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 16px !important;
    background: #3ddc97 !important;
    color: black !important;
    border: none !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    text-decoration: none !important;
    transition: all 0.2s !important;
    white-space: nowrap !important;
    box-shadow: none !important;
    line-height: normal !important;
    height: auto !important;
    margin: 0 !important;
}

.pdftopost-download-btn:hover {
    background: #35c885 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(61,220,151,0.3);
    color: black;
    text-decoration: none;
}

.pdftopost-download-btn svg {
    width: 16px;
    height: 16px;
    stroke: black;
}

/* ── Page input (scoped to override theme resets) ── */
.pdftopost-page-input-wrap {
    display: flex !important;
    align-items: center !important;
    background: white !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    padding: 4px 8px 4px 0 !important;
    max-width: 120px !important;
    margin: 0 !important;
}

.pdftopost-viewer-toolbar .pdftopost-page-input,
.pdftopost-page-input-wrap .pdftopost-page-input {
    width: 40px !important;
    min-width: 40px !important;
    max-width: 50px !important;
    padding: 4px !important;
    border: none !important;
    border-radius: 4px !important;
    text-align: center !important;
    font-size: 14px !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    height: auto !important;
    line-height: normal !important;
}

.pdftopost-page-input:focus {
    background: #f5f5f5 !important;
}

.pdftopost-page-total {
    color: #666 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
}

/* ── Download wrapper + dropdown ── */
.pdftopost-download-wrapper {
    position: relative;
}

.pdftopost-download-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 140px;
    z-index: 1001;
    overflow: hidden;
    padding: 6px;
    animation: pdftopost-fadeDown 0.15s ease-out;
}

/* Mobile dropdown opens upward */
.pdftopost-dropdown-up {
    top: auto;
    bottom: calc(100% + 8px);
    animation: pdftopost-fadeUp 0.15s ease-out;
}

@keyframes pdftopost-fadeDown {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pdftopost-fadeUp {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.pdftopost-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: #333;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
}

.pdftopost-dropdown-item:hover {
    background: #f5f5f5;
}

.pdftopost-dropdown-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #666;
}

/* ── Download gate modal ── */
.pdftopost-download-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pdftopost-modalFadeIn 0.2s ease-out;
}

@keyframes pdftopost-modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pdftopost-modal-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.pdftopost-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    animation: pdftopost-modalSlideUp 0.3s ease-out;
}

@keyframes pdftopost-modalSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.pdftopost-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s;
}

.pdftopost-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.pdftopost-modal-icon {
    margin-bottom: 16px;
}

.pdftopost-modal-content h3,
.pdftopost-modal-heading {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
}

.pdftopost-modal-content p {
    margin: 0 0 8px;
    font-size: 15px;
    color: #555;
    line-height: 1.5;
}

.pdftopost-modal-count {
    margin-bottom: 24px !important;
}

.pdftopost-modal-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: #3ddc97;
    color: black;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.pdftopost-modal-upload-btn:hover {
    background: #35c885;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(61,220,151,0.3);
    color: black;
    text-decoration: none;
}

.pdftopost-modal-upload-btn svg {
    width: 18px;
    height: 18px;
}

/* ── Auth modal (login/signup) ── */
.pdftopost-auth-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pdftopost-modalFadeIn 0.2s ease-out;
}

.pdftopost-auth-content {
    max-width: 380px;
    padding: 32px 28px;
}

.pdftopost-auth-tab {
    display: none;
}

.pdftopost-auth-tab.active {
    display: block;
}

.pdftopost-auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.pdftopost-auth-form input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s;
    outline: none;
}

.pdftopost-auth-form input:focus {
    border-color: #3ddc97;
    box-shadow: 0 0 0 3px rgba(61,220,151,0.12);
}

.pdftopost-auth-submit {
    width: 100%;
    padding: 12px;
    background: #3ddc97;
    color: black;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 4px;
}

.pdftopost-auth-submit:hover {
    background: #35c885;
}

.pdftopost-auth-submit:disabled {
    opacity: 0.6;
    cursor: wait;
}

.pdftopost-auth-error {
    padding: 10px 14px;
    background: #fef0f0;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    color: #c00;
    font-size: 13px;
}

.pdftopost-auth-switch {
    margin-top: 16px;
    font-size: 14px;
    color: #666;
    text-align: center;
}

.pdftopost-auth-switch a {
    color: #3ddc97;
    font-weight: 600;
    text-decoration: none;
}

.pdftopost-auth-switch a:hover {
    text-decoration: underline;
}

/* ── Google sign-in button ── */
.pdftopost-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: white;
    border: 1px solid #dadce0;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    color: #3c4043;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 16px;
    font-family: inherit;
}

.pdftopost-google-btn:hover {
    background: #f7f8f8;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.pdftopost-google-btn svg {
    flex-shrink: 0;
}

/* ── "or" divider ── */
.pdftopost-auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: #999;
    font-size: 13px;
}

.pdftopost-auth-divider::before,
.pdftopost-auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e0e0e0;
}

/* ── Icon buttons (hardened against theme resets) ── */
.pdftopost-icon-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    border: none !important;
    background: transparent !important;
    color: #666 !important;
    cursor: pointer !important;
    border-radius: 8px !important;
    transition: all 0.2s !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    line-height: 1 !important;
}

.pdftopost-icon-btn:hover {
    background: #f5f5f5 !important;
    color: #333 !important;
}

.pdftopost-icon-btn svg {
    width: 18px !important;
    height: 18px !important;
}

/* ── Desktop: bigger toolbar ── */
@media (min-width: 769px) {
    .pdftopost-viewer-toolbar {
        padding: 10px 12px;
        gap: 12px;
    }

    .pdftopost-download-btn {
        gap: 10px;
        padding: 10px 20px;
        font-size: 16px;
    }

    .pdftopost-download-btn svg {
        width: 18px;
        height: 18px;
    }

    .pdftopost-icon-btn {
        width: 44px;
        height: 44px;
    }

    .pdftopost-icon-btn svg {
        width: 20px;
        height: 20px;
    }

    .pdftopost-page-input {
        width: 45px;
        font-size: 16px;
        padding: 6px;
    }

    .pdftopost-page-total {
        font-size: 16px;
    }

    .pdftopost-page-input-wrap {
        border-radius: 8px;
        padding: 6px 10px 6px 0;
    }
}

/* ── Fix Elementor ancestor overflow that breaks sticky ── */
.elementor-widget-pdftopost_viewer,
.elementor-widget-pdftopost_viewer .elementor-widget-container,
.elementor-element:has(.pdftopost-viewer),
.elementor-section:has(.pdftopost-viewer),
.elementor-container:has(.pdftopost-viewer),
.elementor-column:has(.pdftopost-viewer),
.elementor-column-wrap:has(.pdftopost-viewer),
.elementor-widget-wrap:has(.pdftopost-viewer) {
    overflow: visible !important;
    transform: none !important;
    contain: none !important;
    isolation: auto !important;
}

/* On mobile, prevent Elementor ancestor overflow:visible from causing horizontal scroll */
@media (max-width: 768px) {
    .elementor-widget-pdftopost_viewer,
    .elementor-widget-pdftopost_viewer .elementor-widget-container,
    .elementor-element:has(.pdftopost-viewer),
    .elementor-section:has(.pdftopost-viewer),
    .elementor-container:has(.pdftopost-viewer),
    .elementor-column:has(.pdftopost-viewer),
    .elementor-column-wrap:has(.pdftopost-viewer),
    .elementor-widget-wrap:has(.pdftopost-viewer) {
        overflow-x: hidden !important;
    }
}

/* ── Scroll wrapper — clips horizontal overflow, JS syncs with sticky scrollbar ── */
.pdftopost-viewer-scroll {
    width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
}

/* ── Pages container (matches .pdf-pages-container) ── */
.pdftopost-pages-container {
    max-width: none !important;
    min-width: 0;
    height: auto;
    margin: 0 auto;
    padding-top: 8px;
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: transparent !important;
    gap: 20px;
    transform-origin: top center;
    /* Removed will-change: transform — causes excessive GPU memory on iOS Safari,
       leading to stuttering/lag during scroll. Each .pf uses contain instead. */
    box-sizing: border-box;
    text-align: center;
    overflow-y: visible;
    overflow-x: visible;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

/* ── Scaling: CSS variable --pz on .pdftopost-viewer drives transform:scale()
   on all .pf pages. Inline <script> sets --pz immediately — no visibility
   toggling, no JS per-page loop, pages render scaled on first paint. ── */

/* ── .pf — pdf2htmlEX page elements ── */
/* Keep original pdf2htmlEX dimensions (w0/h0 classes) — needed because
   .pc and .bi inside use position:absolute with width/height:100%.
   JS applies CSS zoom to fit container width (or transform:scale on iOS). */
.pdftopost-pages-container .pf {
    background: white !important;
    border: 1px solid rgba(0,0,0,0.08) !important;
    border-radius: 8px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    margin-top: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
    position: static !important;
    box-sizing: border-box !important;
    /* Isolate each page for rendering — prevents Safari from re-laying-out
       ALL pages on every scroll frame. Massive iOS Safari perf win. */
    contain: layout style paint !important;
    /* Tell browser off-screen pages can skip rendering entirely.
       auto = browser picks intrinsic size hint from w0/h0 classes. */
    content-visibility: auto;
    /* Prevent iOS from auto-enlarging small text — essential for pdf2htmlEX positioning.
       Must be 'none' (not '100%') — Chrome iOS ignores '100%' on zoomed elements. */
    -webkit-text-size-adjust: none !important;
    -moz-text-size-adjust: none !important;
    text-size-adjust: none !important;
}

/* Force ALL descendants inside pdf2htmlEX pages to disable text inflation.
   Chrome iOS WebKit applies inflation per-element — a selector on .pf alone
   is not inherited by deeply nested spans inside .t divs. The wildcard is essential. */
.pdftopost-pages-container .pf * {
    -webkit-text-size-adjust: none !important;
    text-size-adjust: none !important;
}

/* Explicit on text/content elements for specificity against pdf2htmlEX's own styles */
.pdftopost-pages-container .t,
.pdftopost-pages-container .c,
.pdftopost-pages-container .t span,
.pdftopost-pages-container .c span {
    -webkit-text-size-adjust: none !important;
    text-size-adjust: none !important;
}

/* Loaded page gets subtle shadow */
.pdftopost-pages-container .pdftopost-page-loaded {
    box-shadow: 0 1px 4px rgba(0,0,0,0.06) !important;
}

/* Placeholder pages (before content loads) */
.pdftopost-placeholder-page {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 14px;
}

.pdftopost-placeholder-page::after {
    content: '';
    width: 30px;
    height: 30px;
    border: 3px solid #e0e0e0;
    border-top-color: #999;
    border-radius: 50%;
    animation: pdftopost-spin 0.8s linear infinite;
}

/* ── Text layer — selectable text (matches .t rules from PDFViewer.scss) ── */
.pdftopost-pages-container .t {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

/* ── Text selection highlights (matches PDFViewer.scss) ── */
.pdftopost-pages-container .text-selection-highlight,
.pdftopost-pages-container mark.text-selection-highlight {
    background-color: rgba(255, 255, 0, 0.6) !important;
    background: rgba(255, 255, 0, 0.6) !important;
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
    padding: 2px 0 !important;
    border-radius: 2px !important;
    display: inline !important;
    position: relative !important;
    z-index: 3 !important;
    cursor: pointer;
}

.pdftopost-pages-container .t .text-selection-highlight,
.pdftopost-pages-container .t mark.text-selection-highlight {
    background-color: rgba(255, 255, 0, 0.6) !important;
    background: rgba(255, 255, 0, 0.6) !important;
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
    display: inline !important;
    position: relative !important;
    z-index: 3 !important;
}

/* ── iframe handling inside pages (YouTube etc.) ── */
.pdftopost-pages-container .pf iframe {
    max-width: 100%;
    aspect-ratio: 16/9;
}

/* ── Loading overlay ── */
.pdftopost-viewer-loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(247, 248, 249, 0.95);
    z-index: 20;
    gap: 12px;
    color: #666;
    font-size: 14px;
}

.pdftopost-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: pdftopost-spin 0.8s linear infinite;
}

@keyframes pdftopost-spin {
    to { transform: rotate(360deg); }
}

/* ── Error state ── */
.pdftopost-viewer-error {
    padding: 20px;
    text-align: center;
    color: #c00;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* ── Elementor editor placeholder ── */
.pdftopost-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: #f9f9f9;
    color: #999;
    font-size: 14px;
    padding: 20px;
    text-align: center;
}

/* ── Responsive (matches PDFViewer.scss media queries) ── */
@media (max-width: 768px) {
    .pdftopost-viewer-toolbar {
        padding: 6px 10px;
        gap: 4px;
    }

    .pdftopost-pages-container {
        gap: 10px;
        width: 100vw !important;
        max-width: 100% !important;
        overflow-x: hidden;
    }

    .pdftopost-pages-container .pf {
        border: 1px solid rgba(0,0,0,0.12) !important;
        border-radius: 8px !important;
        box-shadow: none !important;
        margin-left: calc(-0.5px * var(--pdftopost-page-width) * (1 - var(--pz))) !important;
        margin-right: calc(-0.5px * var(--pdftopost-page-width) * (1 - var(--pz))) !important;
    }

    .pdftopost-pages-container .pdftopost-page-loaded {
        box-shadow: none !important;
    }
}

@media (max-width: 480px) {
    .pdftopost-pages-container {
        gap: 8px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Mobile Bottom Toolbar (matches MobileToolbar.scss)
   ═══════════════════════════════════════════════════════════════ */

/* Hidden on desktop */
.pdftopost-mobile-toolbar {
    display: none;
}

/* Desktop toolbar hidden on mobile */
@media (max-width: 768px) {
    .pdftopost-toolbar-container {
        display: none !important;
    }

    .pdftopost-mobile-toolbar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        display: flex !important;
        flex-direction: column;
        background: white !important;
        border-top: 1px solid #e0e0e0;
        box-shadow: 0 -1px 3px rgba(0,0,0,0.05);
        z-index: 99999 !important;
        padding: 8px 16px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        box-sizing: border-box;
        width: 100% !important;
        min-height: 68px;
        gap: 8px;
        animation: pdftopost-slideUp 0.6s ease-out;
    }

    /* Add bottom padding to pages so content isn't hidden behind toolbar */
    .pdftopost-pages-container {
        padding-bottom: calc(140px + env(safe-area-inset-bottom)) !important;
    }
}

@keyframes pdftopost-slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Top row: horizontally scrollable text buttons */
.pdftopost-mobile-top-row {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    padding-bottom: 4px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.pdftopost-mobile-top-row::-webkit-scrollbar {
    display: none;
}

/* Text buttons (hardened) */
.pdftopost-mobile-text-btn {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 8px 12px !important;
    background: white !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    color: #333 !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    line-height: normal !important;
    height: auto !important;
    min-width: auto !important;
    box-shadow: none !important;
    margin: 0 !important;
}

.pdftopost-mobile-text-btn svg {
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0 !important;
}

.pdftopost-mobile-text-btn:active {
    background: #f5f5f5 !important;
    transform: scale(0.98) !important;
}

/* Bottom row */
.pdftopost-mobile-bottom-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    width: 100% !important;
}

.pdftopost-mobile-left {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

/* Page navigation */
.pdftopost-mobile-page-wrap {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

/* Mobile page input (hardened) */
.pdftopost-mobile-page-input-wrap {
    display: flex !important;
    align-items: center !important;
    background: white !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    padding: 4px 8px 4px 0 !important;
    max-width: 100px !important;
    margin: 0 !important;
}

.pdftopost-mobile-toolbar .pdftopost-mobile-page-input,
.pdftopost-mobile-page-input-wrap .pdftopost-mobile-page-input {
    width: 36px !important;
    min-width: 36px !important;
    max-width: 44px !important;
    padding: 6px 4px !important;
    border: none !important;
    border-radius: 4px !important;
    text-align: center !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    background: transparent !important;
    outline: none !important;
    color: #333 !important;
    box-shadow: none !important;
    margin: 0 !important;
    height: auto !important;
    line-height: normal !important;
}

.pdftopost-mobile-page-input:focus {
    background: #f5f5f5 !important;
}

.pdftopost-mobile-page-total {
    color: #666 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
}

/* Mobile icon buttons (hardened) */
.pdftopost-mobile-icon-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #f8fbff !important;
    border: none !important;
    border-radius: 8px !important;
    color: #333 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    line-height: 1 !important;
}

.pdftopost-mobile-icon-btn svg {
    width: 18px !important;
    height: 18px !important;
}

.pdftopost-mobile-icon-btn:active {
    background: #f0f7ff !important;
    transform: scale(0.95) !important;
}

/* Mobile download button (hardened) */
.pdftopost-mobile-download-btn {
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 6px 16px !important;
    background: #3ddc97 !important;
    border: none !important;
    border-radius: 8px !important;
    color: black !important;
    font-weight: 600 !important;
    font-size: 15px !important;
    cursor: pointer !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 4px rgba(61,220,151,0.3) !important;
    white-space: nowrap !important;
    margin: 0 !important;
    line-height: normal !important;
}

.pdftopost-mobile-download-btn svg {
    width: 16px !important;
    height: 16px !important;
    stroke: black !important;
}

.pdftopost-mobile-download-btn:hover {
    color: black !important;
    text-decoration: none !important;
}

.pdftopost-mobile-download-btn:active {
    transform: scale(0.98) !important;
}

/* ── Post title above viewer ── */
.pdftopost-viewer-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 16px;
    padding: 0;
    line-height: 1.3;
}

@media (max-width: 768px) {
    .pdftopost-viewer-title {
        font-size: 18px;
        margin-bottom: 12px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   External Link Confirmation Modal
   ═══════════════════════════════════════════════════════════════ */

.pdftopost-extlink-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pdftopost-modalFadeIn 0.2s ease-out;
}

.pdftopost-extlink-url {
    word-break: break-all;
    font-family: monospace;
    font-size: 13px;
    color: #1d4ed8;
    background: #f0f4ff;
    padding: 10px 14px;
    border-radius: 8px;
    margin: 12px 0 4px;
    line-height: 1.5;
    max-height: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdftopost-extlink-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.pdftopost-extlink-cancel {
    flex: 1;
    padding: 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
}

.pdftopost-extlink-cancel:hover {
    background: #f5f5f5;
}

.pdftopost-extlink-continue {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: #3ddc97;
    color: black;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.pdftopost-extlink-continue:hover {
    background: #35c885;
    color: black;
    text-decoration: none;
}
