:root {
    color-scheme: dark;
    --toolbar-height: 58px;
    --sidebar-width: 216px;
    --toolbar-bg: #333333;
    --toolbar-border: rgba(255, 255, 255, 0.12);
    --viewer-bg: #242424;
    --sidebar-bg: #2b2b2b;
    --control-bg: rgba(255, 255, 255, 0.08);
    --control-hover: rgba(255, 255, 255, 0.16);
    --control-active: #ff6b22;
    --text-main: #f5f5f5;
    --text-muted: #b7b7b7;
    --page-gap: 18px;
    --page-shadow: 0 4px 18px rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--viewer-bg);
    color: var(--text-main);
    font-family: Arial, "Helvetica Neue", sans-serif;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

button:focus-visible,
input:focus-visible,
.viewer-main:focus-visible {
    outline: 2px solid #ff8a50;
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.viewer-app {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.viewer-toolbar {
    position: relative;
    z-index: 30;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    width: 100%;
    height: var(--toolbar-height);
    padding: 0 14px;
    background: var(--toolbar-bg);
    border-bottom: 1px solid var(--toolbar-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
    user-select: none;
}

.toolbar-section {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 6px;
}

.toolbar-start {
    justify-self: start;
}

.toolbar-center {
    justify-self: center;
}

.toolbar-end {
    justify-self: end;
}

.tool-button,
.zoom-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    min-width: 36px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    transition: background-color 140ms ease, opacity 140ms ease;
}

.tool-button:hover,
.zoom-value:hover {
    background: var(--control-hover);
}

.tool-button:active,
.zoom-value:active {
    background: var(--control-bg);
}

.tool-button:disabled {
    opacity: 0.32;
    cursor: default;
    background: transparent;
}

.tool-button svg {
    width: 21px;
    height: 21px;
    fill: currentColor;
}

.document-identity {
    display: flex;
    align-items: center;
    min-width: 0;
    margin-left: 8px;
    gap: 12px;
}

.seeposh-wordmark {
    color: #ff6b22;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.document-title {
    min-width: 0;
    overflow: hidden;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-control {
    display: flex;
    align-items: center;
    height: 34px;
    gap: 7px;
    color: var(--text-muted);
    font-size: 14px;
}

.page-control input {
    width: 46px;
    height: 30px;
    padding: 0 5px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 4px;
    background: #222222;
    color: #ffffff;
    text-align: center;
}

.zoom-value {
    min-width: 58px;
    padding: 0 8px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
}

.viewer-shell {
    display: flex;
    width: 100%;
    height: calc(100% - var(--toolbar-height));
    overflow: hidden;
}

.thumbnail-sidebar {
    position: relative;
    z-index: 20;
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    height: 100%;
    overflow: hidden;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--toolbar-border);
    transition: flex-basis 180ms ease, width 180ms ease, transform 180ms ease;
}

body.sidebar-closed .thumbnail-sidebar {
    flex-basis: 0;
    width: 0;
    border-right: 0;
}

.thumbnail-list {
    width: var(--sidebar-width);
    height: 100%;
    padding: 18px 18px 24px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-color: #686868 transparent;
    scrollbar-width: thin;
}

.thumbnail-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 0 0 18px;
    padding: 6px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
}

.thumbnail-button:hover {
    background: rgba(255, 255, 255, 0.06);
}

.thumbnail-button.is-current {
    border-color: var(--control-active);
    background: rgba(255, 107, 34, 0.1);
}

.thumbnail-canvas-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 150px;
    min-height: 86px;
    overflow: hidden;
    background: #404040;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.thumbnail-canvas-wrap canvas {
    display: block;
    max-width: 150px;
    height: auto;
    background: #ffffff;
}

.thumbnail-number {
    margin-top: 7px;
    color: #d8d8d8;
    font-size: 12px;
    line-height: 1;
}

.viewer-main {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    overflow: auto;
    overscroll-behavior: contain;
    background: var(--viewer-bg);
    scrollbar-color: #707070 #2a2a2a;
    scrollbar-width: auto;
}

.pdf-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: max-content;
    min-width: 100%;
    min-height: 100%;
    padding: 24px 28px 42px;
    gap: var(--page-gap);
}

.pdf-page {
    position: relative;
    flex: 0 0 auto;
    overflow: hidden;
    background: #ffffff;
    box-shadow: var(--page-shadow);
    transition: width 100ms ease, height 100ms ease;
}

.pdf-page canvas {
    display: block;
    background: #ffffff;
}

.page-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f4f4;
}

.page-loading .loading-spinner {
    border-color: rgba(0, 0, 0, 0.18);
    border-top-color: #ff6b22;
}

.loading-panel,
.error-panel {
    position: fixed;
    z-index: 25;
    left: 50%;
    top: calc(var(--toolbar-height) + 50%);
    transform: translate(-50%, -50%);
}

.loading-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(28, 28, 28, 0.94);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    color: #eeeeee;
    font-size: 14px;
}

.loading-spinner {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    border: 3px solid rgba(255, 255, 255, 0.22);
    border-top-color: #ff6b22;
    border-radius: 50%;
    animation: viewer-spin 800ms linear infinite;
}

.error-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 300px;
    padding: 22px 28px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: #343434;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    text-align: center;
}

.error-panel strong {
    margin-bottom: 8px;
    color: #ffffff;
}

.error-panel span {
    color: var(--text-muted);
    font-size: 14px;
}

.viewer-toast {
    position: fixed;
    z-index: 80;
    left: 50%;
    bottom: 28px;
    max-width: calc(100vw - 32px);
    padding: 10px 15px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 7px;
    background: rgba(20, 20, 20, 0.94);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
    color: #ffffff;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.viewer-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.noscript-message {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #242424;
    color: #ffffff;
    text-align: center;
}

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

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

@media (max-width: 880px) {
    .document-title {
        display: none;
    }

    .document-identity {
        margin-left: 4px;
    }

    .thumbnail-sidebar {
        position: absolute;
        left: 0;
        top: var(--toolbar-height);
        width: var(--sidebar-width);
        height: calc(100% - var(--toolbar-height));
        flex-basis: var(--sidebar-width);
        box-shadow: 5px 0 18px rgba(0, 0, 0, 0.35);
    }

    body.sidebar-closed .thumbnail-sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }
}

@media (max-width: 620px) {
    :root {
        --toolbar-height: 54px;
        --page-gap: 10px;
    }

    .viewer-toolbar {
        grid-template-columns: auto 1fr auto;
        padding: 0 6px;
    }

    .toolbar-section {
        gap: 2px;
    }

    .seeposh-wordmark {
        display: none;
    }

    .page-control {
        gap: 4px;
    }

    .page-control input {
        width: 38px;
    }

    .tool-button {
        min-width: 32px;
        width: 32px;
    }

    .tool-button svg {
        width: 19px;
        height: 19px;
    }

    .zoom-value {
        min-width: 48px;
        padding: 0 4px;
        font-size: 12px;
    }

    .fullscreen-button {
        display: none;
    }

    .pdf-pages {
        padding: 12px 10px 28px;
    }
}

@media (max-width: 390px) {
    #zoomOut,
    #zoomIn {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media print {
    html,
    body {
        background: #ffffff !important;
    }

    .viewer-app {
        display: none !important;
    }

    body::after {
        content: "Printing is disabled for this document.";
        display: block;
        padding: 48px;
        color: #222222;
        font: 18px/1.5 Arial, sans-serif;
        text-align: center;
    }
}
