@import url('/css/fonts/inter.css');

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

:root {
    --primary:    #0067C1;
    --primary-d:  #005AA8;
    --primary-lt: #e8f3fd;
    --bg:         #eef4fb;
    --surface:    #fff;
    --border:     #e2e8f0;
    --border2:    #cbd5e1;
    --text:       #1e293b;
    --muted:      #64748b;
    --dim:        #94a3b8;
    --success:    #16a34a;
    --danger:     #dc2626;
    --video-bg:   #111827;
    --radius:     8px;
    --shadow:     0 2px 8px rgba(0,103,193,.08);
    --shadow-md:  0 4px 20px rgba(0,103,193,.12);
    --font:       'Inter', system-ui, -apple-system, sans-serif;
}

html, body { height: 100%; font-family: var(--font); font-size: 13px; color: var(--text); }
body { background: var(--bg); overflow: hidden; }

/* ── AUTH ──────────────────────────────── */
.auth-wrap {
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center;
    background: linear-gradient(145deg, #c7e0f8 0%, #eef4fb 60%);
}
.auth-card {
    width: 380px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 16px;
    padding: 36px 32px; box-shadow: var(--shadow-md);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon { font-size: 40px; }
.auth-logo h1 { font-size: 22px; font-weight: 700; color: var(--primary); margin-top: 8px; }
.auth-logo p  { font-size: 12px; color: var(--muted); margin-top: 4px; }

.auth-tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.auth-tab  { flex: 1; padding: 10px; background: none; border: none; color: var(--muted); font: 500 13px/1 var(--font); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .15s, border-color .15s; }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form.hidden { display: none; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.form-input { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 10px 14px; font: 13px/1 var(--font); outline: none; transition: border-color .15s, box-shadow .15s; width: 100%; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,103,193,.1); background: #fff; }
.auth-error { background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius); color: var(--danger); padding: 9px 12px; font-size: 12px; display: none; }
.auth-error.visible { display: block; }

/* ── BUTTONS ───────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 14px; border-radius: var(--radius); border: 1px solid transparent;
    font: 500 13px/1 var(--font); cursor: pointer; white-space: nowrap;
    transition: background .15s, box-shadow .12s, transform .08s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm  { padding: 5px 11px; font-size: 12px; }
.btn-full{ width: 100%; }

.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 6px rgba(0,103,193,.25); }
.btn-primary:hover:not(:disabled)   { background: var(--primary-d); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border2); box-shadow: var(--shadow); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover:not(:disabled)   { background: #15803d; }
.btn-danger    { background: #fff; color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover:not(:disabled)    { background: #fef2f2; }
.btn-outline-danger { background: transparent; color: var(--danger); border-color: #fca5a5; }
.btn-outline-danger:hover:not(:disabled) { background: #fef2f2; }

/* ── APP LAYOUT ────────────────────────── */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.app-header {
    height: 50px; flex-shrink: 0;
    display: flex; align-items: center; gap: 12px; padding: 0 16px;
    background: rgba(255,255,255,.97); border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px); z-index: 10;
    box-shadow: 0 1px 6px rgba(0,103,193,.07);
}
.header-logo { display: flex; align-items: center; gap: 7px; font-size: 16px; font-weight: 700; color: var(--primary); flex-shrink: 0; }
.header-save { font-size: 11px; color: var(--muted); flex: 1; padding-left: 4px; }
.header-save.saving { color: var(--primary); }
.header-save.error  { color: var(--danger); }
.header-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.header-user  { font-size: 12px; color: var(--muted); font-weight: 500; }

/* workspace: left column (clips + timeline) | right result pane */
.app-workspace { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.app-left { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── MEDIA BIN (LEFT) ──────────────────── */
.media-bin {
    flex: 1; min-width: 120px;
    display: flex; flex-direction: column;
    background: var(--surface);
    overflow: hidden;
}

/* ── PANE RESIZER ──────────────────────── */
.pane-resizer {
    width: 8px; flex-shrink: 0;
    background: var(--border);
    cursor: col-resize;
    position: relative;
    transition: background .15s;
    z-index: 5; user-select: none;
}
.pane-resizer:hover, .pane-resizer.dragging { background: var(--primary); }
.pane-resizer::before {
    content: '';
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 2px; height: 28px;
    background: rgba(0,0,0,.15); border-radius: 1px;
    box-shadow: -3px 0 0 rgba(0,0,0,.1), 3px 0 0 rgba(0,0,0,.1);
    pointer-events: none;
}
.pane-resizer:hover::before, .pane-resizer.dragging::before {
    background: rgba(255,255,255,.5);
    box-shadow: -3px 0 0 rgba(255,255,255,.3), 3px 0 0 rgba(255,255,255,.3);
}

.bin-toolbar {
    height: 46px; flex-shrink: 0;
    display: flex; align-items: center; gap: 8px; padding: 0 10px;
    border-bottom: 1px solid var(--border); background: #f8fafc;
}

.bin-list {
    flex: 1; overflow-y: auto; padding: 8px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
    gap: 6px; align-content: start;
}
.bin-list::-webkit-scrollbar { width: 4px; }
.bin-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* iOS-style toggle */
.toggle-wrap { display: flex; align-items: center; gap: 6px; margin-left: auto; cursor: pointer; }
.toggle-label { font-size: 11px; color: var(--muted); font-weight: 500; white-space: nowrap; user-select: none; }
.toggle { position: relative; display: inline-block; width: 34px; height: 18px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
    position: absolute; inset: 0;
    background: #cbd5e1; border-radius: 18px;
    transition: background .2s; cursor: pointer;
}
.toggle-slider::before {
    content: '';
    position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px;
    background: #fff; border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
    transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

.bin-empty {
    padding: 36px 16px; text-align: center;
    color: var(--dim); font-size: 12px; line-height: 1.8;
}

/* Clip card — vertical */
.tl-clip {
    display: flex; flex-direction: column;
    border: 1px solid var(--border); border-radius: 7px;
    background: #fff; cursor: pointer; position: relative;
    transition: border-color .12s, box-shadow .12s, opacity .12s;
    user-select: none; overflow: hidden;
}
.tl-clip:hover     { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,103,193,.12); }
.tl-clip.dragging  { opacity: .35; }
.tl-clip.drag-over { border-color: var(--primary); box-shadow: inset 0 3px 0 var(--primary); }

.tl-del {
    position: absolute; top: 5px; right: 5px; z-index: 2;
    width: 17px; height: 17px;
    background: rgba(0,0,0,.4); color: #fff;
    border: none; border-radius: 50%; cursor: pointer;
    font-size: 12px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .12s, background .12s;
}
.tl-clip:hover .tl-del { opacity: 1; }
.tl-del:hover { background: var(--danger); }

.tl-thumb-wrap { position: relative; width: 100%; }
.tl-thumb { width: 100%; height: 58px; object-fit: cover; border-radius: 0; background: var(--video-bg); display: block; }
.tl-badge {
    position: absolute; bottom: 2px; right: 2px;
    font-size: 7px; font-weight: 700; letter-spacing: .3px;
    padding: 2px 4px; border-radius: 3px;
    white-space: nowrap;
}
.badge-video { background: rgba(0,103,193,.85); color: #fff; }
.badge-photo { background: rgba(22,163,74,.85); color: #fff; }

.tl-info { flex: 1; min-width: 0; }
.tl-name { font-size: 10px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); padding: 4px 6px 5px; }
.tl-meta { font-size: 10px; color: var(--muted); margin-top: 3px; }

/* Drag handle — icon before the file name */
.tl-drag-handle {
    display: inline-block; margin-right: 3px;
    font-size: 11px; color: var(--muted);
    cursor: grab; user-select: none; touch-action: none;
    opacity: 0; transition: opacity .12s;
    vertical-align: middle;
}
.tl-clip:hover .tl-drag-handle { opacity: 0.5; }
@media (hover: none) {
    .tl-drag-handle { opacity: 0.7; }
}

/* ── OVERLAY PREVIEW ──────────────────── */
.ovl-preview-wrap {
    position: absolute; inset: 0;
    pointer-events: none; overflow: hidden; z-index: 5;
}
.fade-overlay {
    position: absolute; inset: 0; z-index: 999;
    background: #000; opacity: 0;
    pointer-events: none;
    transition: opacity 400ms ease;
    /* Force its own compositing layer, otherwise the video covers overlay */
    transform: translateZ(0);
    will-change: opacity;
}
.ovl-preview-text {
    position: absolute;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: bold; line-height: 1.2;
    white-space: pre-wrap; max-width: 92%;
    text-align: center;
    text-shadow: 2px 2px 5px rgba(0,0,0,.95), -1px -1px 3px rgba(0,0,0,.8);
}

/* ── RESULT PANE (RIGHT) ───────────────── */
.result-pane {
    width: 280px; flex-shrink: 0;
    display: flex; flex-direction: column;
    background: #f8fafc; overflow: hidden;
    box-shadow: -2px 0 12px rgba(0,103,193,.06);
}

.result-player-wrap {
    flex: 1; display: flex; align-items: center; justify-content: center;
    position: relative; min-height: 0; overflow: hidden;
    background: #e2e8f0;
}

#videoPlayer {
    max-width: 100%; max-height: 100%; display: none; outline: none;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0,0,0,.2);
}

.preview-ph {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--dim); gap: 10px; pointer-events: none;
}
.preview-ph .ph-icon { font-size: 44px; opacity: .5; }
.preview-ph p { font-size: 12px; line-height: 1.7; text-align: center; }

.player-bar {
    flex-shrink: 0; height: 38px;
    display: flex; align-items: center; gap: 8px; padding: 0 12px;
    background: #fff; border-top: 1px solid var(--border);
    box-shadow: 0 -1px 4px rgba(0,103,193,.05);
}
.pbtn {
    background: var(--surface); border: 1px solid var(--border2);
    color: var(--text); border-radius: 6px; width: 28px; height: 26px;
    cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center;
    transition: background .12s, border-color .12s, color .12s;
    box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.pbtn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-lt); }
