:root {
    --primary-950: #202328;
    --primary-900: #34383f;
    --primary-800: #474c54;
    --primary-700: #5d646e;
    --accent-500: #59616c;
    --accent-400: #c5c9cf;
    --ink: #20242a;
    --muted: #68717c;
    --surface: #f7f8f9;
    --surface-solid: #ffffff;
    --surface-soft: rgba(255, 255, 255, 0.5);
    --stage: #c7cbd1;
    --stage-light: #eef0f3;
    --line: rgba(45, 50, 57, 0.14);
    --glass: rgba(255, 255, 255, 0.46);
    --glass-strong: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.78);
    --shadow: 0 18px 48px rgba(31, 35, 41, 0.22);
    --toolbar-height: 72px;
    --topbar-height: 74px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

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

body {
    overflow: hidden;
    color: var(--ink);
    background: var(--stage);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
a,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
}

svg {
    display: block;
    width: 1.35rem;
    height: 1.35rem;
    fill: currentColor;
}

.app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    min-height: 100%;
    background: var(--surface);
}

.topbar {
    position: relative;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: calc(var(--topbar-height) + var(--safe-top));
    padding: calc(8px + var(--safe-top)) 18px 8px;
    gap: 18px;
    background: var(--glass-strong);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 4px 24px rgba(31, 35, 41, 0.1);
    backdrop-filter: blur(18px) saturate(135%);
    -webkit-backdrop-filter: blur(18px) saturate(135%);
}

.brand {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 14px;
    color: inherit;
    text-decoration: none;
}

.brand-logo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(150px, 16vw, 210px);
    height: 50px;
    padding: 3px;
    flex: 0 0 auto;
    overflow: visible;
}

.brand-logo {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    flex: 0 1 auto;
    object-fit: contain;
    object-position: center;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.15;
}

.brand-copy strong {
    overflow: hidden;
    font-size: 0.98rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.brand-copy small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.76rem;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-button,
.toolbar-button,
.edge-button,
.zoom-controls button {
    display: inline-grid;
    place-items: center;
    border: 0;
    cursor: pointer;
}

.icon-button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: var(--primary-900);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 5px 16px rgba(31, 35, 41, 0.08);
    backdrop-filter: blur(13px) saturate(130%);
    -webkit-backdrop-filter: blur(13px) saturate(130%);
    transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.icon-button:hover {
    background: rgba(255, 255, 255, 0.82);
    box-shadow: inset 0 1px 0 #fff, 0 7px 20px rgba(31, 35, 41, 0.12);
}

.icon-button:active {
    transform: scale(0.94);
}

.download-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 17px;
    gap: 8px;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(145deg, rgba(70, 75, 83, 0.94), rgba(41, 45, 51, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.24);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 750;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 8px 22px rgba(31, 35, 41, 0.2);
    backdrop-filter: blur(13px) saturate(125%);
    -webkit-backdrop-filter: blur(13px) saturate(125%);
    transition: transform 160ms ease, background 160ms ease;
}

.download-button:hover {
    background: linear-gradient(145deg, var(--primary-700), var(--primary-900));
}

.download-button:active {
    transform: scale(0.97);
}

.viewer-main {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    background: var(--stage);
}

.stage {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 18px 74px;
    isolation: isolate;
    background:
        radial-gradient(circle at 50% 32%, rgba(255, 255, 255, 0.8), transparent 32%),
        radial-gradient(circle at 50% 78%, rgba(91, 97, 106, 0.13), transparent 48%),
        linear-gradient(145deg, var(--stage-light), var(--stage) 62%, #aeb3ba);
    touch-action: pan-y;
}

.stage::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0.18;
    pointer-events: none;
    background-image:
        linear-gradient(120deg, transparent 45%, rgba(255, 255, 255, 0.03) 46%, transparent 47%),
        linear-gradient(60deg, transparent 45%, rgba(255, 255, 255, 0.025) 46%, transparent 47%);
    background-size: 74px 74px;
}

.book-shell {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    perspective: 2400px;
    filter: drop-shadow(0 28px 32px rgba(0, 0, 0, 0.32));
}

.book {
    position: relative;
    overflow: visible;
    transform-style: preserve-3d;
    user-select: none;
    -webkit-user-select: none;
    transition: width 220ms ease, height 220ms ease;
}

.page-slot,
.turn-sheet {
    position: absolute;
    top: 0;
    height: 100%;
    overflow: hidden;
    background: #fff;
}

.page-slot {
    z-index: 1;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.page-slot img,
.turn-face img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    -webkit-user-drag: none;
}

.page-slot.blank {
    background: transparent;
    box-shadow: none;
}

.page-slot.blank img {
    display: none;
}

.book[data-mode="spread"] .page-left {
    left: 0;
    width: 50%;
    border-radius: 7px 0 0 7px;
}

.book[data-mode="spread"] .page-right {
    left: 50%;
    width: 50%;
    border-radius: 0 7px 7px 0;
}

.book[data-mode="single"] .page-left {
    display: none;
}

.book[data-mode="single"] .page-right {
    left: 0;
    width: 100%;
    border-radius: 8px;
}

.page-slot::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.book[data-mode="spread"] .page-left::after {
    background: linear-gradient(to left, rgba(0, 0, 0, 0.1), transparent 8%);
}

.book[data-mode="spread"] .page-right::after {
    background: linear-gradient(to right, rgba(0, 0, 0, 0.11), transparent 8%);
}

.book-gutter {
    position: absolute;
    z-index: 4;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 20px;
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.19), transparent);
}

