/* ========================================
   PDF Toolkit Pro — Design System v2
   ======================================== */

:root {
    /* Dark theme (default) */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.06);
    --bg-input: rgba(255, 255, 255, 0.05);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-active: rgba(255, 255, 255, 0.12);
    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-muted: #55556a;
    --shadow-base: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 40px rgba(124, 58, 237, 0.15);
    --overlay: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] {
    --bg-primary: #f5f5fa;
    --bg-secondary: #ffffff;
    --bg-card: rgba(0, 0, 0, 0.02);
    --bg-card-hover: rgba(0, 0, 0, 0.04);
    --bg-input: rgba(0, 0, 0, 0.04);
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-active: rgba(0, 0, 0, 0.15);
    --text-primary: #1a1a2e;
    --text-secondary: #666680;
    --text-muted: #999aad;
    --shadow-base: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 40px rgba(124, 58, 237, 0.08);
    --overlay: rgba(255, 255, 255, 0.6);
}

:root {
    /* Accent colors (theme-independent) */
    --accent-green: #34d399;
    --accent-green-dim: rgba(52, 211, 153, 0.1);
    --accent-green-glow: rgba(52, 211, 153, 0.15);
    --accent-blue: #60a5fa;
    --accent-blue-dim: rgba(96, 165, 250, 0.1);
    --accent-blue-glow: rgba(96, 165, 250, 0.15);
    --accent-red: #f472b6;
    --accent-red-dim: rgba(244, 114, 182, 0.1);
    --accent-red-glow: rgba(244, 114, 182, 0.15);
    --accent-purple: #a78bfa;
    --accent-purple-dim: rgba(167, 139, 250, 0.1);
    --accent-purple-glow: rgba(167, 139, 250, 0.15);
    --accent-orange: #fb923c;
    --gradient-primary: linear-gradient(135deg, #a78bfa, #60a5fa, #34d399);
    --gradient-btn: linear-gradient(135deg, #7c3aed, #6366f1, #818cf8);
    --gradient-btn-hover: linear-gradient(135deg, #6d28d9, #4f46e5, #6366f1);
    --danger: #ef4444;
    --danger-dim: rgba(239, 68, 68, 0.1);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* ========================================
   Reset & Base
   ======================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    transition: background var(--transition-base), color var(--transition-base);
}

/* ========================================
   Background Orbs
   ======================================== */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.4; animation: orb-float 20s ease-in-out infinite; }
[data-theme="light"] .orb { opacity: 0.25; }
.orb-1 { width: 500px; height: 500px; background: radial-gradient(circle, rgba(124,58,237,0.15), transparent 70%); top: -150px; left: -100px; }
.orb-2 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(96,165,250,0.12), transparent 70%); top: 50%; right: -100px; animation-delay: -7s; animation-duration: 25s; }
.orb-3 { width: 350px; height: 350px; background: radial-gradient(circle, rgba(52,211,153,0.1), transparent 70%); bottom: -100px; left: 30%; animation-delay: -14s; animation-duration: 22s; }
@keyframes orb-float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(40px, 30px) scale(1.02); }
}

/* ========================================
   Header
   ======================================== */
#app-header {
    position: relative; z-index: 10;
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-md) var(--space-xl);
    max-width: 1300px; margin: 0 auto;
    flex-wrap: wrap; gap: var(--space-md);
}
.header-left { display: flex; align-items: center; gap: var(--space-xl); flex-wrap: wrap; }
.header-right { display: flex; align-items: center; gap: var(--space-md); }
.logo { display: flex; align-items: center; gap: var(--space-sm); }
.logo-icon {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: var(--radius-md);
    background: var(--gradient-btn); color: white;
    box-shadow: 0 4px 16px rgba(124,58,237,0.3);
}
.logo-text { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
.logo-pro {
    font-size: 0.6rem; font-weight: 800; padding: 2px 5px;
    background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    border: 1px solid rgba(167,139,250,0.3); border-radius: var(--radius-sm);
    vertical-align: super; letter-spacing: 0.08em;
}

/* Navigation Tabs */
.main-nav { display: flex; gap: 2px; background: var(--bg-card); border-radius: var(--radius-md); padding: 3px; border: 1px solid var(--border-subtle); }
.nav-tab {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: none; background: transparent;
    color: var(--text-secondary); font-family: inherit; font-size: 0.82rem; font-weight: 500;
    border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition-fast);
    white-space: nowrap;
}
.nav-tab:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.nav-tab.active { color: var(--text-primary); background: var(--gradient-btn); color: white; box-shadow: 0 2px 8px rgba(124,58,237,0.25); }

/* Theme Toggle */
.theme-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: var(--radius-md);
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    color: var(--text-secondary); cursor: pointer; transition: all var(--transition-fast);
}
.theme-toggle:hover { color: var(--text-primary); border-color: var(--border-active); background: var(--bg-card-hover); }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Header Badge */
.header-badge {
    display: flex; align-items: center; gap: var(--space-sm);
    padding: 6px 14px; background: var(--accent-green-dim);
    border: 1px solid rgba(52,211,153,0.15); border-radius: var(--radius-full);
    font-size: 0.75rem; font-weight: 500; color: var(--accent-green);
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-green); animation: pulse-dot 2s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(0.8); } }

/* ========================================
   Main Content
   ======================================== */
