/* ============================================
   GIF Merger - Stylesheet
   Dark Mode Support with Light Mode Default
   ============================================ */

/* CSS Variables - Light Mode (Default) */
:root {
    --transition-speed: 0.25s;

    --primary: #3399cc;
    --primary-light: #e0f0f8;
    --primary-dark: #2277aa;
    --accent: #66bbdd;

    /* Brand palette + GIF-tool accent (purple) */
    --color-1: #e64e4e;
    --color-2: #3399cc;
    --color-3: #339966;
    --gm-accent: #8b5cf6;
    --gm-accent-light: rgba(139,92,246,0.12);

    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;

    --bg: #f4f8fc;
    --bg-elevated: #ffffff;
    --bg-secondary: #eaf3fa;
    --bg-tertiary: #d6eaf5;

    --text: #1a2a3a;
    --text-secondary: #1d5a8a;
    --text-muted: #6b7280;

    --border: #c8dff0;
    --border-light: #daeef8;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
    --shadow-primary: 0 4px 14px rgba(51,153,204,0.25);
    --shadow-primary-hover: 0 6px 20px rgba(51,153,204,0.35);

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --checker-light: #f3f4f6;
    --checker-dark: #e5e7eb;

    --input-bg: #ffffff;
    --input-border: #c8dff0;

    --scrollbar-track: var(--bg);
    --scrollbar-thumb: var(--text-muted);
    --scrollbar-thumb-hover: var(--text-secondary);
}

/* Dark Mode Colors */
[data-theme="dark"] {
    --primary: #55aadd;
    --primary-light: rgba(51,153,204,0.18);
    --primary-dark: #3399cc;
    --accent: #88ccee;

    --color-1: #f16b6b;
    --color-2: #55aadd;
    --color-3: #4db38a;
    --gm-accent: #a78bfa;
    --gm-accent-light: rgba(167,139,250,0.20);

    --success: #34d399;
    --success-light: rgba(52,211,153,0.15);
    --warning: #fbbf24;
    --warning-light: rgba(251,191,36,0.15);
    --danger: #f87171;
    --danger-light: rgba(248,113,113,0.15);

    --bg: #0d1a24;
    --bg-elevated: #0f2232;
    --bg-secondary: #14304a;
    --bg-tertiary: #1a3d5a;

    --text: #e8f4fc;
    --text-secondary: #88ccee;
    --text-muted: #9ca3af;

    --border: #1e3a4a;
    --border-light: #1e4a60;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.5);
    --shadow-primary: 0 4px 14px rgba(51,153,204,0.2);
    --shadow-primary-hover: 0 6px 20px rgba(51,153,204,0.3);

    --checker-light: #14304a;
    --checker-dark: #1a3d5a;

    --input-bg: #14304a;
    --input-border: #1e4a60;

    --scrollbar-track: var(--bg-elevated);
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* Container */
.tool-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.tool-header {
    text-align: center;
    margin-bottom: 2rem;
}

.tool-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.tool-icon-wrapper {
    width: 64px;
    height: 64px;
    background: var(--gm-accent);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-primary);
    flex-shrink: 0;
    transition: background-color var(--transition-speed), box-shadow var(--transition-speed);
}

.tool-icon-wrapper svg,
.tool-icon-wrapper i {
    width: 28px;
    height: 28px;
}

.tool-title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    margin: 0;
    color: var(--gm-accent);
    letter-spacing: -0.02em;
}

.tool-description {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.7;
}

.tool-description a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.tool-description a:hover { text-decoration: underline; }

/* Main Tool Area */
.tool-main {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: visible;
    border: 1px solid var(--border);
    margin-bottom: 2rem;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

/* Upload Section */
.upload-section { padding: 3rem; }

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-secondary);
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--primary-light);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: var(--bg);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.upload-content { position: relative; z-index: 1; }

.upload-icon {
    color: var(--primary);
    margin-bottom: 1.5rem;
    transition: transform 0.3s ease;
}

.upload-area:hover .upload-icon { transform: translateY(-5px); }

.upload-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.5rem;
}

.upload-subtitle {
    color: var(--text-muted);
    margin: 0 0 1rem;
    font-size: 1rem;
}

