.sn-pdf {
    --pdf-radius: 6px;
    --pdf-bg: #f5f6fa;
    --pdf-nav-bg: #ffffff;
    --pdf-line: #e5e9f2;
    --pdf-text: #364a63;
    --pdf-muted: #6e7f99;
    --pdf-surface: #f5f6fa;
    --pdf-surface-strong: #ebeef4;
    --pdf-sheet: #ffffff;
    --pdf-sheet-shadow: rgba(0, 0, 0, 0.16) 0 1px 4px;
    --pdf-bone: #edf0f5;
    --pdf-bone-shine: #f7f8fb;
    --pdf-scrollbar: #cdd3e0;
    --pdf-scrollbar-hover: #b7c2d0;
    --pdf-danger: #e85347;
    --pdf-nav-height: 63px;
    --pdf-primary: #0969da;
    --pdf-primary-soft: rgba(9, 105, 218, 0.12);
    --pdf-close: #cf222e;
    --pdf-close-soft: rgba(207, 34, 46, 0.08);
    --pdf-btn-bg: #ffffff;
    --pdf-btn-border: #d0d7de;
    --pdf-btn-hover: #f3f6f9;
    --pdf-btn-shadow: 0 1px 2px rgba(31, 35, 40, 0.05), 0 6px 16px -8px rgba(31, 35, 40, 0.12);
    --pdf-cap: 6px;
    --pdf-glass: rgba(255, 255, 255, 0.72);
    --pdf-glass-line: rgba(208, 215, 222, 0.7);
    display: flex;
    flex-direction: column;
    background: var(--pdf-bg);
    font-family: font, system-ui, sans-serif;
}

[data-theme='dark'] .sn-pdf,
body.dark-mode .sn-pdf {
    --pdf-bg: #0d141d;
    --pdf-nav-bg: #141c26;
    --pdf-line: #3d444d;
    --pdf-text: #e9eefb;
    --pdf-muted: #8f9fbb;
    --pdf-surface: rgba(255, 255, 255, 0.05);
    --pdf-surface-strong: rgba(255, 255, 255, 0.09);
    --pdf-sheet: #1a2330;
    --pdf-sheet-shadow: rgba(0, 0, 0, 0.19) 0 10px 20px, rgba(0, 0, 0, 0.23) 0 6px 6px;
    --pdf-bone: #232d3b;
    --pdf-bone-shine: #2c3848;
    --pdf-scrollbar: rgba(139, 148, 158, 0.4);
    --pdf-scrollbar-hover: #3c4d62;
    --pdf-primary: #58a6ff;
    --pdf-primary-soft: rgba(88, 166, 255, 0.14);
    --pdf-close: #ff7b72;
    --pdf-close-soft: rgba(255, 123, 114, 0.1);
    --pdf-btn-bg: #141c26;
    --pdf-btn-border: #2c3642;
    --pdf-btn-hover: #1b2532;
    --pdf-btn-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    --pdf-glass: rgba(20, 28, 38, 0.7);
    --pdf-glass-line: rgba(61, 68, 77, 0.7);
}

.sn-pdf__toolbar {
    flex: none;
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--pdf-nav-height);
    padding: 0 18px;
    background: var(--pdf-nav-bg);
    border-bottom: 1px solid var(--pdf-line);
}

.sn-pdf__heading {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sn-pdf__icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--pdf-radius);
    background: var(--pdf-primary-soft);
    color: var(--pdf-primary);
    font-size: 17px;
}

.sn-pdf__titles {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sn-pdf__title {
    overflow: hidden;
    color: var(--pdf-text);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: start;
    unicode-bidi: plaintext;
}

.sn-pdf__meta {
    color: var(--pdf-muted);
    font-size: 12.5px;
    line-height: 1.3;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.sn-pdf__meta:empty {
    width: 64px;
    height: 12px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--pdf-bone) 25%, var(--pdf-bone-shine) 37%, var(--pdf-bone) 63%) 0 0 / 400% 100%;
    animation: sn-pdf-shimmer 1.4s ease infinite;
}

.sn-pdf__actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sn-pdf__divider {
    flex-shrink: 0;
    width: 1px;
    height: 24px;
    margin-inline: 4px;
    background: var(--pdf-line);
}

.sn-pdf__btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--pdf-btn-border);
    border-radius: var(--pdf-radius);
    background: var(--pdf-btn-bg);
    box-shadow: var(--pdf-btn-shadow);
    color: var(--pdf-primary);
    font-size: 16px;
    cursor: pointer;
    outline: none;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        transform 0.1s ease;
}

.sn-pdf__btn[hidden] {
    display: none;
}

.sn-pdf__btn:hover,
.sn-pdf__btn:focus-visible {
    background: var(--pdf-btn-hover);
}

.sn-pdf__btn:focus-visible {
    border-color: var(--pdf-primary);
}

.sn-pdf__btn:active {
    transform: scale(0.95);
}