.book[data-mode="spread"] .book-gutter {
    opacity: 0.8;
}

.turn-sheet {
    z-index: 12;
    display: none;
    transform-style: preserve-3d;
    will-change: transform;
    overflow: visible;
}

.turn-sheet.active {
    display: block;
}

.turn-face {
    position: absolute;
    inset: 0;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: #fff;
    box-shadow: 0 0 26px rgba(0, 0, 0, 0.3);
}

.turn-face::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, transparent 55%, rgba(0, 0, 0, 0.2));
}

.turn-back {
    transform: rotateY(180deg);
}

.turn-back::after {
    background: linear-gradient(270deg, transparent 55%, rgba(0, 0, 0, 0.18));
}

.book[data-mode="spread"] .turn-sheet.turn-next {
    left: 50%;
    width: 50%;
    transform-origin: left center;
    animation: turn-next 680ms cubic-bezier(0.42, 0, 0.16, 1) forwards;
}

.book[data-mode="spread"] .turn-sheet.turn-prev {
    left: 0;
    width: 50%;
    transform-origin: right center;
    animation: turn-prev 680ms cubic-bezier(0.42, 0, 0.16, 1) forwards;
}

.book[data-mode="single"] .turn-sheet {
    left: 0;
    width: 100%;
}

.book[data-mode="single"] .turn-sheet.turn-next {
    transform-origin: left center;
    animation: turn-next 620ms cubic-bezier(0.42, 0, 0.16, 1) forwards;
}

.book[data-mode="single"] .turn-sheet.turn-prev {
    transform-origin: right center;
    animation: turn-prev 620ms cubic-bezier(0.42, 0, 0.16, 1) forwards;
}

@keyframes turn-next {
    0% { transform: rotateY(0deg); }
    48% { filter: brightness(0.84); }
    100% { transform: rotateY(-180deg); filter: brightness(1); }
}

@keyframes turn-prev {
    0% { transform: rotateY(0deg); }
    48% { filter: brightness(0.84); }
    100% { transform: rotateY(180deg); filter: brightness(1); }
}

