:root {
    --bg: #f0f5fb;
    --paper: #ffffff;
    --ink: #101820;
    --accent: #0f4c81;
    --accent-2: #0b3a62;
    --muted: #4a5864;
    --line: #d5e0ea;
    --shadow: 0 10px 28px rgba(8, 23, 38, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100dvh;
    color: var(--ink);
    background:
        radial-gradient(circle at 90% 10%, rgba(15, 76, 129, 0.12), transparent 45%),
        linear-gradient(180deg, #f7fbff 0%, #f0f5fb 100%),
        var(--bg);
    font-family: Georgia, "Times New Roman", serif;
    display: flex;
    flex-direction: column;
}

body.embed-mode {
    background: #ffffff;
}

body.embed-mode .site-header,
body.embed-mode .controls,
body.embed-mode .status-row {
    display: none;
}

body.front-mode .controls,
body.front-mode .status-row {
    display: none;
}

body.embed-mode .reader-shell {
    padding: 0;
}

body.front-mode .reader-shell {
    padding-top: 0.75rem;
}

body.front-mode .flipbook {
    touch-action: pan-x pan-y pinch-zoom;
}

body.front-mode .flipbook * {
    touch-action: auto;
}

body.front-mode .flipbook.mobile-linear {
    overflow-x: auto;
}

body.embed-mode .flipbook {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    height: 100vh;
    max-height: none;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
    box-shadow: 0 3px 12px rgba(5, 22, 36, 0.24);
}

.top-line {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.6rem 1rem;
    color: #f2f6fa;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    letter-spacing: 0.02em;
    font-size: 0.9rem;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.top-line strong {
    font-size: 1.05rem;
    letter-spacing: 0.02em;
}

.top-line span {
    font-size: 0.82rem;
}

.brand-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d73f3f;
    flex: 0 0 auto;
}

.nav-wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.35rem 0.8rem 0.55rem;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.main-nav a {
    color: #f8fbff;
    text-decoration: none;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    font-weight: 700;
    font-size: 0.92rem;
    line-height: 1.2;
    letter-spacing: 0.01em;
    padding: 0.45rem 0.65rem;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
    transform-origin: center;
}

.main-nav a:hover,
.main-nav a:focus-visible {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.35);
    outline: none;
    transform: translateY(-1px);
}

.main-nav a.active {
    background: #ffffff;
    color: var(--accent-2);
    border-color: #ffffff;
}

.label-mobile {
    display: none;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    max-width: 1400px;
    margin: 0.8rem auto 0;
    padding: 0.55rem 0.85rem 0.65rem;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.controls label {
    font-weight: 700;
    color: var(--muted);
}

.controls select,
.controls button {
    font: inherit;
    padding: 0.48rem 0.7rem;
    border: 1px solid #b8b8b8;
    border-radius: 10px;
    background: #fff;
}

.controls select {
    min-width: 8.5rem;
}

#yearSelect {
    min-width: 5.8rem;
}

#monthSelect {
    min-width: 12rem;
}

.controls button {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    cursor: pointer;
    font-weight: 700;
    min-width: 6.6rem;
}

.controls button:hover {
    filter: brightness(0.95);
}

.status-row {
    max-width: 1400px;
    margin: 0.5rem auto 0;
    padding: 0 0.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

#statusText {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.mode-btn {
    display: none;
    border: 1px solid #b8b8b8;
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 0.82rem;
    padding: 0.3rem 0.55rem;
    white-space: nowrap;
}

.reader-shell {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0.65rem 1rem 1.2rem;
    flex: 1;
    min-height: 0;
    display: flex;
}

.page-turn-hints {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto 0.9rem;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    position: relative;
    z-index: 1;
}

.edge-turn-hint {
    border: 1px solid rgba(15, 76, 129, 0.42);
    background: rgba(255, 255, 255, 0.9);
    color: #0b3a62;
    border-radius: 999px;
    padding: 0.52rem 0.72rem;
    min-width: 11.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.42rem;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 8px 20px rgba(8, 23, 38, 0.24);
    cursor: pointer;
    transition: transform 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
    animation: edgeHintPulse 1.9s ease-in-out infinite;
}

.edge-turn-hint .arrow {
    font-size: 1.3rem;
    line-height: 1;
}