#app-main { position: relative; z-index: 10; max-width: 1100px; margin: 0 auto; padding: var(--space-md) var(--space-xl) var(--space-3xl); }
.tool-panel { display: none; }
.tool-panel.active { display: block; animation: fadeInUp 0.4s ease; }
.step { display: none; }
.step.active { display: block; animation: fadeInUp 0.4s ease; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* ========================================
   Hero Text
   ======================================== */
.hero-text { text-align: center; margin-bottom: var(--space-2xl); }
.hero-text h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; margin-bottom: var(--space-sm); }
.gradient-text { background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.subtitle { font-size: 1rem; color: var(--text-secondary); max-width: 520px; margin: 0 auto; line-height: 1.6; }

/* ========================================
   Drop Zone
   ======================================== */
.drop-zone {
    position: relative; border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-xl); padding: var(--space-3xl) var(--space-xl);
    text-align: center; cursor: pointer; transition: all var(--transition-base);
    background: var(--bg-card); backdrop-filter: blur(12px); overflow: hidden;
}
.drop-zone::before { content: ''; position: absolute; inset: 0; border-radius: var(--radius-xl); background: radial-gradient(ellipse at center, rgba(124,58,237,0.04), transparent 70%); pointer-events: none; }
.drop-zone:hover, .drop-zone:focus-visible { border-color: rgba(124,58,237,0.3); background: var(--bg-card-hover); box-shadow: var(--shadow-glow); }
.drop-zone.drag-over { border-color: rgba(124,58,237,0.5); background: rgba(124,58,237,0.06); box-shadow: 0 0 60px rgba(124,58,237,0.2); transform: scale(1.01); }
.drop-zone:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 2px; }
.upload-icon-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; margin-bottom: var(--space-lg); }
.upload-icon-ring { position: absolute; width: 96px; height: 96px; border-radius: 50%; border: 2px solid rgba(124,58,237,0.15); animation: ring-pulse 3s ease-in-out infinite; }
@keyframes ring-pulse { 0%, 100% { transform: scale(1); opacity: 0.5; } 50% { transform: scale(1.15); opacity: 0; } }
.upload-icon { color: var(--accent-purple); animation: float-icon 3s ease-in-out infinite; }
@keyframes float-icon { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.drop-title { font-size: 1.15rem; font-weight: 600; margin-bottom: var(--space-xs); }
.drop-subtitle { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: var(--space-lg); }
.file-types { display: flex; align-items: center; justify-content: center; gap: var(--space-md); }
.file-badge { padding: 4px 12px; background: rgba(124,58,237,0.1); border: 1px solid rgba(124,58,237,0.2); border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 600; color: var(--accent-purple); letter-spacing: 0.05em; }
.file-badge-new { background: var(--accent-green-dim); border-color: rgba(52,211,153,0.2); color: var(--accent-green); }
.size-limit { font-size: 0.78rem; color: var(--text-muted); }

/* ========================================
   File Queue
   ======================================== */
.file-queue-container { margin-bottom: var(--space-xl); background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); backdrop-filter: blur(12px); overflow: hidden; }
.file-queue-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--border-subtle); flex-wrap: wrap; gap: var(--space-sm); }
.queue-title { display: flex; align-items: center; gap: var(--space-sm); font-size: 0.95rem; font-weight: 600; }
.queue-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; background: var(--gradient-btn); color: white; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 700; }
.queue-actions { display: flex; gap: var(--space-sm); }
.file-queue-list { max-height: 220px; overflow-y: auto; }
.file-queue-list::-webkit-scrollbar { width: 4px; }
.file-queue-list::-webkit-scrollbar-track { background: transparent; }
.file-queue-list::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: var(--radius-full); }
.queue-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
    cursor: pointer;
}
.queue-item:hover { background: var(--bg-card-hover); }
.queue-item.active { background: var(--accent-purple-dim); border-left: 3px solid var(--accent-purple); }
.queue-item:last-child { border-bottom: none; }
.queue-item-left { display: flex; align-items: center; gap: var(--space-md); min-width: 0; }
.queue-item-icon { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--accent-purple-dim); color: var(--accent-purple); flex-shrink: 0; }
.queue-item-name { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.queue-item-size { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }
.queue-item-remove {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    background: transparent; border: none; color: var(--text-muted);
    cursor: pointer; transition: all var(--transition-fast); flex-shrink: 0;
}
.queue-item-remove:hover { background: var(--danger-dim); color: var(--danger); }

/* ========================================
   Preview Panel
   ======================================== */
.preview-panel {
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); padding: var(--space-lg);
    margin-bottom: var(--space-xl); backdrop-filter: blur(12px);
}
.preview-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-md); }
.preview-title { display: flex; align-items: center; gap: var(--space-sm); font-size: 0.92rem; font-weight: 600; }
.preview-nav { display: flex; align-items: center; gap: var(--space-sm); }
.page-indicator { font-size: 0.82rem; color: var(--text-secondary); font-weight: 500; min-width: 50px; text-align: center; }
.btn-icon {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    background: var(--bg-input); border: 1px solid var(--border-subtle);
    color: var(--text-secondary); cursor: pointer; transition: all var(--transition-fast);
}
.btn-icon:hover { color: var(--text-primary); border-color: var(--border-active); }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }

.preview-canvas-wrap {
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.15); border-radius: var(--radius-md);
    min-height: 280px; margin-bottom: var(--space-md); overflow: hidden;
    position: relative;
}
[data-theme="light"] .preview-canvas-wrap { background: rgba(0,0,0,0.04); }
#preview-canvas { max-width: 100%; max-height: 350px; border-radius: var(--radius-sm); }