.time-display { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }

.result-controls {
    flex-shrink: 0;
    display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
    padding: 7px 10px;
    background: #fff; border-top: 1px solid var(--border);
}
.progress-wrap { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 160px; }
.prog-top {
    display: flex; justify-content: space-between; align-items: baseline; gap: 6px;
}
.status-msg { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.prog-outdur {
    font-size: 11px; font-weight: 700; color: var(--primary);
    white-space: nowrap; flex-shrink: 0;
}
.progress-track {
    width: 100%; height: 16px; background: var(--border); border-radius: 8px;
    overflow: hidden; position: relative;
}
.progress-fill  {
    height: 100%; width: 0; border-radius: 8px;
    background: linear-gradient(90deg, var(--primary) 0%, #3b82f6 100%);
    transition: width .3s;
}
.progress-pct {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,.55);
    pointer-events: none; font-variant-numeric: tabular-nums;
}
.prog-time-row {
    display: flex; justify-content: space-between; align-items: center;
    min-height: 14px;
}
.progress-elapsed {
    font-size: 11px; color: var(--muted);
    font-variant-numeric: tabular-nums; white-space: nowrap;
}
.progress-eta {
    font-size: 11px; color: var(--muted);
    font-variant-numeric: tabular-nums; white-space: nowrap;
}

.log-area {
    flex-shrink: 0; height: 60px; overflow-y: auto;
    padding: 4px 12px;
    background: #f8fafc; border-top: 1px solid var(--border);
    font: 10px/1.75 'Consolas','JetBrains Mono',monospace; color: var(--muted);
}
.log-area::-webkit-scrollbar { width: 3px; }
.log-area::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.log-line.info  { color: var(--muted); }
.log-line.ok    { color: #15803d; font-weight: 600; }
.log-line.error { color: var(--danger); font-weight: 600; }
.log-line.warn  { color: #b45309; }

/* ── BOTTOM TIMELINE (scrubber) ────────── */
.app-timeline {
    height: 185px; flex-shrink: 0;
    background: #fff; border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(0,103,193,.07);
    display: flex; flex-direction: column; overflow: hidden;
}

.tl-top-bar {
    height: 30px; flex-shrink: 0;
    display: flex; align-items: center; gap: 6px; padding: 0 10px;
    background: #f8fafc; border-bottom: 1px solid var(--border);
}
.tl-top-label {
    font-size: 10px; font-weight: 600; color: var(--dim);
    text-transform: uppercase; letter-spacing: .5px; margin-right: 4px;
}
.tl-btn {
    padding: 2px 9px; font-size: 11px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border2); border-radius: 5px;
    cursor: pointer; transition: background .12s, border-color .12s, color .12s;
    white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.tl-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-lt); }

.tl-body {
    flex: 1; display: flex; overflow: hidden; min-height: 0;
}
.tl-label-col {
    width: 40px; flex-shrink: 0;
    display: flex; flex-direction: column;
    background: #f8fafc; border-right: 1px solid var(--border);
}
.tl-track-lbl {
    flex: 1; display: flex; align-items: center; justify-content: center;
    font-size: 15px; cursor: default; color: var(--dim);
}
.tl-track-lbl + .tl-track-lbl { border-top: 1px solid var(--border); }

.tl-inner {
    flex: 1;
    overflow-x: auto; overflow-y: hidden;
    cursor: pointer; user-select: none; position: relative;
}
.tl-inner::-webkit-scrollbar { height: 3px; }
.tl-inner::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.tl-rows-wrap {
    position: relative; height: 100%; min-width: 100%;
    display: flex; flex-direction: column;
}

.tl-clips-row {
    flex: 1; position: relative;
    display: flex; min-width: 100%;
    border-bottom: 1px solid var(--border);
}

.tl-overlay-row {
    flex: 1; position: relative;
    min-width: 100%; background: #f0f4f8;
}

/* Overlay blocks */
.tl-ovl-block {
    position: absolute; top: 4px; bottom: 4px;
    border-radius: 4px; overflow: hidden;
    cursor: pointer; user-select: none;
    display: flex; align-items: center; padding: 0 6px;
    font-size: 10px; font-weight: 600;
    white-space: nowrap; min-width: 4px;
}
.tl-ovl-block:hover { filter: brightness(.94); }
.tl-ovl-block.type-text {
    background: rgba(124,58,237,.12); border: 1px solid rgba(124,58,237,.5);
    color: #5b21b6;
}
.tl-ovl-block.type-audio {
    background: rgba(5,150,105,.12); border: 1px solid rgba(5,150,105,.5);
    color: #065f46;
}
.tl-ovl-label {
    overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; pointer-events: none;
}
.tl-ovl-del {
    position: absolute; top: 2px; right: 2px;
    width: 13px; height: 13px;
    background: rgba(0,0,0,.18); color: var(--text);
    border: none; border-radius: 50%; cursor: pointer;
    font-size: 9px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .12s;
}
.tl-ovl-block:hover .tl-ovl-del { opacity: 1; }
.tl-ovl-del:hover { background: var(--danger); color: #fff; }
.tl-ovl-resize {
    position: absolute; top: 0; bottom: 0; width: 5px;
    cursor: ew-resize; z-index: 2; background: rgba(0,0,0,.12);
    opacity: 0; transition: opacity .15s;
}
.tl-ovl-resize.right { right: 0; border-radius: 0 4px 4px 0; }
.tl-ovl-block:hover .tl-ovl-resize { opacity: 1; }

.tl-clip-block {
    height: 100%; flex-shrink: 0;
    position: relative; overflow: hidden;
    border-right: 2px solid #fff;
    background-color: #dbeafe;
    background-size: auto 100%;
    background-repeat: repeat-x;
    background-position: left center;
    box-shadow: inset 0 0 0 1px rgba(0,103,193,.15);
}
.tl-clip-block::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(to bottom,
        rgba(255,255,255,.55) 0%, transparent 30%,
        transparent 70%, rgba(255,255,255,.35) 100%);
    pointer-events: none;
}
.tl-clip-block-label {
    position: absolute; top: 5px; left: 7px; right: 5px;
    font-size: 10px; font-weight: 600;
    color: #1e3a5f;
    text-shadow: 0 1px 2px rgba(255,255,255,.8);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    pointer-events: none; z-index: 1;
}
.tl-clip-block-type {
    position: absolute; bottom: 5px; left: 7px;
    font-size: 9px; font-weight: 700;
    padding: 1px 4px; border-radius: 3px; color: #fff;
    pointer-events: none; z-index: 1;
    white-space: nowrap;
}

.tl-timeline-empty {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--dim); font-size: 12px; pointer-events: none;
}

