.os5-pdf-block,
.os5-pdf-shortcode {
    width: 100%;
}

.os5-pdf {
    --os5-border: #d7dce2;
    --os5-canvas-shadow: 0 2px 10px rgb(15 23 42 / 12%);
    --os5-control-bg: #fff;
    --os5-control-hover: #f2f4f7;
    --os5-focus: #2271b1;
    --os5-ink: #1d2327;
    --os5-muted: #646970;
    --os5-surface: #eef1f4;
    box-sizing: border-box;
    width: min(100%, var(--os5-max-width, 960px));
    max-width: 100%;
    margin: 0 auto;
    color: var(--os5-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

.os5-pdf *,
.os5-pdf *::before,
.os5-pdf *::after {
    box-sizing: border-box;
}

.os5-pdf__toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 7px 8px;
    border: 1px solid var(--os5-border);
    border-bottom: 0;
    border-radius: 6px 6px 0 0;
    background: var(--os5-control-bg);
}

.os5-pdf__group {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 4px;
}

.os5-pdf__group--actions {
    margin-left: auto;
}

.os5-pdf__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 34px;
    margin: 0;
    padding: 5px 9px;
    border: 1px solid var(--os5-border);
    border-radius: 4px;
    background: var(--os5-control-bg);
    color: var(--os5-ink);
    font: inherit;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    appearance: none;
}

.os5-pdf__button:hover:not(:disabled) {
    border-color: #aeb5be;
    background: var(--os5-control-hover);
    color: var(--os5-ink);
}

.os5-pdf__button:focus-visible,
.os5-pdf__page-input:focus-visible,
.os5-pdf__viewport:focus-visible {
    outline: 2px solid var(--os5-focus);
    outline-offset: 2px;
}

.os5-pdf__button:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.os5-pdf__button--fit,
.os5-pdf__button--text {
    min-width: auto;
}

.os5-pdf__page-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 0;
    color: var(--os5-muted);
    white-space: nowrap;
}

.os5-pdf__page-input {
    width: 52px;
    height: 34px;
    margin: 0;
    padding: 4px 5px;
    border: 1px solid var(--os5-border);
    border-radius: 4px;
    background: #fff;
    color: var(--os5-ink);
    font: inherit;
    text-align: center;
    appearance: textfield;
}

.os5-pdf__page-input::-webkit-inner-spin-button,
.os5-pdf__page-input::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
}

.os5-pdf__status {
    min-width: 0;
    overflow: hidden;
    color: var(--os5-muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.os5-pdf__viewport {
    position: relative;
    width: 100%;
    border: 1px solid var(--os5-border);
    border-radius: 0 0 6px 6px;
    background: var(--os5-surface);
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.os5-pdf:not(:has(.os5-pdf__toolbar)) .os5-pdf__viewport {
    border-radius: 6px;
}

.os5-pdf__viewport--single {
    display: flex;
    min-height: 160px;
    padding: 16px;
    overflow: auto;
}

.os5-pdf__viewport--continuous {
    height: var(--os5-height, 720px);
    min-height: 320px;
    padding: 16px;
    overflow: auto;
}

.os5-pdf__single-page,
.os5-pdf__page {
    position: relative;
    flex: 0 0 auto;
    margin: 0 auto;
    background: #fff;
    box-shadow: var(--os5-canvas-shadow);
}

.os5-pdf__single-page {
    align-self: flex-start;
    min-width: 1px;
    min-height: 1px;
}

.os5-pdf__pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    min-width: min-content;
}

.os5-pdf__page {
    overflow: hidden;
}

.os5-pdf__page::after {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgb(17 24 39 / 68%);
    color: #fff;
    font-size: 11px;
    line-height: 1.4;
    content: attr(data-page-number);
    opacity: 0;
    transition: opacity 120ms ease;
    pointer-events: none;
}

.os5-pdf__page:hover::after,
.os5-pdf__page:focus-within::after {
    opacity: 1;
}

.os5-pdf canvas {
    display: block;
    max-width: none;
    margin: 0;
}

.os5-pdf__page canvas {
    width: 100%;
    height: 100%;
}

.os5-pdf__loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 140px;
    color: var(--os5-muted);
    pointer-events: none;
}

.os5-pdf[data-state="ready"] > .os5-pdf__viewport > .os5-pdf__loading,
.os5-pdf[data-state="error"] > .os5-pdf__viewport > .os5-pdf__loading {
    display: none;
}

.os5-pdf__spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #c4cbd3;
    border-top-color: var(--os5-focus);
    border-radius: 50%;
    animation: os5-pdf-spin 700ms linear infinite;
}

.os5-pdf__error {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid #d63638;
    border-top: 0;
    background: #fcf0f1;
    color: #8a2424;
}

.os5-pdf__caption {
    margin-top: 8px;
    color: var(--os5-muted);
    font-size: 13px;
    text-align: center;
}

.os5-pdf:fullscreen {
    width: 100%;
    max-width: none;
    height: 100%;
    margin: 0;
    padding: 12px;
    background: var(--os5-surface);
}

.os5-pdf:fullscreen .os5-pdf__viewport--continuous {
    height: calc(100vh - 78px);
}

.os5-pdf:fullscreen .os5-pdf__viewport--single {
    height: calc(100vh - 78px);
}

.os5-pdf .screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

@media (max-width: 700px) {
    .os5-pdf__toolbar {
        flex-wrap: wrap;
        gap: 6px;
    }

    .os5-pdf__status {
        order: 3;
        flex: 1 0 100%;
        padding-inline: 3px;
    }

    .os5-pdf__group--actions {
        margin-left: auto;
    }

    .os5-pdf__button {
        min-width: 36px;
        min-height: 36px;
    }

    .os5-pdf__button--text {
        font-size: 12px;
    }

    .os5-pdf__viewport--single,
    .os5-pdf__viewport--continuous {
        padding: 8px;
    }

    .os5-pdf__viewport--continuous {
        height: min(var(--os5-height, 720px), 80vh);
        min-height: min(320px, 70vh);
    }

    .os5-pdf__pages {
        gap: 8px;
    }
}

@media (max-width: 440px) {
    .os5-pdf__button--fit {
        display: none;
    }

    .os5-pdf__button--text {
        padding-inline: 7px;
    }

    .os5-pdf__page-input {
        width: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .os5-pdf__spinner {
        animation-duration: 1400ms;
    }

    .os5-pdf__page::after {
        transition: none;
    }
}
