:root {
    --brand-red: #f53132;
    --brand-blue: #355bf4;
    --peek-w: 48px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: radial-gradient(circle at top, #2a2930 0%, #141316 55%, #0d0c0e 100%);
    color: #fff;
    font-family: Manrope, Arial, sans-serif;
    overflow: hidden;
}

body.catalog-viewer-body {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    height: 100dvh;
}

.viewer-toolbar {
    flex: 0 0 auto;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(10, 10, 12, .92);
    border-bottom: 1px solid rgba(255,255,255,.08);
    position: relative;
    z-index: 5;
}

.viewer-toolbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
}

.viewer-toolbar-brand a.brand-mark {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    text-decoration: none;
    opacity: .92;
}

.viewer-toolbar-brand a.brand-mark:hover { opacity: 1; }

.viewer-toolbar-brand a.brand-mark img {
    display: block;
    height: 22px;
    width: auto;
    max-width: 88px;
    object-fit: contain;
}

.viewer-toolbar-brand a.brand-mark span {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .02em;
}

.viewer-toolbar h1 {
    font-size: 15px;
    margin: 0;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.viewer-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.page-info {
    min-width: 4.25rem;
    padding: 0 4px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #ddd;
    font-variant-numeric: tabular-nums;
}

.icon-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,.08);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    flex: 0 0 44px;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    display: block;
    pointer-events: none;
}

.icon-btn:hover,
.icon-btn:focus-visible {
    background: rgba(255,255,255,.16);
    color: #fff;
    outline: none;
}

.icon-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.icon-btn.primary { background: var(--brand-red); }
.icon-btn.primary:hover,
.icon-btn.primary:focus-visible { background: #d42829; }

.icon-btn.secondary { background: var(--brand-blue); }
.icon-btn.secondary:hover,
.icon-btn.secondary:focus-visible { background: #2a4ad4; }

.viewer-stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 10px 8px;
    overflow: hidden;
}

.stage-book {
    display: flex;
    align-items: stretch;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
    min-width: 0;
}

#book {
    margin: 0;
    flex: 0 0 auto;
    max-width: 100%;
}

.stf__parent {
    margin: 0 auto !important;
}

.catalog-page {
    background: #f2f2f2;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.catalog-page img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
    user-select: none;
    background: #fff;
}

.page-peek {
    appearance: none;
    border: 0;
    padding: 0;
    margin: 0;
    width: var(--peek-w);
    flex: 0 0 var(--peek-w);
    overflow: hidden;
    background: rgba(255,255,255,.04);
    cursor: pointer;
    position: relative;
    border-radius: 2px;
    opacity: .72;
}

.page-peek[hidden] { display: none !important; }

.page-peek:hover,
.page-peek:focus-visible {
    opacity: 1;
    outline: none;
}

.page-peek img {
    height: 100%;
    width: auto;
    max-width: none;
    display: block;
    pointer-events: none;
    user-select: none;
}

.page-peek--prev img {
    margin-left: auto;
    margin-right: 0;
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
}

.page-peek--next img {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
}

.stage-badge {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(10, 10, 12, .55);
    border: 1px solid rgba(255,255,255,.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    text-decoration: none;
    color: rgba(255,255,255,.88);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
    opacity: .78;
    max-width: min(90vw, 320px);
}

.stage-badge:hover {
    opacity: 1;
    background: rgba(10, 10, 12, .78);
    color: #fff;
    text-decoration: none;
}

.stage-badge img {
    height: 16px;
    width: auto;
    max-width: 64px;
    object-fit: contain;
    display: block;
}

.stage-badge .badge-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(20,19,22,.88);
    font-weight: 700;
    z-index: 6;
}

.loading.hidden { display: none; }

.progress {
    width: min(360px, 80vw);
    height: 8px;
    background: #333;
    border-radius: 999px;
    overflow: hidden;
}

.progress > span {
    display: block;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #f53132, #355bf4);
    transition: width .15s linear;
}

.viewer-thumbs {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    padding: 8px 12px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    background: rgba(10, 10, 12, .72);
    border-top: 1px solid rgba(255,255,255,.06);
}

.viewer-thumbs button {
    appearance: none;
    border: 2px solid transparent;
    background: #1c1b20;
    padding: 0;
    border-radius: 6px;
    overflow: hidden;
    width: 44px;
    height: 58px;
    flex: 0 0 auto;
    cursor: pointer;
}

.viewer-thumbs button.is-active {
    border-color: var(--brand-red);
}

.viewer-thumbs button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.viewer-promo {
    flex: 0 0 auto;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 6px 12px;
    background: linear-gradient(90deg, rgba(245,49,50,.18), rgba(53,91,244,.22));
    border-top: 1px solid rgba(255,255,255,.1);
    position: relative;
    z-index: 5;
}

.viewer-promo a {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    max-width: 100%;
}

.viewer-promo a:hover { text-decoration: none; opacity: .92; }

.viewer-promo a img {
    height: 18px;
    width: auto;
    max-width: 72px;
    object-fit: contain;
    display: block;
    opacity: .95;
}

.viewer-promo .promo-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--brand-red);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.viewer-promo .promo-copy {
    opacity: .92;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 900px) {
    .viewer-toolbar h1 { display: none; }
    .stage-badge { display: none; }
    .viewer-promo .promo-copy { display: none; }
    .icon-btn {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
        border-radius: 12px;
    }
}

@media (max-width: 480px) {
    .page-info { min-width: 3.5rem; font-size: 11px; }
    .viewer-toolbar { padding: 4px 6px; gap: 4px; }
    .viewer-thumbs button {
        width: 40px;
        height: 52px;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .viewer-promo { display: none; }
    .viewer-thumbs { display: none; }
    .stage-badge { display: none; }
    .icon-btn {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }
}
