/* ============ EditorIA — estilos ============ */
:root {
  --bg: #0e0f13;
  --bg-2: #16181f;
  --bg-3: #1e212b;
  --line: #2a2e3a;
  --text: #e8eaf0;
  --text-dim: #9aa0b0;
  --accent: #e8b33b;      /* ámbar */
  --primary: #4f7cff;     /* azul */
  --danger: #e85b5b;
  --ok: #4fc47f;
  --radius: 12px;
  --topbar-h: 56px;
  --timeline-h: 300px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
/* El atributo [hidden] debe ganar siempre, aunque una regla con id/clase fije display */
[hidden] { display: none !important; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
input, textarea, select { -webkit-user-select: text; user-select: text; }

#app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

/* ===== Barra superior ===== */
#topbar {
  height: var(--topbar-h); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand-logo { color: var(--accent); font-size: 20px; }
.brand-name em { color: var(--accent); font-style: normal; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.sep { width: 1px; height: 26px; background: var(--line); margin: 0 2px; }

/* ===== Botones ===== */
.btn {
  min-height: 44px; padding: 0 16px; border: none; border-radius: var(--radius);
  font: 600 14px/1 system-ui, sans-serif; color: var(--text);
  background: var(--bg-3); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: filter .12s, transform .06s;
}
.btn:active { transform: scale(.97); filter: brightness(1.2); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.primary { background: var(--primary); }
.btn.accent  { background: var(--accent); color: #14120a; }
.btn.ghost   { background: transparent; border: 1px solid var(--line); }
.btn.danger  { background: var(--danger); }
.btn.icon-only { width: 44px; padding: 0; font-size: 18px; }
.btn.wide { width: 100%; margin: 6px 0 14px; }
.btn .ic { font-size: 15px; }
.btn-row { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
@media (max-width: 900px) { .btn .lbl { display: none; } .btn { padding: 0 12px; } }

/* ===== Zona central ===== */
#main { flex: 1 1 auto; display: flex; min-height: 0; }
#preview-wrap {
  flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  background: #000; position: relative; padding: 12px;
}
#preview-canvas {
  max-width: 100%; max-height: calc(100% - 64px);
  border-radius: 8px; background: #000;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
#video-pool { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
#transport {
  display: flex; align-items: center; gap: 10px;
  background: rgba(22,24,31,.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 18px 6px 8px;
}
.tbtn {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: transparent; color: var(--text); font-size: 17px; cursor: pointer;
}
.tbtn.big { width: 52px; height: 52px; background: var(--accent); color: #14120a; font-size: 20px; }
.tbtn:active { filter: brightness(1.25); }
#time-display { font: 500 13px/1 ui-monospace, "SF Mono", Menlo, monospace; color: var(--text-dim); min-width: 110px; text-align: center; }

/* ===== Panel lateral ===== */
#side-panel {
  flex: 0 0 340px; max-width: 44vw; display: flex; flex-direction: column;
  background: var(--bg-2); border-left: 1px solid var(--line); min-height: 0;
}
#panel-tabs { display: flex; flex: 0 0 auto; border-bottom: 1px solid var(--line); }
.tab-btn {
  flex: 1; min-height: 48px; background: transparent; border: none; color: var(--text-dim);
  font: 600 13px/1 system-ui, sans-serif; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.panel { display: none; flex: 1 1 auto; overflow-y: auto; padding: 14px 16px 24px; min-height: 0; -webkit-overflow-scrolling: touch; }
.panel.active { display: block; }
.panel h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-dim); margin: 18px 0 8px; padding-top: 12px; border-top: 1px solid var(--line);
}
.panel h3:first-child { margin-top: 0; padding-top: 0; border-top: none; }

/* ===== Campos ===== */
.field-row { margin: 8px 0; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0; }
.field-grid.three { grid-template-columns: 1fr 1fr 1fr; align-items: end; }
label { display: flex; flex-direction: column; gap: 5px; font: 500 12.5px/1.3 system-ui, sans-serif; color: var(--text-dim); }
label output { float: right; color: var(--accent); font-weight: 600; margin-left: 6px; }
label.check { flex-direction: row; align-items: center; min-height: 44px; gap: 8px; color: var(--text); font-size: 13.5px; }
input[type="number"], input[type="text"], input[type="password"], input[type="url"], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font: 500 14px/1.3 system-ui, sans-serif;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 34px; }
input[type="color"] { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 3px; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; }

/* ===== Listas (sugerencias / subtítulos) ===== */
.list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.empty-hint { color: var(--text-dim); font-size: 13px; padding: 10px 4px; }
.hint { color: var(--text-dim); font-size: 12px; margin-top: 10px; }
.sug-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--bg-3); border-radius: 10px; cursor: pointer; min-height: 46px;
}
.sug-item .sug-kind { font-size: 16px; }
.sug-item .sug-label { flex: 1; font-size: 13px; }
.sug-item .sug-time { font: 500 11.5px/1 ui-monospace, monospace; color: var(--text-dim); }
.sub-item {
  display: grid; grid-template-columns: 62px 62px 1fr 34px; gap: 6px; align-items: center;
  padding: 6px 8px; background: var(--bg-3); border-radius: 10px;
}
.sub-item.active { outline: 2px solid var(--accent); }
.sub-item input { min-height: 36px; padding: 4px 6px; font-size: 12.5px; text-align: center; }
.sub-item textarea { min-height: 36px; padding: 6px 8px; font-size: 13px; grid-column: auto; }
.sub-item .del { background: none; border: none; color: var(--text-dim); font-size: 15px; cursor: pointer; min-height: 34px; }

/* ===== Progreso ===== */
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.progress .bar { height: 100%; width: 0%; background: var(--accent); border-radius: 99px; transition: width .2s; }
.status-line { font-size: 12.5px; color: var(--text-dim); min-height: 18px; }

/* ===== Línea de tiempo ===== */
#timeline-wrap {
  flex: 0 0 var(--timeline-h); background: var(--bg-2);
  border-top: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0;
}
#timeline-tools { display: flex; align-items: center; gap: 6px; padding: 6px 12px 2px; flex-wrap: wrap; }
#timeline-tools .spacer { flex: 1; }
#timeline-tools .btn { min-height: 36px; font-size: 13px; padding: 0 10px; }
#timeline-tools .btn.icon-only { width: 40px; }
#timeline-tools .tsep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
#timeline-tools .btn.tool.active { background: var(--primary); color: #fff; border-color: var(--primary); }
#zoom-range { width: 120px; }
#timeline-canvas { flex: 1 1 auto; width: 100%; display: block; touch-action: none; cursor: crosshair; min-height: 0; }

