:root {
  --bg: #08080a;
  --surface: #0c0c10;
  --surface-2: #101015;
  --surface-3: #16161c;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --dim: #71717a;
  --violet: #a78bfa;
  --violet-neon: #8b5cf6;
  --violet-dim: rgba(139, 92, 246, 0.14);
  --emerald: #34d399;
  --emerald-dim: rgba(52, 211, 153, 0.14);
  --amber: #fbbf24;
  --amber-dim: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-dim: rgba(248, 113, 113, 0.14);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: "Outfit", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, sans-serif;
  --radius: 10px;
  --shadow: 0 12px 32px -14px rgba(0, 0, 0, 0.65);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
}

.mono { font-family: var(--mono); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #26262c; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #34343c; }

::selection { background: rgba(139, 92, 246, 0.35); }

/* ---------- Status bar (top) ---------- */
.statusbar {
  height: 46px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo {
  font-size: 22px;
  color: transparent;
  background: linear-gradient(135deg, var(--violet-neon), var(--amber));
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.4));
}
.brand-t { line-height: 1.1; }
.brand h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.tagline {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
}
.status-metrics {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  min-width: 0;
}
.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  white-space: nowrap;
}
.stat-pill .slabel {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}
.stat-pill .svalue {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
}
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot.violet { background: var(--violet); box-shadow: 0 0 8px var(--violet); }
.dot.emerald { background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }
.dot.amber { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.dot.danger { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.dot.gray { background: var(--dim); }
.dot.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.palette-trigger {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.palette-trigger:hover { border-color: var(--border-strong); color: var(--text); }
.palette-trigger svg { width: 13px; height: 13px; }
.kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
}

/* ---------- Studio layout ---------- */
.studio {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* Left studio bar */
.studiobar {
  width: 66px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.sbtn {
  width: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 9px 4px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: all 0.18s ease;
}
.sbtn svg { width: 19px; height: 19px; }
.sbtn span { font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; }
.sbtn:hover { color: var(--muted); background: var(--surface); border-color: var(--border); }
.sbtn.active {
  color: var(--violet);
  background: var(--violet-dim);
  border-color: rgba(139, 92, 246, 0.35);
  box-shadow: inset 0 0 18px rgba(139, 92, 246, 0.08);
}
.sbtn.active svg { filter: drop-shadow(0 0 6px rgba(167, 139, 250, 0.6)); }

/* Canvas */
.canvas {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 24px 32px;
}
.mod-head { margin-bottom: 18px; }
.mod-head h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.mod-head .sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  margin-top: 3px;
}
.mod-head .sub .chip {
  color: var(--violet);
  background: var(--violet-dim);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 999px;
  padding: 1px 8px;
}

/* Inspector */
.inspector {
  width: 320px;
  flex: none;
  border-left: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  flex: none;
}
.inspector-x {
  cursor: pointer;
  font-size: 16px;
  color: var(--dim);
  line-height: 1;
  padding: 0 4px;
}
.inspector-x:hover { color: var(--danger); }
.inspector-body { flex: 1; overflow-y: auto; padding: 14px; }
.insp-empty {
  color: var(--dim);
  font-size: 12.5px;
  text-align: center;
  padding: 30px 10px;
}
.insp-empty .key {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--violet);
}

/* Render dock */
.renderdock {
  height: 148px;
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.dock-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
}
.dock-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}
.dock-live {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--emerald);
}
.dock-track {
  flex: 1;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 14px;
}
.dock-item {
  width: 132px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, transform 0.2s;
}
.dock-item:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.dock-item.selected { border-color: var(--violet-neon); box-shadow: 0 0 0 1px var(--violet-neon), 0 0 16px rgba(139, 92, 246, 0.25); }
.dock-thumb { width: 100%; height: 68px; object-fit: cover; background: var(--surface-3); display: block; }
.dock-meta { padding: 6px 8px; }
.dock-meta .dt { font-size: 10.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-meta .dd { font-family: var(--mono); font-size: 9px; color: var(--dim); margin-top: 2px; }

/* ---------- Panels / grid ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  transition: border-color 0.2s;
}
.panel:hover { border-color: var(--border-strong); }
.panel h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h3 .tag {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 400;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-left: auto;
}
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }
@media (max-width: 1000px) {
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}

/* ---------- Live panels ---------- */
.live { display: flex; flex-direction: column; gap: 12px; }
.live-row .lr-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.live-row .lr-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}
.live-row .lr-value { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.track-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  animation: shimmer 2.4s ease-in-out infinite;
}
.track-fill.violet { background: linear-gradient(90deg, var(--violet-neon), var(--violet)); box-shadow: 0 0 10px rgba(139, 92, 246, 0.5); }
.track-fill.emerald { background: linear-gradient(90deg, #10b981, var(--emerald)); box-shadow: 0 0 10px rgba(52, 211, 153, 0.5); }
.track-fill.amber { background: linear-gradient(90deg, #d97706, var(--amber)); box-shadow: 0 0 10px rgba(251, 191, 36, 0.5); }
.track-fill.danger { background: linear-gradient(90deg, #dc2626, var(--danger)); box-shadow: 0 0 10px rgba(248, 113, 113, 0.5); }
@keyframes shimmer {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.done, .badge.published, .badge.active, .badge.connected, .badge.completed, .badge.succeeded {
  color: var(--emerald);
  border-color: rgba(52, 211, 153, 0.35);
  background: var(--emerald-dim);
}
.badge.warning, .badge.pending, .badge.scheduled, .badge.processing, .badge.queued {
  color: var(--amber);
  border-color: rgba(251, 191, 36, 0.35);
  background: var(--amber-dim);
}
.badge.critical, .badge.failed, .badge.error, .badge.pendiente-conectar {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
  background: var(--danger-dim);
}
.badge.image { color: var(--violet); border-color: rgba(167, 139, 250, 0.35); background: var(--violet-dim); }
.badge.video { color: var(--emerald); border-color: rgba(52, 211, 153, 0.35); background: var(--emerald-dim); }
.badge.audio { color: var(--amber); border-color: rgba(251, 191, 36, 0.35); background: var(--amber-dim); }
.badge.info { color: var(--muted); border-color: var(--border-strong); background: var(--surface-2); }
.badge.violet { color: var(--violet); border-color: rgba(167, 139, 250, 0.35); background: var(--violet-dim); }
.badge.emerald { color: var(--emerald); border-color: rgba(52, 211, 153, 0.35); background: var(--emerald-dim); }
.badge.amber { color: var(--amber); border-color: rgba(251, 191, 36, 0.35); background: var(--amber-dim); }

/* ---------- Rows / lists ---------- */
.list { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.2s;
}
.row:hover { background: var(--surface-2); }
.row + .row { border-top: 1px solid var(--border); }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 12px; }
.dim { color: var(--dim); font-size: 11px; }
.mono-sm { font-family: var(--mono); font-size: 11px; }

/* ---------- Asset gallery ---------- */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filters select, .filters input {
  font-family: var(--body);
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.2s;
}
.filters select:hover, .filters input:hover { border-color: var(--border-strong); }
.filters select:focus, .filters input:focus { border-color: var(--violet-neon); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15); }
.filters input { flex: 1; min-width: 180px; }
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.card.selected { border-color: var(--violet-neon); box-shadow: 0 0 0 1px var(--violet-neon), 0 0 18px rgba(139, 92, 246, 0.22); }
.card .thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: linear-gradient(135deg, var(--surface-3), #0a0a0f);
  display: block;
}
.card .meta { padding: 10px 12px 12px; }
.card .t { font-size: 13px; font-weight: 600; line-height: 1.3; margin-bottom: 6px; }
.card .d { font-family: var(--mono); font-size: 10px; color: var(--dim); margin-top: 4px; }
.empty {
  grid-column: 1 / -1;
  padding: 34px 16px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.empty code {
  color: var(--violet);
  background: var(--violet-dim);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 10px;
}

/* ---------- Pipeline graph ---------- */
.pipeline-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 6px;
  margin-bottom: 16px;
  overflow: hidden;
}
.pipeline-wrap svg { width: 100%; height: auto; display: block; }
.pnode { cursor: pointer; }
.pnode rect {
  fill: var(--surface-2);
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 1;
  rx: 12;
  transition: all 0.2s ease;
}
.pnode:hover rect { stroke: var(--violet-neon); fill: var(--surface-3); filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.4)); }
.pnode .pt { font-family: var(--mono); font-size: 12px; font-weight: 600; fill: var(--text); }
.pnode .ps { font-family: var(--mono); font-size: 8.5px; fill: var(--dim); letter-spacing: 0.08em; }
.pnode.accent-violet rect { stroke: rgba(139, 92, 246, 0.5); }
.pnode.accent-violet:hover rect { stroke: var(--violet-neon); }
.pnode.accent-emerald rect { stroke: rgba(52, 211, 153, 0.5); }
.pnode.accent-emerald:hover rect { stroke: var(--emerald); }
.pnode.accent-amber rect { stroke: rgba(251, 191, 36, 0.5); }
.pnode.accent-amber:hover rect { stroke: var(--amber); }
.pnode .glow { opacity: 0; transition: opacity 0.2s; }
.pnode:hover .glow { opacity: 1; }
.pipe-line {
  stroke: var(--dim);
  stroke-width: 1.6;
  stroke-dasharray: 6 5;
  animation: flow 0.9s linear infinite;
  opacity: 0.7;
}
.pipe-line.violet { stroke: var(--violet); }
.pipe-line.emerald { stroke: var(--emerald); }
.pipe-line.amber { stroke: var(--amber); }
@keyframes flow { to { stroke-dashoffset: -11; } }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
tr:hover td { background: var(--surface-2); }
td.num { font-family: var(--mono); text-align: right; }

/* ---------- Chart ---------- */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 8px; }
.bar {
  flex: 1;
  min-width: 4px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--violet), var(--violet-neon));
  opacity: 0.9;
  position: relative;
  transition: all 0.3s ease;
}
.bar:hover { opacity: 1; filter: brightness(1.2); }
.bar .bv {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
}
.bar:hover .bv { opacity: 1; }

