*,
        *::before,
        *::after {
            margin: 0;
            padding: 0;
            box-sizing: border-box
        }

        :root {
            --bg: #080810;
            --bg2: #10101a;
            --bg3: #181824;
            --bg4: #202030;
            --bdr: #2a2a3a;
            --txt: #e4e4e7;
            --txt2: #9ca3af;
            --txt3: #6b7280;
            --purple: #8b5cf6;
            --cyan: #00c8ff;
            --green: #22c55e;
            --red: #ef4444;
            --gold: #d4af37;
            --r: 10px;
            --track-h: 60px
        }

        body {
            font-family: 'Inter', sans-serif;
            background: var(--bg);
            color: var(--txt);
            height: 100vh;
            overflow: hidden;
            display: flex;
            flex-direction: column
        }

        /* Header */
        .header {
            background: var(--bg2);
            border-bottom: 1px solid var(--bdr);
            padding: 10px 20px;
            display: flex;
            align-items: center;
            gap: 14px;
            flex-shrink: 0
        }

        .logo {
            width: 34px;
            height: 34px;
            background: linear-gradient(135deg, var(--purple), var(--cyan));
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px
        }

        .header h1 {
            font-size: 16px;
            font-weight: 600;
            background: linear-gradient(135deg, var(--txt), var(--purple));
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent
        }

        .nav {
            display: flex;
            gap: 4px;
            margin-left: 16px
        }

        .nav a {
            padding: 6px 14px;
            border-radius: 6px;
            font-size: 12px;
            font-weight: 500;
            text-decoration: none;
            color: var(--txt2);
            border: 1px solid transparent;
            transition: all .2s
        }

        .nav a:hover {
            color: var(--txt);
            background: var(--bg3)
        }

        .nav a.active {
            background: var(--purple);
            color: #fff
        }

        .toolbar {
            margin-left: auto;
            display: flex;
            gap: 6px;
            align-items: center;
            flex-wrap: wrap;
            justify-content: flex-end
        }

        .tool-btn {
            padding: 7px 14px;
            border-radius: 6px;
            border: 1px solid var(--bdr);
            background: var(--bg3);
            color: var(--txt);
            font-size: 12px;
            font-weight: 500;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 5px;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
            overflow: visible;
            /* Required for custom tooltips */
        }

        .tool-btn:hover {
            border-color: var(--cyan);
            background: var(--bg4);
            box-shadow: 0 0 16px rgba(0, 200, 255, 0.25), inset 0 0 8px rgba(0, 200, 255, 0.1);
            transform: translateY(-1px);
            z-index: 10;
        }

        .tool-btn[style*="var(--gold)"]:hover {
            box-shadow: 0 0 16px rgba(212, 175, 55, 0.35), inset 0 0 8px rgba(212, 175, 55, 0.15) !important;
            text-shadow: 0 0 12px rgba(212, 175, 55, 0.5);
            border-color: #fde047 !important;
            color: #fde047 !important;
        }

        .tool-btn[style*="var(--red)"]:hover {
            box-shadow: 0 0 16px rgba(239, 68, 68, 0.35), inset 0 0 8px rgba(239, 68, 68, 0.15) !important;
            text-shadow: 0 0 12px rgba(239, 68, 68, 0.5);
            border-color: #fca5a5 !important;
            color: #fca5a5 !important;
        }

        .tool-btn.primary {
            background: linear-gradient(135deg, var(--purple), #6d28d9);
            border-color: transparent;
            color: #fff
        }

        .tool-btn.primary:hover {
            box-shadow: 0 4px 20px rgba(139, 92, 246, 0.6), inset 0 0 12px rgba(255, 255, 255, 0.2);
            border-color: #a78bfa;
            transform: translateY(-2px);
        }

        /* Custom Tooltips & Glowing Interactivity */
        [data-tooltip] {
            position: relative;
        }

        [data-tooltip]::after {
            content: attr(data-tooltip);
            position: absolute;
            bottom: -38px;
            left: 50%;
            transform: translateX(-50%) translateY(-10px);
            background: rgba(10, 10, 16, 0.95);
            backdrop-filter: blur(8px);
            color: #fff;
            padding: 6px 14px;
            border-radius: 6px;
            font-size: 11px;
            white-space: nowrap;
            opacity: 0;
            pointer-events: none;
            transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            z-index: 1000;
            border: 1px solid var(--purple);
            box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
            font-weight: 500;
            letter-spacing: 0.02em;
        }

        [data-tooltip]:hover::after {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }

        [data-tooltip]:hover {
            text-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
        }

        /* Main Area */
        .main {
            flex: 1;
            display: grid;
            grid-template-columns: 200px 1fr 240px;
            overflow: hidden;
            min-height: 0
        }

        /* Media Browser */
        .media-browser {
            background: var(--bg2);
            border-right: 1px solid var(--bdr);
            display: flex;
            flex-direction: column;
            overflow: hidden
        }

        .panel-head {
            padding: 10px 14px;
            border-bottom: 1px solid var(--bdr);
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: .1em;
            color: var(--txt3);
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 6px
        }

        .media-list {
            flex: 1;
            overflow-y: auto;
            padding: 8px
        }

        .media-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px;
            border-radius: var(--r);
            cursor: grab;
            transition: all .15s;
            border: 1px solid transparent;
            margin-bottom: 4px
        }

        .media-item:hover {
            background: var(--bg3);
            border-color: var(--bdr)
        }

        .media-item.dragging {
            opacity: .5
        }

        .media-thumb {
            width: 48px;
            height: 32px;
            border-radius: 4px;
            background: var(--bg4);
            overflow: hidden;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center
        }

        .media-thumb img {
            width: 100%;
            height: 100%;
            object-fit: cover
        }

        .media-thumb .icon {
            font-size: 16px;
            opacity: .5
        }

        .media-name {
            font-size: 11px;
            font-weight: 500;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            flex: 1
        }

        .media-dur {
            font-size: 10px;
            color: var(--txt3);
            font-family: 'JetBrains Mono', monospace
        }

        /* Preview */
        .preview-area {
            background: var(--bg);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 12px;
            position: relative;
            min-height: 0;
            overflow: hidden
        }

        .canvas-wrap {
            border-radius: var(--r);
            overflow: hidden;
            box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
            border: 1px solid var(--bdr);
            position: relative;
            max-width: 100%;
            max-height: calc(100% - 50px)
        }

        canvas {
            display: block;
            background: #000;
            max-width: 100%;
            max-height: 100%;
            width: auto;
            height: auto
        }

        .preview-controls {
            display: flex;
            gap: 6px;
            margin-top: 10px;
            align-items: center
        }

        .play-btn {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            border: none;
            background: var(--purple);
            color: #fff;
            font-size: 14px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
            transition: all 0.2s;
            overflow: visible;
        }

        .play-btn:hover {
            background: #7c3aed;
            box-shadow: 0 0 16px rgba(139, 92, 246, 0.4);
            transform: scale(1.05);
        }

        .time-display {
            font-size: 11px;
            color: var(--txt3);
            font-family: 'JetBrains Mono', monospace;
            min-width: 100px;
            text-align: center
        }

        /* Properties */
        .properties {
            background: var(--bg2);
            border-left: 1px solid var(--bdr);
            overflow-y: auto
        }

        .prop-section {
            padding: 12px 14px;
            border-bottom: 1px solid var(--bdr)
        }

        .prop-section h4 {
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: .08em;
            color: var(--txt3);
            margin-bottom: 8px
        }

        .prop-row {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 8px
        }

        .prop-row label {
            font-size: 11px;
            color: var(--txt2);
            width: 60px;
            flex-shrink: 0
        }

        .prop-row input,
        .prop-row select,
        .prop-row textarea {
            flex: 1;
            padding: 5px 8px;
            border-radius: 6px;
            border: 1px solid var(--bdr);
            background: var(--bg3);
            color: var(--txt);
            font-size: 12px;
            font-family: 'Inter', sans-serif;
            outline: none
        }

        .prop-row input:focus,
        .prop-row select:focus {
            border-color: var(--purple)
        }

        .prop-row textarea {
            height: 60px;
            resize: vertical
        }

        .prop-row input[type=color] {
            width: 32px;
            height: 28px;
            padding: 2px;
            cursor: pointer;
            flex: 0
        }

        .prop-row input[type=range] {
            accent-color: var(--purple)
        }

        .prop-row .val {
            font-size: 10px;
            color: var(--cyan);
            font-family: 'JetBrains Mono', monospace;
            width: 30px;
            text-align: right
        }

        /* Timeline */
        .timeline {
            background: var(--bg2);
            border-top: 1px solid var(--bdr);
            flex-shrink: 0;
            height: clamp(140px, 25vh, 220px);
            display: flex;
            flex-direction: column
        }

        .timeline-head {
            display: flex;
            align-items: center;
            padding: 6px 14px;
            border-bottom: 1px solid var(--bdr);
            gap: 8px
        }

        .timeline-head .title {
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: .08em;
            color: var(--txt3);
            font-weight: 600
        }

        .add-btns {
            display: flex;
            gap: 4px;
            margin-left: auto
        }

        .add-btn {
            padding: 4px 10px;
            border-radius: 5px;
            border: 1px solid var(--bdr);
            background: var(--bg3);
            color: var(--txt2);
            font-size: 11px;
            cursor: pointer;
            transition: all .15s
        }

        .add-btn:hover {
            border-color: var(--purple);
            color: var(--txt)
        }

        .timeline-body {
            flex: 1;
            display: flex;
            overflow-y: auto;
            overflow-x: hidden;
        }

        .track-labels {
            width: 90px;
            flex-shrink: 0;
            border-right: 1px solid var(--bdr)
        }

        .track-label {
            height: var(--track-h);
            display: flex;
            align-items: center;
            padding: 0 10px;
            font-size: 11px;
            color: var(--txt3);
            border-bottom: 1px solid var(--bdr);
            gap: 4px
        }

        .track-label .dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            flex-shrink: 0
        }

        .timeline-scroll {
            flex: 1;
            overflow-x: auto;
            overflow-y: hidden;
            position: relative
        }

        .timeline-ruler {
            height: 20px;
            background: var(--bg);
            border-bottom: 1px solid var(--bdr);
            position: relative;
            min-width: 100%
        }

        .ruler-mark {
            position: absolute;
            top: 0;
            font-size: 9px;
            color: var(--txt3);
            font-family: 'JetBrains Mono', monospace;
            padding: 3px 4px
        }

        .ruler-mark::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 1px;
            height: 6px;
            background: var(--bdr)
        }

        .tracks-area {
            position: relative;
            min-width: 100%
        }

        .track-row {
            height: var(--track-h);
            border-bottom: 1px solid var(--bdr);
            position: relative
        }

        .clip {
            position: absolute;
            top: 4px;
            height: calc(var(--track-h) - 8px);
            border-radius: 6px;
            cursor: pointer;
            overflow: hidden;
            display: flex;
            align-items: center;
            padding: 0 8px;
            font-size: 10px;
            font-weight: 500;
            white-space: nowrap;
            border: 1px solid transparent;
            transition: border-color .15s, box-shadow .15s
        }

        .clip:hover,
        .clip.selected {
            border-color: #fff3;
            box-shadow: 0 2px 8px rgba(0, 0, 0, .3)
        }

        .clip.selected {
            outline: 2px solid var(--cyan);
            outline-offset: -1px
        }

        .clip.video {
            background: linear-gradient(135deg, #1e3a5f, #1a2744)
        }

        .clip.image {
            background: linear-gradient(135deg, #2d1b4e, #1e1535)
        }

        .clip.text {
            background: linear-gradient(135deg, #1b4332, #15322a)
        }

        .clip.audio {
            background: linear-gradient(135deg, #4a1d1d, #331515)
        }

        .clip-thumb {
            width: 36px;
            height: 100%;
            object-fit: cover;
            margin-right: 6px;
            flex-shrink: 0;
            border-radius: 4px
        }

        .playhead {
            position: absolute;
            top: 0;
            width: 2px;
            background: var(--red);
            z-index: 10;
            pointer-events: none
        }

        .playhead::before {
            content: '';
            position: absolute;
            top: -2px;
            left: -5px;
            width: 12px;
            height: 6px;
            background: var(--red);
            border-radius: 2px
        }

        /* Toast */
        .toast-box {
            position: fixed;
            bottom: 20px;
            right: 20px;
            z-index: 9999
        }

        .toast {
            padding: 10px 16px;
            border-radius: 6px;
            font-size: 12px;
            font-weight: 500;
            color: #fff;
            animation: tIn .3s ease;
            box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
            margin-top: 6px
        }

        .toast.ok {
            background: var(--green)
        }

        .toast.err {
            background: var(--red)
        }

        .toast.info {
            background: var(--purple)
        }

        @keyframes tIn {
            from {
                transform: translateX(80px);
                opacity: 0
            }

            to {
                transform: translateX(0);
                opacity: 1
            }
        }

        /* Render overlay */
        .render-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, .85);
            z-index: 500;
            display: none;
            align-items: center;
            justify-content: center;
            flex-direction: column
        }

        .render-overlay.active {
            display: flex
        }

        .render-overlay .spinner {
            width: 40px;
            height: 40px;
            border: 3px solid var(--bdr);
            border-top-color: var(--purple);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-bottom: 12px
        }

        .render-overlay p {
            font-size: 14px;
            font-weight: 500
        }

        .render-overlay .sub {
            color: var(--txt3);
            font-size: 12px;
            margin-top: 4px
        }

        @keyframes spin {
            to {
                transform: rotate(360deg)
            }
        }

        /* Modals */
        .modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, .7);
            z-index: 400;
            display: none;
            align-items: center;
            justify-content: center
        }

        .modal-overlay.active {
            display: flex
        }

        .modal {
            background: var(--bg2);
            border: 1px solid var(--bdr);
            border-radius: 12px;
            padding: 24px;
            width: 420px;
            max-width: 90vw
        }

        .modal h3 {
            font-size: 16px;
            margin-bottom: 16px
        }

        .modal .field {
            margin-bottom: 12px
        }

        .modal .field label {
            display: block;
            font-size: 12px;
            color: var(--txt2);
            margin-bottom: 4px
        }

        .modal .field input,
        .modal .field textarea,
        .modal .field select {
            width: 100%;
            padding: 8px 10px;
            border-radius: 8px;
            border: 1px solid var(--bdr);
            background: var(--bg3);
            color: var(--txt);
            font-size: 13px;
            font-family: 'Inter', sans-serif;
            outline: none
        }

        .modal .field textarea {
            height: 80px;
            resize: vertical
        }

        .modal-btns {
            display: flex;
            gap: 8px;
            justify-content: flex-end;
            margin-top: 16px
        }

        ::-webkit-scrollbar {
            width: 6px;
            height: 6px
        }

        ::-webkit-scrollbar-track {
            background: var(--bg)
        }

        ::-webkit-scrollbar-thumb {
            background: var(--bdr);
            border-radius: 3px
        }

        /* AI Chat Panel */
        .chat-toggle {
            position: fixed;
            bottom: 20px;
            right: 20px;
            width: 52px;
            height: 52px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--purple), var(--cyan));
            border: none;
            color: #fff;
            font-size: 22px;
            cursor: pointer;
            z-index: 300;
            box-shadow: 0 4px 20px rgba(139, 92, 246, .4);
            transition: all .2s;
            display: flex;
            align-items: center;
            justify-content: center
        }

        .chat-toggle:hover {
            transform: scale(1.1);
            box-shadow: 0 6px 28px rgba(139, 92, 246, .5)
        }

        .chat-toggle.active {
            background: var(--bg4);
            box-shadow: none
        }

        .chat-panel {
            position: fixed;
            bottom: 80px;
            right: 20px;
            width: 380px;
            height: 500px;
            background: var(--bg2);
            border: 1px solid var(--bdr);
            border-radius: 16px;
            z-index: 300;
            display: none;
            flex-direction: column;
            overflow: hidden;
            box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
            animation: chatIn .25s ease
        }

        .chat-panel.open {
            display: flex
        }

        @keyframes chatIn {
            from {
                opacity: 0;
                transform: translateY(20px)
            }

            to {
                opacity: 1;
                transform: translateY(0)
            }
        }

        .chat-head {
            padding: 12px 16px;
            border-bottom: 1px solid var(--bdr);
            display: flex;
            align-items: center;
            gap: 8px;
            background: linear-gradient(135deg, rgba(139, 92, 246, .1), rgba(0, 200, 255, .05))
        }

        .chat-head .avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--purple), var(--cyan));
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px
        }

        .chat-head .name {
            font-size: 13px;
            font-weight: 600
        }

        .chat-head .name span {
            font-size: 10px;
            color: var(--green);
            margin-left: 6px
        }

        .chat-msgs {
            flex: 1;
            overflow-y: auto;
            padding: 12px;
            display: flex;
            flex-direction: column;
            gap: 8px
        }

        .chat-msg {
            max-width: 85%;
            padding: 10px 14px;
            border-radius: 12px;
            font-size: 12px;
            line-height: 1.5;
            word-wrap: break-word
        }

        .chat-msg.bot {
            background: var(--bg3);
            align-self: flex-start;
            border-bottom-left-radius: 4px
        }

        .chat-msg.user {
            background: var(--purple);
            align-self: flex-end;
            border-bottom-right-radius: 4px
        }

        .chat-msg.system {
            background: rgba(0, 200, 255, .1);
            border: 1px solid rgba(0, 200, 255, .2);
            align-self: center;
            text-align: center;
            font-size: 11px;
            color: var(--cyan)
        }

        .chat-msg .typing {
            display: inline-flex;
            gap: 4px
        }

        .chat-msg .typing span {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: var(--txt3);
            animation: typeBounce .6s ease infinite
        }

        .chat-msg .typing span:nth-child(2) {
            animation-delay: .1s
        }

        .chat-msg .typing span:nth-child(3) {
            animation-delay: .2s
        }

        @keyframes typeBounce {

            0%,
            100% {
                opacity: .3
            }

            50% {
                opacity: 1
            }
        }

        .chat-input-wrap {
            padding: 10px;
            border-top: 1px solid var(--bdr);
            display: flex;
            gap: 6px
        }

        .chat-input {
            flex: 1;
            padding: 10px 14px;
            border-radius: 10px;
            border: 1px solid var(--bdr);
            background: var(--bg3);
            color: var(--txt);
            font-size: 12px;
            font-family: 'Inter', sans-serif;
            outline: none;
            resize: none
        }

        .chat-input:focus {
            border-color: var(--purple)
        }

        .chat-send {
            width: 36px;
            height: 36px;
            border-radius: 8px;
            border: none;
            background: var(--purple);
            color: #fff;
            font-size: 14px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0
        }

        .chat-send:hover {
            background: #7c3aed
        }

        .chat-send:disabled {
            opacity: .4;
            cursor: not-allowed
        }

        /* ── Responsive ── */
        @media (max-width: 1100px) {
            .main {
                grid-template-columns: 160px 1fr 200px
            }

            .tool-btn span.label {
                display: none
            }
        }

        @media (max-width: 900px) {
            .main {
                grid-template-columns: 1fr;
                grid-template-rows: 1fr
            }

            .media-browser,
            .properties {
                display: none
            }

            .header {
                padding: 8px 12px;
                gap: 8px
            }

            .header h1 {
                font-size: 13px
            }

            .nav a {
                padding: 4px 8px;
                font-size: 11px
            }

            .tool-btn {
                padding: 5px 8px;
                font-size: 11px
            }

            .preview-controls {
                flex-wrap: wrap;
                justify-content: center
            }

            .chat-panel {
                width: calc(100vw - 20px);
                right: 10px;
                bottom: 70px;
                height: 60vh
            }
        }

        @media (max-height: 600px) {
            .timeline {
                height: 120px
            }

            .preview-area {
                padding: 6px
            }

            .header {
                padding: 6px 12px
            }

            :root {
                --track-h: 40px
            }
        }