/* Page Thumbnails */
.page-thumbnails {
    display: flex; gap: var(--space-sm); overflow-x: auto;
    padding: var(--space-sm) 0; margin-bottom: var(--space-md);
}
.page-thumbnails::-webkit-scrollbar { height: 4px; }
.page-thumbnails::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: var(--radius-full); }
.page-thumb {
    position: relative; flex-shrink: 0; width: 56px; height: 72px;
    border-radius: var(--radius-sm); overflow: hidden;
    border: 2px solid transparent; cursor: pointer;
    transition: all var(--transition-fast); background: rgba(0,0,0,0.1);
}
.page-thumb canvas { width: 100%; height: 100%; object-fit: cover; }
.page-thumb.active { border-color: var(--accent-purple); box-shadow: 0 0 8px var(--accent-purple-glow); }
.page-thumb-label { position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); font-size: 0.6rem; font-weight: 600; color: white; background: rgba(0,0,0,0.6); padding: 1px 4px; border-radius: 3px; }
.page-thumb-check {
    position: absolute; top: 2px; right: 2px;
    width: 16px; height: 16px; border-radius: 3px;
    background: var(--accent-green); display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity var(--transition-fast);
}
.page-thumb-check svg { width: 10px; height: 10px; color: white; }
.page-thumb.selected .page-thumb-check { opacity: 1; }
.page-thumb.deselected { opacity: 0.4; }

/* Page Select Bar */
.page-select-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-sm) 0; margin-bottom: var(--space-md);
    border-top: 1px solid var(--border-subtle); padding-top: var(--space-md);
}
.checkbox-wrap { display: flex; align-items: center; gap: var(--space-sm); cursor: pointer; font-size: 0.85rem; font-weight: 500; }
.checkbox-wrap input[type="checkbox"] { display: none; }
.checkmark {
    width: 18px; height: 18px; border-radius: 4px;
    border: 2px solid var(--border-active); display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast);
}
.checkbox-wrap input:checked + .checkmark { background: var(--accent-purple); border-color: var(--accent-purple); }
.checkbox-wrap input:checked + .checkmark::after { content: '✓'; color: white; font-size: 0.7rem; font-weight: 700; }
.selected-pages-count { font-size: 0.78rem; color: var(--text-muted); }

/* PDF Info Grid */
.pdf-info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-sm); }
.pdf-info-item { text-align: center; padding: var(--space-sm); background: var(--bg-input); border-radius: var(--radius-sm); }
.info-label { display: block; font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.info-value { display: block; font-size: 0.82rem; font-weight: 600; }

/* ========================================
   Section Title
   ======================================== */
.section-title { text-align: center; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: var(--space-lg); }

/* ========================================
   Compression Cards
   ======================================== */
.compression-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-md); margin-bottom: var(--space-xl); }
.comp-card {
    position: relative; padding: var(--space-lg);
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); cursor: pointer;
    transition: all var(--transition-base); overflow: hidden;
    backdrop-filter: blur(12px);
}
.comp-card:hover { background: var(--bg-card-hover); border-color: var(--border-active); transform: translateY(-2px); }
.comp-card.selected { border-width: 2px; }
.comp-card.selected[data-level="low"] { border-color: var(--accent-green); box-shadow: 0 0 30px var(--accent-green-glow); }
.comp-card.selected[data-level="high"] { border-color: var(--accent-blue); box-shadow: 0 0 30px var(--accent-blue-glow); }
.comp-card.selected[data-level="extreme"] { border-color: var(--accent-red); box-shadow: 0 0 30px var(--accent-red-glow); }
.comp-card.selected[data-level="custom"] { border-color: var(--accent-purple); box-shadow: 0 0 30px var(--accent-purple-glow); }
.comp-card:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 2px; }

.card-glow { position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; opacity: 0; transition: opacity var(--transition-slow); pointer-events: none; }
.comp-card.selected .card-glow { opacity: 1; }
.card-glow-green { background: radial-gradient(circle, var(--accent-green-dim), transparent 70%); }
.card-glow-blue { background: radial-gradient(circle, var(--accent-blue-dim), transparent 70%); }
.card-glow-red { background: radial-gradient(circle, var(--accent-red-dim), transparent 70%); }
.card-glow-purple { background: radial-gradient(circle, var(--accent-purple-dim), transparent 70%); }

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-sm); position: relative; z-index: 1; }
.card-icon { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--radius-md); }
.card-icon-green { background: var(--accent-green-dim); color: var(--accent-green); }
.card-icon-blue { background: var(--accent-blue-dim); color: var(--accent-blue); }
.card-icon-red { background: var(--accent-red-dim); color: var(--accent-red); }
.card-icon-purple { background: var(--accent-purple-dim); color: var(--accent-purple); }
.card-badge { font-size: 0.65rem; font-weight: 600; padding: 3px 8px; border-radius: var(--radius-full); letter-spacing: 0.02em; }
.badge-green { background: var(--accent-green-dim); color: var(--accent-green); }
.badge-blue { background: var(--accent-blue-dim); color: var(--accent-blue); }
.badge-red { background: var(--accent-red-dim); color: var(--accent-red); }
.badge-purple { background: var(--accent-purple-dim); color: var(--accent-purple); }
.card-title { font-size: 1rem; font-weight: 700; margin-bottom: 4px; position: relative; z-index: 1; }
.card-desc { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: var(--space-md); position: relative; z-index: 1; }
.card-target { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-sm); position: relative; z-index: 1; }
.target-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; }
.target-value { font-size: 0.82rem; font-weight: 700; }
.target-green { color: var(--accent-green); }
.target-blue { color: var(--accent-blue); }
.target-red { color: var(--accent-red); }
.quality-bar { height: 4px; background: var(--bg-input); border-radius: var(--radius-full); overflow: hidden; margin-bottom: var(--space-xs); position: relative; z-index: 1; }
.quality-fill { height: 100%; border-radius: var(--radius-full); transition: width 0.6s ease; }
.quality-fill-green { background: var(--accent-green); }
.quality-fill-blue { background: var(--accent-blue); }
.quality-fill-red { background: var(--accent-red); }
.quality-label { font-size: 0.7rem; color: var(--text-muted); position: relative; z-index: 1; }

