/* Web Studio — sistema de diseño: tokens y componentes base (docs/diseno.md).
   Tema oscuro neutro, un acento (ámbar WD), densidad compacta. Lo cargan index.html y editor.js. */
@font-face {
  font-family: "Inter var"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("vendor/inter/inter-latin-wght-normal.woff2") format("woff2");
}
:root {
  color-scheme: dark;
  /* superficies por niveles */
  --bg-0: #0E0F11; --bg-1: #16171A; --bg-2: #1D1F23; --bg-3: #26282D; --bg-4: #30333A;
  --line: #2A2C31; --line-2: #3A3D44; --line-soft: rgba(255,255,255,.06);
  /* texto (AA sobre bg-1: 15.3 / 7.9 / 5.5) */
  --tx-1: #ECEDEF; --tx-2: #A9ACB4; --tx-3: #8B8F98; --tx-dis: #5E626B;
  /* acento único */
  --ac: #BCA3FF; --ac-hover: #D8C5FF; --ac-press: #9C7DE8; --on-ac: #17130A; --ac-soft: rgba(188,163,255,.14); --ac-line: rgba(188,163,255,.45);
  /* estados */
  --ok: #3DD68C; --warn: #F5A524; --err: #FF6B70; --info: #6AA8FF;
  --ok-soft: rgba(61,214,140,.12); --err-soft: rgba(255,107,112,.12); --info-soft: rgba(106,168,255,.12); --warn-soft: rgba(245,165,36,.12);
  --playhead: #FF4D5E;
  /* tipos de clip (mismos en línea de tiempo, biblioteca e inspector) */
  --clip-video: #2D5F99; --clip-texto: #7447B0; --clip-imagen: #2A756B; --clip-efecto: #9E3C5F; --clip-preset: #9A4A2A;
  --clip-musica: #22694A; --clip-sfx: #8F5B1F; --clip-voz: #24657F; --clip-flash: #6B6E75; --clip-resplandor: #7A6A22; --clip-trans: #BCA3FF; --clip-escena: #8A4A9E;
  /* tipografía */
  --font: "Inter var", "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
  --fs-xs: 11px; --fs-sm: 12px; --fs-md: 13px; --fs-lg: 15px; --fs-xl: 18px; --fs-2xl: 22px;
  /* espaciado (retícula de 4) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  /* radios */
  --r1: 4px; --r2: 6px; --r3: 10px; --r4: 14px; --r-pill: 999px;
  /* sombras */
  --sh1: 0 1px 2px rgba(0,0,0,.45); --sh2: 0 8px 24px rgba(0,0,0,.45); --sh3: 0 18px 48px rgba(0,0,0,.6);
  /* movimiento */
  --t-fast: 120ms; --t-med: 180ms; --ease: cubic-bezier(.2,.8,.2,1);
  /* tamaños */
  --h-ctl: 28px; --h-ctl-lg: 32px; --barra-app: 44px;
  --foco: 0 0 0 2px var(--bg-0), 0 0 0 4px var(--ac);
  /* alias de la versión anterior (código viejo y módulos de otros equipos) */
  --fondo: var(--bg-0); --panel: var(--bg-1); --panel2: var(--bg-2); --panel3: var(--bg-3); --borde: var(--line-2); --borde-suave: var(--line);
  --texto: var(--tx-1); --tenue: var(--tx-2); --acento: var(--ac); --azul: var(--info); --violeta: #8B6CFF; --aviso: var(--warn); --error: var(--err);
  --radio: var(--r3); --sombra: var(--sh2);
}
@media (prefers-reduced-motion: reduce) { :root { --t-fast: 0ms; --t-med: 0ms; } *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg-0); color: var(--tx-1); font: 400 var(--fs-md)/1.45 var(--font); -webkit-font-smoothing: antialiased; }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--foco); border-radius: var(--r2); }
.ico { flex: none; display: inline-block; vertical-align: -3px; }
.num, .tabular { font-variant-numeric: tabular-nums; }
kbd, .kbd { display: inline-flex; align-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r1); background: var(--bg-3); border: 1px solid var(--line-2); border-bottom-width: 2px;
  font: 500 11px/1 var(--mono); color: var(--tx-2); white-space: nowrap; }
