:root {
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --success: #22c55e;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --card-radius: 16px;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Layout */
.app-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 20px;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

/* Sidebar / Control Panel */
.control-panel {
    width: 320px;
    min-width: 320px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.control-panel header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.subtitle {
    margin: 5px 0 20px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.file-name {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin: 20px 0;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: bold;
    margin-top: 5px;
}

.success-text {
    color: var(--success);
}

.danger-text {
    color: var(--danger);
}

.muted-text {
    color: var(--text-muted);
}

.divider {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
    width: 100%;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.full-width {
    width: 100%;
}

.primary {
    background: var(--primary);
    color: white;
}

.primary-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.primary-outline:hover {
    background: rgba(59, 130, 246, 0.1);
}

.success {
    background: var(--success);
    color: #000;
}

.danger {
    background: var(--danger);
    color: white;
}

.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.big-btn {
    height: 60px;
    font-size: 1.1rem;
}

/* Toggle Switch */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #475569;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(18px);
}

/* Navigation */
.nav-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px;
    border-radius: 8px;
}

#pageIndicator {
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
}

/* Viewer */
.viewer-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: auto;
}

.canvas-container {
    position: relative;
    padding: 0;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

canvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

#introMessage {
    color: var(--text-muted);
    font-size: 1.2rem;
    text-align: center;
    padding: 20px;
}

.hidden {
    display: none !important;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(239, 68, 68, 0.25);
    /* Red tint */
    border: 4px solid var(--danger);
    border-radius: var(--card-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    /* Let clicks pass through */
}

.overlay.hidden {
    display: none !important;
}

.overlay span {
    font-size: 4rem;
    font-weight: 900;
    color: white;
    transform: rotate(-15deg);
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    border: 5px solid white;
    padding: 10px 40px;
    border-radius: 10px;
}

.kb-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 20px;
    line-height: 1.5;
}

.disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Mobile Responsive */
@media (max-width: 900px) {
    .app-wrapper {
        flex-direction: column;
        padding: 10px;
        overflow-y: auto;
    }

    .control-panel {
        width: 100%;
        min-width: 0;
        max-height: 400px;
        flex-shrink: 0;
    }

    .viewer-area {
        min-height: 400px;
    }

    .stats-grid {
        margin: 10px 0;
    }

    .overlay span {
        font-size: 2rem;
    }
}