.tl-playhead {
    position: absolute; top: 0; bottom: 0;
    width: 14px; margin-left: -7px;
    background: linear-gradient(to right,
        transparent 6px, #ef4444 6px, #ef4444 8px, transparent 8px);
    z-index: 20; cursor: ew-resize;
}
.tl-playhead::before {
    content: '';
    position: absolute; top: 0; left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 9px solid #ef4444;
}
.tl-playhead::after {
    content: '';
    position: absolute; bottom: 0; left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 9px solid #ef4444;
}

/* ── MODALS ────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.5); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 200; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.visible { opacity: 1; pointer-events: all; }

.modal {
    background: #fff; border: 1px solid var(--border); border-radius: 14px;
    padding: 24px; max-width: 95vw;
    transform: scale(.95); transition: transform .2s;
    box-shadow: 0 20px 60px rgba(0,103,193,.14);
}
.modal-overlay.visible .modal { transform: scale(1); }

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px; }
.modal-x { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1; border-radius: 4px; transition: color .12s, background .12s; }
.modal-x:hover { color: var(--text); background: var(--border); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-text { color: var(--muted); font-size: 13px; }

/* Edit modal */
.modal-edit { width: 520px; }
.edit-preview {
    background: var(--video-bg); border-radius: 8px;
    overflow: hidden; height: 240px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}
#editVideo { max-width: 100%; max-height: 240px; outline: none; }
.edit-photo-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.edit-photo-ph img { max-width: 100%; max-height: 240px; object-fit: contain; }

/* Trim */
.trim-bar {
    position: relative; height: 44px;
    margin: 14px 8px 2px; user-select: none; cursor: pointer;
}
.trim-bg {
    position: absolute; top: 50%; left: 0; right: 0;
    transform: translateY(-50%); height: 6px;
    background: var(--border2); border-radius: 3px;
}
.trim-range {
    position: absolute; top: 50%;
    transform: translateY(-50%); height: 6px;
    background: var(--primary); border-radius: 3px; pointer-events: none;
}
.trim-handle {
    position: absolute; top: 50%;
    transform: translate(-50%, -50%);
    width: 14px; height: 34px;
    background: var(--primary); border-radius: 5px;
    cursor: ew-resize; z-index: 2;
    box-shadow: 0 2px 8px rgba(0,103,193,.4);
    transition: box-shadow .12s;
}
.trim-handle:hover { box-shadow: 0 0 0 5px rgba(0,103,193,.18), 0 2px 8px rgba(0,103,193,.4); }
.trim-handle::before {
    content: '';
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 2px; height: 12px;
    background: rgba(255,255,255,.8); border-radius: 1px;
    box-shadow: -3px 0 0 rgba(255,255,255,.8), 3px 0 0 rgba(255,255,255,.8);
}
.trim-times {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px; color: var(--muted); padding: 0 2px; margin-top: 4px;
}
.trim-actions {
    display: flex; align-items: center; gap: 8px; justify-content: space-between;
    margin-top: 10px; flex-wrap: wrap;
}
.trim-fine {
    display: flex; align-items: center; gap: 4px;
    background: #f1f5f9; border: 1px solid var(--border); border-radius: 6px;
    padding: 2px 6px;
}
.trim-fine-btn {
    width: 22px; height: 22px; padding: 0;
    border: 1px solid var(--border2); background: #fff; color: var(--text);
    border-radius: 4px; cursor: pointer; font: 600 12px/1 var(--font);
    display: flex; align-items: center; justify-content: center;
    transition: border-color .12s, color .12s, background .12s;
}
.trim-fine-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-lt); }
.trim-fine-sep { color: var(--dim); font-size: 11px; padding: 0 2px; }