code { background: var(--bg-2); padding: 1px 5px; border-radius: var(--r1); font: 12px var(--mono); }
.tenue { color: var(--tx-2); } .muy-tenue { color: var(--tx-3); } .pequeno { font-size: var(--fs-sm); } .centrado { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--ac-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #444851; } ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }

/* ================================================================== botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--h-ctl); padding: 0 12px; border-radius: var(--r2);
  border: 1px solid var(--line-2); background: var(--bg-3); color: var(--tx-1); font-weight: 500; cursor: pointer; white-space: nowrap; user-select: none;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.btn:hover { background: var(--bg-4); }
.btn:active { transform: translateY(.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primario, .btn.acento { background: var(--ac); border-color: var(--ac); color: var(--on-ac); font-weight: 600; }
.btn.primario:hover, .btn.acento:hover { background: var(--ac-hover); border-color: var(--ac-hover); }
.btn.primario:active, .btn.acento:active { background: var(--ac-press); }
.btn.sec { background: var(--bg-3); }
.btn.fantasma { background: transparent; border-color: transparent; color: var(--tx-2); } .btn.fantasma:hover { background: var(--bg-3); color: var(--tx-1); }
.btn.peligro { background: transparent; border-color: rgba(255,107,112,.45); color: var(--err); } .btn.peligro:hover { background: var(--err-soft); }
.btn.peligro-lleno { background: #C8383E; border-color: #C8383E; color: #fff; }
.btn.chico { height: 24px; padding: 0 8px; font-size: var(--fs-sm); gap: 4px; }
.btn.grande { height: 36px; padding: 0 16px; font-size: var(--fs-lg); }
.btn.solo-ico, .icono-btn { width: var(--h-ctl); padding: 0; }
.icono-btn { display: inline-grid; place-items: center; height: var(--h-ctl); border-radius: var(--r2); border: 0; background: transparent; color: var(--tx-2); cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast); }
.icono-btn:hover { background: var(--bg-3); color: var(--tx-1); }
.icono-btn[aria-pressed="true"], .icono-btn.on { background: var(--ac-soft); color: var(--ac); }
.icono-btn:disabled { opacity: .35; cursor: not-allowed; }
.enlace { color: var(--info); cursor: pointer; text-decoration: none; background: none; border: 0; padding: 0; font: inherit; }
.enlace:hover { text-decoration: underline; }

/* ================================================================== campos */
.campo-txt, input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]), select, textarea {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r2); color: var(--tx-1); padding: 0 9px; height: var(--h-ctl); min-width: 0;
  transition: border-color var(--t-fast), box-shadow var(--t-fast); }
