:root {
    --cdpv-border: #d9dee8;
    --cdpv-surface: #ffffff;
    --cdpv-stage: #edf1f6;
    --cdpv-text: #172033;
    --cdpv-muted: #69758b;
    --cdpv-accent: #1f5eff;
    --cdpv-danger: #a32020;
    --cdpv-shadow: 0 14px 34px rgba(20, 31, 55, 0.13);
}

.cdpv-viewer,
.cdpv-viewer * {
    box-sizing: border-box;
}

.cdpv-viewer {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    color: var(--cdpv-text);
    background: var(--cdpv-surface);
    border: 1px solid var(--cdpv-border);
    border-radius: 14px;
    box-shadow: var(--cdpv-shadow);
    font: 500 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.cdpv-viewer [hidden] { display: none !important; }

.cdpv-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 54px;
    padding: 7px 9px;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(255,255,255,.98);
    border-bottom: 1px solid var(--cdpv-border);
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.cdpv-toolbar__title {
    display: inline-flex;
    flex: 1 1 170px;
    min-width: 120px;
    max-width: 300px;
    align-items: center;
    gap: 7px;
    overflow: hidden;
}

.cdpv-toolbar__title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
}

.cdpv-engine-badge {
    flex: 0 0 auto;
    padding: 3px 7px;
    color: #385071;
    background: #edf3ff;
    border: 1px solid #cbd9f7;
    border-radius: 999px;
    white-space: nowrap;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.cdpv-toolbar__group {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 5px;
}

.cdpv-toolbar__group--end { margin-left: auto; }

.cdpv-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    color: var(--cdpv-text);
    background: #f7f8fb;
    border: 1px solid #dbe0e8;
    border-radius: 8px;
    text-decoration: none !important;
    font: 700 18px/1 sans-serif;
    cursor: pointer;
    appearance: none;
    transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}

.cdpv-button:hover,
.cdpv-button:focus-visible,
.cdpv-button.is-active {
    color: #fff;
    background: var(--cdpv-accent);
    border-color: var(--cdpv-accent);
    outline: none;
}

.cdpv-button:disabled { opacity: .42; cursor: not-allowed; }
.cdpv-button:active { transform: translateY(1px); }
.cdpv-button--text { width: auto; min-width: 54px; padding: 0 9px; font-size: 11px; }
.cdpv-button--engine { width: auto; min-width: 78px; padding: 0 10px; font-size: 11px; white-space: nowrap; }

.cdpv-page-control {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--cdpv-muted);
    white-space: nowrap;
}

.cdpv-page-control input {
    width: 52px;
    height: 36px;
    padding: 4px 6px;
    color: var(--cdpv-text);
    background: #fff;
    border: 1px solid #dbe0e8;
    border-radius: 8px;
    text-align: center;
    font: inherit;
}

.cdpv-zoom-value { min-width: 46px; color: var(--cdpv-muted); text-align: center; font-size: 12px; }

.cdpv-viewport {
    position: relative;
    width: 100%;
    height: var(--cdpv-height, 720px);
    min-height: 320px;
    overflow: hidden;
    background: var(--cdpv-stage);
}

.cdpv-poster {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: grid;
    place-items: center;
    background-color: #e9edf4;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
}

.cdpv-poster__shade {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(15,23,42,.08), rgba(15,23,42,.56));
}

.cdpv-poster__content {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 12px;
    width: min(88%, 520px);
    padding: 24px;
    color: #fff;
    text-align: center;
    text-shadow: 0 2px 12px rgba(0,0,0,.35);
}

.cdpv-poster__icon {
    display: grid;
    place-items: center;
    width: 68px;
    height: 82px;
    color: #fff;
    background: #d62020;
    border-radius: 8px 8px 8px 18px;
    box-shadow: 0 10px 24px rgba(0,0,0,.28);
    font-weight: 900;
}

