/* ==========================================================================
   Tema
   ========================================================================== */
:root {
  --bg: #0b0c0f;
  --bg-2: #111318;
  --panel: #15181e;
  --panel-2: #1b1f27;
  --line: #262b35;
  --line-2: #323845;
  --text: #e8eaef;
  --text-2: #9aa2b1;
  --text-3: #687082;
  --accent: #ff7a45;
  --accent-2: #ff9a6e;
  --accent-ink: #1a0d06;
  --teal: #37d6c4;
  --danger: #ff5d6c;
  --ok: #4ade80;
  --radius: 12px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ==========================================================================
   Layout
   ========================================================================== */
.app { display: grid; grid-template-rows: auto 1fr; height: 100vh; height: 100dvh; }
header.top {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.brand svg { width: 26px; height: 26px; }
.brand small { font-weight: 500; color: var(--text-3); margin-left: 2px; }
.author { display: flex; align-items: center; gap: 8px; color: var(--text-2); text-decoration: none; font-size: 12.5px; white-space: nowrap; padding: 3px 10px 3px 3px; border-radius: 999px; border: 1px solid var(--line); }
.author:hover { color: var(--text); border-color: var(--accent); }
.avatar { position: relative; width: 26px; height: 26px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: linear-gradient(45deg, #f9ce34, #ee2a7b 55%, #6228d7); color: #fff; flex: none; }
.avatar svg { width: 15px; height: 15px; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
a.btn.kofi, a.btn.lang { text-decoration: none; }
a.btn.lang { font-weight: 700; letter-spacing: .5px; padding: 0 10px; }
a.btn.kofi svg { color: #ff5e5b; }
.filename { color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.filename b { color: var(--text); font-weight: 600; }
.pill { font: 500 11px var(--mono); padding: 3px 8px; border-radius: 99px; background: var(--panel-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: #1f4d32; }
.pill.warn { color: #fbbf24; border-color: #5a4512; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); font-weight: 500; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #222733; border-color: #3c4352; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.icon { width: 34px; padding: 0; }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn.on { color: var(--accent); border-color: #6b3a24; background: #2a1a12; }

.main { display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
.stage { display: grid; grid-template-rows: 1fr auto auto; min-width: 0; min-height: 0; background: var(--bg); }

/* Visor */
.viewport { position: relative; min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 16px;
  background: radial-gradient(ellipse at 50% 40%, #13161c 0%, var(--bg) 70%); }
.canvas-wrap { position: relative; box-shadow: 0 10px 40px rgba(0,0,0,.55); border-radius: 4px; overflow: hidden; background: #000; touch-action: none; }
#view { display: block; width: 100%; height: 100%; cursor: grab; }
#view.dragging { cursor: grabbing; }
#view.nopan { cursor: default; }
.split { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(255,255,255,.9); box-shadow: 0 0 0 1px rgba(0,0,0,.35); pointer-events: none; }
.split-handle { position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%;
  background: #fff; color: #111; display: grid; place-items: center; pointer-events: auto; cursor: ew-resize; box-shadow: 0 2px 10px rgba(0,0,0,.5); touch-action: none; }
.split-handle svg { width: 18px; height: 18px; }
.tag { position: absolute; top: 10px; font: 600 11px Inter; letter-spacing: .6px; text-transform: uppercase; padding: 4px 8px; border-radius: 6px; background: rgba(0,0,0,.55); color: #fff; pointer-events: none; backdrop-filter: blur(4px); }
.tag.left { left: 10px; } .tag.right { right: 10px; }
.hud { position: absolute; left: 10px; bottom: 10px; font: 500 11px var(--mono); color: rgba(255,255,255,.75); background: rgba(0,0,0,.45); padding: 3px 7px; border-radius: 6px; pointer-events: none; }

/* Zona de soltar */
.drop {
  position: absolute; inset: 16px; border: 2px dashed var(--line-2); border-radius: 18px;
  display: grid; place-items: center; text-align: center; padding: 24px; transition: border-color .15s, background .15s; background: rgba(17,19,24,.6);
}
.drop.over { border-color: var(--accent); background: rgba(255,122,69,.06); }
.drop h2 { margin: 14px 0 6px; font-size: 22px; letter-spacing: -.2px; }
.drop p { margin: 0 auto 18px; color: var(--text-2); max-width: 460px; }
.drop .big { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto; background: linear-gradient(135deg, #2a1a12, #13261f); border: 1px solid var(--line-2); }
.drop .big svg { width: 30px; height: 30px; color: var(--accent); }
.drop .fine { margin-top: 18px; font-size: 12px; color: var(--text-3); }
.features { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 0 0 20px; }
.features span { font-size: 12px; color: var(--text-2); background: var(--panel); border: 1px solid var(--line); padding: 4px 10px; border-radius: 99px; }

/* Transporte */
.transport { display: flex; align-items: center; gap: 6px; padding: 8px 16px; border-top: 1px solid var(--line); background: var(--bg-2); flex-wrap: wrap; }
.btn.snd { padding: 0 10px; gap: 6px; font-size: 12px; }
.btn.snd #sndLabel { color: var(--text-2); }
.btn.snd.on #sndLabel { color: var(--accent); }
.vu { width: 34px; height: 5px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.vu i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), #fbbf24 80%, var(--danger)); transition: width .06s; }
.time { font: 500 12px var(--mono); color: var(--text-2); margin: 0 8px; white-space: nowrap; }
.time b { color: var(--text); font-weight: 500; }
.spacer { flex: 1; }

/* Línea de tiempo */
.timeline-wrap { padding: 4px 16px 14px; background: var(--bg-2); }
.timeline { position: relative; height: 44px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; touch-action: none; user-select: none; }
.tl-range { position: absolute; top: 0; bottom: 0; background: rgba(255,122,69,.13); border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); }
.tl-handle { position: absolute; top: -1px; bottom: -1px; width: 12px; margin-left: -6px; background: var(--accent); border-radius: 4px; cursor: ew-resize; display: grid; place-items: center; }
.tl-handle::after { content: ""; width: 2px; height: 14px; background: var(--accent-ink); opacity: .5; border-radius: 2px; }
.tl-head { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: #fff; pointer-events: none; box-shadow: 0 0 6px rgba(255,255,255,.6); }
.tl-labels { display: flex; justify-content: space-between; font: 500 11px var(--mono); color: var(--text-3); margin-top: 6px; gap: 8px; }
.tl-labels .accent { color: var(--accent); }
.tl-health { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; width: 100%; pointer-events: none; border-radius: 0 0 7px 7px; }
.sig-row { display: flex; align-items: center; gap: 6px; margin: 6px 0 0 66px; flex-wrap: wrap; font: 500 11px var(--mono); color: var(--text-3); }
.sig-row .btn { height: 24px; padding: 0 8px; font: 500 11px Inter; }
.sig-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 4px 0 8px; vertical-align: -1px; }
.tl-row { display: grid; grid-template-columns: 58px 1fr; gap: 8px; align-items: center; }
.tl-row + .tl-row { margin-top: 6px; }
.tl-name { font: 600 10px Inter; letter-spacing: .6px; text-transform: uppercase; color: var(--text-3); text-align: right; }
.timeline.b { height: 30px; cursor: default; overflow: hidden; }
.tl-clip { position: absolute; top: 3px; bottom: 3px; border-radius: 6px; background: linear-gradient(90deg, rgba(55,214,196,.28), rgba(55,214,196,.16)); border: 1px solid rgba(55,214,196,.7);
  cursor: grab; display: flex; align-items: center; padding: 0 8px; font: 500 11px var(--mono); color: #bff3ec; white-space: nowrap; overflow: hidden; touch-action: none; }
.tl-clip.dragging { cursor: grabbing; }
.sync-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-bottom: 10px; }
.sync-row .btn { height: 30px; padding: 0; min-width: 0; font: 500 11px var(--mono); white-space: nowrap; }
.offset { font: 600 18px var(--mono); color: var(--teal); margin: 2px 0 10px; }
.wave { width: 100%; height: 86px; display: block; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); margin-bottom: 8px; }
.wave-legend { display: flex; gap: 14px; font-size: 11px; color: var(--text-3); margin-bottom: 12px; }
.wave-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.audio-status { font: 500 12px/1.5 var(--mono); color: var(--text-2); min-height: 18px; margin-bottom: 8px; }
.bthumb { width: 96px; height: 64px; border-radius: 8px; background: var(--panel-2) center/cover no-repeat; border: 1px solid var(--line-2); flex: none; display: grid; place-items: center; color: var(--text-3); }
.bthumb svg { width: 26px; height: 26px; } .bthumb.has svg { display: none; }

/* Panel lateral */
aside.panel { border-left: 1px solid var(--line); background: var(--panel); display: grid; grid-template-rows: auto 1fr; min-height: 0; }
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 10px; border-bottom: 1px solid var(--line); }
.tabs button { height: 32px; padding: 0 2px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text-2); font-weight: 600; font-size: 12.5px; }
.tabs button.active { background: var(--panel-2); color: var(--text); border-color: var(--line-2); }
.panel-body { overflow-y: auto; overflow-x: hidden; padding: 4px 14px 20px; min-height: 0; }
.panel-body::-webkit-scrollbar { width: 8px; } .panel-body::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }

.section { padding: 12px 0 6px; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.section h3 { margin: 0 0 10px; font-size: 11px; letter-spacing: .9px; text-transform: uppercase; color: var(--text-3); font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

details.adv { border-top: 1px solid var(--line); padding-top: 4px; }
details.adv > summary { list-style: none; cursor: pointer; padding: 12px 0 8px; font-size: 11px; letter-spacing: .9px; text-transform: uppercase; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: "▸"; transition: transform .15s; display: inline-block; }
details.adv[open] > summary::before { transform: rotate(90deg); }
details.adv > .section:first-of-type { border-top: 0; }
.tagline { font: 500 10px var(--mono); text-transform: none; letter-spacing: 0; padding: 2px 6px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--text-3); }
.tagline.auto { color: var(--teal); border-color: #1d5a52; }
.tagline.custom { color: #fbbf24; border-color: #5a4512; }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.preset { text-align: left; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); min-height: 48px; position: relative; }
.preset:hover { border-color: var(--line-2); }
.preset.active { border-color: var(--accent); background: #24170f; }
.preset b { display: block; font-size: 13px; font-weight: 600; }
.preset span { display: block; font-size: 11px; color: var(--text-3); margin-top: 1px; }
.preset .del { position: absolute; top: 4px; right: 6px; color: var(--text-3); font-size: 15px; line-height: 1; padding: 2px; border: 0; background: none; }
.preset .del:hover { color: var(--danger); }
.preset.auto { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; background: linear-gradient(90deg, #24170f, #10221f); border-color: #4a2e1f; min-height: 44px; }
.preset.auto svg { width: 20px; height: 20px; color: var(--accent); flex: none; }
.save-row { display: flex; gap: 6px; margin-top: 8px; }
.save-row input { flex: 1; min-width: 0; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); padding: 0 10px; }

.row { display: grid; grid-template-columns: 1fr 58px; gap: 4px 10px; align-items: center; margin: 2px 0 10px; }
.row label { font-size: 13px; color: var(--text-2); grid-column: 1 / -1; display: flex; justify-content: space-between; }
.row label .reset { color: var(--text-3); font-size: 11px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.row:hover label .reset { opacity: 1; }
.row input[type=number] { width: 58px; height: 26px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg-2); padding: 0 6px; font: 500 12px var(--mono); text-align: right; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) 0 var(--p, 50%), var(--line-2) var(--p, 50%) 100%); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; margin-top: -6px; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.6); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line-2); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 0; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 12px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.toggle small { display: block; color: var(--text-3); font-size: 11px; }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; background: var(--line-2); border-radius: 20px; transition: background .15s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); }

.seg { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); margin-bottom: 12px; }
.seg button { min-width: 0; padding: 8px 6px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); text-align: center; font-size: 12px; color: var(--text-2); }
.seg button b { display: block; color: var(--text); font-size: 13px; font-weight: 600; }
.seg button .shape { display: block; margin: 0 auto 6px; border: 1.5px solid currentColor; border-radius: 2px; opacity: .7; }
.seg button.active { border-color: var(--accent); background: #24170f; color: var(--accent-2); }
.seg.two { grid-template-columns: 1fr 1fr; }
.seg.three { grid-template-columns: 1fr 1fr 1fr; }
.seg.four { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg.four button { padding: 8px 4px; font-size: 11px; }
.seg-label { font-size: 11px; color: var(--text-2); margin: 0 0 6px; }
.hint { font-size: 12px; color: var(--text-3); margin: -4px 0 12px; }
.crop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.crop-grid label { font-size: 12px; color: var(--text-2); display: grid; gap: 4px; }
.crop-grid input { min-width: 0; width: 100%; height: 30px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg-2); padding: 0 8px; font: 500 12px var(--mono); }
select { height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); padding: 0 8px; width: 100%; }
.info { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--line-2);
  font: 600 10px/1 Inter, sans-serif; font-style: normal; text-transform: none; letter-spacing: 0; color: var(--text-3); margin-left: 6px; cursor: help; vertical-align: 1px; }
.info:hover, .info:focus { color: var(--text); border-color: var(--text-3); outline: none; }
.tip { position: fixed; z-index: 70; max-width: 290px; background: #22262f; border: 1px solid var(--line-2); color: var(--text); font-size: 12px; line-height: 1.5;
  padding: 9px 11px; border-radius: 9px; box-shadow: 0 10px 30px rgba(0,0,0,.5); pointer-events: none; }
.logo-row { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.logo-prev { width: 64px; height: 64px; border-radius: 50%; background: var(--panel-2) center/cover no-repeat; border: 2px solid var(--line-2); display: grid; place-items: center; color: var(--text-3); flex: none; }
.logo-prev svg { width: 28px; height: 28px; }
.logo-prev.has { border-color: #fff; } .logo-prev.has svg { display: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12px; margin-bottom: 8px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; font-family: var(--mono); color: var(--text-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Modal de exportación */
.modal-bg { position: fixed; inset: 0; background: rgba(5,6,8,.72); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal p { color: var(--text-2); margin: 0 0 16px; }
.bar { height: 10px; border-radius: 10px; background: var(--bg-2); overflow: hidden; border: 1px solid var(--line); }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ffb36e); transition: width .2s; }
.modal .stats { display: flex; justify-content: space-between; font: 500 12px var(--mono); color: var(--text-2); margin: 10px 0 18px; gap: 10px; flex-wrap: wrap; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; }
pre.cmd { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: 500 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; color: #cfe; margin: 0 0 14px; }

/* Avisos */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--teal); border-radius: 10px; padding: 10px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.45); font-size: 13px; animation: tin .2s ease-out; }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: #fbbf24; }
.toast b { display: block; margin-bottom: 2px; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.scan-badge { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 22px; border-radius: 14px;
  background: rgba(11,12,15,.72); backdrop-filter: blur(6px); border: 1px solid var(--line-2); font: 500 12px var(--mono); color: var(--text-2); }
.scan-badge .spinner { margin: 0; }
.busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(11,12,15,.55); font-size: 13px; color: var(--text-2); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Móvil */
@media (max-width: 900px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; }
  .main { grid-template-columns: 1fr; }
  .viewport { height: 56vh; padding: 10px; }
  aside.panel { border-left: 0; border-top: 1px solid var(--line); }
  .panel-body { overflow: visible; }
  header.top { flex-wrap: wrap; gap: 8px 12px; }
  .filename { order: 3; flex-basis: 100%; }
  .brand small { display: none; }
  .author-name, .kofi span { display: none; }
  .author { padding: 3px; }
  .drop { inset: 10px; }
}
