@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800;900&family=Playfair+Display:wght@700&family=Roboto+Mono:wght@700&family=Bebas+Neue&family=Montserrat:wght@900&family=Pacifico&family=Oswald:wght@700&family=Permanent+Marker&display=swap');

        :root {
            --bg: #0a0c10;
            --surface: #161b22;
            --surface-light: #21262d;
            --accent: #4f46e5;
            --accent-hover: #6366f1;
            --text: #ffffff;
            --text-muted: #8b949e;
            --border: #30363d;
            --radius: 16px;
            --danger: #f85149;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Inter', sans-serif;
            -webkit-tap-highlight-color: transparent;
        }

        body {
            background-color: var(--bg);
            color: var(--text);
            line-height: 1.5;
            min-height: 100vh;
            overflow-x: hidden;
            padding-bottom: 40px;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 15px;
        }

        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 0 25px;
        }

        .brand {
            display: flex;
            align-items: center;
            gap: 12px;
            text-decoration: none;
            color: white;
        }

        .logo {
            background: var(--accent);
            width: 36px;
            height: 36px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 900;
            font-size: 20px;
        }

        .brand-name {
            font-size: 22px;
            font-weight: 800;
            letter-spacing: -0.5px;
        }

        .main-layout {
            display: grid;
            grid-template-columns: 1fr 380px;
            gap: 25px;
        }

        @media (max-width: 1100px) {
            .main-layout { grid-template-columns: 1fr; }
        }

        .editor-card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 20px;
            display: flex;
            flex-direction: column;
            box-shadow: 0 20px 50px rgba(0,0,0,0.5);
        }

        .preview-container {
            width: 100%;
            margin: 0 auto 24px;
            position: relative;
        }

        .preview-window {
            width: 100%;
            background: #000;
            border-radius: 12px;
            position: relative;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid var(--border);
            touch-action: none;
            aspect-ratio: 16/9; 
        }

        video {
            position: absolute;
            pointer-events: none;
            will-change: transform;
            z-index: 1;
            transform-origin: center center;
        }

        .overlay-layer {
            position: absolute;
            inset: 0;
            pointer-events: none;
            z-index: 100;
        }

        .guide-box {
            background: rgba(79, 70, 229, 0.05);
            border: 1px solid rgba(79, 70, 229, 0.2);
            border-radius: 12px;
            padding: 15px;
            margin-bottom: 20px;
        }

        .guide-title {
            font-size: 13px;
            font-weight: 800;
            color: var(--accent);
            margin-bottom: 8px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .guide-text {
            font-size: 12px;
            color: var(--text-muted);
            line-height: 1.4;
        }

        .range-slider-container {
            padding: 15px 10px 30px;
        }

        .slider-track-wrap {
            position: relative;
            width: 100%;
            height: 10px;
            background: var(--surface-light);
            border-radius: 5px;
            touch-action: none;
        }

        .slider-highlight {
            position: absolute;
            height: 100%;
            background: var(--accent);
            border-radius: 5px;
            z-index: 1;
        }

        .thumb {
            position: absolute;
            top: 50%;
            width: 30px;
            height: 30px;
            background: white;
            border-radius: 50%;
            transform: translate(-50%, -50%);
            z-index: 2;
            cursor: pointer;
            box-shadow: 0 4px 12px rgba(0,0,0,0.6);
            border: 3px solid var(--accent);
        }

        .sidebar { display: flex; flex-direction: column; gap: 20px; }

        .control-group {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 20px;
        }

        .label {
            display: block;
            font-size: 11px;
            font-weight: 800;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-bottom: 12px;
        }

        .btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
        .btn-row-3 { grid-template-columns: repeat(3, 1fr); }

        .toggle-btn {
            background: var(--surface-light);
            border: 1px solid var(--border);
            color: var(--text-muted);
            padding: 12px;
            border-radius: 10px;
            font-weight: 700;
            font-size: 12px;
            cursor: pointer;
            transition: all 0.2s;
            text-align: center;
        }

        .toggle-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

        .action-btn {
            width: 100%;
            padding: 16px;
            border-radius: 12px;
            font-weight: 800;
            border: none;
            cursor: pointer;
            transition: 0.3s;
            margin-top: 10px;
            font-size: 14px;
        }

        .primary { background: var(--accent); color: white; box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4); }
        .primary:hover { background: var(--accent-hover); transform: translateY(-2px); }
        .primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

        .secondary { background: var(--surface-light); color: white; border: 1px solid var(--border); }

        .overlay-list {
            margin-top: 15px;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .overlay-list-item {
            background: var(--surface-light);
            padding: 10px 12px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 13px;
            border: 1px solid transparent;
            cursor: pointer;
        }

        .overlay-list-item:hover { border-color: var(--accent); }

        .item-preview {
            display: flex;
            align-items: center;
            gap: 10px;
            overflow: hidden;
        }

        .item-text {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-weight: 600;
        }

        .delete-btn {
            background: none;
            border: none;
            color: var(--danger);
            cursor: pointer;
            font-size: 18px;
            padding: 0 5px;
            opacity: 0.6;
        }
        .delete-btn:hover { opacity: 1; }

        .modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.95);
            backdrop-filter: blur(12px);
            z-index: 3000;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .modal {
            background: var(--surface);
            border: 1px solid var(--border);
            padding: 30px;
            border-radius: 24px;
            width: 100%;
            max-width: 500px;
            max-height: 90vh;
            overflow-y: auto;
            box-shadow: 0 30px 60px rgba(0,0,0,0.8);
        }

        .text-input {
            width: 100%;
            background: var(--surface-light);
            border: 2px solid var(--border);
            color: white;
            padding: 18px;
            border-radius: 14px;
            margin-bottom: 25px;
            font-size: 18px;
            outline: none;
        }

        .text-input:focus { border-color: var(--accent); }

        .font-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
            margin-bottom: 25px;
        }

        .font-option {
            background: var(--surface-light);
            border: 2px solid transparent;
            padding: 15px;
            border-radius: 12px;
            text-align: center;
            cursor: pointer;
            transition: 0.2s;
            color: white;
            font-size: 13px;
        }

        .font-option.selected { border-color: var(--accent); background: rgba(79, 70, 229, 0.1); }