/* Custom Slider */
.custom-slider-wrap { position: relative; z-index: 1; margin-top: var(--space-sm); }
.custom-slider {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 6px; border-radius: var(--radius-full);
    background: var(--bg-input); outline: none; cursor: pointer;
}
.custom-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--gradient-btn); border: 2px solid white;
    cursor: pointer; box-shadow: 0 2px 8px rgba(124,58,237,0.3);
}
.custom-slider::-moz-range-thumb {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--gradient-btn); border: 2px solid white;
    cursor: pointer;
}
.slider-labels { display: flex; justify-content: space-between; margin-top: var(--space-xs); font-size: 0.68rem; color: var(--text-muted); }
.slider-current { font-weight: 700; color: var(--accent-purple); font-size: 0.78rem; }

/* ========================================
   Buttons
   ======================================== */
.btn-primary {
    display: flex; align-items: center; justify-content: center; gap: var(--space-sm);
    width: 100%; padding: 14px var(--space-xl);
    background: var(--gradient-btn); color: white; border: none;
    border-radius: var(--radius-lg); font-family: inherit;
    font-size: 0.95rem; font-weight: 600; cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 0 4px 20px rgba(124,58,237,0.25); position: relative; overflow: hidden;
}
.btn-primary::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent); opacity: 0; transition: opacity var(--transition-fast); }
.btn-primary:hover:not(:disabled)::before { opacity: 1; }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(124,58,237,0.35); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }
.btn-download { background: linear-gradient(135deg, #059669, #10b981, #34d399); box-shadow: 0 4px 20px rgba(52,211,153,0.2); }
.btn-download:hover:not(:disabled) { box-shadow: 0 8px 30px rgba(52,211,153,0.35); }

.btn-ghost {
    display: inline-flex; align-items: center; gap: var(--space-sm);
    padding: 8px 14px; background: transparent;
    color: var(--text-secondary); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md); font-family: inherit;
    font-size: 0.82rem; font-weight: 500; cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-active); background: var(--bg-card); }
.btn-sm { padding: 6px 10px; font-size: 0.78rem; }
.btn-danger:hover { color: var(--danger); border-color: rgba(239,68,68,0.3); background: var(--danger-dim); }

/* ========================================
   File Info Bar
   ======================================== */
.file-info-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); margin-bottom: var(--space-xl);
    backdrop-filter: blur(12px);
}
.file-info-left { display: flex; align-items: center; gap: var(--space-md); }
.file-icon-small {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: var(--accent-purple-dim); color: var(--accent-purple);
}
.file-name { font-weight: 600; font-size: 0.9rem; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 0.78rem; color: var(--text-secondary); margin-top: 1px; }

/* ========================================
   Processing
   ======================================== */
.processing-container { text-align: center; padding: var(--space-2xl) 0; }
.processing-animation { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 120px; height: 120px; margin-bottom: var(--space-xl); }
.pulse-ring { position: absolute; border-radius: 50%; border: 2px solid rgba(124,58,237,0.2); animation: pulse-expand 2s ease-out infinite; }
.pulse-ring-1 { width: 80px; height: 80px; animation-delay: 0s; }
.pulse-ring-2 { width: 80px; height: 80px; animation-delay: 0.5s; }
.pulse-ring-3 { width: 80px; height: 80px; animation-delay: 1s; }
@keyframes pulse-expand { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(2); opacity: 0; } }
.processing-icon {
    display: flex; align-items: center; justify-content: center;
    width: 72px; height: 72px; border-radius: 50%;
    background: var(--gradient-btn); color: white;
    box-shadow: 0 0 40px rgba(124,58,237,0.3); animation: spin-slow 4s linear infinite;
}
@keyframes spin-slow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.processing-title { font-size: 1.4rem; font-weight: 700; margin-bottom: var(--space-sm); }
.processing-subtitle { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: var(--space-xl); }
.progress-container { max-width: 400px; margin: 0 auto; display: flex; align-items: center; gap: var(--space-md); }
.progress-bar { flex: 1; height: 8px; background: var(--bg-input); border-radius: var(--radius-full); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--gradient-primary); border-radius: var(--radius-full); transition: width 0.3s ease; position: relative; }
.progress-fill::after { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 40px; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3)); animation: shimmer 1.5s ease-in-out infinite; }
@keyframes shimmer { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
.progress-percent { font-size: 0.82rem; font-weight: 600; color: var(--accent-purple); min-width: 40px; }

/* Batch Progress */
.batch-progress { max-width: 500px; margin: var(--space-xl) auto 0; text-align: left; }
.batch-progress-item { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-sm) 0; border-bottom: 1px solid var(--border-subtle); }
.batch-progress-item:last-child { border-bottom: none; }
.bp-name { font-size: 0.82rem; font-weight: 500; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-status { font-size: 0.72rem; font-weight: 600; padding: 3px 8px; border-radius: var(--radius-full); }
.bp-pending { background: var(--bg-input); color: var(--text-muted); }
.bp-active { background: var(--accent-blue-dim); color: var(--accent-blue); }
.bp-done { background: var(--accent-green-dim); color: var(--accent-green); }
.bp-error { background: var(--danger-dim); color: var(--danger); }

/* ========================================
   Result Section
   ======================================== */
.result-container { text-align: center; padding: var(--space-xl) 0; }
.success-icon-wrap {
    display: inline-flex; align-items: center; justify-content: center;
    width: 96px; height: 96px; border-radius: 50%;
    background: var(--accent-green-dim); margin-bottom: var(--space-lg);
    animation: success-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes success-pop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.success-check { color: var(--accent-green); }
.result-title { font-size: 1.6rem; font-weight: 800; margin-bottom: var(--space-xl); letter-spacing: -0.02em; }
.stats-grid { display: flex; align-items: center; justify-content: center; gap: var(--space-md); margin-bottom: var(--space-xl); flex-wrap: wrap; }
.stat-card { padding: var(--space-md) var(--space-lg); background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); min-width: 130px; backdrop-filter: blur(12px); }
.stat-card.stat-arrow { min-width: auto; padding: var(--space-md); background: none; border: none; color: var(--text-muted); }
.stat-card.stat-reduction { border-color: rgba(52,211,153,0.15); background: rgba(52,211,153,0.04); }
.stat-label { display: block; font-size: 0.7rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-xs); }
.stat-value { display: block; font-size: 1.2rem; font-weight: 700; }
.stat-highlight { color: var(--accent-blue); }
.stat-green { color: var(--accent-green); }
.result-actions { display: flex; flex-direction: column; align-items: center; gap: var(--space-md); max-width: 400px; margin: 0 auto; }