.file-types {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.file-type-badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

.upload-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Editor Section */
.editor-section {
    background: var(--bg-elevated);
    transition: background-color var(--transition-speed);
}

/* Files Header */
.files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.files-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text);
}

.files-header-left svg,
.files-header-left i { color: var(--primary); }

.btn-text {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.btn-text:hover { background: var(--primary-light); }

/* Files Grid */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1rem;
    padding: 1.5rem 2rem;
    max-height: 340px;
    overflow-y: auto;
}

.files-grid.sortable .file-item { cursor: grab; }
.files-grid.sortable .file-item:active { cursor: grabbing; }

.file-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0.75rem 0.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    position: relative;
    gap: 0.4rem;
}

.file-item:hover {
    border-color: var(--primary);
    background: var(--bg);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.file-item.sortable-ghost { opacity: 0.4; }
.file-item.sortable-chosen { border-color: var(--primary); box-shadow: var(--shadow-lg); }

.file-order {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.file-preview-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    flex-shrink: 0;
    transition: opacity 0.2s ease;
}

.file-info {
    text-align: center;
    width: 100%;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    color: var(--text);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.15rem;
}

.file-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Opacity Row */
.file-opacity-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    width: 100%;
    padding: 0.3rem 0.25rem;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s ease;
}

.file-opacity-row i,
.file-opacity-row svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.file-opacity-row.opacity-highlighted {
    background: var(--primary-light);
}

.file-opacity-row.opacity-highlighted i,
.file-opacity-row.opacity-highlighted svg {
    color: var(--primary);
}

.opacity-slider {
    flex: 1;
    height: 4px;
    border-radius: var(--radius-full);
    background: var(--border);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    min-width: 0;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.opacity-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.opacity-value {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 26px;
    text-align: right;
}

.file-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--danger-light);
    color: var(--danger);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
    transform: scale(0.8);
}

.file-item:hover .file-remove {
    opacity: 1;
    transform: scale(1);
}

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

/* Sort Hint */
.sort-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.sort-hint i,
.sort-hint svg { color: var(--primary); }

/* Settings Panel */
.settings-panel { padding: 2rem; }

.panel-header { margin-bottom: 1.5rem; }

.panel-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.panel-header h3 svg,
.panel-header h3 i { color: var(--primary); }

/* Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.settings-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Section Label */
.section-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.section-label svg,
.section-label i {
    color: var(--primary);
    width: 16px;
    height: 16px;
}

/* Merge Mode Options */
.merge-modes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.merge-mode-option { cursor: pointer; }
.merge-mode-option input { display: none; }

.mode-card {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.mode-card:hover { border-color: var(--primary); }

.merge-mode-option input:checked + .mode-card {
    background: var(--primary-light);
    border-color: var(--primary);
}

.mode-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.merge-mode-option input:checked + .mode-card .mode-icon {
    background: var(--primary);
    color: white;
}

.mode-info { flex: 1; min-width: 0; }

.mode-name {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 0.1rem;
}

.mode-desc {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Overlay Hint */
.overlay-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    transition: background-color var(--transition-speed);
}

.overlay-hint i,
.overlay-hint svg {
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 2px;
}

/* Frame Rate Section */
.framerate-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.slider-input {
    flex: 1;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--primary);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 3px solid var(--primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform 0.15s ease;
}

.slider-input::-webkit-slider-thumb:hover { transform: scale(1.15); }

.slider-input::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 3px solid var(--primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.framerate-value {
    min-width: 60px;
    padding: 0.5rem 0.75rem;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-md);
    font-weight: 700;
    text-align: center;
    font-size: 0.9rem;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.framerate-presets {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.preset-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.preset-btn {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.preset-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Size Options */
.size-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.size-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
}

.size-option input { accent-color: var(--primary); }

.custom-size-row {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.size-input-group { flex: 1; }

.size-input-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.size-input-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 0.9rem;
    text-align: center;
    transition: border-color 0.2s ease;
}

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

.size-separator {
    color: var(--text-muted);
    font-size: 1.2rem;
    padding-bottom: 0.5rem;
}

/* Loop Options */
.loop-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.loop-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
}

.loop-option input[type="radio"] { accent-color: var(--primary); }

.loop-count-input {
    width: 50px;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 0.85rem;
    text-align: center;
}

.loop-count-input:focus {
    outline: none;
    border-color: var(--primary);
}

.loop-count-input:disabled { opacity: 0.5; cursor: not-allowed; }

/* Info Box */
.info-box {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-speed);
}

.info-box .info-icon { color: var(--primary); flex-shrink: 0; }

.info-box .info-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.info-box .info-text a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.info-box .info-text a:hover { text-decoration: underline; }

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
}