textarea { padding: 6px 9px; height: auto; resize: vertical; line-height: 1.45; }
select { padding-right: 24px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A9ACB4' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; }
select option, select optgroup { background: var(--bg-2); color: var(--tx-1); }
input::placeholder, textarea::placeholder { color: var(--tx-3); }
input:hover:not(:focus):not(:disabled), select:hover:not(:focus):not(:disabled), textarea:hover:not(:focus):not(:disabled) { border-color: #4A4E57; }
input:focus-visible, select:focus-visible, textarea:focus-visible, input:focus, select:focus, textarea:focus { border-color: var(--ac); box-shadow: 0 0 0 3px var(--ac-soft); border-radius: var(--r2); }
input:disabled, select:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }
input[type=number] { font-variant-numeric: tabular-nums; }
input[type=checkbox], input[type=radio] { accent-color: var(--ac); width: 15px; height: 15px; cursor: pointer; }
input[type=color] { width: 30px; height: 24px; padding: 0 2px; border: 1px solid var(--line-2); border-radius: var(--r1); background: var(--bg-2); cursor: pointer; }
.ayuda-campo { font-size: var(--fs-xs); color: var(--tx-3); font-weight: 400; }
/* slider */
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 18px; cursor: pointer; padding: 0; border: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--ac) var(--p, 0%), var(--bg-4) var(--p, 0%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; border: 2px solid var(--ac); box-shadow: var(--sh1); transition: transform var(--t-fast); }
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.12); }
input[type=range]:focus-visible { box-shadow: none; } input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: var(--foco); }
/* interruptor */
.interruptor { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 500; }
.interruptor input { appearance: none; -webkit-appearance: none; width: 30px; height: 18px; border-radius: 99px; background: var(--bg-4); position: relative; transition: background var(--t-fast); margin: 0; }
.interruptor input::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform var(--t-fast); }
.interruptor input:checked { background: var(--ac); } .interruptor input:checked::after { transform: translateX(12px); }
/* segmentado */
.segmentado { display: inline-flex; padding: 2px; gap: 2px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r2); }
.segmentado button { height: 22px; padding: 0 10px; border: 0; border-radius: var(--r1); background: transparent; color: var(--tx-2); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; }
.segmentado button:hover { color: var(--tx-1); }
.segmentado button[aria-pressed="true"], .segmentado button.on { background: var(--bg-4); color: var(--tx-1); box-shadow: var(--sh1); }

/* ================================================================== pestañas */
.pestanas { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 6px; overflow-x: auto; scrollbar-width: none; flex: none; }
.pestanas > button { display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 9px; border: 0; background: none; color: var(--tx-2); font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.pestanas > button:hover { color: var(--tx-1); }
.pestanas > button[aria-selected="true"], .pestanas > button.activa { color: var(--tx-1); border-bottom-color: var(--ac); }

/* ================================================================== chips */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); background: var(--bg-3); border: 1px solid var(--line-2);
  font-size: var(--fs-xs); font-weight: 600; color: var(--tx-2); white-space: nowrap; }
.chip.ac { background: var(--ac-soft); border-color: var(--ac-line); color: var(--ac); }
.chip.ok { background: var(--ok-soft); border-color: rgba(61,214,140,.35); color: var(--ok); }
.chip.err { background: var(--err-soft); border-color: rgba(255,107,112,.35); color: var(--err); }
button.chip { cursor: pointer; } button.chip:hover { border-color: var(--ac-line); color: var(--tx-1); }
.punto { width: 8px; height: 8px; border-radius: 50%; background: var(--tx-3); flex: none; display: inline-block; }
.punto.ok { background: var(--ok); } .punto.err, .punto.falta { background: var(--err); } .punto.aviso { background: var(--warn); }

/* ================================================================== toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; width: min(400px, 92vw); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r3); padding: 10px 6px 10px 12px;
  box-shadow: var(--sh3); animation: entra var(--t-med) var(--ease); }
.toast > .ico { margin-top: 2px; color: var(--info); } .toast.ok > .ico { color: var(--ok); } .toast.error > .ico { color: var(--err); } .toast.aviso > .ico { color: var(--warn); }
.toast-txt { flex: 1; white-space: pre-wrap; word-break: break-word; font-size: var(--fs-sm); line-height: 1.45; } .toast-txt b { font-size: var(--fs-md); }
.toast .btn { margin-top: -2px; } .toast .icono-btn { width: 24px; height: 24px; margin-top: -3px; }
@keyframes entra { from { transform: translateY(6px); opacity: 0; } }

/* ================================================================== tooltip (data-tip; app.js lo mueve desde title) */
.tip { position: fixed; z-index: 2000; pointer-events: none; max-width: 300px; padding: 5px 8px; border-radius: var(--r2); background: #2E3138; color: var(--tx-1); border: 1px solid #454952;
  font-size: var(--fs-sm); line-height: 1.35; box-shadow: var(--sh2); white-space: pre-line; display: flex; gap: 8px; align-items: center; opacity: 0; transition: opacity var(--t-fast); }