/* Batch results table */
.batch-results-table {
    max-width: 700px; margin: 0 auto var(--space-xl);
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); overflow: hidden;
}
.batch-results-table table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.batch-results-table th { padding: var(--space-sm) var(--space-md); text-align: left; font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 1px solid var(--border-subtle); }
.batch-results-table td { padding: var(--space-sm) var(--space-md); border-bottom: 1px solid var(--border-subtle); }
.batch-results-table tr:last-child td { border-bottom: none; }
.batch-dl-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border: 1px solid var(--accent-green);
    background: var(--accent-green-dim); color: var(--accent-green);
    border-radius: var(--radius-sm); font-size: 0.72rem; font-weight: 600;
    cursor: pointer; transition: all var(--transition-fast); font-family: inherit;
}
.batch-dl-btn:hover { background: var(--accent-green); color: white; }

/* ========================================
   Merge Tool
   ======================================== */
.merge-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-sm); flex-wrap: wrap; gap: var(--space-sm); }
.merge-hint { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: var(--space-lg); }
.merge-file-list { display: flex; flex-direction: column; gap: var(--space-sm); margin-bottom: var(--space-xl); }
.merge-file-item {
    display: flex; align-items: center; gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md); transition: all var(--transition-fast);
    cursor: grab;
}
.merge-file-item:active { cursor: grabbing; }
.merge-file-item.dragging { opacity: 0.5; border-color: var(--accent-purple); }
.merge-file-item.drag-over-item { border-color: var(--accent-blue); background: var(--accent-blue-dim); }
.merge-drag-handle { color: var(--text-muted); cursor: grab; display: flex; }
.merge-file-num { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--gradient-btn); color: white; font-size: 0.75rem; font-weight: 700; flex-shrink: 0; }
.merge-file-info { flex: 1; min-width: 0; }
.merge-file-name { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.merge-file-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }

/* ========================================
   Split Tool
   ======================================== */
.split-mode-tabs { display: flex; gap: 2px; background: var(--bg-card); border-radius: var(--radius-md); padding: 3px; border: 1px solid var(--border-subtle); margin-bottom: var(--space-lg); width: fit-content; }
.split-tab {
    padding: 8px 20px; border: none; background: transparent;
    color: var(--text-secondary); font-family: inherit; font-size: 0.85rem; font-weight: 500;
    border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition-fast);
}
.split-tab.active { background: var(--gradient-btn); color: white; }
.split-tab:hover:not(.active) { color: var(--text-primary); }
.split-mode { display: none; margin-bottom: var(--space-xl); }
.split-mode.active { display: block; }
.range-input-group { display: flex; align-items: flex-end; gap: var(--space-md); margin-bottom: var(--space-md); }
.range-field { flex: 1; }
.range-field label { display: block; font-size: 0.78rem; font-weight: 500; color: var(--text-secondary); margin-bottom: var(--space-xs); }
.range-divider { padding-bottom: 10px; color: var(--text-muted); font-weight: 500; }
.input-field {
    width: 100%; padding: 10px 14px;
    background: var(--bg-input); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md); color: var(--text-primary);
    font-family: inherit; font-size: 0.9rem;
    transition: border-color var(--transition-fast);
}
.input-field:focus { outline: none; border-color: var(--accent-purple); }
.input-full { width: 100%; }
.range-hint { font-size: 0.78rem; color: var(--text-muted); margin-bottom: var(--space-md); }
.range-hint code { padding: 2px 6px; background: var(--bg-input); border-radius: 4px; font-size: 0.78rem; }