.btn svg,
.btn i { width: 18px; height: 18px; }

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-primary-hover);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
    border-color: var(--text-muted);
}

/* Processing Overlay */
.processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}

.processing-card {
    background: var(--bg-elevated);
    padding: 2rem 2.5rem;
    border-radius: var(--radius-xl);
    text-align: center;
    min-width: 340px;
    max-width: 400px;
    box-shadow: var(--shadow-xl);
    transition: background-color var(--transition-speed);
}

/* Stage dots */
.processing-stages {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.stage-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.3s, background-color 0.3s, color 0.3s;
}

.stage-dot.active {
    border-color: var(--primary);
    color: var(--primary);
    animation: stagePulse 1.4s ease-in-out infinite;
}

.stage-dot.done {
    border-color: var(--success);
    background: var(--success);
    color: #fff;
    animation: none;
}

@keyframes stagePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(51, 153, 204, 0.35); }
    50%      { box-shadow: 0 0 0 6px rgba(51, 153, 204, 0); }
}

.stage-connector {
    width: 28px;
    height: 2px;
    background: var(--border);
    flex-shrink: 0;
    transition: background-color 0.3s;
}

.stage-connector.done { background: var(--success); }

.processing-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.5rem 0;
}

.processing-subtext {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0 0 1.25rem 0;
    min-height: 1.2em;
}