#btn-save-text {
    margin: 0;
}

#modal-color-input {
    width: 70px; height: 45px; border:none; background:none; cursor:pointer;
}

#text-color {
    margin:0;
}

#text-color-div {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 30px;
}

#modal-scale-input {
    width: 100%; accent-color: var(--accent);
}

#text-size-val {
    font-size: 12px; font-weight: 800; color: var(--accent);
}

#text-size-span {
    margin:0;
}

#text-size-div {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}

#text-size-container {
    margin-bottom: 25px;
}

#modal-title {
    margin-bottom: 15px; font-weight: 900;
}

#inter {
    font-family: 'Inter'; font-weight: 900;
}

#bebas {
    font-family: 'Bebas Neue';
}

#playfair {
    font-family: 'Playfair Display'; font-weight: 700;
}

#pacifico {
    font-family: 'Pacifico';
}

#roboto {
    font-family: 'Roboto Mono';
}

#permanent-marker {
    font-family: 'Permanent Marker';
}

#oswald {
    font-family: 'Oswald';
}

#montserrat {
    font-family: 'Montserrat'; font-weight: 900;
}

#btn-download {
    display: block; text-align: center;
}

#final-gif {
    width: 100%; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 12px;
}

#progress-text {
    font-size: 11px; text-align: center; margin-top: 10px; color: var(--text-muted);
}

#progress-bar {
    width: 0%; height: 100%; background: var(--accent);
}

#progress-bar-div {
    height: 6px; background: var(--surface-light); border-radius: 3px; overflow: hidden;
}

#progress-container {
    margin-top: 20px;
}

#add-caption-btn {
    margin:0;
}

#zoom-div {
    margin-top: 20px; display:flex; align-items:center; gap: 15px;
}

#zoom-control {
    flex:1; accent-color: var(--accent);
}

#zoom-span {
    font-size: 11px; font-weight: 800; color: var(--text-muted);
}

#fill-div {
    margin-top: 15px;
}

#time-display {
    font-size: 13px; font-weight: 800; color: var(--accent); background: rgba(79, 70, 229, 0.1); padding: 6px 14px; border-radius: 8px;
}

#set-duration-text {
    margin:0;
}

#range-slider-div {
    display: flex; justify-content: space-between; margin-bottom: 15px; align-items: center;
}

#secure-browser-text {
    color: var(--text-muted); font-size: 0.9rem; margin-top: 5px;
}

#select-video-text {
    font-weight: 800; font-size: 1.2rem;
}

#video-icon {
    font-size: 50px; margin-bottom: 15px;
}

        .overlay-item {
            position: absolute;
            color: white;
            font-weight: 900;
            cursor: grab;
            pointer-events: auto;
            white-space: nowrap;
            user-select: none;
            transform-origin: center center;
            touch-action: none;
            text-shadow: 0 4px 10px rgba(0,0,0,0.9);
            z-index: 200;
            padding: 4px 8px; /* Adjusted padding to be more precise */
            min-width: 20px;
            min-height: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 28px; /* Fixed base size for consistency */
        }
        
        .overlay-item.selected { border: 2px dashed var(--accent); border-radius: 8px; background: rgba(79, 70, 229, 0.1); }

        .upload-placeholder {
            height: 350px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            border: 2px dashed var(--border);
            border-radius: var(--radius);
            cursor: pointer;
            transition: 0.3s;
        }

        .upload-placeholder:hover { border-color: var(--accent); background: rgba(79, 70, 229, 0.05); }

        .hidden { display: none !important; }

        footer {
            margin-top: 80px;
            padding-top: 50px;
            border-top: 1px solid var(--border);
            display: grid;
            grid-template-columns: 1.5fr 1fr;
            gap: 40px;
        }

        @media (max-width: 768px) { footer { grid-template-columns: 1fr; } }

        .footer-heading { color: white; font-weight: 800; margin-bottom: 15px; }
        .footer-text { color: var(--text-muted); font-size: 14px; line-height: 1.6; }
        .footer-links a { color: var(--accent); text-decoration: none; display: block; margin-bottom: 10px; font-weight: 600; font-size: 14px; }
 