/* ============================================
   GIF Analyzer - Improved Stylesheet
   Dark Mode Support - Light Default
   SURITD TOOLS Brand Colors
   ============================================ */

:root {
    --transition-speed: 0.25s;
    
    /* Brand Colors */
    --color-red: #e64e4e;
    --color-blue: #3399cc;
    --color-green: #339966;
    
    /* Primary - Blue */
    --primary: #3399cc;
    --primary-light: #e0f2fe;
    --primary-dark: #2980b9;
    --accent: #60a5fa;
    --success: #339966;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #e64e4e;
    
    /* Stat icon colors */
    --blue: #3399cc;
    --blue-light: #e0f2fe;
    --green: #339966;
    --green-light: #dcfce7;
    --red: #e64e4e;
    --red-light: #fee2e2;
    
    /* Background Colors */
    --bg: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-secondary: #f1f5f9;
    
    /* Text Colors */
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    /* Border Colors */
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --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);
    
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    --upload-bg: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
    --upload-hover-bg: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
    --scrollbar-track: var(--bg);
    --scrollbar-thumb: var(--text-muted);
    --scrollbar-thumb-hover: var(--text-secondary);
}

[data-theme="dark"] {
    --primary: #5bb8e8;
    --primary-light: rgba(51, 153, 204, 0.15);
    --primary-dark: #3399cc;
    --accent: #93c5fd;
    --success: #4ade80;
    --success-light: rgba(74, 222, 128, 0.15);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --danger: #f87171;
    
    --blue: #5bb8e8;
    --blue-light: rgba(51, 153, 204, 0.15);
    --green: #4ade80;
    --green-light: rgba(51, 153, 102, 0.15);
    --red: #f87171;
    --red-light: rgba(230, 78, 78, 0.15);
    
    --bg: #0f172a;
    --bg-elevated: #1e293b;
    --bg-secondary: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --border-light: #475569;
    
    --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);
    
    --upload-bg: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    --upload-hover-bg: linear-gradient(135deg, rgba(51,153,204,0.1) 0%, rgba(51,153,204,0.2) 100%);
    --scrollbar-track: var(--bg-elevated);
    --scrollbar-thumb: var(--text-muted);
    --scrollbar-thumb-hover: var(--text-secondary);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    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(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
}

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

.tool-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    margin: 0;
    color: var(--color-blue);
    letter-spacing: -0.02em;
}

.tool-description {
    font-size: 1.15rem;
    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 !important; /* override custom_styles.css overflow:hidden */
    border: 1px solid var(--border);
    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(--upload-bg);
    position: relative;
    overflow: hidden;
}

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

.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-secondary);
    margin: 0 0 1rem;
    font-size: 1rem;
}

.upload-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    transition: background-color var(--transition-speed);
}

.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;
}

/* Progress */
.progress-container {
    padding: 1.5rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

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

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

.progress-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    display: block;
}

/* ── Processing Overlay (stage-dots card) ── */
.gfa-processing-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.gfa-processing-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    padding: 2rem 2.5rem;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0,0,0,.35);
    min-width: 320px;
    max-width: 420px;
    width: 90%;
    border: 1px solid var(--border);
}

.gfa-stage-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 1.75rem;
}

.gfa-stage-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    color: var(--text-muted);
    transition: color .3s;
}

.gfa-stage-icon {
    width: 20px;
    height: 20px;
    padding: 7px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .3s;
    box-sizing: content-box;
}

.gfa-stage-icon svg { width: 16px; height: 16px; display: block; }

.gfa-stage-dot span {
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.gfa-stage-dot.active .gfa-stage-icon { background: var(--primary); color: #fff; }
.gfa-stage-dot.active                  { color: var(--primary); }
.gfa-stage-dot.done .gfa-stage-icon   { background: var(--success); color: #fff; }
.gfa-stage-dot.done                    { color: var(--success); }

.gfa-stage-connector {
    width: 28px;
    height: 2px;
    background: var(--border);
    margin: 0 .25rem 1.1rem;
    flex-shrink: 0;
}

.gfa-css-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: gfa-spin .8s linear infinite;
    margin: 0 auto 1rem;
}

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

.gfa-progress-bar-wrap {
    height: 6px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: .75rem 0 .5rem;
}

.gfa-progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width .4s ease;
}

.gfa-processing-status {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 .25rem;
}

.gfa-progress-pct {
    font-size: .8rem;
    color: var(--text-muted);
    margin: 0;
}

/* Error */
.error-container {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    padding: 1.25rem 1.5rem;
    margin: 1rem 2rem;
    background: rgba(230, 78, 78, 0.08);
    border: 1px solid rgba(230, 78, 78, 0.3);
    border-radius: var(--radius-md);
    color: var(--danger);
}

.error-icon-main { flex-shrink: 0; margin-top: 2px; }

.error-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.error-body #errorText {
    font-weight: 500;
    font-size: 0.95rem;
}

