/* ===== CSS Variables & Reset ===== */
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-bg: rgba(99, 102, 241, 0.12);
    --primary-glow: 0 0 20px rgba(99, 102, 241, 0.3), 0 0 40px rgba(99, 102, 241, 0.1);
    --accent: #22d3ee;
    --accent-glow: 0 0 16px rgba(34, 211, 238, 0.3);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --success-glow: 0 0 16px rgba(16, 185, 129, 0.25);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);

    --bg: #080812;
    --bg-card: rgba(20, 20, 42, 0.7);
    --bg-card-solid: #14142a;
    --bg-hover: rgba(30, 30, 60, 0.5);
    --bg-input: rgba(12, 12, 28, 0.8);
    --border: rgba(255, 255, 255, 0.08);
    --border-active: rgba(255, 255, 255, 0.15);
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 2px 4px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 12px 28px rgba(0,0,0,0.6);
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --transition: 0.2s ease;
}

/* ===== Light Theme ===== */
[data-theme="light"] {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #4338ca;
    --primary-bg: rgba(79, 70, 229, 0.07);
    --primary-glow: 0 0 16px rgba(79, 70, 229, 0.12);
    --accent: #0891b2;
    --accent-glow: 0 0 12px rgba(8, 145, 178, 0.12);
    --success-glow: 0 0 12px rgba(16, 185, 129, 0.12);

    --bg: #f0f4ff;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-card-solid: #ffffff;
    --bg-hover: rgba(241, 245, 249, 0.7);
    --bg-input: #f8fafc;
    --border: rgba(0, 0, 0, 0.07);
    --border-active: rgba(0, 0, 0, 0.12);
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.03);
    --shadow: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 28px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scroll-behavior: smooth;
}

/* Smooth theme transitions on key properties */
body, #app-header, .tool-card, .btn, .upload-area, .file-item, .file-list-row,
.controls-panel, .action-bar, .preview-area, .tool-tabs, .stat-card, .toast,
.control-group input, .control-group select, .split-group-item, .pdf-page-item,
.merge-file-item, .layout-option, .tool-card-icon, .badge {
    transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg);
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

[data-theme="light"] body {
    background-image:
        linear-gradient(rgba(79, 70, 229, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(79, 70, 229, 0.03) 1px, transparent 1px);
}

/* Ambient glow orbs */
body::before {
    content: '';
    position: fixed;
    top: -200px;
    left: 10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99,102,241,0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -200px;
    right: 5%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(34,211,238,0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

[data-theme="light"] body::before {
    background: radial-gradient(circle, rgba(79,70,229,0.04) 0%, transparent 70%);
}

[data-theme="light"] body::after {
    background: radial-gradient(circle, rgba(8,145,178,0.03) 0%, transparent 70%);
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.hidden { display: none !important; }

/* ===== Header ===== */
#app-header {
    background: rgba(10, 10, 24, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

[data-theme="light"] #app-header {
    background: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.4));
    transition: all 0.3s ease;
}

/* Theme toggle button animation */
#btn-theme svg {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="light"] #btn-theme svg {
    transform: rotate(180deg);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.12);
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.2);
}

/* ===== Main Content ===== */
#app-content {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    opacity: 1;
    transition: opacity 0.25s cubic-bezier(0.22, 0.61, 0.36, 1),
                transform 0.25s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ===== Homepage ===== */
.homepage-hero {
    text-align: center;
    padding: 56px 0 40px;
    animation: heroIn 0.55s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes heroIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.homepage-hero h2 {
    font-size: 40px;
    font-weight: 800;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--accent), #a78bfa, var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s ease-in-out infinite;
    background-size: 200% 200%;
}

@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.homepage-hero p {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 520px;
    margin: 0 auto;
    animation: fadeUpIn 0.5s 0.1s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.homepage-badges {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
    animation: fadeUpIn 0.5s 0.15s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes fadeUpIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 14px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    backdrop-filter: blur(4px);
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 36px;
}

.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: cardIn 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.tool-card:nth-child(1) { animation-delay: 0.05s; }
.tool-card:nth-child(2) { animation-delay: 0.1s; }
.tool-card:nth-child(3) { animation-delay: 0.15s; }
.tool-card:nth-child(4) { animation-delay: 0.2s; }
.tool-card:nth-child(5) { animation-delay: 0.25s; }
.tool-card:nth-child(6) { animation-delay: 0.3s; }

@keyframes cardIn {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), var(--primary), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.tool-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.08) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.35s;
}

.tool-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.5), var(--primary-glow);
    border-color: rgba(99, 102, 241, 0.3);
}

.tool-card:hover::before { opacity: 1; }
.tool-card:hover::after { opacity: 1; }

.tool-card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(4px);
}

.tool-card-icon.image { background: rgba(254, 243, 199, 0.15); box-shadow: 0 0 16px rgba(251, 191, 36, 0.15); }
.tool-card-icon.pdf { background: rgba(254, 226, 226, 0.15); box-shadow: 0 0 16px rgba(239, 68, 68, 0.15); }
.tool-card-icon.ppt { background: rgba(255, 237, 213, 0.15); box-shadow: 0 0 16px rgba(249, 115, 22, 0.15); }
.tool-card-icon.word { background: rgba(219, 234, 254, 0.15); box-shadow: 0 0 16px rgba(59, 130, 246, 0.15); }
.tool-card-icon.excel { background: rgba(209, 250, 229, 0.15); box-shadow: 0 0 16px rgba(16, 185, 129, 0.15); }