/* ===== Overlays ===== */
#drop-overlay {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(14,15,19,.85); border: 3px dashed var(--primary); border-radius: 18px;
  font-size: 20px; font-weight: 700; color: var(--primary);
}
#toasts {
  position: fixed; top: calc(var(--topbar-h) + 10px); left: 50%; transform: translateX(-50%);
  z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  padding: 10px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  box-shadow: 0 6px 24px rgba(0,0,0,.5); animation: toast-in .2s ease-out;
  max-width: min(520px, 86vw);
}
.toast.ok { border-color: var(--ok); color: var(--ok); }
.toast.error { border-color: var(--danger); color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

dialog#dialog {
  margin: auto; padding: 22px; width: min(480px, 92vw); max-height: 84dvh; overflow-y: auto;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: 16px;
}
dialog#dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
#dialog-title { font-size: 17px; margin-bottom: 12px; }
#dialog-body { font-size: 14px; color: var(--text-dim); }
#dialog-body p { margin: 8px 0; }
#dialog-body ol { margin: 8px 0 8px 20px; }
#dialog-body input { margin-top: 8px; }
#dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ===== Diseño vertical (iPad en retrato / móvil) ===== */
@media (max-width: 720px), (orientation: portrait) {
  #main { flex-direction: column; }
  #side-panel { flex: 0 0 38%; max-width: none; border-left: none; border-top: 1px solid var(--line); }
  :root { --timeline-h: 240px; }
}