.error-contact {
    font-size: 0.85rem;
    color: var(--text-muted);
}

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

.error-contact a:hover { text-decoration: underline; }

.error-close {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.error-close:hover { background: rgba(230, 78, 78, 0.15); }

/* Editor */
.editor-section {
    padding: 0;
    animation: fadeIn 0.4s ease;
}

/* File Info Bar */
.file-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1.25rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.file-info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-info-item svg { color: var(--text-muted); }

.format-badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.format-badge svg { color: var(--primary); }

.animation-badge {
    background: var(--green-light);
    color: var(--green);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.animation-badge svg { color: var(--green); }
.animation-badge.static { background: var(--red-light); color: var(--red); }
.animation-badge.static svg { color: var(--red); }

/* Toolbar */
.viewer-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    gap: 1rem;
    flex-wrap: wrap;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.view-toggle {
    display: flex;
    background: var(--bg);
    border-radius: var(--radius-full);
    padding: 4px;
    border: 1px solid var(--border);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.view-toggle button {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-full);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.view-toggle button:hover { color: var(--text); }

.view-toggle button.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Speed Control */
.speed-control {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 2px;
}

.speed-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
}

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

.speed-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 32px;
    text-align: center;
}

.toolbar-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.toolbar-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.toolbar-btn.playing {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Viewer Content */
.viewer-content {
    min-height: 400px;
    position: relative;
}

.preview-panel {
    padding: 0;
    display: none;
}

.preview-panel.active { display: block; }

/* Animation Preview */
.animation-preview-container {
    position: relative;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    overflow: auto; /* allow scrolling for large GIFs */
    transition: background-color var(--transition-speed);
}

.animation-preview-container #animationCanvas {
    position: relative;
    z-index: 1;
    background: #ffffff;
}

[data-theme="dark"] .animation-preview-container #animationCanvas {
    background: #ffffff;
}

.animation-preview-container img {
    position: relative;
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    z-index: 1;
}

.preview-loading {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
    z-index: 2;
}

.preview-loading .spinner {
    animation: spin 1s linear infinite;
    color: var(--primary);
}

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

.frame-indicator {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 3;
}

/* Frame Scrubber */
.frame-scrubber {
    padding: 1rem 2rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.frame-slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: var(--radius-full);
    outline: none;
    cursor: pointer;
}

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

.frame-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

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

.scrubber-info {
    display: flex;
    justify-content: space-between;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Frames Panel */
.frames-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
    transition: border-color var(--transition-speed);
}

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

.frames-header h3 svg { color: var(--primary); }

.frames-summary { display: flex; gap: 1.5rem; }

.summary-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

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

.frames-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    padding: 2rem;
    max-height: 500px;
    overflow-y: auto;
}

.frame-card {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
}

.frame-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.frame-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.frame-preview {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    overflow: hidden;
}

.frame-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.frame-info {
    padding: 0.5rem;
    font-size: 0.75rem;
    text-align: center;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
}

.frame-number { font-weight: 600; color: var(--text); display: block; }
.frame-delay { color: var(--text-muted); }
.frame-disposal { color: var(--text-muted); font-size: 0.7rem; display: block; }

/* Colors Panel */
.colors-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    transition: border-color var(--transition-speed);
}

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

.colors-header h3 svg { color: var(--primary); }

.colors-hint {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.colors-content { padding: 2rem; }

.palette-section { margin-bottom: 2rem; }
.palette-section:last-child { margin-bottom: 0; }

.palette-section h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    font-size: 1rem;
    color: var(--text);
}

.palette-section h4 svg { color: var(--primary); }

.palette-info { display: flex; gap: 1.5rem; margin-bottom: 1rem; }

.palette-stat { font-size: 0.875rem; color: var(--text-secondary); }
.palette-stat strong { color: var(--text); }

.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.color-swatch {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease;
    border: 1px solid rgba(0,0,0,0.1);
}

.color-swatch:hover {
    transform: scale(1.2);
    z-index: 1;
}

.color-swatch::after {
    content: attr(data-color);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    color: var(--text);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    pointer-events: none;
}

.color-swatch:hover::after { opacity: 1; visibility: visible; }

.dominant-colors { display: flex; gap: 1rem; flex-wrap: wrap; }

.dominant-color {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.dominant-color:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.dominant-swatch {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0,0,0,0.1);
}

.dominant-info { display: flex; flex-direction: column; }

.dominant-hex {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    font-family: monospace;
}