.tool-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    position: relative;
    z-index: 1;
}

.tool-card p {
    font-size: 13px;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
}

.tool-card-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    opacity: 0;
    transition: all 0.25s ease;
}

.tool-card:hover .tool-card-arrow {
    opacity: 1;
    right: 12px;
    color: var(--primary-light);
}

/* ===== Tool Page ===== */
.tool-page {
    animation: toolPageIn 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes toolPageIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.tool-page-header {
    margin-bottom: 24px;
    animation: fadeUpIn 0.45s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.tool-page-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.tool-page-header p {
    color: var(--text-secondary);
    font-size: 14px;
    animation: fadeUpIn 0.45s 0.05s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.tool-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 4px;
    overflow-x: auto;
    backdrop-filter: blur(8px);
    animation: fadeUpIn 0.4s 0.08s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.tool-tab {
    padding: 8px 20px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: var(--transition);
}

.tool-tab:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.tool-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: var(--primary-glow);
}

/* ===== Upload Area ===== */
.upload-area {
    border: 2px dashed rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-lg);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 50%, rgba(99,102,241,0.05) 0%, transparent 60%);
    transition: opacity 0.3s;
    opacity: 0;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.06);
    box-shadow: var(--primary-glow);
}

.upload-area:hover::before,
.upload-area.dragover::before { opacity: 1; }

.upload-area svg {
    color: var(--text-muted);
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.upload-area p {
    color: var(--text-secondary);
    font-size: 14px;
    position: relative;
    z-index: 1;
}

.upload-area .upload-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    position: relative;
    z-index: 1;
}

/* ===== File List ===== */
.file-list { margin-top: 16px; }

.file-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.file-list-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.file-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    position: relative;
    transition: var(--transition);
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.file-item:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: var(--shadow-md);
}

.file-item.selected {
    border-color: var(--primary);
    background: var(--primary-bg);
    box-shadow: var(--primary-glow);
}

.file-item-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
}

.file-item-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 8px;
    background: rgba(0,0,0,0.3);
}

.file-item-info {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.file-item-size {
    font-size: 11px;
    color: var(--text-muted);
}

.file-item-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(0,0,0,0.6);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    z-index: 2;
}

.file-item:hover .file-item-remove { opacity: 1; }

/* ===== File List Row View ===== */
.file-list-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
    backdrop-filter: blur(4px);
}

.file-list-row:hover {
    border-color: rgba(99, 102, 241, 0.3);
}

.file-list-row.selected {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.file-list-row-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    background: rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.file-list-row-info { flex: 1; min-width: 0; }

.file-list-row-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-list-row-meta {
    font-size: 11px;
    color: var(--text-muted);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--bg-card);
    color: var(--text);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.25s ease;
    white-space: nowrap;
    backdrop-filter: blur(4px);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-color: transparent;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    box-shadow: var(--primary-glow);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border-color: transparent;
}

.btn-success:hover {
    box-shadow: var(--success-glow);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border-color: transparent;
}

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.4);
}

/* ===== Controls Panel ===== */
.controls-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 16px;
    backdrop-filter: blur(8px);
}

.controls-panel h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.control-group input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

.control-group select,
.control-group input[type="number"],
.control-group input[type="text"],
.control-group input[type="color"] {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--bg-input);
    color: var(--text);
    transition: var(--transition);
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.control-group input[type="color"] {
    width: 40px;
    height: 32px;
    padding: 2px;
    cursor: pointer;
}

.control-group select {
    color: var(--text);
    background: var(--bg-input);
}
.control-group select option {
    background: var(--bg-card-solid);
    color: var(--text);
}

.range-value {
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
}

/* ===== Action Bar ===== */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    flex-wrap: wrap;
    backdrop-filter: blur(8px);
}

.action-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.action-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== Result/Preview ===== */
.preview-area {
    margin-top: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    backdrop-filter: blur(8px);
}

.preview-area h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.preview-canvas-wrap {
    display: flex;
    justify-content: center;
    overflow: auto;
    background: repeating-conic-gradient(rgba(255,255,255,0.02) 0% 25%, transparent 0% 50%) 50% / 20px 20px;
    border-radius: var(--radius);
    padding: 12px;
}

.preview-canvas-wrap canvas {
    max-width: 100%;
    height: auto;
}

/* ===== Comparison ===== */
.comparison {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
}

.comparison-item { text-align: center; }
.comparison-item .size { font-size: 20px; font-weight: 700; }
.comparison-item .label { font-size: 12px; color: var(--text-muted); }
.comparison-arrow { color: var(--success); font-size: 20px; }
.comparison-item.after .size { color: var(--success); }

/* ===== PDF Page Grid ===== */
.pdf-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.pdf-page-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
}

