* {
    box-sizing: border-box;
}

:root {
    color-scheme: dark;
    --ink: #f4eee3;
    --muted-ink: #b9ad9d;
    --gold: #c8a976;
}

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 44%, #51443a 0, #302923 43%, #191715 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

#viewer {
    width: min(100%, 1600px);
    min-height: 100vh;
    display: grid;
    grid-template-rows: 68px 1fr 86px;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(15, 14, 13, 0.38), transparent 20%, transparent 78%, rgba(15, 14, 13, 0.32));
}

.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 28px;
    background: rgba(15, 14, 13, 0.62);
    border-bottom: 1px solid rgba(231, 213, 185, 0.12);
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(200, 169, 118, 0.45);
    border-radius: 10px;
    color: var(--gold);
    background: rgba(200, 169, 118, 0.1);
}

.brand-mark svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
}

.brand-copy {
    display: grid;
    gap: 2px;
}

.viewer-title {
    color: #f2eadc;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 16px;
    letter-spacing: 0.025em;
}

.viewer-subtitle {
    color: #a99c8b;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

#status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted-ink);
    font-size: 12px;
}

#status::before {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 10px rgba(200, 169, 118, 0.65);
    content: "";
}

#stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 32px 56px 54px;
    overflow: auto;
    background:
        radial-gradient(ellipse at 50% 48%, rgba(207, 174, 126, 0.105), transparent 52%),
        repeating-linear-gradient(90deg, transparent 0, transparent 79px, rgba(255, 255, 255, 0.012) 80px);
}

#book {
    margin: auto;
    filter: drop-shadow(0 28px 28px rgba(0, 0, 0, 0.48));
    isolation: isolate;
}

#book::before {
    content: "";
    position: absolute;
    inset: 6px -7px -7px 6px;
    z-index: -1;
    border: 1px solid rgba(90, 73, 52, 0.3);
    border-radius: 2px 3px 4px 2px;
    background: repeating-linear-gradient(to bottom, #e7dfcf 0, #e7dfcf 1px, #bcb09b 2px, #f1eadc 3px);
    pointer-events: none;
}

.page {
    position: relative;
    background: #f8f4eb;
    overflow: hidden;
    border: 1px solid rgba(96, 76, 51, 0.18);
    box-shadow: inset 0 0 16px rgba(82, 62, 40, 0.1);
}

.page canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.pdf-link-layer {
    position: absolute;
    z-index: 2;
    inset: 0;
    pointer-events: none;
}

.pdf-link {
    position: absolute;
    display: block;
    border-radius: 3px;
    pointer-events: auto;
    cursor: pointer;
    transition: background-color 120ms ease, box-shadow 120ms ease;
}

.pdf-link:hover,
.pdf-link:focus-visible {
    background: rgba(197, 153, 82, 0.16);
    box-shadow: 0 0 0 1px rgba(151, 105, 39, 0.28);
    outline: none;
}

.toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    min-height: 86px;
    padding: 12px 20px 18px;
    color: #e8dfd1;
    background: linear-gradient(180deg, rgba(16, 15, 14, 0), rgba(16, 15, 14, 0.48));
}

.toolbar button {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 9px;
    color: inherit;
    background: transparent;
    font: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.toolbar button:hover,
.toolbar button:focus-visible {
    color: #f5d7a3;
    background: rgba(200, 169, 118, 0.12);
    border-color: rgba(200, 169, 118, 0.24);
    outline: none;
}

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

.toolbar button[aria-pressed="false"] {
    color: #81796e;
}

.toolbar button svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.55;
}

.toolbar-divider {
    width: 1px;
    height: 22px;
    margin: 0 8px;
    background: rgba(234, 221, 202, 0.18);
}

#counter {
    min-width: 72px;
    padding: 0 8px;
    color: #d9cbb6;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-align: center;
}

.stage-hint {
    position: absolute;
    bottom: 19px;
    left: 50%;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: rgba(220, 208, 190, 0.55);
    font-size: 11px;
    letter-spacing: 0.035em;
    transform: translateX(-50%);
    white-space: nowrap;
    pointer-events: none;
}

.stage-hint svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
}

@media (max-width: 620px) {
    #viewer {
        grid-template-rows: 60px 1fr 76px;
    }

    #stage {
        padding: 18px 8px 54px;
    }

    .viewer-header {
        padding: 0 14px;
    }

    .viewer-subtitle {
        font-size: 9px;
    }

    #status {
        font-size: 11px;
    }

    .toolbar {
        gap: 1px;
        min-height: 76px;
        padding: 8px 6px 12px;
    }

    .toolbar button {
        width: 35px;
        height: 38px;
    }

    .toolbar-divider {
        margin: 0 3px;
    }

    #counter {
        min-width: 56px;
        padding: 0 3px;
        font-size: 11px;
    }

    .stage-hint {
        bottom: 16px;
        font-size: 10px;
    }
}
