:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --font-family: 'Outfit', sans-serif;
}

/* Floating Banner */
.floating-banner {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 16px 24px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.floating-banner-under {
    position: fixed;
    right: 50%;
    top: auto;
    bottom: 20px;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 16px 24px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    width: max-content;
    transform: translateX(50%);
}

.floating-banner:hover {
    transform: translateY(-50%) scale(1.05) translateX(-5px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.6);
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}


.floating-banner-under:hover {
    transform: translateX(50%) scale(1.05);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.6);
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

@media (max-width: 768px) {
    .floating-banner {
        bottom: 20px;
        top: auto;
        right: 50%;
        transform: translateX(50%);
        width: max-content;
    }

    .floating-banner:hover {
        transform: translateX(50%) scale(1.05);
    }
}

.floating-banner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: translateX(-100%);
    transition: 0.5s;
}

.floating-banner:hover::after {
    transform: translateX(100%);
}

.floating-banner-under::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: translateX(-100%);
    transition: 0.5s;
}

.floating-banner-under:hover::after {
    transform: translateX(100%);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Container */
.container {
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Upload Section */
.upload-container {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.hero-text {
    max-width: 800px;
    margin-bottom: 3rem;
}

.hero-text h2 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-main);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.privacy-note {
    font-size: 0.9rem;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    display: inline-block;
    border: 1px solid var(--border-color);
}

.upload-box {
    width: 100%;
    max-width: 600px;
    height: 300px;
    border: 2px dashed var(--border-color);
    border-radius: 1rem;
    background: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.upload-box:hover,
.upload-box.drag-active {
    border-color: var(--primary-color);
    background: #eef2ff;
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
}

.or-divider {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Buttons */
.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    font-family: var(--font-family);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

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

.secondary-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.secondary-btn:hover {
    border-color: var(--text-main);
    color: var(--text-main);
    background: #f8fafc;
}

.icon-btn,
.icon-nav-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.4rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover,
.icon-nav-btn:hover {
    background: #eff6ff;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Editor Section */
.editor-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    width: 100%;
}

.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.control-panel {
    width: 350px;
    flex-shrink: 0;
}

.panel-card,
.preview-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.image-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    border-radius: 0.5rem;
    overflow: hidden;
}

#gif-preview,
#resized-gif-preview {
    max-width: 100%;
    height: auto;
    display: block;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* GIF Info Grid */
.gif-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

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

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

.info-value {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    font-family: monospace;
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    padding-bottom: 2rem;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    aspect-ratio: 1;
}

.tool-btn:hover {
    background: #eef2ff;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.tool-btn span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-main);
}

.tool-btn:hover span {
    color: var(--primary-color);
}

.icon-box {
    color: var(--text-muted);
    transition: color 0.2s;
}

.tool-btn:hover .icon-box {
    color: var(--primary-color);
}

/* Tool Panel (Generic) */
.tool-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-bottom: 2rem;
}

.panel-header h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Resize Controls */
.resize-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.control-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.slider-input-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.range-slider {
    flex: 1;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    appearance: none;
}

.range-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Cut Tool Dual Sliders */
.dual-range-container {
    position: relative;
    width: 100%;
    height: 30px;
    margin: 1.5rem 0;
}

.range-track {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    z-index: 1;
}

.range-highlight {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    background: var(--primary-color);
    z-index: 2;
    border-radius: 3px;
    pointer-events: none;
}

.dual-range-container input[type=range] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    z-index: 3;
}

.dual-range-container input[type=range]::-webkit-slider-thumb {
    pointer-events: auto;
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: #fff;
    border: 3px solid var(--primary-color);
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    margin-top: -9px;
    /* Adjust for vertical centering if needed, relative to track logic usually */
    /* Since we set height 100% on input, centering might depend. 
       Actually, standard "vertical-align" inside input is tricky.
       Let's stick to simple props. margin-top often needed in webkit for custom track. */
}

/* Firefox */
.dual-range-container input[type=range]::-moz-range-thumb {
    pointer-events: auto;
    width: 24px;
    height: 24px;
    background: #fff;
    border: 3px solid var(--primary-color);
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: none;
    border: 3px solid var(--primary-color);
}

.number-input {
    width: 70px;
    padding: 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-main);
}