.edge-button {
    position: absolute;
    z-index: 8;
    top: 50%;
    width: 48px;
    height: 48px;
    transform: translateY(-50%);
    border-radius: 50%;
    color: var(--primary-900);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 1px 0 #fff, 0 9px 28px rgba(31, 35, 41, 0.16);
    backdrop-filter: blur(14px) saturate(135%);
    -webkit-backdrop-filter: blur(14px) saturate(135%);
    transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.edge-button:hover {
    background: rgba(255, 255, 255, 0.84);
}

.edge-button:active {
    transform: translateY(-50%) scale(0.92);
}

.edge-button:disabled,
.toolbar-button:disabled,
.page-counter:disabled {
    opacity: 0.28;
    cursor: default;
}

.edge-prev {
    left: 18px;
}

.edge-next {
    right: 18px;
}

.swipe-hint {
    position: absolute;
    z-index: 15;
    left: 50%;
    bottom: 16px;
    display: flex;
    align-items: center;
    max-width: calc(100% - 32px);
    padding: 9px 14px;
    gap: 8px;
    transform: translateX(-50%);
    border-radius: 999px;
    color: #fff;
    background: rgba(41, 45, 51, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.24);
    backdrop-filter: blur(13px);
    -webkit-backdrop-filter: blur(13px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
    font-size: 0.8rem;
    white-space: nowrap;
    pointer-events: none;
    animation: hint-in 300ms ease both;
}

.swipe-hint svg {
    width: 1.1rem;
    height: 1.1rem;
}

.swipe-hint.hide {
    animation: hint-out 300ms ease forwards;
}

@keyframes hint-in {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes hint-out {
    to { opacity: 0; transform: translate(-50%, 8px); }
}

.bottom-toolbar {
    position: relative;
    z-index: 25;
    display: grid;
    grid-template-columns: minmax(70px, 1fr) minmax(76px, 1fr) minmax(88px, auto) minmax(76px, 1fr) minmax(70px, 1fr);
    align-items: center;
    min-height: calc(var(--toolbar-height) + var(--safe-bottom));
    padding: 7px max(12px, env(safe-area-inset-right)) calc(7px + var(--safe-bottom)) max(12px, env(safe-area-inset-left));
    gap: 5px;
    background: var(--glass-strong);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 26px rgba(31, 35, 41, 0.13);
    backdrop-filter: blur(18px) saturate(135%);
    -webkit-backdrop-filter: blur(18px) saturate(135%);
}

.toolbar-button {
    min-width: 0;
    min-height: 54px;
    padding: 5px 7px;
    gap: 3px;
    border-radius: 12px;
    color: var(--primary-900);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid transparent;
    transition: background 150ms ease, transform 150ms ease;
}

.toolbar-button:hover {
    background: var(--glass);
    border-color: var(--glass-border);
}

.toolbar-button:active {
    transform: scale(0.96);
}

.toolbar-button span {
    overflow: hidden;
    max-width: 100%;
    font-size: 0.69rem;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.page-counter {
    display: flex;
    align-items: baseline;
    justify-content: center;
    min-height: 48px;
    min-width: 88px;
    padding: 7px 13px;
    gap: 5px;
    border: 1px solid rgba(6, 79, 59, 0.14);
    border-radius: 999px;
    color: var(--primary-950);
    background: var(--glass);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76), 0 5px 16px rgba(31, 35, 41, 0.07);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    white-space: nowrap;
}

.page-counter strong {
    font-size: 1rem;
}

.page-counter span {
    color: var(--muted);
    font-size: 0.73rem;
}

.panel-backdrop {
    position: fixed;
    z-index: 55;
    inset: 0;
    background: rgba(0, 0, 0, 0.48);
    opacity: 0;
    transition: opacity 220ms ease;
}

.panel-backdrop.visible {
    opacity: 1;
}

.thumbnail-panel {
    position: fixed;
    z-index: 60;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    width: min(390px, 90vw);
    flex-direction: column;
    background: rgba(247, 248, 249, 0.94);
    border-left: 1px solid rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px) saturate(125%);
    -webkit-backdrop-filter: blur(20px) saturate(125%);
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.28);
    transform: translateX(105%);
    transition: transform 260ms cubic-bezier(0.22, 0.8, 0.25, 1);
}

.thumbnail-panel.open {
    transform: translateX(0);
}

.panel-handle {
    display: none;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.panel-header > div {
    display: flex;
    flex-direction: column;
}

.panel-header strong {
    font-size: 1rem;
}

.panel-header small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.75rem;
}

.thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 14px;
    gap: 12px;
    overscroll-behavior: contain;
}

.thumbnail-item {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    padding: 7px;
    gap: 7px;
    border: 2px solid transparent;
    border-radius: 12px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.58);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: border 150ms ease, transform 150ms ease, background 150ms ease;
}