.progress-bar-container {
    height: 8px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

/* Results Section */
.results-section {
    padding: 2.5rem;
    text-align: center;
}

.results-header { margin-bottom: 2rem; }

.success-icon {
    width: 72px;
    height: 72px;
    background: var(--success);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    color: white;
    transition: background-color var(--transition-speed);
}

.success-icon svg,
.success-icon i { width: 36px; height: 36px; }

.results-header h2 {
    font-size: 1.75rem;
    color: var(--text);
    margin: 0 0 0.5rem 0;
}

.results-header p { color: var(--text-muted); margin: 0; }

/* Result Preview */
.result-preview { margin-bottom: 2rem; }

.preview-container {
    max-width: 500px;
    max-height: 400px;
    margin: 0 auto;
    background-image:
        linear-gradient(45deg, var(--checker-light) 25%, transparent 25%),
        linear-gradient(-45deg, var(--checker-light) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--checker-light) 75%),
        linear-gradient(-45deg, transparent 75%, var(--checker-light) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-container img {
    max-width: 100%;
    max-height: 400px;
    display: block;
}

/* Results Stats */
.results-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.stat-item { text-align: center; }

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

/* Results Actions */
.results-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

/* Further Actions */
.further-actions {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
}

.further-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
}

.further-links {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.further-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.further-link:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.further-link svg,
.further-link i { color: var(--primary); }

.further-link:hover svg,
.further-link:hover i { color: white; }

/* Error Message */
.gm-error-message {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: var(--danger-light);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin: 1.25rem;
    font-weight: 500;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.gm-error-message a {
    color: var(--danger);
    font-weight: 700;
    text-decoration: underline;
}

/* Related Tools */
.related-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.related-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text);
    font-size: 0.9rem;
}

.related-label svg,
.related-label i {
    color: var(--primary);
    width: 16px;
    height: 16px;
}

.related-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.related-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.related-link:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

.related-link svg,
.related-link i { width: 16px; height: 16px; }

/* Info Sections */
.info-sections {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.info-card {
    border-radius: var(--radius-xl);
    padding: 2rem;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.info-card h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.3rem;
    color: var(--text);
    margin: 0 0 1.5rem 0;
}

.info-card h2 svg,
.info-card h2 i {
    color: var(--primary);
    width: 24px;
    height: 24px;
}

/* Steps List */
.steps-list {
    counter-reset: step;
    list-style: none;
    padding: 0;
    margin: 0;
}

.steps-list li {
    position: relative;
    padding-left: 3.25rem;
    margin-bottom: 1rem;
    counter-increment: step;
    color: var(--text-secondary);
    line-height: 1.6;
}

.steps-list li:not(:last-child)::after {
    content: '';
    position: absolute;
    left: calc(1rem - 1px);
    top: 2rem;
    bottom: 0;
    width: 2px;
    background: var(--primary-light);
}

.steps-list li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 2rem;
    height: 2rem;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    z-index: 1;
}

.steps-list li:last-child { margin-bottom: 0; }

.steps-list li a {
    color: var(--primary);
    text-decoration: none;
}

.steps-list li a:hover { text-decoration: underline; }

/* Steps Tip */
.steps-tip {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    background: var(--warning-light);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.steps-tip i,
.steps-tip svg {
    color: var(--warning);
    flex-shrink: 0;
    margin-top: 2px;
}

.steps-tip a {
    color: var(--warning);
    font-weight: 600;
    text-decoration: none;
}

.steps-tip a:hover { text-decoration: underline; }

/* Mode Explanations */
.mode-explanations {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mode-explain {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.mode-tag {
    flex-shrink: 0;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    color: white;
}

.mode-tag.sequence  { background: var(--primary); }
.mode-tag.overlay   { background: #8855cc; }
.mode-tag.horizontal { background: #3399cc; }
.mode-tag.vertical  { background: #339966; }
.mode-tag.grid      { background: #f59e0b; }

.mode-explain p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Use Cases Grid */
.use-cases-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.use-case {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.use-case-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}

.use-case-content h4 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    color: var(--text);
}

.use-case-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* FAQ */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition-speed);
}

.faq-question {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
    text-align: left;
    transition: all 0.2s ease;
}

.faq-question:hover { background: var(--bg-tertiary); }

.faq-question svg,
.faq-question i {
    flex-shrink: 0;
    color: var(--primary);
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.faq-item.open .faq-question svg,
.faq-item.open .faq-question i { transform: rotate(180deg); }

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.faq-item.open .faq-answer { max-height: 500px; }

.faq-answer p {
    padding: 1rem 1.25rem;
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.7;
    background: var(--bg-elevated);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.faq-answer a {
    color: var(--primary);
    text-decoration: none;
}

.faq-answer a:hover { text-decoration: underline; }

/* Cancel Processing Button */
.cancel-processing-btn {
    margin-top: 1rem;
    padding: 0.4rem 1rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.cancel-processing-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.editor-section,
.results-section { animation: fadeIn 0.4s ease; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* Selection */
::selection { background: rgba(51,153,204,0.2); color: var(--text); }
[data-theme="dark"] ::selection { background: rgba(51,153,204,0.3); }

/* Responsive */
@media (max-width: 900px) {
    .settings-grid { grid-template-columns: 1fr; }
    .merge-modes { grid-template-columns: 1fr 1fr; }
    .use-cases-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .tool-container { padding: 1rem; }
    .tool-title-row { gap: 0.75rem; }
    .tool-icon-wrapper { width: 50px; height: 50px; }
    .tool-icon-wrapper svg, .tool-icon-wrapper i { width: 24px; height: 24px; }
    .upload-section { padding: 2rem 1.5rem; }
    .upload-area { padding: 2.5rem 1.5rem; }
    .files-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); padding: 1rem 1.5rem; gap: 0.75rem; }
    .file-item { padding: 0.5rem 0.5rem 0.35rem; }
    .file-preview-img { width: 52px; height: 52px; }
    .settings-panel { padding: 1.5rem; }
    .action-bar { flex-direction: column; padding: 1.25rem; }
    .btn { width: 100%; }
    .results-section { padding: 2rem 1.5rem; }
    .results-stats { gap: 1.5rem; }
    .results-actions { flex-direction: column; }
    .results-actions .btn { width: 100%; }
    .related-tools { flex-direction: column; align-items: flex-start; }
    .mode-explain { flex-direction: column; gap: 0.5rem; }
    .info-card { padding: 1.5rem; }
    .further-links { flex-direction: column; width: 100%; }
    .further-link { justify-content: center; }
}

@media (max-width: 480px) {
    .tool-title-row { flex-direction: column; gap: 0.75rem; }
    .files-grid { grid-template-columns: repeat(2, 1fr); }
    .merge-modes { grid-template-columns: 1fr; }
    .framerate-presets { flex-direction: column; align-items: flex-start; }
    .custom-size-row { flex-direction: column; gap: 0.5rem; }
    .size-separator { display: none; }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================
   NEW FEATURE CONTROLS (2026-07-07)
   Transitions, overlay position, trim, live preview, image layers
   ========================================== */

/* --- Transition controls --- */
.transition-section,
.overlay-pos-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.transition-options {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.transition-option {
    flex: 1;
    cursor: pointer;
}

.transition-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.transition-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.7rem 0.4rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

.transition-option input:checked + .transition-card {
    border-color: var(--gm-accent);
    background: var(--gm-accent-light);
    color: var(--gm-accent);
}

.transition-frames-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.9rem;
}

.transition-frames-row .slider-input { flex: 1; }

.mini-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.mini-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    min-width: 62px;
    text-align: right;
}

/* --- Overlay position grid --- */
.overlay-pos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.pos-option { cursor: pointer; }

.pos-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.pos-option span {
    display: block;
    text-align: center;
    padding: 0.5rem 0.3rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

.pos-option input:checked + span {
    border-color: var(--gm-accent);
    background: var(--gm-accent-light);
    color: var(--gm-accent);
}

.overlay-pos-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    margin-top: 0.85rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.overlay-pos-hint i { margin-top: 2px; flex-shrink: 0; }

/* --- Per-file trim row --- */
.file-trim-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px dashed var(--border-light);
}

.file-trim-row .trim-start,
.file-trim-row .trim-end {
    flex: 1;
    min-width: 0;
    height: 4px;
    accent-color: var(--gm-accent);
}

.file-trim-row .trim-value {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 34px;
    text-align: right;
}

/* --- Static image badge on file cards --- */
.file-type-tag {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 2;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: var(--color-3, #339966);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

/* --- Live preview --- */
.live-preview-wrap {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.live-preview-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.9rem;
}

.live-preview-header i { color: var(--gm-accent); }

.live-preview-note {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
}

.live-preview-canvas-box {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-radius: var(--radius-md);
    background:
        linear-gradient(45deg, var(--checker-light) 25%, transparent 25%),
        linear-gradient(-45deg, var(--checker-light) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--checker-light) 75%),
        linear-gradient(-45deg, transparent 75%, var(--checker-light) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

#livePreviewCanvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

@media (max-width: 640px) {
    .live-preview-note { display: none; }
    .overlay-pos-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ==========================================
   GIF COLLAGE MAKER - layout & style controls
   ========================================== */

/* Layout picker cards */
.gcm-layouts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.gcm-layout-option { cursor: pointer; }
.gcm-layout-option input { position: absolute; opacity: 0; width: 0; height: 0; }

.gcm-layout-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem 0.4rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    text-align: center;
    transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

.gcm-layout-option input:checked + .gcm-layout-card {
    border-color: var(--gm-accent);
    background: var(--gm-accent-light);
    color: var(--gm-accent);
}

/* Mini SVG diagram inside each layout card */
.gcm-layout-card svg { width: 34px; height: 34px; }
.gcm-layout-card svg rect { fill: currentColor; opacity: 0.85; }

/* Slider rows (gap, radius, border width) */
.gcm-slider-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.9rem;
}
.gcm-slider-row .slider-input { flex: 1; }
.gcm-slider-row .gcm-mini-label { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; min-width: 74px; }
.gcm-slider-row .gcm-mini-value { font-size: 0.8rem; font-weight: 600; color: var(--text); white-space: nowrap; min-width: 48px; text-align: right; }

/* Color picker rows */
.gcm-color-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.9rem;
    flex-wrap: wrap;
}
.gcm-color-field {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.gcm-color-field input[type="color"] {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    cursor: pointer;
}
.gcm-color-field .gcm-swatch-none {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

/* Custom rows x cols inputs */
.gcm-dims-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.9rem;
}
.gcm-dims-row label { font-size: 0.82rem; color: var(--text-secondary); }
.gcm-dims-row input[type="number"] {
    width: 64px;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 0.85rem;
}
.gcm-dims-sep { color: var(--text-muted); font-weight: 600; }

@media (max-width: 640px) {
    .gcm-layouts { grid-template-columns: repeat(3, 1fr); }
}
