*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bar-h: 44px;
}

body {
    font-family: sans-serif;
    background: #111;
}

/* ---- Layout ---- */

#viewer-container {
    background: #000;
}

#topbar,
#controls {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--bar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    background: #111;
}

#topbar {
    top: 0;
    justify-content: space-between;
    border-bottom: 1px solid #2a2a2a;
}

#controls {
    bottom: 0;
    justify-content: center;
    border-top: 1px solid #2a2a2a;
}

#page-display {
    width: 100%;
    height: 100dvh;
    padding: var(--bar-h) 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#page-display.zoomed {
    overflow: auto;
    align-items: flex-start;
}

/* ---- Fullscreen : masquer les barres ---- */

#viewer-container:fullscreen #topbar,
#viewer-container:fullscreen #controls,
#viewer-container:-webkit-full-screen #topbar,
#viewer-container:-webkit-full-screen #controls {
    display: none;
}

#viewer-container:fullscreen #page-display,
#viewer-container:-webkit-full-screen #page-display {
    padding: 0;
}

/* ---- Topbar ---- */

#btn-back {
    background: transparent;
    color: #aaa;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    white-space: nowrap;
    transition: color 0.15s;
    flex-shrink: 0;
}

#btn-back:hover {
    color: #fff;
}

#chapter-title {
    flex: 1;
    font-size: 0.9rem;
    color: #eee;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#chapter-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Boutons génériques de l'UI */
.ui-btn {
    background: #222;
    color: #eee;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
}

.ui-btn:hover:not(:disabled) {
    background: #333;
}

.ui-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

#chapter-nav button {
    padding: 4px 10px;
    font-size: 1rem;
}

#chapter-select,
#page-select {
    background: #222;
    color: #eee;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.85rem;
    cursor: pointer;
}

#btn-fullscreen {
    padding: 4px 8px;
}

#btn-read-mode {
    padding: 4px 8px;
}

/* ---- Image ---- */

#zone-prev,
#zone-next {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    z-index: 1;
}

#zone-prev {
    left: 0;
}

#zone-next {
    right: 0;
}

#page-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
    pointer-events: none;
}

/* ---- Mode vertical ---- */

#page-display.vertical {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    gap: 0;
}

#page-display.vertical #zone-prev,
#page-display.vertical #zone-next {
    display: none;
}

#page-display.vertical #page-img {
    display: none;
    /* remplacé par #strip */
}

#strip {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#page-display.vertical #strip {
    display: flex;
}

#strip img {
    width: 100%;
    max-width: 800px;
    height: auto;
    display: block;
    user-select: none;
    pointer-events: none;
}

/* ---- Bottom controls ---- */

#page-counter {
    font-size: 0.9rem;
    color: #aaa;
    min-width: 60px;
    text-align: center;
}