:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --primary: #38bdf8;
    --primary-glow: rgba(56, 189, 248, 0.4);
    --secondary: #94a3b8;
    --accent: #8b5cf6;
    --text: #f1f5f9;
    --text-dim: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 1rem;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 0% 0%, rgba(56, 189, 248, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
}

#app {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--glass-border);
    border-radius: 16px;
    padding: 3rem 1rem;
    text-align: center;
    transition: all 0.3s ease;
}

.upload-zone:active {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
}

.upload-content svg {
    width: 48px;
    height: 48px;
    color: var(--primary);
    margin-bottom: 1rem;
}

.upload-content p {
    color: var(--text-dim);
    margin-bottom: 1.5rem;
}

/* Video Preview & Crop */
.video-container {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    margin-bottom: 1.5rem;
}

video {
    width: 100%;
    display: block;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.crop-box {
    position: absolute;
    border: 2px solid var(--primary);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    pointer-events: all;
    cursor: move;
}

.handle {
    position: absolute;
    width: 28px;
    height: 28px;
    background: var(--primary);
    border: 3px solid #fff;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 10;
}

.handle.nw { top: -14px; left: -14px; cursor: nw-resize; }
.handle.ne { top: -14px; right: -14px; cursor: ne-resize; }
.handle.sw { bottom: -14px; left: -14px; cursor: sw-resize; }
.handle.se { bottom: -14px; right: -14px; cursor: se-resize; }

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

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

#time-display {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 600;
}

/* Dual Range Slider */
.range-slider-container {
    position: relative;
    width: 100%;
    height: 40px;
}

.slider {
    position: absolute;
    width: 100%;
    pointer-events: none;
    appearance: none;
    background: none;
    z-index: 2;
    height: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.slider::-webkit-slider-thumb {
    appearance: none;
    pointer-events: all;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.slider-track {
    position: absolute;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    overflow: hidden;
}

.slider-track::before {
    content: "";
    position: absolute;
    height: 100%;
    background: var(--primary);
    left: var(--range-start, 0%);
    right: var(--range-end, 0%);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-round {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 24px;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider-round {
    background-color: var(--primary);
}

input:checked + .slider-round:before {
    transform: translateX(26px);
}

/* Buttons */
.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.8rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
    text-decoration: none;
}

.primary-btn:active {
    transform: scale(0.98);
}

.primary-btn.large {
    padding: 1.2rem;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.primary-btn.secondary {
    background: linear-gradient(135deg, var(--accent), #d8b4fe);
}

.secondary-btn {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem;
    cursor: pointer;
}

.glass-btn {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
    border: 1px solid var(--glass-border);
    color: var(--text);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.8rem;
}

/* Progress */
#progress-container {
    margin: 1rem 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

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

#progress-text {
    font-size: 0.8rem;
    color: var(--primary);
    text-align: center;
}

/* Result */
.result-container {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    margin: 1rem 0;
}

#gif-result {
    width: 100%;
    display: block;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

footer {
    text-align: center;
    padding: 1rem;
}

footer p {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    body {
        padding: 0.5rem;
    }
    .card {
        padding: 1rem;
    }
}