.split-page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: var(--space-sm); margin-bottom: var(--space-lg); }
.split-page-btn {
    display: flex; align-items: center; justify-content: center;
    height: 44px; border-radius: var(--radius-sm);
    background: var(--bg-input); border: 2px solid var(--border-subtle);
    color: var(--text-secondary); font-family: inherit; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; transition: all var(--transition-fast);
}
.split-page-btn:hover { border-color: var(--border-active); color: var(--text-primary); }
.split-page-btn.selected { border-color: var(--accent-purple); background: var(--accent-purple-dim); color: var(--accent-purple); }

/* ========================================
   History
   ======================================== */
.history-empty { text-align: center; padding: var(--space-3xl) var(--space-xl); color: var(--text-muted); }
.history-empty p { margin-top: var(--space-md); font-size: 0.95rem; }
.history-empty-sub { font-size: 0.82rem !important; margin-top: var(--space-xs) !important; }
.history-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-md); }
.history-count { font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; }
.history-table-wrap { }
.history-table {
    width: 100%; border-collapse: collapse;
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); overflow: hidden; font-size: 0.82rem;
}
.history-table th { padding: var(--space-sm) var(--space-md); text-align: left; font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 1px solid var(--border-subtle); }
.history-table td { padding: var(--space-sm) var(--space-md); border-bottom: 1px solid var(--border-subtle); }
.history-table tr:last-child td { border-bottom: none; }
.level-badge { display: inline-block; padding: 2px 8px; border-radius: var(--radius-full); font-size: 0.7rem; font-weight: 600; }
.level-badge-low { background: var(--accent-green-dim); color: var(--accent-green); }
.level-badge-high { background: var(--accent-blue-dim); color: var(--accent-blue); }
.level-badge-extreme { background: var(--accent-red-dim); color: var(--accent-red); }
.level-badge-custom { background: var(--accent-purple-dim); color: var(--accent-purple); }

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: var(--space-sm); }
.toast {
    display: flex; align-items: center; gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md); box-shadow: var(--shadow-base);
    min-width: 300px; max-width: 420px;
    animation: toast-in 0.3s ease;
    backdrop-filter: blur(16px);
}
.toast.toast-out { animation: toast-out 0.3s ease forwards; }
.toast-icon { flex-shrink: 0; }
.toast-success .toast-icon { color: var(--accent-green); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--accent-blue); }
.toast-content { flex: 1; }
.toast-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 2px; }
.toast-msg { font-size: 0.78rem; color: var(--text-secondary); }
.toast-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; display: flex; }
.toast-close:hover { color: var(--text-primary); }
@keyframes toast-in { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(50px); } }

/* ========================================
   Cookie Consent Banner
   ======================================== */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    padding: var(--space-md) var(--space-xl);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    backdrop-filter: blur(16px);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
    animation: slide-up 0.4s ease;
}
.cookie-consent.hidden { display: none; }
@keyframes slide-up { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slide-down { from { transform: translateY(0); opacity: 1; } to { transform: translateY(100%); opacity: 0; } }
.cookie-content {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
    flex-wrap: wrap;
}
.cookie-content p {
    flex: 1;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    min-width: 250px;
}
.cookie-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-shrink: 0;
}
.cookie-link {
    font-size: 0.78rem;
    color: var(--accent-purple);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}
.cookie-link:hover { color: var(--accent-blue); text-decoration: underline; }
.btn-cookie-accept {
    padding: 8px 20px;
    background: var(--gradient-btn);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-cookie-accept:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3); }
