:root {
    --topbar-height: 52px;
    --counter-height: 10px;
}

body {
    margin: 0;
    background: #111;
    color: white;
    font-family: sans-serif;
}

.topbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;

    height: var(--topbar-height);
    box-sizing: border-box;

    padding: 6px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);

    position: sticky;
    top: 0;
    z-index: 10;
}

/* shared button base */
.iconBtn {
    background: transparent;
    border: none;

    cursor: pointer;

    padding: 6px;

    display: flex;
    align-items: center;
    justify-content: center;

    transition: transform 0.15s ease, opacity 0.15s ease;
}

/* IMAGE MODE */
.iconBtn img {
    height: 40px;   /* your target size */
    width: auto;
    display: block;
}

/* TEXT FALLBACK MODE */
.iconBtn .fallback {
    display: none;

    color: white;
    font-size: 16px;

    padding: 6px 12px;
    border: 1px solid #444;
    border-radius: 10px;

    background: #222;
}

/* if image is missing OR hidden → show text */
.iconBtn img[style*="display: none"] + .fallback {
    display: inline-block;
}

/* hover effects work for both modes */
.iconBtn:hover {
    transform: scale(1.08);
}

.iconBtn:active {
    transform: scale(0.95);
    opacity: 0.7;
}

/* SPECIAL STYLE FOR DOWNLOAD */
#downloadBtn .fallback {
    border-color: #6b4eff;
}

#downloadBtn .fallback:hover {
    background: #6b4eff;
}

.viewer {
    display: flex;
    justify-content: center;
    align-items: center;

    width: 100vw;

    /* exact remaining screen height */
    height: calc(100vh - var(--topbar-height) - var(--counter-height));

    overflow: hidden;

    gap: 0;
}

.page {
    display: block;

    width: auto;
    height: auto;

    /* THIS is the important part */
    max-width: 45%;
    max-height: 95%;
    padding-bottom: 40px;
    margin-bottom: 40px;

    object-fit: contain;

    margin: 0;
    padding: 0;

    transition: opacity .1s ease-in;
}
/* ALWAYS reserve space */
#rightPage {
    visibility: hidden;
    box-shadow: 20px 0 20px rgba(0,0,0,0.4);
}

#leftPage {
    box-shadow: -20px 0 20px rgba(0,0,0,0.4);
}

#pageCounter {

    width: 100%;

    text-align: center;
    height: var(--counter-height);
    margin-top: 2px;
    margin-bottom: 2px;

    color: rgba(255,255,255,0.45);

    font-size: 6px;
    letter-spacing: 0.08em;

    user-select: none;
}

/* MOBILE MODE */
@media (max-width: 800px) {

  .viewer {
    flex-direction: column;
    overflow-y: auto;
  }

  .page {
    max-width: 95%;
    max-height: none;
  }

}