.thumbnail-item:hover {
    background: rgba(255, 255, 255, 0.92);
    transform: translateY(-2px);
}

.thumbnail-item.active {
    border-color: var(--accent-500);
    background: rgba(234, 237, 240, 0.92);
}

.thumbnail-image-wrap {
    display: block;
    width: 100%;
    overflow: hidden;
    aspect-ratio: 992 / 1525;
    border-radius: 7px;
    background: #dfe2e6;
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.14);
}

.thumbnail-image-wrap img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-item > span:last-child {
    font-size: 0.74rem;
    font-weight: 700;
}

.modal-overlay,
.zoom-overlay {
    position: fixed;
    z-index: 80;
    inset: 0;
    background: rgba(0, 0, 0, 0.76);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-overlay {
    display: grid;
    place-items: center;
    padding: 20px;
}

.compact-dialog {
    width: min(420px, 100%);
    overflow: hidden;
    border-radius: 20px;
    background: rgba(248, 249, 250, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(22px) saturate(125%);
    -webkit-backdrop-filter: blur(22px) saturate(125%);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
    animation: dialog-in 220ms ease both;
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.compact-dialog header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 18px 12px;
}

.compact-dialog header > div {
    display: flex;
    flex-direction: column;
}

.compact-dialog header small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.78rem;
}

.compact-dialog form {
    display: grid;
    grid-template-columns: 1fr auto;
    padding: 8px 18px 20px;
    gap: 9px;
}

.compact-dialog input {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid #cfd3d8;
    border-radius: 12px;
    color: var(--ink);
    background: #fff;
    font-size: 1rem;
    outline: none;
}

.compact-dialog input:focus {
    border-color: var(--primary-700);
    box-shadow: 0 0 0 3px rgba(93, 100, 110, 0.16);
}

.compact-dialog form button {
    min-height: 48px;
    padding: 0 17px;
    border: 0;
    border-radius: 12px;
    color: #fff;
    background: var(--primary-900);
    cursor: pointer;
    font-weight: 750;
}

.zoom-overlay {
    display: grid;
    grid-template-rows: auto 1fr auto;
    color: #fff;
    background: #1d2025;
}

.zoom-header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: calc(64px + var(--safe-top));
    padding: calc(10px + var(--safe-top)) 14px 10px;
    background: rgba(35, 38, 44, 0.88);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.11);
}

.zoom-header > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.zoom-header small {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.64);
    font-size: 0.72rem;
}