.sn-pdf__btn .icon {
    pointer-events: none;
}

.sn-pdf__svg {
    width: 1em;
    height: 1em;
    stroke-width: 1.6;
}

.sn-pdf__btn--close {
    color: var(--pdf-close);
}

.sn-pdf__btn--close:hover,
.sn-pdf__btn--close:focus-visible {
    border-color: var(--pdf-close);
    background: var(--pdf-close-soft);
}

.sn-pdf__pages {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 16px;
    border-top: var(--pdf-cap) solid var(--pdf-bg);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--pdf-scrollbar) transparent;
}

.sn-pdf__pages::-webkit-scrollbar {
    width: 6px;
}

.sn-pdf__pages::-webkit-scrollbar-thumb {
    background: var(--pdf-scrollbar);
    border-radius: 999px;
}

.sn-pdf__pages::-webkit-scrollbar-thumb:hover {
    background: var(--pdf-scrollbar-hover);
}

.sn-pdf__skeleton {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.sn-pdf__sheet {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: min(calc(100% - 24px), 880px);
    aspect-ratio: 210 / 297;
    padding: 3% 6% 6%;
    flex-shrink: 0;
    background: var(--pdf-sheet);
    border-radius: var(--pdf-radius);
    box-shadow: var(--pdf-sheet-shadow);
}

.sn-pdf__bone,
.sn-pdf.is-loading .sn-pdf__actions .sn-pdf__btn {
    background: linear-gradient(90deg, var(--pdf-bone) 25%, var(--pdf-bone-shine) 37%, var(--pdf-bone) 63%) 0 0 / 400% 100%;
    animation: sn-pdf-shimmer 1.4s ease infinite;
}

.sn-pdf.is-loading .sn-pdf__actions .sn-pdf__btn {
    display: inline-flex;
    border-color: transparent;
    box-shadow: none;
    pointer-events: none;
}

.sn-pdf.is-loading .sn-pdf__actions .sn-pdf__btn .icon {
    visibility: hidden;
}

.sn-pdf__bone {
    display: block;
    border-radius: var(--pdf-radius);
}

.sn-pdf__bone.is-title {
    width: 180px;
    max-width: 100%;
    height: 16px;
    border-radius: 2px;
}

.sn-pdf__bone.is-head {
    width: 45%;
    height: 9%;
}

.sn-pdf__bone.is-meta {
    width: 100%;
    height: 7%;
}

.sn-pdf__bone.is-table {
    width: 100%;
    height: 32%;
}

.sn-pdf__bone.is-line {
    width: 80%;
    height: 2.5%;
}

.sn-pdf__bone.is-short {
    width: 50%;
}

.sn-pdf__bone.is-total {
    width: 35%;
    height: 8%;
    margin-inline-start: auto;
}

@keyframes sn-pdf-shimmer {
    from {
        background-position: 100% 0;
    }

    to {
        background-position: 0 0;
    }
}

@keyframes sn-pdf-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sn-pdf__bone,
    .sn-pdf__meta:empty,
    .sn-pdf.is-loading .sn-pdf__actions .sn-pdf__btn {
        animation: none;
    }
}

@media (max-width: 767px) {
    .sn-pdf {
        --pdf-nav-height: 56px;
        position: relative;
    }

    .sn-pdf__toolbar {
        position: static;
        gap: 10px;
        padding: 0 12px;
    }

    .sn-pdf__heading {
        gap: 10px;
    }

    .sn-pdf__icon {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }

    .sn-pdf__title {
        font-size: 15px;
    }

    .sn-pdf__meta {
        font-size: 12px;
    }

    .sn-pdf__divider {
        display: none;
    }

    .sn-pdf__btn--close {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }

    .sn-pdf__actions {
        position: absolute;
        inset-inline: 0;
        bottom: calc(16px + env(safe-area-inset-bottom));
        z-index: 4;
        gap: 4px;
        width: max-content;
        margin-inline: auto;
        padding: 6px;
        border: 1px solid var(--pdf-glass-line);
        border-radius: 999px;
        background: var(--pdf-glass);
        -webkit-backdrop-filter: blur(16px) saturate(160%);
        backdrop-filter: blur(16px) saturate(160%);
        box-shadow:
            0 12px 32px -12px rgba(16, 24, 40, 0.35),
            0 2px 6px rgba(16, 24, 40, 0.08);
    }

    .sn-pdf__actions .sn-pdf__btn {
        width: 46px;
        height: 46px;
        border: 0;
        border-radius: 999px;
        background: transparent;
        box-shadow: none;
        font-size: 18px;
    }

    .sn-pdf__actions .sn-pdf__btn:hover,
    .sn-pdf__actions .sn-pdf__btn:active {
        background: var(--pdf-primary-soft);
    }

    .sn-pdf__pages {
        padding-bottom: calc(96px + env(safe-area-inset-bottom));
    }

    .sn-pdf__sheet {
        width: max(100%, 280px);
    }
}
