/* Titra Shqip - Zeemo-style Dark Editor */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Roboto:wght@400;500;700;900&family=Open+Sans:wght@400;600;700;800&family=Montserrat:wght@400;500;600;700;800;900&family=Lato:wght@400;700;900&family=Oswald:wght@400;500;600;700&family=Poppins:wght@400;500;600;700;800;900&display=swap');

:root {
    --bg-darkest: #0a0a0f;
    --bg-dark: #111118;
    --bg-panel: #16161f;
    --bg-card: #1c1c28;
    --bg-hover: #22222f;
    --bg-active: #2a2a3a;
    --border: #2a2a38;
    --border-light: #353545;
    --text: #e8e8ef;
    --text-dim: #8888a0;
    --text-muted: #555568;
    --primary: #7c5cfc;
    --primary-light: #9b7fff;
    --primary-dark: #5a3fd6;
    --primary-bg: rgba(124,92,252,0.12);
    --primary-border: rgba(124,92,252,0.3);
    --accent: #00d4aa;
    --accent-bg: rgba(0,212,170,0.1);
    --danger: #ff4757;
    --danger-bg: rgba(255,71,87,0.1);
    --warning: #ffa502;
    --success: #2ed573;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-darkest);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ==================== HEADER ==================== */
.header {
    height: 48px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    cursor: pointer;
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: #fff;
}

.logo span { font-weight: 700; font-size: 14px; }
.logo span em { font-style: normal; color: var(--primary-light); }

.divider-v { width: 1px; height: 20px; background: var(--border); }

.project-name {
    font-size: 13px;
    color: var(--text-dim);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.save-status {
    font-size: 11px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-right { display: flex; align-items: center; gap: 8px; }

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

.btn-export {
    background: linear-gradient(135deg, var(--primary), #9b7fff);
    color: #fff;
    padding: 7px 18px;
    border-radius: 20px;
    font-weight: 700;
}
.btn-export:hover { filter: brightness(1.15); transform: translateY(-1px); }

.btn-ghost { background: transparent; color: var(--text-dim); padding: 6px 10px; }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }

.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-light); }

.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(255,71,87,0.2); }
.btn-danger:hover { background: rgba(255,71,87,0.2); }

