:root {
    --bg: #12151c;
    --bg-soft: #161a23;
    --surface: #1f2430;
    --surface-hover: #2a3040;
    --border: #2a3040;
    --text: #e8eaf0;
    --text-dim: #9aa3b2;
    --accent: #6ea8ff;
    --danger: #ff6b6b;
}
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    text-align: center;
    margin: 0;
    padding: 24px 16px 40px;
    background: radial-gradient(1200px 600px at 50% -10%, var(--bg-soft), var(--bg));
    color: var(--text);
    min-height: 100vh;
}
#flipbook-container {
    width: min(90vw, 700px);
    margin: 24px auto;
    position: relative;
}
#flipbook {
    width: 100%;
    position: relative;
    touch-action: none;
}
.photo {
    width: 100%;
    display: none;
    transition: transform 0.2s ease;
    border-radius: 10px;
}
.photo.active {
    display: block;
    box-shadow: 0 0 45px rgba(255,255,255,0.10), 0 0 16px rgba(255,255,255,0.06);
    animation: fadeIn 0.35s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
#progress-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: transparent;
    z-index: 1000;
}
#progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #8b7bff);
    transition: width 0.1s ease;
}
#controls {
    margin: 18px auto;
    max-width: min(92vw, 700px);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
}
button {
    padding: 11px 18px;
    margin: 0;
    cursor: pointer;
    border: 1px solid var(--border);
    border-radius: 999px;
    background-color: var(--surface);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    line-height: 1.2;
    touch-action: manipulation;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
button:hover {
    background-color: var(--surface-hover);
    border-color: #3a4155;
}
button:active {
    transform: scale(0.96);
}
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
body.controls-hidden .action-btn {
    display: none;
}
body.controls-hidden {
    padding-top: 8px;
}
body.controls-hidden #flipbook-container {
    width: min(96vw, 1400px);
}
.btn-icon {
    font-size: 18px;
    padding: 11px 14px;
    line-height: 1;
}
.btn-danger {
    background-color: rgba(255, 107, 107, 0.12);
    border-color: rgba(255, 107, 107, 0.35);
    color: var(--danger);
}
.btn-danger:hover {
    background-color: rgba(255, 107, 107, 0.22);
    border-color: var(--danger);
}
.btn-active {
    background-color: rgba(110, 168, 255, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}
#counter {
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
    padding: 8px 6px;
}
#loading {
    margin: 32px 20px;
    font-style: italic;
    color: var(--text-dim);
}
#grid-view {
    display: none;
    width: min(90vw, 700px);
    margin: 24px auto;
    padding: 12px 0;
}
.grid-item {
    width: min(110px, 22vw);
    height: min(110px, 22vw);
    object-fit: cover;
    margin: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 8px;
    touch-action: manipulation;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.grid-item:hover {
    border-color: var(--accent);
    transform: scale(1.03);
}
@media (max-width: 480px) {
    body {
        padding: 16px 8px 32px;
    }
    h1 {
        font-size: 18px;
    }
    #flipbook-container {
        width: 96vw;
        margin: 14px auto;
    }
    button {
        padding: 15px 16px;
        font-size: 16px;
        flex: 1 1 30%;
    }
    .btn-icon {
        font-size: 20px;
        padding: 13px 16px;
    }
    #controls {
        gap: 7px;
    }
    #counter {
        font-size: 16px;
        flex-basis: 100%;
    }
    #loading {
        font-size: 16px;
    }
    .grid-item {
        width: 24vw;
        height: 24vw;
        margin: 3px;
    }
}