/* Audio block in edit modal */
#audioBlock {
    margin: 12px 8px 0; padding: 10px 12px;
    background: #f8fafc; border-radius: var(--radius); border: 1px solid var(--border);
}
.audio-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.audio-icon { font-size: 18px; flex-shrink: 0; transition: opacity .15s; }
.audio-icon.muted { opacity: .35; }
.audio-lbl { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; }
.audio-slider {
    flex: 1; min-width: 100px; height: 6px;
    -webkit-appearance: none; appearance: none;
    background: var(--border2); border-radius: 3px; outline: none;
    cursor: pointer; padding: 0;
}
.audio-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--primary); cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,103,193,.4);
    border: 2px solid #fff;
}
.audio-slider::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--primary); cursor: pointer; border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,103,193,.4);
}
#clipVolumeLbl { font-size: 12px; color: var(--muted); min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.audio-hint { margin: 8px 0 0; font-size: 11px; color: var(--dim); font-style: italic; line-height: 1.4; }

.photo-dur-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.photo-dur-row label { font-size: 12px; font-weight: 500; color: var(--text); }
.photo-dur-row input[type=number] { width: 80px; padding: 6px 9px; border: 1px solid var(--border); border-radius: var(--radius); font: 13px/1 var(--font); outline: none; background: #f8fafc; }
.photo-dur-row input[type=number]:focus { border-color: var(--primary); background: #fff; }
.trim-unit { font-size: 12px; color: var(--muted); }

/* Export modal */
.modal-export { width: 360px; max-height: 90vh; overflow-y: auto; }
.export-device-info {
    font-size: 12px; padding: 8px 16px; line-height: 1.5;
    background: var(--surface); border-bottom: 1px solid var(--border);
    color: var(--muted); display: none;
}
.export-device-info b { color: var(--text); }
.export-device-info.profile-high   { border-left: 3px solid #16a34a; }
.export-device-info.profile-mid    { border-left: 3px solid var(--primary); }
.export-device-info.profile-low    { border-left: 3px solid #d97706; }
.export-device-info.profile-vlow   { border-left: 3px solid var(--danger); }
.export-fields { display: flex; flex-direction: column; gap: 12px; }
.efield { display: flex; flex-direction: column; gap: 4px; }
.efield label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.efield select {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
    font: 13px/1 var(--font); outline: none; background: #f8fafc; color: var(--text); cursor: pointer;
}
.efield select:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 2px rgba(0,103,193,.1); }
.res-warning {
    font-size: 12px; padding: 6px 8px; border-radius: 4px; line-height: 1.45;
    margin-top: 2px;
}
.res-warning.ok      { background: #dcfce7; color: #166534; }
.res-warning.caution { background: #fef9c3; color: #854d0e; }
.res-warning.info    { background: #dbeafe; color: #1e40af; }
.res-warning.danger  { background: #fee2e2; color: #991b1b; }

/* Export method selector */
.export-methods { display: flex; flex-direction: column; gap: 6px; }
.method-opt {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 12.5px; line-height: 1.4; cursor: pointer; background: #f8fafc;
}
.method-opt:hover { border-color: var(--primary); background: #fff; }
.method-opt input { margin-top: 2px; flex: 0 0 auto; }
.method-opt b { color: var(--text); }
.method-opt i { color: var(--muted); font-style: normal; }
.method-opt.sel { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 2px rgba(0,103,193,.1); }
.method-meta { color: var(--muted); font-size: 11px; }

/* Export analysis panel */
.export-analysis {
    font-size: 12px; padding: 8px 16px; line-height: 1.5;
    color: var(--muted); border-top: 1px solid var(--border);
}
.export-analysis b { color: var(--text); }
.export-analysis .an-copy { color: #166534; font-weight: 600; }
.export-analysis .an-enc  { color: #854d0e; font-weight: 600; }

/* Confirm modal */
.modal-confirm { min-width: 280px; max-width: 400px; }

/* Overlay modals */
.modal-ovl { width: 420px; }

/* ── TOASTS ────────────────────────────── */
.toast-container { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 300; }
.toast {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 9px 14px; font-size: 12px; display: flex; align-items: center; gap: 7px;
    box-shadow: var(--shadow-md); animation: slideIn .2s ease; max-width: 300px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--primary); }
.toast.warn    { border-left: 3px solid #d97706; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

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

/* ── TABLET ────────────────────────────── */
@media (max-width: 1100px) and (min-width: 768px) {
    .result-pane { width: 240px; }
}

/* ── MOBILE PORTRAIT ──────────────────── */
@media (max-width: 767px) and (orientation: portrait) {
    /* Vertical stack instead of side-by-side */
    .app-workspace { flex-direction: column; }

    /* Left block: fixed height, clips + timeline */
    .app-left { flex: 0 0 auto; overflow: hidden; }

    /* Clip bin: more compact to free vertical space */
    .media-bin { flex: 0 0 120px; min-width: 0; }

    /* Slightly larger clip cards for touch */
    .bin-list {
        grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    }

    /* Compact timeline */
    .app-timeline { height: 95px; box-shadow: none; }
    .tl-top-label { display: none; }

    /* Hide desktop-only resize handle */
    .pane-resizer { display: none; }

    /* Result pane: full width, fills remaining height — give it priority */
    .result-pane {
        width: 100% !important;
        flex: 2 1 0;
        min-height: 280px;
        box-shadow: 0 -2px 12px rgba(0,103,193,.07);
    }

    /* Dark video bg for better contrast on mobile */
    .result-player-wrap { background: var(--video-bg); min-height: 200px; }
    .preview-ph { color: #94a3b8; }
    #videoPlayer { width: 100%; height: 100%; object-fit: contain; }

    /* Bigger log area — user wants more vertical room for export progress */
    .log-area { height: 70px; font-size: 11px; line-height: 1.65; }

    /* result-controls: progress block takes full width */
    .result-controls { gap: 6px; }
    .progress-wrap { flex-basis: 100%; order: 10; }

    /* Header: hide low-priority items */
    .header-save { display: none; }
    .header-user { display: none; }
    .app-header { padding: 0 10px; gap: 8px; }

    /* Always show delete button on touch devices */
    .tl-del { opacity: 1; }

    /* Bigger toolbar buttons for touch */
    .bin-toolbar { gap: 6px; padding: 0 8px; }
    .bin-toolbar .btn { padding: 7px 12px; }

    /* Modals: full-width on small screens, scrollable if content overflows */
    .modal { max-height: 88vh; overflow-y: auto; }
    .modal-edit,
    .modal-ovl { width: min(520px, 94vw); }
    .modal-export,
    .modal-confirm { width: min(340px, 94vw); }
    .edit-preview { height: 160px; }
    #editVideo { max-height: 160px; }

    /* Timeline tracks compact */
    .tl-top-bar { height: 26px; padding: 0 8px; }
    .tl-btn { padding: 2px 7px; font-size: 10px; }
    .tl-track-lbl { font-size: 12px; }
    .tl-label-col { width: 28px; }
}

/* ── MOBILE LANDSCAPE ─────────────────── */
@media (max-width: 932px) and (orientation: landscape) and (max-height: 500px) {
    /* Compact desktop-like layout for landscape phones */
    .pane-resizer { display: none; }
    .result-pane { width: 220px !important; }
    .app-timeline { height: 100px; }
    .media-bin { flex: 0 0 90px; }
    .header-save { display: none; }
    .header-user { display: none; }
    .app-header { height: 42px; }
    .log-area { height: 50px; font-size: 11px; }
    .result-controls { padding: 4px 8px; }
    .bin-toolbar { height: 38px; }
    .tl-top-bar { height: 24px; }
}