.btn-success { background: var(--accent); color: #000; font-weight: 700; }
.btn-success:hover { filter: brightness(1.1); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.icon-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: transparent; color: var(--text-dim);
    border-radius: 6px; cursor: pointer; transition: var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.active { color: var(--primary-light); background: var(--primary-bg); }

/* ==================== UPLOAD PAGE ==================== */
.upload-page {
    height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.upload-hero {
    text-align: center;
    margin-bottom: 2rem;
    animation: fadeUp 0.6s ease;
}

.upload-hero h2 {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 0.75rem;
}

.upload-hero h2 span {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.upload-hero p {
    font-size: 1rem;
    color: var(--text-dim);
    max-width: 500px;
    line-height: 1.5;
}

.features-strip {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.feature-badge {
    padding: 5px 14px;
    background: var(--primary-bg);
    border: 1px solid var(--primary-border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-light);
}

.upload-zone {
    width: 100%;
    max-width: 560px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    animation: fadeUp 0.6s ease 0.1s both;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.upload-zone svg { width: 48px; height: 48px; color: var(--text-muted); margin-bottom: 1rem; }
.upload-zone h3 { font-size: 1rem; margin-bottom: 0.4rem; }
.upload-zone p { font-size: 0.85rem; color: var(--text-dim); }
.upload-zone .formats { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.75rem; }

.recent-projects {
    width: 100%;
    max-width: 560px;
    margin-top: 2rem;
    animation: fadeUp 0.6s ease 0.2s both;
}

.recent-projects h3 {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.project-item:hover { border-color: var(--primary-border); background: var(--bg-card); }
.project-item .name { font-size: 0.85rem; font-weight: 600; }
.project-item .date { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ==================== EDITOR LAYOUT ==================== */
.editor-container {
    display: flex;
    height: calc(100vh - 48px);
    overflow: hidden;
}

/* LEFT PANEL */
.left-panel {
    width: 380px;
    min-width: 320px;
    background: var(--bg-dark);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.left-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.left-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    font-family: inherit;
}

.left-tab:hover { color: var(--text-dim); }
.left-tab.active { color: var(--primary-light); border-bottom-color: var(--primary); }

/* Transcribe Panel */
.transcribe-panel {
    padding: 14px 16px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.transcribe-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.transcribe-bar .btn { flex: 1; }

.transcribe-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-dim);
}

.transcribe-progress {
    width: 100%;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.transcribe-progress .bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s;
}

.pulse-dot {
    width: 8px; height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 1.2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.4); }
}

/* Subtitle List */
.subtitle-list-area {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.sub-item {
    display: flex;
    gap: 0;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.sub-item:hover { background: var(--bg-hover); }
.sub-item.active { background: var(--primary-bg); border-left: 3px solid var(--primary); }

.sub-index {
    width: 24px;
    font-size: 11px;
    color: var(--text-muted);
    padding-top: 2px;
    flex-shrink: 0;
    text-align: center;
}

.sub-content { flex: 1; min-width: 0; }

.sub-times {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Consolas', monospace;
    margin-bottom: 4px;
}

.sub-times span { color: var(--text-dim); }

.sub-text-display {
    font-size: 13px;
    color: var(--text);
    line-height: 1.4;
    word-break: break-word;
}

.sub-actions {
    display: none;
    align-items: center;
    gap: 2px;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

.sub-item:hover .sub-actions { display: flex; }

.sub-action-btn {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    border: none;
    background: var(--bg-card);
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}
.sub-action-btn:hover { color: var(--danger); background: var(--danger-bg); }

/* Subtitle list toolbar */
.subtitle-list-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.subtitle-list-toolbar .btn { font-size: 11px; }
#btnBatchEdit.active { background: var(--primary-bg); color: var(--primary-light); border-color: var(--primary); }

/* Inline editing in subtitle list */
.sub-times-edit {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-bottom: 4px;
}
.time-sep {
    color: var(--text-muted);
    font-size: 10px;
    padding: 0 2px;
}
.inline-time {
    width: 72px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-dim);
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 10px;
    padding: 2px 4px;
    outline: none;
    transition: border-color 0.2s;
}
.inline-time:focus {
    border-color: var(--primary);
    color: var(--text);
}
.inline-text {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    padding: 4px 6px;
    resize: none;
    outline: none;
    line-height: 1.4;
    transition: border-color 0.2s;
}
.inline-text:focus {
    border-color: var(--primary);
}

/* Batch edit table */
.batch-table-wrap {
    overflow-x: auto;
    padding: 0;
}
.batch-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}
.batch-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}
.batch-table th {
    background: var(--bg-card);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 10px;
    padding: 6px 4px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.batch-table td {
    padding: 3px 4px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.batch-table tr { cursor: pointer; transition: background 0.15s; }
.batch-table tr:hover { background: var(--bg-hover); }
.batch-table tr.active { background: var(--primary-bg); }
.bt-num { width: 28px; text-align: center; color: var(--text-muted); font-size: 10px; }
.bt-start, .bt-end { width: 80px; }
.bt-text { }
.bt-act { width: 28px; }
.batch-input {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    color: var(--text);
    font-family: inherit;
    font-size: 11px;
    padding: 3px 4px;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}
.batch-input:hover {
    background: var(--bg-card);
    border-color: var(--border);
}
.batch-input:focus {
    background: var(--bg-card);
    border-color: var(--primary);
}
.batch-time {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 10px;
}

.empty-subs {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-subs svg { margin-bottom: 12px; opacity: 0.4; }
.empty-subs p { font-size: 13px; line-height: 1.5; }

/* ==================== CENTER - Video ==================== */
.center-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-darkest);
    min-width: 0;
}

.video-viewport {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: #000;
}

.video-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: inline-block;
}

.video-wrapper video {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 48px - 44px - 100px);
    background: #000;
}

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

.subtitle-display {
    position: absolute;
    padding: 10px 20px;
    border-radius: 4px;
    max-width: 85%;
    line-height: 1.35;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.5);
    white-space: pre-wrap;
    word-wrap: break-word;
    pointer-events: auto;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* Safe Zone Overlay */
.safe-zone-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
}

.safe-zone-border {
    position: absolute;
    border: 2px dashed rgba(255, 60, 60, 0.7);
    border-radius: 4px;
    box-shadow: 0 0 0 9999px rgba(255, 0, 0, 0.08);
}

.safe-zone-label {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    color: rgba(255, 60, 60, 0.8);
    background: rgba(0,0,0,0.6);
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
}

/* Video Controls */
.video-controls {
    height: 44px;
    background: var(--bg-dark);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 10px;
    flex-shrink: 0;
}

.play-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border: none;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.play-btn:hover { background: var(--primary-light); }

.time-display {
    font-size: 12px;
    color: var(--text-dim);
    font-family: 'SF Mono', 'Consolas', monospace;
    white-space: nowrap;
    flex-shrink: 0;
}

.seek-bar {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

.volume-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.volume-wrap svg { color: var(--text-muted); flex-shrink: 0; }

.volume-bar {
    width: 70px;
    -webkit-appearance: none;
    appearance: none;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.volume-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px; height: 10px;
    background: var(--text-dim);
    border-radius: 50%;
    cursor: pointer;
}

/* ==================== RIGHT PANEL ==================== */
.right-panel {
    width: 280px;
    min-width: 250px;
    background: var(--bg-dark);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.right-panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.style-section {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.style-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

/* Collapsible sections */
.collapse-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: color 0.2s;
}
.collapse-toggle:hover { color: var(--text-dim); }
.collapse-arrow {
    transition: transform 0.25s;
    flex-shrink: 0;
}
.collapse-body {
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease, opacity 0.25s;
    opacity: 1;
}
.collapse-body.collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
}

/* Template grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.template-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.template-btn:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}
.template-btn.active {
    border-color: var(--primary);
    background: var(--primary-bg);
}
.tpl-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 24px;
    border-radius: 3px;
    line-height: 1;
    overflow: hidden;
}
.tpl-name {
    font-size: 9px;
    color: var(--text-dim);
    text-align: center;
    line-height: 1;
}

.style-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.style-row:last-child { margin-bottom: 0; }

.style-label {
    font-size: 12px;
    color: var(--text-dim);
    width: 55px;
    flex-shrink: 0;
}

.style-input {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    outline: none;
    transition: var(--transition);
}

.style-input:focus { border-color: var(--primary); }

select.style-input {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}

textarea.style-input {
    resize: vertical;
    min-height: 54px;
    line-height: 1.4;
}

input[type="color"].style-color {
    -webkit-appearance: none;
    appearance: none;
    width: 28px; height: 28px;
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    background: none;
    flex-shrink: 0;
}

input[type="color"].style-color::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"].style-color::-webkit-color-swatch { border-radius: 3px; border: none; }

.format-toolbar {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.fmt-btn {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-dim);
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: var(--transition);
}

.fmt-btn:hover { border-color: var(--primary-border); color: var(--text); }
.fmt-btn.active { background: var(--primary-bg); border-color: var(--primary); color: var(--primary-light); }

.fmt-divider { width: 1px; height: 30px; background: var(--border); margin: 0 2px; }

.pos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.pos-dot {
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 10px;
    color: var(--text-muted);
}

.pos-dot:hover { border-color: var(--primary-border); }
.pos-dot.active { background: var(--primary-bg); border-color: var(--primary); color: var(--primary-light); }

input[type="range"].style-range {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type="range"].style-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

/* ==================== TIMELINE ==================== */
.timeline-area {
    height: 100px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-x: auto;
    position: relative;
}

.timeline-ruler {
    height: 22px;
    position: relative;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    min-width: 100%;
}

.timeline-ruler-mark {
    position: absolute;
    top: 0;
    height: 100%;
    border-left: 1px solid var(--border);
    font-size: 9px;
    color: var(--text-muted);
    padding: 4px 4px;
    user-select: none;
}

.timeline-tracks {
    flex: 1;
    position: relative;
    min-width: 100%;
    cursor: pointer;
}

.timeline-sub {
    position: absolute;
    top: 10px;
    height: 26px;
    background: var(--primary-bg);
    border: 1px solid var(--primary-border);
    border-radius: 4px;
    padding: 0 8px;
    font-size: 11px;
    color: var(--primary-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 26px;
    cursor: pointer;
    transition: background 0.15s;
}

.timeline-sub:hover { background: rgba(124,92,252,0.2); }
.timeline-sub.active { background: var(--primary); color: #fff; border-color: var(--primary-light); }

.timeline-playhead {
    position: absolute;
    top: 0; bottom: 0;
    width: 2px;
    background: var(--danger);
    z-index: 10;
    pointer-events: none;
}

.timeline-playhead::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -4px;
    width: 10px; height: 10px;
    background: var(--danger);
    border-radius: 50%;
}

/* ==================== MODAL ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 90%;
    max-width: 440px;
    text-align: center;
    box-shadow: var(--shadow);
}

.modal h3 { font-size: 1.1rem; margin-bottom: 1rem; }

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

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 3px;
    transition: width 0.3s;
}

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

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

/* ==================== TOAST ==================== */
.toast-container {
    position: fixed;
    top: 56px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toast {
    padding: 10px 16px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
    max-width: 320px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Drag hint */
.drag-hint {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 12px;
    background: rgba(0,0,0,0.6);
    border-radius: 12px;
    font-size: 10px;
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.video-wrapper:hover .drag-hint { opacity: 1; }

/* Mobile/Desktop visibility */
.mobile-only { display: none !important; }
.desktop-only { display: inline-flex !important; }

/* Mobile backdrop */
.mobile-backdrop {
    display: none;
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 190;
    -webkit-tap-highlight-color: transparent;
}
.mobile-backdrop.active { display: block; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .left-panel { width: 280px; min-width: 240px; }
    .right-panel { width: 240px; min-width: 220px; }
}

@media (max-width: 768px) {
    .mobile-only { display: inline-flex !important; }
    .desktop-only { display: none !important; }

    .editor-container {
        flex-direction: column;
        height: calc(100vh - 48px);
        overflow: hidden;
        position: relative;
    }

    .center-panel {
        flex: 1;
        min-height: 0;
        order: 1;
    }

    .video-wrapper video {
        max-height: calc(100vh - 48px - 44px - 70px);
    }

    .timeline-area { height: 70px; }

    /* Panels slide in from sides on mobile */
    .left-panel {
        position: fixed;
        top: 48px;
        left: 0;
        bottom: 0;
        width: 85vw;
        max-width: 360px;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .left-panel.mobile-open {
        transform: translateX(0);
    }

    .right-panel {
        position: fixed;
        top: 48px;
        right: 0;
        bottom: 0;
        width: 85vw;
        max-width: 320px;
        z-index: 200;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        box-shadow: -4px 0 24px rgba(0,0,0,0.5);
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .right-panel.mobile-open {
        transform: translateX(0);
    }

    /* Bigger touch targets for mobile */
    .collapse-toggle {
        min-height: 44px;
        padding: 10px 0;
    }

    .template-btn {
        min-height: 48px;
    }

    .fmt-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .style-input, .style-color {
        min-height: 38px;
        font-size: 14px;
    }

    select.style-input {
        font-size: 14px;
        -webkit-appearance: menulist;
        appearance: menulist;
    }

    input[type="range"].style-range {
        height: 32px;
        -webkit-appearance: auto;
    }

    input[type="number"].style-input {
        font-size: 16px; /* Prevents iOS zoom */
    }

    input[type="color"].style-color {
        min-width: 44px;
        min-height: 38px;
    }

    /* Subtitle list items - bigger touch targets */
    .sub-item {
        min-height: auto;
    }

    .sub-item textarea {
        font-size: 14px;
        min-height: 50px;
    }

    .sub-item .sub-time input {
        font-size: 13px;
        min-height: 32px;
    }

    .btn {
        min-height: 40px;
        -webkit-tap-highlight-color: rgba(138, 92, 246, 0.3);
    }

    .icon-btn {
        min-width: 40px;
        min-height: 40px;
        -webkit-tap-highlight-color: rgba(138, 92, 246, 0.3);
    }

    .upload-page {
        padding: 1.5rem 1rem;
        height: calc(100vh - 48px);
    }

    .upload-hero h2 { font-size: 1.5rem; }
    .upload-hero p { font-size: 0.85rem; }
    .upload-zone { padding: 2rem 1.5rem; }
    .upload-zone h3 { font-size: 0.9rem; }
    .features-strip { gap: 6px; }
    .feature-badge { font-size: 11px; padding: 4px 10px; }

    .header { padding: 0 10px; }
    .project-name { max-width: 100px; font-size: 11px; }

    .volume-wrap { display: none !important; }

    .sub-item .sub-actions { display: flex; }

    /* Batch edit table mobile */
    .batch-table-wrap {
        -webkit-overflow-scrolling: touch;
    }
    .batch-table input,
    .batch-table textarea {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .project-name { display: none; }
    .divider-v { display: none; }
    .upload-hero h2 { font-size: 1.3rem; }

    .left-panel { width: 100vw; max-width: 100vw; }
    .right-panel { width: 100vw; max-width: 100vw; }

    .style-row { flex-wrap: wrap; }
    .style-label { width: 100%; margin-bottom: 2px; }

    .template-grid { grid-template-columns: repeat(4, 1fr); gap: 4px; }
    .template-btn { padding: 6px 2px; }
    .tpl-preview { height: 20px; }
    .tpl-name { font-size: 8px; }

    .collapse-toggle { padding: 6px 0; min-height: 44px; }
    .style-section { padding: 10px 12px; }

    /* Full-width inputs on very small screens */
    .style-input { min-height: 40px; }
    select.style-input { font-size: 16px; }
}