.zoom-header .icon-button {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.zoom-viewport {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 18px;
    text-align: center;
    overscroll-behavior: contain;
    touch-action: none;
    cursor: grab;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.zoom-viewport.dragging {
    cursor: grabbing;
}

.zoom-viewport img {
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
    margin: 0 auto;
    transform-origin: top center;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
    user-select: none;
    -webkit-user-drag: none;
}

.zoom-controls {
    display: grid;
    grid-template-columns: 56px minmax(86px, auto) 56px;
    justify-content: center;
    align-items: center;
    min-height: calc(66px + var(--safe-bottom));
    padding: 8px 12px calc(8px + var(--safe-bottom));
    gap: 8px;
    background: rgba(35, 38, 44, 0.9);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid rgba(255, 255, 255, 0.11);
}

.zoom-controls button {
    height: 46px;
    border-radius: 12px;
    color: #fff;
    background: rgba(255, 255, 255, 0.11);
}

.zoom-controls .zoom-level {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    padding: 0 16px;
    font-weight: 750;
}

.toast {
    position: fixed;
    z-index: 100;
    left: 50%;
    bottom: calc(var(--toolbar-height) + var(--safe-bottom) + 18px);
    max-width: calc(100% - 32px);
    padding: 11px 16px;
    transform: translate(-50%, 12px);
    border-radius: 999px;
    color: #fff;
    background: rgba(0, 0, 0, 0.82);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
    font-size: 0.82rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

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

.loading-screen {
    position: fixed;
    z-index: 120;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.22), transparent 34%),
        linear-gradient(145deg, var(--primary-800), var(--primary-950));
    transition: opacity 350ms ease, visibility 350ms ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-card {
    display: flex;
    width: min(420px, 100%);
    flex-direction: column;
    align-items: center;
    padding: 28px 26px;
    border-radius: 24px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.76);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    text-align: center;
}

.loading-card img {
    display: block;
    width: min(270px, 100%);
    height: auto;
    margin-bottom: 22px;
}

.loading-card strong {
    margin-top: 12px;
    font-size: 1.02rem;
}

.loading-card small {
    margin-top: 5px;
    color: var(--muted);
}

.loading-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid #dce0e5;
    border-top-color: var(--primary-800);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

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

.noscript-message {
    position: fixed;
    z-index: 999;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    color: #fff;
    background: var(--primary-950);
    text-align: center;
}

.noscript-message a {
    color: var(--accent-400);
}

[hidden] {
    display: none !important;
}

body.modal-open {
    overflow: hidden;
}

:focus-visible {
    outline: 3px solid var(--accent-500);
    outline-offset: 3px;
}

@media (max-width: 820px) {
    :root {
        --topbar-height: 60px;
        --toolbar-height: 68px;
    }

    .topbar {
        padding-right: 10px;
        padding-left: 10px;
        gap: 8px;
    }

    .brand {
        gap: 8px;
    }

    .brand-logo-wrap {
        width: 132px;
        height: 36px;
        padding: 2px;
    }

    .brand-copy {
        display: none;
    }

    .desktop-action {
        display: none;
    }

    .download-button {
        width: 42px;
        min-height: 42px;
        padding: 0;
        border-radius: 50%;
    }

    .download-button span {
        display: none;
    }

    .stage {
        padding: 10px 12px 12px;
        touch-action: pan-y;
    }

    .edge-button {
        display: none;
    }

    .swipe-hint {
        bottom: 10px;
        font-size: 0.74rem;
    }

    .thumbnail-panel {
        top: auto;
        right: 0;
        left: 0;
        width: 100%;
        height: min(72dvh, 680px);
        max-height: calc(100dvh - 40px);
        border-radius: 22px 22px 0 0;
        transform: translateY(105%);
    }

    .thumbnail-panel.open {
        transform: translateY(0);
    }

    .panel-handle {
        display: block;
        width: 48px;
        height: 5px;
        margin: 9px auto 0;
        border-radius: 999px;
        background: #cbd0d6;
    }

    .panel-header {
        min-height: 64px;
        padding-top: 7px;
    }

    .thumbnail-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        padding-bottom: calc(16px + var(--safe-bottom));
        gap: 9px;
    }

    .thumbnail-item {
        padding: 5px;
    }

    .bottom-toolbar {
        grid-template-columns: 1fr 1fr minmax(76px, auto) 1fr 1fr;
        padding-right: 5px;
        padding-left: 5px;
    }

    .toolbar-button {
        padding-right: 3px;
        padding-left: 3px;
    }

    .toolbar-button span {
        font-size: 0.61rem;
    }

    .page-counter {
        min-width: 76px;
        padding-right: 9px;
        padding-left: 9px;
    }

    .page-counter strong {
        font-size: 0.91rem;
    }

    .page-counter span {
        font-size: 0.66rem;
    }

    .zoom-viewport {
        padding: 10px;
    }
}

@media (max-width: 390px) {
    .brand-logo-wrap {
        width: 118px;
    }

    .toolbar-button span {
        font-size: 0.56rem;
    }

    .thumbnail-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 340px) {
    .brand-logo-wrap {
        width: 96px;
        padding: 2px;
    }

    .top-actions,
    .topbar {
        gap: 5px;
    }

    .icon-button,
    .download-button {
        width: 40px;
        height: 40px;
        min-height: 40px;
    }
}

@media (min-width: 821px) and (max-height: 700px) {
    :root {
        --topbar-height: 60px;
        --toolbar-height: 62px;
    }

    .topbar {
        padding-top: calc(5px + var(--safe-top));
        padding-bottom: 5px;
    }

    .brand-logo-wrap {
        height: 38px;
        width: 150px;
    }

    .bottom-toolbar {
        padding-top: 4px;
    }

    .toolbar-button {
        min-height: 48px;
    }
}

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