/* ---------- Prompt block ---------- */
.prompt-block {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--violet-neon);
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.chip-btn {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.chip-btn:hover { border-color: var(--violet-neon); background: var(--surface-3); }
.transcript { font-family: var(--mono); font-size: 11px; line-height: 1.6; }
.kv { display: grid; grid-template-columns: 88px 1fr; gap: 6px 10px; font-size: 12px; }
.kv .k { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); padding-top: 1px; }
.kv .v { color: var(--text); word-break: break-word; }

/* ---------- Logs ---------- */
.logs { font-family: var(--mono); font-size: 10.5px; line-height: 1.7; }
.logs .l { display: flex; gap: 8px; padding: 1px 0; }
.logs .l .ts { color: var(--dim); flex: none; }
.logs .l .lv { flex: none; font-weight: 600; }
.logs .l .lv.info { color: var(--violet); }
.logs .l .lv.ok { color: var(--emerald); }
.logs .l .lv.warn { color: var(--amber); }
.logs .l .msg { color: var(--muted); word-break: break-word; }

/* ---------- Command palette ---------- */
.palette {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 8, 10, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.palette.hidden { display: none; }
.palette-box {
  width: 540px;
  max-width: 92vw;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  animation: palDrop 0.18s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes palDrop {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
#palette-input {
  width: 100%;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 16px 18px;
  outline: none;
}
#palette-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.pcmd {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.pcmd .pico { font-family: var(--mono); font-size: 12px; color: var(--violet); width: 20px; text-align: center; flex: none; }
.pcmd .plab { flex: 1; min-width: 0; }
.pcmd .plab b { display: block; font-size: 13px; font-weight: 500; }
.pcmd .plab span { display: block; font-family: var(--mono); font-size: 10px; color: var(--dim); margin-top: 1px; }
.pcmd .pkbd { font-family: var(--mono); font-size: 9px; color: var(--dim); opacity: 0; transition: opacity 0.15s; }
.pcmd.active { background: var(--violet-dim); }
.pcmd.active .pkbd { opacity: 1; color: var(--violet); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 172px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: 2px solid var(--violet-neon);
  border-radius: 10px;
  padding: 10px 16px;
  box-shadow: 0 16px 44px -12px rgba(0, 0, 0, 0.7);
  animation: toastIn 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
  max-width: 76vw;
}
.toast.hidden { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 900px) {
  .inspector { display: none; }
  .studiobar { width: 54px; }
  .sbtn span { display: none; }
}