.tip.ver { opacity: 1; } .tip kbd { background: var(--bg-1); }

/* ================================================================== modales (dialog) */
dialog { background: var(--bg-1); color: var(--tx-1); border: 1px solid var(--line-2); border-radius: var(--r4); width: min(720px, 94vw); max-height: 88vh; padding: var(--s4); box-shadow: var(--sh3); }
dialog::backdrop { background: rgba(6,7,9,.66); }
dialog[open] { animation: entra var(--t-med) var(--ease); }
.dlg-cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.dlg-cab h2 { margin: 0; font-size: var(--fs-lg); font-weight: 600; }

/* ================================================================== menús (contextual y desplegable) */
.menu-lista, .menu-flotante, .wd-menu { position: absolute; z-index: 80; min-width: 220px; padding: 4px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r3); box-shadow: var(--sh3); }
.menu-flotante, .wd-menu { position: fixed; }
.menu-lista button, .menu-flotante button, .wd-menu button { display: flex; align-items: center; gap: 10px; width: 100%; height: 28px; padding: 0 10px; border: 0; border-radius: var(--r1); background: none; color: var(--tx-1);
  text-align: left; cursor: pointer; white-space: nowrap; font-size: var(--fs-md); }
.menu-lista button > span:first-of-type, .wd-menu button > span:first-of-type { flex: 1; }
.menu-lista button:hover:not(:disabled), .menu-flotante button:hover:not(:disabled), .wd-menu button:hover:not(:disabled), .wd-menu button:focus-visible { background: var(--bg-4); box-shadow: none; }
.menu-lista button:disabled, .wd-menu button:disabled { opacity: .4; cursor: not-allowed; }
.menu-lista kbd, .wd-menu kbd { margin-left: auto; background: none; border: 0; color: var(--tx-3); padding: 0; }
.menu-lista hr, .menu-flotante hr, .wd-menu .sep { border: 0; height: 1px; background: var(--line); margin: 4px 2px; }
.menu-lista .ico, .wd-menu .ico { color: var(--tx-2); }
.menu-flotante .peligro, .wd-menu .peligro { color: var(--err); }

/* ================================================================== paneles plegables */
details.plegable { border-bottom: 1px solid var(--line); }
details.plegable > summary { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 2px; list-style: none; cursor: pointer; user-select: none;
  font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--tx-2); }
details.plegable > summary::-webkit-details-marker { display: none; }
details.plegable > summary::before { content: ""; width: 12px; height: 12px; flex: none; transition: transform var(--t-fast);
  background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center/contain no-repeat; }
details.plegable[open] > summary::before { transform: rotate(90deg); }
details.plegable > summary:hover { color: var(--tx-1); }
details.plegable > .cuerpo { padding: 0 0 10px; }

/* ================================================================== skeletons y progreso */
.skel { background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 45%, var(--bg-2) 65%); background-size: 300% 100%; animation: skel 1.3s linear infinite; border-radius: var(--r2); }
@keyframes skel { from { background-position: 100% 0; } to { background-position: 0 0; } }
.barra { height: 4px; background: var(--bg-4); border-radius: 4px; overflow: hidden; }
.barra > div { height: 100%; width: 0; background: var(--ac); border-radius: 4px; transition: width .3s var(--ease); }
.barra.indet > div { width: 30% !important; animation: indet 1.2s var(--ease) infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.giro { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--bg-4); border-top-color: var(--ac); border-radius: 50%; animation: giro .8s linear infinite; vertical-align: -2px; flex: none; }
@keyframes giro { to { transform: rotate(360deg); } }

/* ================================================================== estados vacíos */
.vacio-guia { display: grid; justify-items: center; align-content: center; gap: 8px; text-align: center; color: var(--tx-2); padding: 24px 16px; }
.vacio-guia .ico { color: var(--tx-3); } .vacio-guia b { color: var(--tx-1); font-size: var(--fs-lg); font-weight: 600; }
.vacio-guia .acciones { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
