:root {
    --bg: #111315;
    --panel: #1b1f24;
    --panel-2: #232931;
    --line: rgba(255, 255, 255, 0.08);
    --text: #f5f7fa;
    --muted: #b7c0cc;
    --accent: #4da3ff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-height: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
}

a {
    color: inherit;
    text-decoration: none;
}

button, a {
    border: 0;
    background: var(--panel-2);
    color: var(--text);
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

button:hover, a:hover {
    filter: brightness(1.08);
}

.app {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: rgba(17, 19, 21, 0.86);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.brand strong {
    word-break: keep-all;
}

.brand .sub {
    font-size: 12px;
    color: var(--muted);
}

.controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

#pageInfo {
    min-width: 64px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.viewer-shell {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 16px;
    min-width: 0;
}

.loading {
    width: 100%;
    max-width: 960px;
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}

.viewer-wrap {
    position: relative;
    width: 100%;
    max-width: 960px;
    min-width: 0;
    min-height: 400px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.canvas-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    min-width: 0;
    padding: 10px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

#pdfCanvas {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto !important;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    touch-action: pan-x pan-y;
}

.hidden {
    display: none;
}

.tap-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20%;
    z-index: 5;
}

.tap-zone.left {
    left: 0;
}

.tap-zone.right {
    right: 0;
}

.bottombar {
    display: none;
}

@media (max-width: 768px) {
    .topbar {
        padding: 12px;
        align-items: flex-start;
        flex-direction: column;
    }

    .controls {
        width: 100%;
        justify-content: flex-start;
    }

    .viewer-shell {
        padding: 8px;
    }

    .viewer-wrap {
        min-height: 280px;
    }

    .canvas-container {
        padding: 8px;
    }

    .tap-zone {
        width: 28%;
    }

    .bottombar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 12px;
        position: sticky;
        bottom: 0;
        background: rgba(17, 19, 21, 0.92);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--line);
    }

    .bottombar button {
        padding: 14px;
        font-size: 15px;
    }
}