.mpv-viewer {
    --mpv-height: 720px;
    --mpv-page-gap: 18px;
    --mpv-toolbar-bg: #30343b;
    --mpv-toolbar-color: #fff;
    --mpv-stage-bg: #d9dde3;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    background: #fff;
    box-sizing: border-box;
}

.mpv-viewer *,
.mpv-viewer *::before,
.mpv-viewer *::after {
    box-sizing: border-box;
}

.mpv-title {
    margin: 0;
    padding: 16px 18px;
    font-size: clamp(1.15rem, 2vw, 1.55rem);
    line-height: 1.25;
    background: #fff;
}

.mpv-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 48px;
    padding: 7px 10px;
    color: var(--mpv-toolbar-color);
    background: var(--mpv-toolbar-bg);
    user-select: none;
}

.mpv-toolbar__group {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.mpv-button,
.mpv-page-input {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.08);
    color: inherit;
    font: inherit;
}

.mpv-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    text-decoration: none;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.mpv-button:hover,
.mpv-button:focus-visible,
.mpv-button.is-active {
    background: rgba(255, 255, 255, 0.22);
    color: inherit;
    outline: 2px solid rgba(255, 255, 255, 0.65);
    outline-offset: 1px;
}

.mpv-button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.mpv-page-control {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.mpv-page-input {
    width: 52px;
    height: 34px;
    padding: 4px 5px;
    text-align: center;
}

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

.mpv-page-total,
.mpv-zoom-value {
    min-width: 42px;
    text-align: center;
    font-size: 13px;
}

.mpv-stage {
    position: relative;
    height: var(--mpv-height);
    min-height: 280px;
    overflow: auto;
    overscroll-behavior: contain;
    background: var(--mpv-stage-bg);
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y pinch-zoom;
}

.mpv-document {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--mpv-page-gap);
    width: 100%;
    min-height: 100%;
    padding: 18px;
}

.mpv-viewer[data-active-mode="single"] .mpv-document {
    justify-content: center;
}

.mpv-page {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transform-origin: top center;
}

.mpv-page canvas {
    display: block;
    max-width: none;
    height: auto;
    background: #fff;
}

.mpv-page__loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a4f58;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.8);
}

.mpv-page.is-rendered .mpv-page__loading {
    display: none;
}

.mpv-viewer[data-active-mode="single"][data-swipe-enabled="1"] .mpv-stage {
    cursor: grab;
}

.mpv-viewer[data-active-mode="single"][data-swipe-enabled="1"].is-touching .mpv-stage {
    cursor: grabbing;
}

.mpv-viewer[data-swipe-direction="next"] .mpv-page,
.mpv-viewer[data-swipe-direction="previous"] .mpv-page {
    animation: mpv-swipe-page 180ms ease-out;
}

@keyframes mpv-swipe-page {
    from {
        opacity: 0.72;
        transform: scale(0.992);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.mpv-status {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    transform: translate(-50%, -50%);
    max-width: calc(100% - 40px);
    padding: 11px 16px;
    border-radius: 7px;
    color: #20242a;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.15);
    text-align: center;
}

.mpv-status[hidden],
.mpv-error[hidden] {
    display: none !important;
}

.mpv-error {
    padding: 22px;
    text-align: center;
    background: #fff;
}

.mpv-error p {
    margin: 0 0 10px;
}

.mpv-editor-placeholder {
    padding: 28px;
    border: 1px dashed #a7a7a7;
    border-radius: 6px;
    background: #f7f7f7;
    text-align: center;
}

.mpv-viewer:fullscreen {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    border: 0;
    border-radius: 0;
    background: #fff;
}

.mpv-viewer:fullscreen .mpv-stage {
    flex: 1;
    height: auto;
}

@media (max-width: 767px) {
    .mpv-toolbar {
        flex-wrap: wrap;
        justify-content: center;
        padding: 8px;
    }

    .mpv-toolbar__group {
        flex: 0 0 auto;
    }

    .mpv-toolbar__navigation {
        order: 1;
    }

    .mpv-toolbar__zoom {
        order: 3;
    }

    .mpv-toolbar__actions {
        order: 2;
    }

    .mpv-stage {
        height: var(--mpv-height, 540px);
        min-height: 360px;
    }

    .mpv-document {
        padding: 10px;
    }

    .mpv-button {
        width: 38px;
        height: 38px;
    }

    .mpv-page-input {
        height: 38px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mpv-viewer * {
        scroll-behavior: auto !important;
    }
}

/*
 * Barra móvil compacta (1.0.2)
 * Mantiene los controles en una sola línea sin alterar escritorio/tablet.
 */
@media (max-width: 767px) {
    .mpv-toolbar {
        flex-wrap: nowrap;
        justify-content: space-between;
        gap: 2px;
        min-height: 42px;
        padding: 5px 4px;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x;
    }

    .mpv-toolbar::-webkit-scrollbar {
        display: none;
    }

    .mpv-toolbar__group {
        flex: 0 0 auto;
        gap: 2px;
    }

    .mpv-toolbar__navigation,
    .mpv-toolbar__zoom,
    .mpv-toolbar__actions {
        order: initial;
    }

    .mpv-button {
        flex: 0 0 26px;
        width: 26px;
        height: 32px;
        min-width: 26px;
        padding: 0;
        border-radius: 4px;
        font-size: 16px;
        line-height: 1;
        touch-action: manipulation;
        overflow: hidden;
    }

    .mpv-page-control {
        gap: 2px;
    }

    .mpv-page-input {
        width: 32px;
        min-width: 32px;
        height: 32px;
        padding: 2px;
        border-radius: 4px;
        font-size: 12px;
    }

    .mpv-page-total {
        min-width: 26px;
        font-size: 11px;
    }

    .mpv-zoom-value {
        min-width: 30px;
        font-size: 11px;
    }
}

/* En equipos muy estrechos, imprimir aporta menos que descargar y pantalla completa. */
@media (max-width: 359px) {
    .mpv-toolbar__actions .mpv-print {
        display: none;
    }
}