.cdpv-load-button {
    min-height: 42px;
    padding: 8px 18px;
    color: #fff;
    background: var(--cdpv-accent);
    border: 0;
    border-radius: 9px;
    box-shadow: 0 8px 20px rgba(31,94,255,.32);
    font: 700 14px/1.2 inherit;
    cursor: pointer;
}

.cdpv-native,
.cdpv-stage {
    width: 100%;
    height: 100%;
    min-height: 320px;
}

.cdpv-native__frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

.cdpv-stage {
    overflow: auto;
    overscroll-behavior: contain;
    background:
        linear-gradient(45deg, rgba(255,255,255,.26) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.26) 75%),
        linear-gradient(45deg, rgba(255,255,255,.26) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.26) 75%),
        var(--cdpv-stage);
    background-position: 0 0, 12px 12px;
    background-size: 24px 24px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y pinch-zoom;
}

.cdpv-document {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    width: 100%;
    min-width: min-content;
    min-height: 100%;
    padding: 18px;
}

.cdpv-page {
    position: relative;
    flex: 0 0 auto;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 5px 18px rgba(20,31,55,.18);
}

.cdpv-page canvas { display: block; background: #fff; }

.cdpv-page__loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    color: var(--cdpv-muted);
    background: linear-gradient(110deg, #f8f9fb 8%, #eef1f5 18%, #f8f9fb 33%);
    background-size: 200% 100%;
    animation: cdpv-shimmer 1.25s linear infinite;
    text-align: center;
}

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

.cdpv-status,
.cdpv-error {
    position: absolute;
    z-index: 5;
    top: 50%;
    left: 50%;
    width: min(88%, 430px);
    padding: 18px 22px;
    transform: translate(-50%, -50%);
    color: var(--cdpv-text);
    background: rgba(255,255,255,.97);
    border: 1px solid var(--cdpv-border);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(20,31,55,.18);
    text-align: center;
}

.cdpv-status { display: flex; align-items: center; justify-content: center; gap: 10px; }
.cdpv-error strong { display: block; margin-bottom: 8px; }
.cdpv-error a { color: var(--cdpv-accent); font-weight: 700; }

.cdpv-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #dbe3f1;
    border-top-color: var(--cdpv-accent);
    border-radius: 50%;
    animation: cdpv-spin .8s linear infinite;
}

.cdpv-notice {
    padding: 14px 16px;
    color: var(--cdpv-danger);
    background: #fff2f2;
    border: 1px solid #f1bcbc;
    border-radius: 8px;
}

.cdpv-noscript { padding: 12px; text-align: center; }
.cdpv-viewer:fullscreen { width: 100vw; height: 100vh; max-width: none; border: 0; border-radius: 0; }
.cdpv-viewer:fullscreen .cdpv-viewport { height: calc(100vh - 55px); min-height: 0; }
.cdpv-viewer.is-touching .cdpv-page { user-select: none; }

@keyframes cdpv-spin { to { transform: rotate(360deg); } }
@keyframes cdpv-shimmer { to { background-position-x: -200%; } }

@media (max-width: 767px) {
    .cdpv-viewer { border-radius: 10px; }
    .cdpv-toolbar { gap: 6px; min-height: 49px; padding: 6px; }
    .cdpv-toolbar__title { display: none; }
    .cdpv-toolbar__group--end { margin-left: 0; }
    .cdpv-button { width: 34px; min-width: 34px; height: 34px; border-radius: 7px; }
    .cdpv-button--text { width: auto; min-width: 48px; padding: 0 7px; }
    .cdpv-button--engine { width: auto; min-width: 72px; padding: 0 8px; }
    .cdpv-page-control input { width: 45px; height: 34px; }
    .cdpv-viewport, .cdpv-native, .cdpv-stage { min-height: 300px; }
    .cdpv-document { gap: 12px; padding: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    .cdpv-button, .cdpv-spinner, .cdpv-page__loading { animation: none; transition: none; }
}