.lock-container {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 30px;
}

.lock-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
    z-index: 0;
    transform: translateX(-50%);
}

.lock-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 0.4rem;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1;
    color: var(--text-muted);
    display: flex;
    transition: all 0.2s;
}

.lock-btn.active {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: #eef2ff;
}

/* Progress Bar */
.progress-container {
    width: 100%;
    position: relative;
    margin: 1.5rem 0 0.5rem 0;
    /* Add top margin for text */
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

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

.progress-text {
    position: absolute;
    right: 0;
    top: -22px;
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 600;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(79, 70, 229, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

/* Loading Overlay */
.image-wrapper {
    position: relative;
    /* Ensure overlay is contained */
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 0.5rem;
}

.spinner-large {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(79, 70, 229, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

/* Panel Actions */
.panel-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.panel-actions button {
    flex: 1;
}


/* Utilities */
.hidden {
    display: none !important;
}

/* Crop Controls */
.crop-controls {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Chip Group */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 2rem;
    /* Pill shape */
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

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

.chip-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

/* Radio Group */
.radio-group {
    display: flex;
    gap: 1.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    display: none;
    /* Hide default */
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    margin-right: 0.5rem;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    /* Prevent squashing */
    box-sizing: border-box;
}

.radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: 50%;
    transition: transform 0.2s;
}

.radio-label input:checked+.radio-custom {
    border-color: var(--primary-color);
}

.radio-label input:checked+.radio-custom::after {
    transform: translate(-50%, -50%) scale(1);
}

.radio-text {
    font-size: 0.9rem;
    color: var(--text-main);
}

/* Color Picker */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#crop-bg-color {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    /* Circle */
    overflow: hidden;
    cursor: pointer;
}

.cut-preview-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    width: 100%;
}

#cut-start-preview {
    width: 100%;
}

#cut-end-preview {
    width: 100%;
}

.cut-preview-item {
    width: 100%;
}

#crop-bg-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

#crop-bg-color::-webkit-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: 50%;
}

#crop-bg-text {
    font-family: monospace;
    color: var(--text-main);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
    }

    .container {
        padding: 1rem;
    }

    .hero-text h2 {
        font-size: 2rem;
    }

    /* Editor Mobile Layout: GIF on top, Panel on bottom */
    .editor-layout {
        flex-direction: column;
    }

    .control-panel {
        width: 100%;
        height: auto;
    }
}

/* Value Difference Colors */
.diff-dec {
    color: #2563eb;
    /* Blue for negative/decrease */
    font-weight: 600;
}

.diff-inc {
    color: #dc2626;
    /* Red for positive/increase */
    font-weight: 600;

    /* Convert Tool Styles */
    .format-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
        margin-bottom: 2rem;
    }

    .format-card {
        position: relative;
        cursor: pointer;
    }

    .format-card input {
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

    .format-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 1.5rem 0.5rem;
        background: var(--bg-color);
        border: 2px solid var(--border-color);
        border-radius: 1rem;
        transition: all 0.2s ease;
        height: 100%;
    }

    .format-ext {
        font-size: 1.25rem;
        font-weight: 700;
        color: var(--text-main);
        margin-bottom: 0.25rem;
    }

    .format-name {
        font-size: 0.8rem;
        color: var(--text-muted);
    }

    .format-card input:checked+.format-content {
        border-color: var(--primary-color);
        background: #eef2ff;
        transform: translateY(-2px);
        box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.1);
    }

    .format-card input:checked+.format-content .format-ext {
        color: var(--primary-color);
    }