.btn-cookie-decline {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-cookie-decline:hover { color: var(--text-secondary); border-color: var(--border-active); }

/* ========================================
   Footer
   ======================================== */
#app-footer {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: var(--space-2xl) var(--space-xl) var(--space-xl);
    border-top: 1px solid var(--border-subtle);
    margin-top: var(--space-xl);
}
.footer-content { max-width: 700px; margin: 0 auto; }
.footer-main {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    line-height: 1.5;
}
.footer-disclaimer {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
    line-height: 1.5;
}
.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}
.footer-links a {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}
.footer-links a:hover { color: var(--accent-purple); text-decoration: underline; }
.footer-divider { color: var(--text-muted); font-size: 0.6rem; }
.footer-copy {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ========================================
   Responsive — Mobile Optimizations
   ======================================== */

/* Ensure proper touch behavior on mobile */
@media (hover: none) and (pointer: coarse) {
    /* Increase all touch targets to min 44px */
    .nav-tab { min-height: 44px; min-width: 44px; padding: 10px 14px; }
    .btn-icon { width: 44px; height: 44px; }
    .btn-ghost { min-height: 44px; padding: 10px 16px; }
    .theme-toggle { width: 44px; height: 44px; }
    .queue-item-remove { width: 44px; height: 44px; }
    .page-thumb { width: 64px; height: 82px; }
    .split-page-btn { min-height: 48px; }
    .btn-cookie-accept, .btn-cookie-decline { min-height: 44px; padding: 10px 20px; }

    /* Disable hover effects on touch devices (prevents sticky hover) */
    .comp-card:hover { transform: none; }
    .btn-primary:hover:not(:disabled) { transform: none; }
    .btn-cookie-accept:hover { transform: none; }
}

/* Tablet breakpoint */
@media (max-width: 900px) {
    .compression-cards { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile breakpoint — primary */
@media (max-width: 768px) {
    /* Header: stack vertically */
    #app-header {
        padding: var(--space-sm) var(--space-md);
        gap: var(--space-sm);
    }
    .header-left {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: var(--space-sm);
    }
    .logo { justify-content: center; }

    /* Navigation: horizontal scroll with snap */
    .main-nav {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        scroll-snap-type: x mandatory;
        justify-content: stretch;
    }
    .main-nav::-webkit-scrollbar { display: none; }
    .nav-tab {
        flex: 1 0 auto;
        justify-content: center;
        scroll-snap-align: start;
        font-size: 0.78rem;
        padding: 10px 12px;
        gap: 4px;
    }
    .nav-tab svg { width: 14px; height: 14px; }

    /* Hide badge on mobile to save space */
    .header-badge { display: none; }
    .header-right { width: 100%; justify-content: flex-end; }

    /* Main content */
    #app-main { padding: var(--space-sm) var(--space-md) var(--space-2xl); }

    /* Hero text */
    .hero-text { margin-bottom: var(--space-lg); }
    .hero-text h1 { font-size: 1.6rem; }
    .subtitle { font-size: 0.9rem; }

    /* Drop zone */
    .drop-zone {
        padding: var(--space-xl) var(--space-md);
        border-radius: var(--radius-lg);
    }
    .upload-icon-ring { width: 72px; height: 72px; }
    .upload-icon { width: 36px; height: 36px; }
    .drop-title { font-size: 1rem; }
    .drop-subtitle { font-size: 0.82rem; margin-bottom: var(--space-md); }

    /* Compression cards: single column */
    .compression-cards { grid-template-columns: 1fr; gap: var(--space-sm); }
    .section-title { font-size: 1.1rem; margin-bottom: var(--space-md); }

    /* File queue */
    .file-queue-header { padding: var(--space-sm) var(--space-md); }
    .queue-item { padding: var(--space-sm) var(--space-md); }
    .queue-item-name { max-width: 160px; font-size: 0.82rem; }

    /* Preview panel */
    .preview-panel { padding: var(--space-md); }
    #preview-canvas { max-height: 250px; }
    .preview-canvas-wrap { min-height: 200px; }
    .pdf-info-grid { grid-template-columns: repeat(3, 1fr); gap: var(--space-xs); }
    .info-label { font-size: 0.62rem; }
    .info-value { font-size: 0.75rem; }

    /* Stats grid */
    .stats-grid { flex-direction: column; gap: var(--space-sm); }
    .stat-card { min-width: unset; width: 100%; }
    .stat-card.stat-arrow { transform: rotate(90deg); padding: var(--space-xs); }

    /* File info bar */
    .file-info-bar {
        flex-direction: column;
        gap: var(--space-sm);
        align-items: stretch;
        padding: var(--space-md);
    }
    .file-name { max-width: 100%; }

    /* Split tool */
    .split-mode-tabs { width: 100%; }
    .split-tab { flex: 1; text-align: center; padding: 10px 12px; font-size: 0.82rem; }
    .range-input-group { flex-direction: column; gap: var(--space-sm); }
    .range-divider { display: none; }
    .split-page-grid { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }

    /* Merge tool */
    .merge-file-item { padding: var(--space-sm) var(--space-md); }
    .merge-file-name { font-size: 0.82rem; }
    .merge-header { flex-direction: column; align-items: stretch; }
    .merge-header .section-title { text-align: left; margin-bottom: var(--space-xs); }

    /* Batch results */
    .batch-results-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .batch-results-table table { min-width: 500px; }

    /* History */
    .history-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .history-table table { min-width: 600px; }

    /* Processing */
    .processing-animation { width: 100px; height: 100px; }
    .processing-icon { width: 60px; height: 60px; }
    .processing-icon svg { width: 28px; height: 28px; }
    .processing-title { font-size: 1.2rem; }
    .processing-subtitle { font-size: 0.85rem; }
    .progress-container { max-width: 100%; padding: 0 var(--space-sm); }

    /* Result */
    .result-title { font-size: 1.3rem; }
    .result-actions { max-width: 100%; }
    .success-icon-wrap { width: 72px; height: 72px; }
    .success-icon-wrap svg { width: 40px; height: 40px; }

    /* Buttons — full width on mobile */
    .btn-primary { padding: 14px var(--space-lg); font-size: 0.9rem; border-radius: var(--radius-md); }

    /* Toast */
    .toast-container { left: var(--space-sm); right: var(--space-sm); top: var(--space-sm); }
    .toast { min-width: unset; max-width: 100%; }

    /* Cookie consent */
    .cookie-consent { padding: var(--space-md); }
    .cookie-content { flex-direction: column; gap: var(--space-sm); text-align: center; }
    .cookie-content p { min-width: unset; font-size: 0.78rem; }
    .cookie-actions { width: 100%; justify-content: center; flex-wrap: wrap; gap: var(--space-sm); }

    /* Footer */
    #app-footer { padding: var(--space-lg) var(--space-md) var(--space-md); }
    .footer-links { gap: var(--space-xs); }
    .footer-links a { font-size: 0.72rem; }
    .footer-main { font-size: 0.78rem; }
    .footer-disclaimer { font-size: 0.68rem; }

    /* === MOBILE BLUR FIX === */
    /* Hide background orbs completely on mobile */
    .bg-orbs { display: none; }

    /* Remove ALL backdrop-filter on mobile — causes rendering artifacts on mobile browsers */
    .drop-zone,
    .file-queue-container,
    .preview-panel,
    .comp-card,
    .file-info-bar,
    .stat-card,
    .toast,
    .cookie-consent {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    /* Make ALL content backgrounds fully opaque on mobile */
    .drop-zone { background: var(--bg-secondary); }
    .file-queue-container { background: var(--bg-secondary); }
    .preview-panel { background: var(--bg-secondary); }
    .comp-card { background: var(--bg-secondary); }
    .file-info-bar { background: var(--bg-secondary); }
    .stat-card { background: var(--bg-secondary); }
    .stat-card.stat-arrow { background: none; }
    .stat-card.stat-reduction { background: rgba(52,211,153,0.08); }
    .batch-results-table { background: var(--bg-secondary); }
    .toast { background: var(--bg-secondary); }
    .cookie-consent { background: var(--bg-secondary); }
    .result-container { background: var(--bg-primary); }
}

/* Small phone breakpoint */
@media (max-width: 480px) {
    #app-main { padding: var(--space-xs) var(--space-sm) var(--space-xl); }
    #app-header { padding: var(--space-xs) var(--space-sm); }

    .hero-text h1 { font-size: 1.35rem; }
    .subtitle { font-size: 0.82rem; }

    .comp-card { padding: var(--space-md); }
    .card-title { font-size: 0.92rem; }
    .card-desc { font-size: 0.75rem; }

    .drop-zone { padding: var(--space-lg) var(--space-sm); }
    .drop-title { font-size: 0.92rem; }
    .drop-subtitle { font-size: 0.78rem; }
    .file-badge { font-size: 0.68rem; padding: 3px 8px; }

    .queue-item-name { max-width: 120px; }

    .nav-tab { font-size: 0.72rem; padding: 8px 10px; }
    .nav-tab svg { width: 12px; height: 12px; }

    .btn-primary { font-size: 0.85rem; padding: 12px var(--space-md); }

    /* Cookie banner stacked on very small screens */
    .cookie-actions { flex-direction: column; }
    .btn-cookie-accept, .btn-cookie-decline { width: 100%; }

    .stat-value { font-size: 1rem; }
    .result-title { font-size: 1.15rem; }
    .processing-title { font-size: 1.05rem; }
}

/* Very small phone breakpoint (iPhone SE, etc.) */
@media (max-width: 360px) {
    .hero-text h1 { font-size: 1.2rem; }
    .nav-tab { padding: 8px 8px; font-size: 0.68rem; gap: 2px; }
    .logo-text { font-size: 0.95rem; }
    .logo-icon { width: 34px; height: 34px; }
    .logo-icon svg { width: 18px; height: 18px; }
    .pdf-info-grid { grid-template-columns: 1fr 1fr; }
}

/* Safe area insets for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
    .cookie-consent {
        padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
    }
    #app-footer {
        padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom));
    }
    #app-header {
        padding-top: calc(var(--space-md) + env(safe-area-inset-top));
    }
}

/* Landscape mobile orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-text { margin-bottom: var(--space-md); }
    .hero-text h1 { font-size: 1.4rem; }
    .drop-zone { padding: var(--space-lg) var(--space-md); }
    .processing-animation { width: 80px; height: 80px; margin-bottom: var(--space-md); }
    .processing-icon { width: 48px; height: 48px; }
    .success-icon-wrap { width: 56px; height: 56px; }
}

/* Print: hide non-essential */
@media print {
    .bg-orbs, .toast-container, .cookie-consent, #app-header, #app-footer { display: none; }
    #app-main { padding: 0; max-width: 100%; }
}

/* ========================================
   SEO Section (PdfcomX About)
   ======================================== */
.seo-section {
    margin-top: var(--space-3xl);
    padding: var(--space-2xl) var(--space-xl);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(12px);
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}
.seo-section h2 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: var(--space-md);
    letter-spacing: -0.02em;
    text-align: center;
}
.seo-section h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: var(--space-xl);
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}
.seo-section p {
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}
.seo-section ul {
    margin-left: var(--space-lg);
    margin-bottom: var(--space-md);
    color: var(--text-secondary);
}
.seo-section li {
    font-size: 0.92rem;
    line-height: 1.7;
    margin-bottom: var(--space-xs);
}
.seo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
    margin-top: var(--space-xl);
}
.seo-card {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}
.seo-card h4 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: var(--space-xs);
    color: var(--text-primary);
}
.seo-card p {
    margin-bottom: 0;
    font-size: 0.88rem;
}

