:root {
  --bg: #0b0e14;
  --panel: #131822;
  --panel-2: #1a2130;
  --line: #262f42;
  --text: #e7ecf5;
  --muted: #8b97ad;
  --air: #e11d48;
  --ok: #10b981;
  --accent: #3b82f6;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ------------------------------------------------------------- barra aire -- */
.air {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.air.live { background: linear-gradient(90deg, rgba(225,29,72,.28), var(--panel) 70%); }
.brand { font-weight: 800; letter-spacing: .14em; font-size: 11px; color: var(--muted); }
.tally {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; flex: 1;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: #3b4457; flex: 0 0 auto; }
.air.live .dot { background: var(--air); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.tally-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tally-txt b { font-weight: 700; }
.tally-txt span { color: var(--muted); }
.air-actions { display: flex; gap: 6px; }

/* ------------------------------------------------------------------ botones */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 8px; padding: 7px 12px; font-weight: 600;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: #232c3e; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2f74e6; }
.btn.danger { background: var(--air); border-color: var(--air); color: #fff; }
.btn.danger:hover { background: #c8153e; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.icon { padding: 6px 9px; font-size: 13px; }

/* -------------------------------------------------------------------- lista */
.wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 14px; }
.wrap > * { min-width: 0; }
@media (min-width: 900px) { .wrap { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; } }

/* Monitor y buscador comparten la fila: la lista arranca más arriba. */
.head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.head .toolbar { flex: 1; margin-bottom: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.toolbar input, .toolbar select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; min-width: 0; max-width: 100%;
}
.toolbar input { flex: 1; }

.list { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c, #444);
  border-radius: var(--radius); padding: 9px 10px;
}
.row.live { border-color: var(--air); box-shadow: 0 0 0 1px rgba(225,29,72,.35) inset; }
/* Marca del teclado: se dibuja por fuera, asi no tapa el estado de aire. */
.row.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.row .info { flex: 1; min-width: 0; }
.row .l1 { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .l2 { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px;
  flex: 0 0 auto;
}
.row .acts { display: flex; gap: 4px; flex: 0 0 auto; margin-left: auto; }
.empty { color: var(--muted); text-align: center; padding: 32px 12px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ------------------------------------------------------------------- form -- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card h2 { margin: 0 0 12px; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .06em; }
.field input, .field select {
  width: 100%; min-width: 0; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field input[type=color] { padding: 3px; height: 36px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; }
.form-actions .btn { flex: 1; }
.hint { color: var(--muted); font-size: 11px; margin-top: 10px; line-height: 1.5; }

/* ------------------------------------------------------------------ modal --
   El rotulo se edita aca. La cabecera y los botones quedan fijos; lo unico que
   rueda es el cuerpo, asi que «Guardar» siempre esta a la vista. */
.modal {
  width: min(560px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
  padding: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
.modal::backdrop { background: rgba(4, 7, 13, .68); }
.modal form { display: flex; flex-direction: column; max-height: calc(100vh - 20px); }
.modal-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  flex: 1; margin: 0;
  font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.modal-body { padding: 14px; overflow-y: auto; }
.modal .form-actions { margin: 0; padding: 12px 14px; border-top: 1px solid var(--line); }
.hint code {
  background: var(--bg); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.offline {
  display: none; background: #7c2d12; color: #fff; text-align: center;
  padding: 5px; font-size: 12px; font-weight: 600;
}
body.disconnected .offline { display: block; }

/* Dock angosto de OBS: la busqueda y el filtro se apilan y el panel respira menos. */
@media (max-width: 560px) {
  .wrap { padding: 10px; gap: 10px; }
  .toolbar input, .toolbar select { flex: 1 1 100%; }
  .air { padding: 8px 10px; }
  .brand { display: none; }
  .btn.icon { padding: 6px 7px; }
  .row { padding: 8px; gap: 8px; }
  /* Reordenar se hace en la vista ancha; aqui manda el texto del rotulo. */
  .row [data-act="up"], .row [data-act="down"] { display: none; }
}

/* ------------------------------------------------------------- medios ----- */
/* Adjuntar es lo primero que se ve al elegir imagen o video: el desplegable de
   archivos ya subidos queda arriba, y aca se suelta o se elige uno nuevo. */
.drop {
  position: relative; display: block;
  margin-top: 8px; padding: 14px 12px;
  text-align: center; cursor: pointer;
  background: var(--bg);
  border: 1px dashed var(--line); border-radius: 8px;
  transition: border-color .12s, background .12s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--panel-2); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop b { display: block; font-size: 13px; font-weight: 650; }
.drop span { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }

.up-status {
  display: block; margin-top: 6px;
  font-size: 11px; color: var(--muted);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.up-status:empty { display: none; }
.up-status.err { color: var(--air); }

.thumb:empty { display: none; }
.thumb {
  margin-top: 8px; border: 1px solid var(--line); border-radius: 8px;
  background: repeating-conic-gradient(#1a1a1a 0% 25%, #222 0% 50%) 0 0 / 16px 16px;
  display: grid; place-items: center; overflow: hidden;
}
.thumb img, .thumb video { max-width: 100%; max-height: 140px; display: block; }

.library { display: flex; flex-direction: column; gap: 6px; }
.library .empty { padding: 16px 8px; font-size: 12px; }
.file-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
}
.file-row .info { flex: 1; min-width: 0; }
.file-row .nm { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .sz { font-size: 11px; color: var(--muted); }

/* ------------------------------------------------------------- monitor ---- */
.mon-wrap { width: var(--mon-w, 320px); max-width: 100%; flex: 0 0 auto; }
.monitor {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  /* Damero: recuerda que detrás va el programa, no un fondo negro real. */
  background: repeating-conic-gradient(#151515 0% 25%, #1d1d1d 0% 50%) 0 0 / 24px 24px;
}
.monitor.live { border-color: var(--air); box-shadow: 0 0 0 1px rgba(225, 29, 72, .5) inset; }
#monitor-frame {
  position: absolute; top: 0; left: 0;
  width: 1920px; height: 1080px;
  border: 0;
  transform-origin: 0 0;
  pointer-events: none;
}
.mon-bar { display: flex; align-items: center; gap: 8px; padding: 5px 2px 0; }
.mon-tag {
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}

/* --------------------------------------------------------------- modo aire --
   Todo lo de configurar se esconde: al aire sólo se mira el monitor y se
   aprieta play. Nada de formularios abiertos que se toquen sin querer. */
body.mode-air aside,
body.mode-air #item-new,
body.mode-air .row [data-act="up"],
body.mode-air .row [data-act="down"],
body.mode-air .row [data-act="edit"],
body.mode-air .row [data-act="del"] { display: none; }

body.mode-air .wrap { grid-template-columns: minmax(0, 1fr); }
body.mode-air .row { padding: 12px 10px; }
body.mode-air .row .l1 { font-size: 15px; }
body.mode-air .row .acts .btn { padding: 11px 18px; font-size: 16px; line-height: 1; }
body.mode-air #mode { border-color: var(--air); color: var(--air); }

.mon-size {
  flex: 0 0 auto;
  width: 20px; height: 18px; padding: 0;
  font-size: 10px; font-weight: 700; line-height: 1;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 4px;
}
.mon-size:hover { color: var(--text); }

@media (max-width: 560px) {
  .head { flex-direction: column; }
  .head .toolbar { width: 100%; }
}

/* -------------------------------------------------------------- tareas ----- */
.tasks-panel {
  flex: 1; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px 10px;
}
.tasks-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tasks-title {
  flex: 1;
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}

.task-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.task-form input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; width: 100%; min-width: 0;
}
.task-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.task-form-row { display: flex; gap: 6px; }
.task-form-row input { flex: 1; }

.tasks { display: flex; flex-direction: column; gap: 5px; max-height: 148px; overflow-y: auto; }
.task {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; cursor: pointer;
}
.task:hover { border-color: #3a4459; }
.task.on { border-color: var(--accent); background: var(--panel-2); }
.task .info { flex: 1; min-width: 0; }
.task .tt { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task .tw { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task .tw b { color: var(--ok); font-weight: 600; }
.task .acts { display: none; gap: 4px; }
.task:hover .acts, .task.on .acts { display: flex; }
.tasks .empty { padding: 14px 8px; font-size: 12px; }

.list-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}
.list-head b { color: var(--text); letter-spacing: 0; text-transform: none; font-size: 13px; }
#item-new { flex: 0 0 auto; letter-spacing: 0; text-transform: none; }
.kbd-hint {
  margin-left: auto; flex: 0 0 auto;
  font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: none;
  color: var(--muted);
}
/* En el dock angosto de OBS no cabe la ayuda; el boton se corre solo. */
@media (max-width: 560px) {
  .kbd-hint { display: none; }
  #item-new { margin-left: auto; }
}

@media (max-width: 560px) { .tasks-panel { width: 100%; } }