.dominant-percentage {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Timeline Panel */
.timeline-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    transition: border-color var(--transition-speed);
}

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

.timeline-header h3 svg { color: var(--primary); }
.timeline-content { padding: 2rem; }

.timeline-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.timeline-stat-card {
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    text-align: center;
}

.timeline-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    display: block;
}

.timeline-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.timeline-chart-wrapper { margin-bottom: 2rem; }

.timeline-chart-wrapper h4,
.disposal-overview h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    font-size: 1rem;
    color: var(--text);
}

.timeline-chart-wrapper h4 svg,
.disposal-overview h4 svg { color: var(--primary); }

.timeline-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 120px;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.timeline-bar {
    flex: 1;
    min-width: 3px;
    max-width: 24px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
    transition: background 0.2s ease;
    cursor: pointer;
    position: relative;
}

.timeline-bar:hover { background: var(--color-red); }

.timeline-bar::after {
    content: attr(data-info);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    color: var(--text);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    pointer-events: none;
    margin-bottom: 4px;
}

.timeline-bar:hover::after { opacity: 1; visibility: visible; }

.timeline-legend {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.disposal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.disposal-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius-md);
}

.disposal-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 40px;
    text-align: center;
}

.disposal-info { display: flex; flex-direction: column; }

.disposal-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.disposal-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Info Panel */
.info-body { padding: 2rem; }

.info-section { margin-bottom: 2rem; }
.info-section:last-child { margin-bottom: 0; }

.info-section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-light);
}

.info-section-title svg { color: var(--primary); }

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-speed);
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
    word-break: break-word;
}

/* Optimization Panel */
.optimize-content { padding: 2rem; }

.optimize-score-card {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    background: var(--bg);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    transition: background-color var(--transition-speed);
}

.score-circle {
    position: relative;
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.score-circle svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-bg { fill: none; stroke: var(--border); stroke-width: 8; }

.score-fill {
    fill: none;
    stroke: var(--primary);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.score-value {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-value span:first-child {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.score-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.score-details h3 { margin: 0 0 0.5rem; font-size: 1.25rem; color: var(--text); }
.score-details p { margin: 0; color: var(--text-secondary); line-height: 1.6; }

.optimize-suggestions { display: grid; gap: 1rem; margin-bottom: 2rem; }

.suggestion-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-speed);
}

.suggestion-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.suggestion-icon.success { background: var(--success-light); color: var(--success); }
.suggestion-icon.warning { background: var(--warning-light); color: var(--warning); }
.suggestion-icon.danger { background: rgba(230, 78, 78, 0.15); color: var(--danger); }
.suggestion-icon.info { background: var(--primary-light); color: var(--primary); }

.suggestion-content h4 { margin: 0 0 0.25rem; font-size: 1rem; color: var(--text); }
.suggestion-content p { margin: 0; font-size: 0.9rem; color: var(--text-secondary); }
.suggestion-content a { color: var(--primary); font-weight: 500; text-decoration: none; }
.suggestion-content a:hover { text-decoration: underline; }

/* Bandwidth Estimate */
.bandwidth-estimate {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg);
    border-radius: var(--radius-md);
}

.bandwidth-estimate h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    font-size: 1rem;
    color: var(--text);
}

.bandwidth-estimate h4 svg { color: var(--primary); }

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

.bandwidth-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.bandwidth-connection { font-size: 0.85rem; color: var(--text-secondary); }
.bandwidth-time { font-size: 0.85rem; font-weight: 600; color: var(--text); }

.optimize-actions { display: flex; gap: 1rem; flex-wrap: wrap; }

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 1.5rem;
    padding: 1.25rem 2rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    overflow-x: auto;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: max-content;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--blue-light); color: var(--blue); }
.stat-icon.green { background: var(--green-light); color: var(--green); }
.stat-icon.red { background: var(--red-light); color: var(--red); }

.stat-info { display: flex; flex-direction: column; }

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.action-group { display: flex; gap: 0.75rem; flex-wrap: wrap; }

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

.gfa-btn-primary { background: var(--primary); color: white; }
.gfa-btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }

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

.gfa-btn-success { background: var(--success); color: white; }
.gfa-btn-success:hover { background: #2b8055; transform: translateY(-1px); box-shadow: var(--shadow-md); }

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

.related-label {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
}

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

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

.tool-link:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.tool-link svg { width: 16px; height: 16px; }

/* Info Sections */
.info-sections { margin-top: 2rem; }

.info-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    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.5rem;
    margin: 0 0 1.5rem;
    color: var(--text);
}

.info-card h2 svg { color: var(--primary); }

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

.steps-list li {
    position: relative;
    padding-left: 3.5rem;
    padding-bottom: 1.25rem;
    counter-increment: step;
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.95rem;
}

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

