/* Editor de video — usa la paleta de la marca (ver style.css) */
:root {
    --bg: #0B0B0C;
    --surface: #121212;
    --card: #1a1a1a;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #ffffff;
    --muted: rgba(255, 255, 255, 0.6);
    --dim: rgba(255, 255, 255, 0.38);
    --accent: #FF4D00;
    --teal: #0D9488;
    --c-video: #4d6f96;
    --c-avatar: #7a68a8;
    --c-voice: #2f8f83;
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', system-ui, sans-serif; }
html, body { height: 100%; }
body {
    background: var(--bg); color: var(--text); font-size: 13px;
    display: grid; grid-template-rows: 52px minmax(0, 1fr) 262px; overflow: hidden;
}
button { cursor: pointer; color: inherit; }
[hidden] { display: none !important; }

/* ── Barra superior ── */
.ed-top { display: flex; align-items: center; gap: 10px; padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.ed-back { color: var(--muted); text-decoration: none; font-weight: 600; padding: 6px 8px; border-radius: 6px; }
.ed-back:hover { color: var(--text); background: var(--card); }
.ed-title { font-weight: 700; font-size: 14px; }
.ed-top-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.ed-grow { flex: 1; }
.ed-btn { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 6px 11px; font-size: 12px; font-weight: 600; }
.ed-btn:hover:not(:disabled) { border-color: var(--line-strong); background: #222; }
.ed-btn:disabled { opacity: 0.35; cursor: default; }
.ed-icon { width: 30px; padding: 6px 0; text-align: center; font-size: 14px; }
.ed-primary { background: var(--accent); border-color: var(--accent); color: #fff; padding: 7px 18px; }
.ed-primary:hover:not(:disabled) { background: #ff6624; border-color: #ff6624; }
.ed-seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.ed-seg button { background: transparent; border: 0; padding: 6px 11px; font-size: 12px; font-weight: 600; color: var(--muted); }
.ed-seg button.active { background: var(--accent); color: #fff; }
.ed-save { color: var(--dim); font-size: 11px; }
.ed-credits { color: var(--muted); font-size: 12px; font-weight: 600; padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; }
.ed-mobile-note { display: none; background: #2a1a10; color: #ffb48c; padding: 6px 14px; font-size: 12px; }

/* ── Cuerpo ── */
.ed-main { display: grid; grid-template-columns: 290px minmax(0, 1fr) 290px; min-height: 0; }
.ed-lib, .ed-props { background: var(--surface); min-height: 0; display: flex; flex-direction: column; }
.ed-lib { border-right: 1px solid var(--line); }
.ed-props { border-left: 1px solid var(--line); padding: 14px; overflow-y: auto; gap: 14px; }

.ed-tabs { display: flex; border-bottom: 1px solid var(--line); }
.ed-tabs button { flex: 1; background: transparent; border: 0; padding: 11px 2px; font-size: 11.5px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.ed-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.ed-lib-list { padding: 10px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: max-content; gap: 8px; align-content: start; flex: 1; min-height: 0; }
.ed-upload { padding: 10px 10px 8px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.ed-upload-btn { width: 100%; padding: 9px 10px; border-color: var(--accent); color: var(--accent); background: rgba(255, 77, 0, 0.08); }
.ed-upload-btn:hover:not(:disabled) { background: rgba(255, 77, 0, 0.16); border-color: var(--accent); }
.ed-upload-status { color: var(--dim); font-size: 11px; line-height: 1.4; }
.ed-lib.drag { outline: 2px dashed var(--accent); outline-offset: -4px; background: rgba(255, 77, 0, 0.05); }
.ed-lib-list .empty { grid-column: 1 / -1; color: var(--dim); text-align: center; padding: 28px 10px; line-height: 1.5; }
.ed-lib-list .empty a { color: var(--accent); }
.asset { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; flex-shrink: 0; min-height: max-content; }
.asset:hover { border-color: var(--line-strong); }
.asset .thumb { height: 78px; background: #000; position: relative; overflow: hidden; }
.asset .thumb video, .asset .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.asset .badge { position: absolute; top: 4px; left: 4px; background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 9px; font-weight: 700; padding: 2px 5px; border-radius: 4px; letter-spacing: 0.04em; }
.asset .thumb.alpha { background: repeating-conic-gradient(#2a2a2a 0% 25%, #1a1a1a 0% 50%) 50% / 14px 14px; }
.asset .thumb.audio { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f2f2b, #123a35); color: #6fd3c6; font-size: 22px; }
.asset .meta { padding: 6px 8px 2px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset .acts { display: flex; gap: 4px; padding: 4px 6px 7px; }
.asset .acts button { flex: 1; background: transparent; border: 1px solid var(--line); border-radius: 5px; font-size: 11px; font-weight: 600; padding: 4px 2px; color: var(--text); }
.asset .acts button:hover { border-color: var(--accent); color: var(--accent); }
.asset .acts button.del { flex: 0 0 26px; color: var(--dim); }
.asset .acts button.del:hover { border-color: #ef4444; color: #ef4444; }

/* ── Vista previa ── */
.ed-center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ed-stage-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 14px; background: #070708; }
.ed-stage { position: relative; background: #000; overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
.ed-stage video, .ed-stage img { position: absolute; inset: 0; width: 100%; height: 100%; }
.ed-stage video.cover, .ed-stage img.cover { object-fit: cover; }
.ed-stage video.contain, .ed-stage img.contain { object-fit: contain; }
.ed-stage video.av { inset: auto; height: auto; object-fit: contain; z-index: 100; pointer-events: none; }
.ed-stage-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px; color: var(--dim); }
.ed-transport { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--surface); border-top: 1px solid var(--line); }
.ed-play { width: 38px; font-size: 15px; }
.ed-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; margin-left: 6px; }

/* ── Panel de propiedades ── */
.pp-group { display: flex; flex-direction: column; gap: 8px; }
.pp-h { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); font-weight: 700; }
.pp-name { font-weight: 600; font-size: 13px; word-break: break-word; }
.pp-row { display: flex; align-items: center; gap: 8px; }
.pp-row label { flex: 0 0 74px; color: var(--muted); font-size: 12px; }
.pp-row input[type=number] { width: 100%; background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 5px; padding: 5px 7px; font-size: 12px; }
.pp-row input[type=range] { flex: 1; accent-color: var(--accent); }
.pp-row .val { flex: 0 0 42px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; font-size: 12px; font-weight: 500; }
.chip:hover { border-color: var(--line-strong); }
.chip.active { border-color: var(--accent); color: var(--accent); background: rgba(255, 77, 0, 0.1); }
.pp-hint { color: var(--dim); font-size: 12px; line-height: 1.5; }
.pp-note { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.pp-pos { display: grid; grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(3, 26px); gap: 4px; }
.pp-pos button { background: var(--card); border: 1px solid var(--line); border-radius: 4px; }
.pp-pos button.active { background: var(--accent); border-color: var(--accent); }
.pp-pos button[disabled] { visibility: hidden; }

/* ── Línea de tiempo ── */
.ed-timeline { background: var(--surface); border-top: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tl-head { display: flex; justify-content: space-between; align-items: center; padding: 5px 14px; color: var(--dim); font-size: 11px; font-weight: 600; }
.tl-zoom { display: flex; align-items: center; gap: 8px; }
.tl-zoom input { width: 120px; accent-color: var(--accent); }
.tl-body { flex: 1; display: grid; grid-template-columns: 64px minmax(0, 1fr); min-height: 0; }
.tl-labels { border-right: 1px solid var(--line); }
.tl-label { height: 56px; display: flex; align-items: center; padding-left: 10px; font-size: 11px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); }
.tl-label.ruler-l { height: 24px; }
.tl-label.t-avatar, .tl-label.t-voice { height: 44px; }
.tl-scroll { overflow-x: auto; overflow-y: hidden; position: relative; }
.tl-inner { position: relative; min-width: 100%; }
.tl-ruler { height: 24px; border-bottom: 1px solid var(--line); position: relative; cursor: pointer; }
.tl-tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); font-size: 10px; color: var(--dim); padding: 6px 0 0 4px; pointer-events: none; }
.tl-row { position: relative; border-bottom: 1px solid var(--line); height: 56px; }
.tl-row.t-avatar, .tl-row.t-voice { height: 44px; }
.blk { position: absolute; top: 5px; bottom: 5px; border-radius: 6px; padding: 4px 10px; color: #fff; font-size: 11px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: grab; touch-action: none; user-select: none; border: 1px solid rgba(255, 255, 255, 0.14); }
.blk.dragging { cursor: grabbing; z-index: 30; opacity: 0.9; }
.blk .h { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; z-index: 2; }
.blk .h.l { left: 0; } .blk .h.r { right: 0; }
.blk .h:hover { background: rgba(255, 255, 255, 0.28); }
.blk.k-clip { background: var(--c-video); }
.blk.k-avatar { background: var(--c-avatar); }
.blk.k-voice { background: var(--c-voice); }
.blk.sel { outline: 2px solid var(--accent); outline-offset: 0; z-index: 5; }
.trans-mark { position: absolute; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; background: var(--bg); border: 2px solid var(--accent); transform: rotate(45deg); z-index: 20; cursor: pointer; }
.trans-mark.cut { border-color: var(--dim); }
.trans-mark.sel { background: var(--accent); }
.tl-playhead { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid var(--accent); pointer-events: none; z-index: 40; }
.tl-playhead::before { content: ''; position: absolute; top: 0; left: -7px; border: 6px solid transparent; border-top: 9px solid var(--accent); }

/* ── Modal exportar ── */
.ed-modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.ed-modal-card { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; width: min(520px, 100%); max-height: 92vh; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.ed-modal-card h2 { font-size: 17px; }
.opt { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; cursor: pointer; }
.opt.active { border-color: var(--accent); background: rgba(255, 77, 0, 0.07); }
.opt.disabled { opacity: 0.5; cursor: default; }
.opt input { margin-top: 3px; accent-color: var(--accent); }
.opt b { display: block; font-size: 13px; margin-bottom: 2px; }
.opt span { color: var(--muted); font-size: 12px; }
.ed-modal-card video { width: 100%; max-height: 46vh; background: #000; border-radius: 8px; }
.row-btns { display: flex; gap: 8px; justify-content: flex-end; }
.spin { width: 30px; height: 30px; border: 3px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: sp 0.9s linear infinite; margin: 8px auto; }
@keyframes sp { to { transform: rotate(360deg); } }
.err { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.4); color: #ffb4b4; border-radius: 8px; padding: 10px 12px; line-height: 1.5; }
.ed-toast { position: fixed; bottom: 282px; left: 50%; transform: translateX(-50%); background: #222; border: 1px solid var(--line-strong); padding: 9px 16px; border-radius: 8px; font-size: 12px; z-index: 300; max-width: 90vw; }

@media (max-width: 1000px) {
    .ed-main { grid-template-columns: 220px minmax(0, 1fr) 0; }
    .ed-props { position: fixed; right: 0; top: 52px; bottom: 262px; width: 270px; z-index: 50; transform: translateX(100%); }
    .ed-props.open { transform: none; }
    .ed-mobile-note { display: block; position: fixed; top: 58px; right: 8px; max-width: 250px; border-radius: 8px; z-index: 60; opacity: 0.92; pointer-events: none; }
}
@media (max-width: 640px) {
    .ed-main { grid-template-columns: 0 minmax(0, 1fr) 0; }
    .ed-lib { position: fixed; left: 0; top: 52px; bottom: 262px; width: 240px; z-index: 50; transform: translateX(-100%); }
    .ed-lib.open { transform: none; }
    .ed-title, .ed-save { display: none; }
}
