:root {
    --blue: #275F99;
    --blue-soft: #eaf1f8;
    --blue-deep: #1d4a78;
    --text: #2a3b4d;
    --muted: #6b7c89;
    --line: #d7e2ec;
    --bg: #ffffff;
    --surface: #f5f8fb;
    --font: "Open Sans", "Lato", sans-serif;
    --display: "Ubuntu", "Open Sans", sans-serif;
}

* { box-sizing: border-box; }

.catalog-page {
    position: relative;
    width: min(1180px, calc(100% - 2rem));
    margin: 1.4rem auto 2.6rem;
}

.catalog-page button,
.catalog-page input { font: inherit; color: inherit; }
.catalog-page button { cursor: pointer; }

.full {
    position: absolute;
    top: .75rem;
    right: .75rem;
    z-index: 6;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--blue);
    touch-action: manipulation;
}

.full:hover { background: var(--blue-soft); }
.full svg { width: 20px; height: 20px; }
.full__exit { display: none; }
.full.is-on .full__enter { display: none; }
.full.is-on .full__exit { display: block; }

.stage {
    position: relative;
    min-width: 0;
    height: min(68vh, 760px);
    min-height: 460px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    overflow: hidden;
}

.busy {
    margin: 0;
    color: var(--muted);
    font-size: 1rem;
}

.busy[hidden] { display: none; }

.flip-wrap {
    position: relative;
    width: min(1180px, 100%);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flip-host { width: 100%; height: 100%; }

.sheet .page-frame { width: 100%; height: 100%; }

.page-frame { position: relative; line-height: 0; }

.page-frame > img,
.thumbs img { max-width: none; }

.page-frame > img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: fill;
    pointer-events: none;
    background: #fff;
}

.links { position: absolute; inset: 0; z-index: 3; }

.pdf-link { position: absolute; cursor: pointer; }

.pdf-link:hover,
.pdf-link:focus-visible {
    outline: 2px solid rgba(39, 95, 153, .75);
    background: rgba(39, 95, 153, .12);
    outline-offset: -2px;
}

.toc {
    display: flex;
    align-items: baseline;
    gap: .65rem;
    min-width: 0;
    padding: .55rem 1rem;
    background: #fff;
    border-top: 1px solid var(--line);
}

.toc[hidden] { display: none; }

.toc__label {
    flex: 0 0 auto;
    color: var(--blue);
    font-family: var(--display);
    font-size: .92rem;
    line-height: 1.2;
}

.toc__track {
    display: flex;
    align-items: baseline;
    gap: .35rem;
    min-width: 0;
    overflow-x: auto;
}

.toc__track button {
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    padding: 0 .1rem;
    color: var(--text);
    font-size: .92rem;
    line-height: 1.2;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}

.toc__track button:hover { color: var(--blue); }
.toc__track button.is-on {
    color: var(--blue);
    font-weight: 600;
    border-bottom-color: var(--blue);
}

.toc__sep { flex: 0 0 auto; color: var(--muted); }

.tools {
    display: flex;
    align-items: center;
    gap: .8rem;
    min-width: 0;
    max-width: 100%;
    padding: .55rem 1rem .7rem;
    background: #fff;
    border-top: 1px solid var(--line);
}

.pager {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex: 0 0 auto;
    color: var(--muted);
}

.tool {
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--blue);
    font-size: 1.15rem;
    line-height: 1;
}

.tool:hover { background: var(--blue-soft); }

.pager__label { display: flex; align-items: center; gap: .35rem; }

.pager input {
    width: 4rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: .3rem .4rem;
    text-align: center;
}

.thumbs {
    display: flex;
    gap: .4rem;
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    padding: .1rem 0;
}

.thumbs button {
    flex: 0 0 auto;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    background: transparent;
}

.thumbs button.is-on { border-color: var(--blue); }

.thumbs img {
    display: block;
    height: 52px;
    width: auto;
    border-radius: 2px;
}

.catalog-page:fullscreen,
.catalog-page.is-expanded {
    position: fixed;
    inset: 0;
    z-index: 90;
    width: 100%;
    max-width: none;
    height: 100%;
    height: 100dvh;
    margin: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    padding:
        env(safe-area-inset-top)
        env(safe-area-inset-right)
        env(safe-area-inset-bottom)
        env(safe-area-inset-left);
}

.catalog-page:fullscreen .stage,
.catalog-page.is-expanded .stage {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
}

.catalog-page:fullscreen .full,
.catalog-page.is-expanded .full {
    top: max(.75rem, env(safe-area-inset-top));
    right: max(.75rem, env(safe-area-inset-right));
}

body.catalog-expanded {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
    overflow: hidden;
}

@media (max-width: 760px) {
    .catalog-page { margin: .6rem auto 1.6rem; }
    .full { width: 44px; height: 44px; }
    .stage { height: min(62vh, 640px); min-height: 380px; }
    .thumbs { display: none; }
    .tools { justify-content: center; }
    .toc { padding: .45rem .7rem; }
    .toc__label { font-size: 14px; }
}