@media (max-width: 768px) {
    .seo-section {
        padding: var(--space-xl) var(--space-md);
        margin-top: var(--space-xl);
        backdrop-filter: none !important;
        background: var(--bg-secondary);
    }
    .seo-section h2 { font-size: 1.4rem; }
    .seo-section h3 { font-size: 1.1rem; }
    .seo-grid { grid-template-columns: 1fr; gap: var(--space-md); }
}



/* --- Loading Animations & Skeletons --- */
.thumbnails-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-xl) 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(139, 92, 246, 0.15);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.thumb-skeleton {
    width: 100%;
    height: 100%;
    min-height: 120px;
    background: linear-gradient(90deg, var(--bg-input) 25%, var(--border-subtle) 50%, var(--bg-input) 75%);
    background-size: 200% 100%;
    animation: loading-pulse 1.5s infinite;
    aspect-ratio: 3/4;
}

@keyframes loading-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Rendering state for grids */
.page-thumb.rendering, .img-preview-card.rendering, .rotate-page-card.rendering {
    pointer-events: none;
    border-color: var(--border-subtle) !important;
}

.preview-canvas-wrap {
    position: relative;
}
.preview-loader {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    color: var(--text-primary);
    font-weight: 500;
    backdrop-filter: blur(4px);
    z-index: 10;
}