.pdf-page-item:hover {
    border-color: rgba(99, 102, 241, 0.3);
}

.pdf-page-item.selected {
    border-color: var(--primary);
    background: var(--primary-bg);
    box-shadow: var(--primary-glow);
}

.pdf-page-item canvas {
    width: 100%;
    border-radius: 4px;
}

.pdf-page-item .page-num {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== Split Groups ===== */
.split-groups { margin-top: 16px; }

.split-group-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.split-group-item input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--bg-input);
    color: var(--text);
}

.split-group-item input:focus {
    outline: none;
    border-color: var(--primary);
}

.split-group-item input[type="number"] { width: 70px; }
.split-group-item input[type="text"] { flex: 1; min-width: 100px; }

/* ===== Progress ===== */
.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

/* ===== Loading ===== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(8, 8, 18, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    flex-direction: column;
    gap: 12px;
}

[data-theme="light"] .loading-overlay {
    background: rgba(255, 255, 255, 0.8);
}

.loading-overlay .spinner {
    width: 44px;
    height: 44px;
    border-width: 3px;
    border-top-color: var(--accent);
    box-shadow: var(--accent-glow);
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    animation: slideIn 0.3s ease;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(12px);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
.toast.warning { border-left: 3px solid var(--warning); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== Lightbox ===== */
.lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.95);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 85vh;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 16px; right: 16px;
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    z-index: 2;
}

.lightbox-prev, .lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.08);
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-prev:hover, .lightbox-next:hover {
    background: rgba(255,255,255,0.15);
}

.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.7);
    font-size: 14px;
}

/* ===== Drag Overlay ===== */
.drag-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(99, 102, 241, 0.08);
    border: 3px dashed rgba(99, 102, 241, 0.5);
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

[data-theme="light"] .drag-overlay {
    background: rgba(79, 70, 229, 0.05);
    border-color: rgba(79, 70, 229, 0.35);
}

.drag-overlay-content {
    text-align: center;
    color: var(--primary-light);
}

.drag-overlay-content p {
    font-size: 18px;
    font-weight: 600;
    margin-top: 8px;
}

/* ===== Checkbox ===== */
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ===== Crop Area ===== */
.crop-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
}

.crop-container img {
    max-width: 100%;
    display: block;
}

.crop-box {
    position: absolute;
    border: 2px dashed var(--primary);
    background: rgba(99, 102, 241, 0.15);
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border: 2px solid white;
    border-radius: 2px;
}

.crop-handle.tl { top: -6px; left: -6px; cursor: nwse-resize; }
.crop-handle.tr { top: -6px; right: -6px; cursor: nesw-resize; }
.crop-handle.bl { bottom: -6px; left: -6px; cursor: nesw-resize; }
.crop-handle.br { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* ===== Tab Content ===== */
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
    animation: tabPanelIn 0.3s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

/* Any tab panel gets auto entrance animation */
.tab-panel {
    animation: tabPanelIn 0.3s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes tabPanelIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Stats ===== */
.stats-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin: 12px 0;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    min-width: 120px;
    backdrop-filter: blur(4px);
}

.stat-card .stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-light);
}

.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* ===== Layout Mode Buttons ===== */
.layout-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.layout-option {
    padding: 8px 16px;
    border: 1px solid rgba(255,255,255,0.1);
    background: var(--bg-card);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    text-align: center;
    color: var(--text-secondary);
}

.layout-option:hover {
    border-color: rgba(99, 102, 241, 0.3);
    color: var(--text);
}

.layout-option.active {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary-light);
    box-shadow: var(--primary-glow);
}

/* ===== Merge File Grid ===== */
.merge-file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.merge-file-item {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: grab;
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
    backdrop-filter: blur(4px);
}

.merge-file-item:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: var(--shadow-md);
}

.merge-file-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.merge-file-order {
    position: absolute;
    top: 6px; left: 6px;
    z-index: 2;
    width: 22px; height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
}

.merge-file-preview {
    width: 100%;
    aspect-ratio: 3/4;
    background: rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.merge-file-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.merge-file-placeholder {
    color: var(--text-muted);
    opacity: 0.3;
}

.merge-file-info { padding: 8px 10px; }

.merge-file-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.merge-file-meta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.merge-file-remove {
    position: absolute;
    top: 4px; right: 4px;
    z-index: 2;
    width: 22px; height: 22px;
    border: none;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}

.merge-file-item:hover .merge-file-remove { opacity: 1; }
.merge-file-remove:hover { background: var(--danger); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    #app-content { padding: 16px; }
    .homepage-hero h2 { font-size: 24px; }

    .tool-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 12px;
    }

    .tool-card { padding: 20px 16px; }
    .controls-grid { grid-template-columns: 1fr; }

    .action-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .action-bar-right { justify-content: stretch; }
    .action-bar-right .btn {
        flex: 1;
        justify-content: center;
    }

    .file-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .pdf-page-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }

    .tool-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .split-group-item { flex-wrap: wrap; }
    .split-group-item input[type="number"] { width: 60px; }
}

@media (max-width: 480px) {
    .header-subtitle { display: none; }
    .tool-grid { grid-template-columns: 1fr 1fr; }
}