.edge-turn-hint:hover,
.edge-turn-hint:focus-visible {
    transform: scale(1.03);
    background: #ffffff;
    box-shadow: 0 12px 24px rgba(8, 23, 38, 0.3);
    outline: none;
}

@keyframes edgeHintPulse {
    0% {
        box-shadow: 0 8px 20px rgba(8, 23, 38, 0.24);
    }

    50% {
        box-shadow: 0 10px 26px rgba(11, 58, 98, 0.32);
    }

    100% {
        box-shadow: 0 8px 20px rgba(8, 23, 38, 0.24);
    }
}

.flipbook {
    margin: 0 auto;
    width: min(96vw, 1200px);
    height: min(78vh, 820px);
    max-height: 820px;
    min-height: 420px;
    flex: 1;
    background: transparent;
    touch-action: manipulation;
}

.flipbook.mobile-linear {
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.flipbook.mobile-linear.double-tap-zoom {
    overflow-x: auto;
    overflow-y: auto;
}

.flipbook.mobile-linear .page {
    margin: 0 auto 0.5rem;
    width: min(100%, 980px);
}

.flipbook.mobile-linear .page img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.flipbook.mobile-linear.double-tap-zoom .page {
    overflow: visible;
}

.flipbook.mobile-linear.double-tap-zoom .page img.tap-zoom-target {
    transform: scale(2);
    transform-origin: var(--tap-origin-x, 50%) var(--tap-origin-y, 50%);
    max-width: none;
    transition: transform 120ms ease-out;
    will-change: transform;
}

body.pinch-zoom-active #flipbook .stf__wrapper,
body.pinch-zoom-active #flipbook .stf__block,
body.pinch-zoom-active #flipbook .stf__item,
body.pinch-zoom-active #flipbook img {
    pointer-events: none !important;
}

.page {
    background: var(--paper);
    overflow: hidden;
    border-radius: 2px;
}

.page img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

@media (max-width: 900px) {
    .top-line {
        font-size: 0.82rem;
        padding: 0.48rem 0.7rem;
    }

    .nav-wrap {
        padding: 0.28rem 0.5rem 0.5rem;
    }

    .main-nav {
        gap: 0.3rem;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .main-nav a:not(.mobile-keep) {
        display: none;
    }

    .main-nav a {
        font-size: 0.84rem;
        padding: 0.37rem 0.5rem;
        white-space: nowrap;
    }

    .label-desktop {
        display: none;
    }

    .label-mobile {
        display: inline;
    }

    .controls {
        margin-top: 0.45rem;
        border-radius: 10px;
        padding: 0.4rem 0.5rem 0.55rem;
        gap: 0.3rem;
    }

    .controls label {
        display: none;
    }

    .controls select {
        min-width: 0;
        flex: 1 1 calc(50% - 0.4rem);
        padding: 0.42rem 0.5rem;
    }

    #yearSelect {
        flex: 0 0 5.4rem;
    }

    #monthSelect {
        flex: 1 1 auto;
    }

    .controls button {
        min-width: 0;
        flex: 1 1 calc(33.33% - 0.3rem);
        padding: 0.42rem 0.3rem;
        font-size: 0.9rem;
        white-space: nowrap;
        text-align: center;
    }

    .status-row {
        margin-top: 0.35rem;
        padding: 0 0.1rem;
    }

    .mode-btn {
        display: inline-block;
    }

    .reader-shell {
        padding: 0.4rem 0.2rem 0.45rem;
        min-height: 0;
    }

    .page-turn-hints {
        display: none;
    }

    .flipbook {
        width: 100%;
        max-width: none;
        max-height: none;
        min-height: max(360px, calc(100dvh - 210px));
        height: max(360px, calc(100dvh - 210px));
        touch-action: pinch-zoom;
    }

    body.zoom-mode-active .flipbook {
        touch-action: pan-x pan-y pinch-zoom;
    }

    body.zoom-mode-active .flipbook.mobile-linear {
        overflow-x: auto;
    }

    body.zoom-mode-active .flipbook * {
        touch-action: auto;
    }

    .flipbook.mobile-linear {
        height: auto;
        min-height: 0;
        max-height: none;
    }
}

body.embed-mode .page-turn-hints,
body.front-mode .page-turn-hints {
    display: none;
}