.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: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    z-index: 1;
    box-shadow: 0 2px 4px rgba(51, 153, 204, 0.3);
}

.steps-list li strong { color: var(--text); }
.steps-list li a { color: var(--primary); text-decoration: none; font-weight: 500; }
.steps-list li a:hover { text-decoration: underline; }

.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);
    border: 1px dashed var(--warning);
    font-size: 0.9rem;
    color: #92400E;
    line-height: 1.6;
}

[data-theme="dark"] .steps-tip {
    background: rgba(251, 191, 36, 0.1);
    color: var(--warning);
}

.steps-tip svg { color: var(--warning); flex-shrink: 0; margin-top: 2px; }
.steps-tip a { color: #D97706; font-weight: 600; text-decoration: none; }
[data-theme="dark"] .steps-tip a { color: var(--warning); }
.steps-tip a:hover { text-decoration: underline; }

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.feature-item {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-speed);
}

.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feature-icon.blue { background: var(--blue-light); color: var(--blue); }
.feature-icon.green { background: var(--green-light); color: var(--green); }
.feature-icon.red { background: var(--red-light); color: var(--red); }

.feature-content h3 { margin: 0 0 0.5rem; font-size: 1.1rem; color: var(--text); }
.feature-content p { margin: 0; color: var(--text-secondary); font-size: 0.95rem; line-height: 1.5; }

/* Format Info */
.format-info-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.7;
}

.format-info-content a { color: var(--primary); text-decoration: none; font-weight: 500; }
.format-info-content a:hover { text-decoration: underline; }

.format-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.format-feature {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--text);
    transition: background-color var(--transition-speed);
}

.feature-badge {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feature-badge.blue { background: var(--blue-light); color: var(--blue); }
.feature-badge.green { background: var(--green-light); color: var(--green); }
.feature-badge.red { background: var(--red-light); color: var(--red); }

/* FAQ - styles handled by global custom_styles.css (.faq-item.open) */
.faq-list { display: flex; flex-direction: column; gap: 0.75rem; }
/* icon rotation for chevron on open state */
.faq-item.open .faq-question svg,
.faq-item.open .faq-question i { transform: rotate(180deg); }
/* ensure answer content color matches tool theme */
.faq-answer p { color: var(--text-secondary) !important; }
.faq-answer a { color: var(--primary) !important; }

/* Toast */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 10001;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast-notification.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast-notification.success svg { color: var(--success); }
.toast-notification.error svg { color: var(--danger); }

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

/* Responsive */
@media (max-width: 900px) {
    .viewer-toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-left, .toolbar-right { justify-content: center; }
    .features-grid { grid-template-columns: 1fr; }
    .action-bar { flex-direction: column; }
    .action-group { width: 100%; justify-content: center; }
    .optimize-score-card { flex-direction: column; text-align: center; }
}

@media (max-width: 768px) {
    .tool-container { padding: 1rem; }
    .upload-section { padding: 2rem 1.5rem; }
    .upload-area { padding: 3rem 1.5rem; }
    .viewer-toolbar { padding: 1rem; }
    .stats-bar { gap: 1rem; padding: 1rem; }
    .action-bar { padding: 1.5rem; }
    .gfa-btn { width: 100%; justify-content: center; }
    .file-info-bar { justify-content: center; }
    .related-tools { flex-direction: column; align-items: flex-start; }
    .related-links { width: 100%; }
    .tool-link { flex: 1; min-width: calc(50% - 0.375rem); justify-content: center; }
    .frames-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
    .view-toggle { flex-wrap: wrap; border-radius: var(--radius-md); }
    .view-toggle button { flex: 1; justify-content: center; min-width: calc(33% - 4px); }
    .view-toggle .btn-label { display: none; }
}

@media (max-width: 480px) {
    .tool-title { font-size: 1.75rem; }
    .tool-title-row { flex-direction: column; gap: 0.5rem; }
    .file-info-bar { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
    .toolbar-right { width: 100%; justify-content: space-between; }
    .stats-bar { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .feature-item { flex-direction: column; }
    .frames-summary { flex-direction: column; gap: 0.5rem; }
    .toast-notification { left: 1rem; right: 1rem; transform: translateX(0) translateY(100px); }
    .toast-notification.show { transform: translateX(0) translateY(0); }
}

/* Print */
@media print {
    .upload-section, .viewer-toolbar, .action-bar, .related-tools { display: none !important; }
    .tool-main { box-shadow: none; border: none; }
    .editor-section { display: block !important; }
    .preview-panel { display: block !important; max-height: none !important; }
}

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

/* 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(91, 184, 232, 0.3); }
