:root {
    color-scheme: dark;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: #202124;
    color: #f1f3f4;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: #202124;
}

.viewer-header {
    flex: 0 0 auto;
    min-height: 72px;
    padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #292a2d;
    border-bottom: 1px solid #45474b;
}

.viewer-heading {
    min-width: 0;
}

.viewer-heading h1 {
    margin: 4px 0 0;
    font-size: clamp(0.95rem, 2.6vw, 1.25rem);
    line-height: 1.3;
    font-weight: 600;
}

.back-link,
.pdf-link {
    color: #9ecbff;
    text-decoration: none;
}

.back-link {
    display: inline-block;
    font-size: 0.85rem;
}

.pdf-link {
    flex: 0 0 auto;
    min-width: 88px;
    min-height: 44px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #6f747a;
    border-radius: 6px;
    font-weight: 600;
}

.back-link:hover,
.back-link:focus-visible,
.pdf-link:hover,
.pdf-link:focus-visible {
    color: #d2e7ff;
    text-decoration: underline;
}

.viewer-main {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    padding-bottom: env(safe-area-inset-bottom);
    background: #242528;
}

.viewer-canvas {
    width: 100%;
    height: 100%;
    background: #242528;
    touch-action: none;
}

.viewer-message {
    position: absolute;
    inset: 50% auto auto 50%;
    width: min(90%, 540px);
    padding: 20px;
    transform: translate(-50%, -50%);
    border: 1px solid #6f747a;
    border-radius: 8px;
    background: #292a2d;
    color: #f1f3f4;
    text-align: center;
    line-height: 1.6;
}

.openseadragon-container .openseadragon-canvas:focus-visible {
    outline: 3px solid #8ab4f8;
    outline-offset: -3px;
}

.openseadragon-container img[role="button"] {
    min-width: 44px;
    min-height: 44px;
}

@media (max-width: 600px) {
    .viewer-header {
        min-height: 82px;
        gap: 10px;
    }

    .viewer-heading h1 {
        max-width: 100%;
    }

    .pdf-link {
        min-width: 78px;
        padding-inline: 10px;
        font-size: 0.9rem;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .viewer-header {
        min-height: 58px;
        padding-top: max(6px, env(safe-area-inset-top));
        padding-bottom: 6px;
    }

    .viewer-heading h1 {
        margin-top: 2px;
        font-size: 0.9rem;
    }

    .back-link {
        font-size: 0.75rem;
    }
}
