:root {
    --bg-0: #0f141a;
    --bg-1: #1f2833;
    --bg-2: #2e3d4d;
    --line: rgba(255, 255, 255, 0.16);
    --paper: #f5f1e8;
    --text: #f7f8fa;
    --accent: #d7c2a3;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Manrope", sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 800px at 85% 15%, rgba(215, 194, 163, 0.12), transparent 70%),
        radial-gradient(1000px 600px at 10% 90%, rgba(90, 148, 140, 0.15), transparent 70%),
        linear-gradient(140deg, var(--bg-0), var(--bg-1) 55%, var(--bg-2));
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(8, 12, 16, 0.72);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.toolbar-center input {
    width: 88px;
}

.page-counter {
    font-weight: 700;
    letter-spacing: 0.03em;
}

.flipbook-stage {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.book-wrap {
    width: 100%;
    max-width: 1600px;
    height: calc(100vh - 96px);
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(15, 20, 26, 0.38);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flipbook {
    width: 100%;
    height: 100%;
}

.page {
    background: var(--paper);
    display: flex;
    align-items: center;
    justify-content: center;
}

.page img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.status-box,
.error-box {
    position: absolute;
    inset: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(10, 12, 16, 0.78);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.8rem 1rem;
}

.error-box {
    max-width: min(92vw, 740px);
    color: #ffd4d4;
}

.thumb-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.6rem;
}

.thumb-item {
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    border-radius: 10px;
    padding: 0.4rem;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.thumb-item:hover {
    transform: translateY(-1px);
}

.thumb-item.active {
    border-color: #346f66;
    box-shadow: 0 0 0 2px rgba(52, 111, 102, 0.2);
}

.thumb-item img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}

.thumb-label {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: #3c454f;
    text-align: center;
}

@media (max-width: 992px) {
    .toolbar {
        grid-template-columns: 1fr;
        justify-items: start;
    }

    .book-wrap {
        height: calc(100vh - 152px);
    }

    .toolbar-center {
        width: 100%;
    }
}
