/* ============================================================================
   Centella Agent — Cowork UI con Claude Code CLI
   ============================================================================ */

/* ─── Override del tema claro global para el módulo agent ───────────
   El style.css global tiene --text: #1f2937 (gris oscuro) pensado para
   tema claro. El módulo agent es oscuro, así que redefinimos las vars
   dentro de su propio scope para que `var(--text)` resuelva al color
   correcto sin tener que cambiar cada referencia individualmente. */
.ag-root,
#ag-new-overlay,
.ag-overlay,
.ag-toast {
  --text: #e8eef5;
  --text-dim: #94a8be;
  --text-muted: #6b8096;
  --bg: #0f1923;
  --bg-3: #1e2f3f;
  --card-bg: #162330;
  --border: #2a3f55;
  --accent: #57cc98;
  --accent-dim: #3fa37a;
}

.ag-root {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px - 20px);
  gap: 12px;
  padding: 0 12px 12px;
}

/* ─── Toolbar ─────────────────────────────────────────────── */
.ag-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--card-bg, #162330);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 10px;
  flex-wrap: wrap;
}
.ag-toolbar h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text, #e8eef5);
}
.ag-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.ag-status-pill.ok { background: rgba(87,204,152,0.15); color: var(--accent, #57cc98); border: 1px solid var(--accent-dim, #3fa37a); }
.ag-status-pill.bad { background: rgba(239,68,68,0.15); color: #ef4444; border: 1px solid rgba(239,68,68,0.4); }
.ag-status-pill::before { content: '●'; }

.ag-toolbar-spacer { flex: 1; }

.ag-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--bg-3, #1e2f3f);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 6px;
  color: var(--text-dim, #94a8be);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.ag-btn:hover { border-color: var(--accent, #57cc98); color: var(--accent, #57cc98); }
.ag-btn.primary {
  background: var(--accent, #57cc98); color: #0f1923; border-color: var(--accent, #57cc98);
}
.ag-btn.primary:hover { opacity: 0.9; }

.ag-mode-toggle {
  display: flex;
  background: var(--bg-3, #1e2f3f);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 6px;
  overflow: hidden;
}
.ag-mode-toggle button {
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--text-dim, #94a8be);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.ag-mode-toggle button.active {
  background: var(--accent, #57cc98);
  color: #0f1923;
}

/* ─── Body (sidebar + grid) ──────────────────────────────── */
.ag-body {
  flex: 1;
  display: flex;
  gap: 10px;
  min-height: 0;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.ag-sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--card-bg, #162330);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 10px;
  overflow: hidden;
}
.ag-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-dim, #94a8be);
  border-bottom: 1px solid var(--border, #2a3f55);
  background: var(--bg-3, #1e2f3f);
}
.ag-sidebar-count {
  background: rgba(87, 204, 152, 0.15);
  color: var(--accent, #57cc98);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}
.ag-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ag-sidebar-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--text-muted, #6b8096);
  font-size: 12px;
  line-height: 1.5;
}
.ag-sidebar-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.ag-sidebar-item:hover {
  background: rgba(87, 204, 152, 0.07);
  border-color: rgba(87, 204, 152, 0.2);
}
.ag-sidebar-item.open {
  background: rgba(87, 204, 152, 0.12);
  border-color: var(--accent-dim, #3fa37a);
}
.ag-sidebar-item.open::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--accent, #57cc98);
  border-radius: 2px;
}
.ag-sidebar-item.active {
  background: rgba(87, 204, 152, 0.18);
}
.ag-sidebar-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #e8eef5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ag-sidebar-item-title .pin {
  font-size: 10px;
  color: var(--accent, #57cc98);
}
.ag-sidebar-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-muted, #6b8096);
}
.ag-sidebar-item-meta .mode {
  background: rgba(87, 204, 152, 0.12);
  color: var(--accent, #57cc98);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
}
.ag-sidebar-item-meta .mode.dangerous {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}
.ag-sidebar-item-meta .wd {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.ag-sidebar-item-actions {
  display: none;
  position: absolute;
  right: 8px;
  top: 8px;
  gap: 2px;
}
.ag-sidebar-item:hover .ag-sidebar-item-actions {
  display: flex;
}
.ag-sidebar-item-action {
  background: rgba(15, 25, 35, 0.7);
  border: none;
  color: var(--text-muted, #6b8096);
  padding: 2px 4px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}
.ag-sidebar-item-action:hover {
  color: var(--accent, #57cc98);
  background: rgba(15, 25, 35, 0.9);
}
.ag-sidebar-item-action.danger:hover {
  color: #ef4444;
}
.ag-sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border, #2a3f55);
  background: var(--bg-3, #1e2f3f);
}
.ag-sidebar-new {
  width: 100%;
  justify-content: center;
  font-size: 12px;
}
.ag-sidebar-purge {
  width: 100%;
  justify-content: center;
  font-size: 11px;
  margin-top: 6px;
  background: transparent;
  color: var(--text-muted, #6b8096);
  border: 1px dashed var(--border, #2a3f55);
}
.ag-sidebar-purge:hover {
  color: #ef4444;
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

/* ─── Grid ────────────────────────────────────────────────── */
.ag-grid {
  flex: 1;
  display: grid;
  gap: 10px;
  overflow: hidden;
  min-height: 0;
}
.ag-grid.layout-grid2 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.ag-grid.layout-grid1 {
  grid-template-columns: 1fr;
}
/* Overview: scroll vertical infinito, cards de tamaño fijo, sin recortar */
.ag-grid.layout-overview {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  grid-auto-rows: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: start;
  padding-right: 4px;  /* hueco para la scrollbar */
}
.ag-grid.layout-overview .ag-panel {
  /* en overview los paneles son más compactos */
  font-size: 12px;
}

/* ─── Panel ───────────────────────────────────────────────── */
.ag-panel {
  display: flex;
  flex-direction: column;
  background: var(--card-bg, #162330);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 10px;
  overflow: hidden;
  min-height: 0;
  position: relative;
  transition: border-color 0.15s;
}
.ag-panel.focused {
  border-color: var(--accent, #57cc98);
  box-shadow: 0 0 0 1px var(--accent, #57cc98);
}
.ag-panel.dangerous-wd {
  border-top: 3px solid #f59e0b;
}

/* Header */
.ag-panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-3, #1e2f3f);
  border-bottom: 1px solid var(--border, #2a3f55);
  flex-shrink: 0;
}
.ag-panel-title {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text, #e8eef5);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 2px 4px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ag-panel-title:focus {
  outline: 1px solid var(--accent, #57cc98);
  border-radius: 3px;
}
.ag-panel-mode-select {
  padding: 3px 6px;
  background: var(--bg, #0f1923);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 4px;
  color: var(--text-dim, #94a8be);
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  max-width: 110px;
}
.ag-panel-mode-select.dangerous { color: #f59e0b; border-color: rgba(245,158,11,0.4); }
/* Selector de modelo (mismo estilo que el de modo, color distinto para distinguir) */
.ag-panel-model-select {
  padding: 3px 6px;
  background: var(--bg, #0f1923);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 4px;
  color: var(--accent, #57cc98);
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.ag-panel-model-select:hover { border-color: var(--accent, #57cc98); }
/* Effort dropdown — mismo estilo que mode/model */
.ag-panel-effort-select {
  padding: 3px 6px;
  background: var(--bg, #0f1923);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 4px;
  color: var(--text-dim, #94a8be);
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.ag-panel-effort-select:hover { border-color: var(--accent, #57cc98); color: var(--accent, #57cc98); }
.ag-panel-model-select optgroup,
#ag-new-modelo optgroup {
  background: var(--bg, #0f1923);
  color: var(--text-dim, #94a8be);
  font-style: normal;
  font-weight: 700;
}
.ag-panel-model-select option,
#ag-new-modelo option {
  background: var(--card-bg, #162330);
  color: var(--text, #e8eef5);
  padding: 4px;
}

/* ─── TABLÓN (4º layout, canvas tipo Miro con círculos) ─────────── */
.ag-tablon {
  flex: 1;
  position: relative;
  display: flex;
  min-height: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border, #2a3f55);
}
.ag-tablon-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-color: #0a1420;
  /* Fondo de puntos sutil tipo Miro */
  background-image: radial-gradient(rgba(87, 204, 152, 0.10) 1px, transparent 1px);
  background-size: 28px 28px;
  cursor: grab;
}
.ag-tablon-viewport.dragging-pan { cursor: grabbing; }
.ag-tablon-viewport.dragging-circle { cursor: grabbing; }

.ag-tablon-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 7200px;
  height: 5400px;
  transform-origin: 0 0;
  /* JS aplica transform: translate(...) scale(...) */
}
.ag-tablon-edges {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
}
.ag-tablon-edges path {
  stroke: rgba(87, 204, 152, 0.4);
  stroke-width: 2;
  fill: none;
  stroke-dasharray: 6 4;
  animation: tablonEdgeFlow 3s linear infinite;
}
@keyframes tablonEdgeFlow {
  to { stroke-dashoffset: -20; }
}

/* "Círculo" de sesión — en realidad cuadrado redondeado estilo app icon iOS.
   Mantenemos la clase .ag-tablon-circle por compatibilidad con el JS.
   Estilo simple: solo color sólido + sombra suave + RING EXTERIOR de
   estado (post Deep Research workflows 2026-04-27 — todas las herramientas
   maduras ponen estados visibles directamente en el nodo). */
.ag-tablon-circle {
  position: absolute;
  width: 160px;
  height: 160px;
  border-radius: 32px;     /* squircle estilo app icon */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  cursor: pointer;
  user-select: none;
  text-align: center;
  color: #ffffff;
  background: var(--circle-bg, #57CC98);
  border: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.18s;
  /* JS aplica transform: translate(canvas_x, canvas_y) scale(canvas_scale) */
}
.ag-tablon-circle:hover {
  transform: translate(var(--cx, 0), var(--cy, 0)) scale(calc(var(--cs, 1) * 1.06));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  z-index: 10;
}
.ag-tablon-circle.dragging {
  transition: none;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  z-index: 100;
  cursor: grabbing;
}
.ag-tablon-circle.subagent {
  width: 110px;
  height: 110px;
  padding: 12px;
  border-radius: 24px;
}

/* Ring exterior de estado — pseudo-elemento para no interferir con drag/click.
   Cada estado tiene su color. Por defecto está oculto (idle). */
.ag-tablon-circle::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 38px;             /* squircle radius + 6 */
  border: 3px solid transparent;
  pointer-events: none;
  transition: border-color 0.2s, opacity 0.2s, box-shadow 0.2s;
  opacity: 0;
}
.ag-tablon-circle.subagent::before {
  inset: -5px;
  border-radius: 29px;
  border-width: 2.5px;
}

/* Ring por estado */
.ag-tablon-circle.state-running::before {
  opacity: 1;
  border-color: #57CC98;
  animation: tablonRingPulse 1.4s ease-in-out infinite;
}
.ag-tablon-circle.state-waiting::before {
  opacity: 1;
  border-color: #F59E0B;            /* ámbar — necesita tu input */
  animation: tablonRingShake 1s ease-in-out infinite;
}
.ag-tablon-circle.state-error::before {
  opacity: 1;
  border-color: #EF4444;            /* rojo — error */
}
.ag-tablon-circle.state-done::before {
  opacity: 1;
  border-color: rgba(87, 204, 152, 0.55);  /* verde tenue — ok recientemente */
}
.ag-tablon-circle.state-archived::before {
  opacity: 1;
  border-color: rgba(120, 144, 156, 0.5);  /* gris archivado */
}

@keyframes tablonRingPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(87, 204, 152, 0.45); }
  50%      { box-shadow: 0 0 0 10px rgba(87, 204, 152, 0); }
}
@keyframes tablonRingShake {
  0%, 100% { transform: translate(0, 0); }
  25%      { transform: translate(-2px, 0); }
  75%      { transform: translate(2px, 0); }
}
.ag-tablon-circle .ag-tc-icon {
  width: 32px;
  height: 32px;
  opacity: 0.95;
  flex-shrink: 0;
}
.ag-tablon-circle.subagent .ag-tc-icon {
  width: 22px;
  height: 22px;
}
.ag-tablon-circle .ag-tc-title {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  max-width: 132px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.ag-tablon-circle.subagent .ag-tc-title {
  font-size: 10px;
  -webkit-line-clamp: 2;
  max-width: 90px;
}
.ag-tablon-circle .ag-tc-preview {
  font-size: 9px;
  font-weight: 500;
  opacity: 0.78;
  line-height: 1.2;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ag-tablon-circle.subagent .ag-tc-preview { display: none; }

/* Badge de estado (esquina superior derecha del círculo) */
.ag-tc-status {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.2);
}
.ag-tc-status i { width: 12px; height: 12px; }
.ag-tc-status.idle { display: none; }
.ag-tc-status.streaming { background: rgba(87, 204, 152, 0.85); animation: tablonStatusPulse 1.2s ease-in-out infinite; }
.ag-tc-status.waiting-user { background: #fbbf24; animation: tablonBellShake 1s ease-in-out infinite; }
.ag-tc-status.completed { background: #57cc98; }
.ag-tc-status.error { background: #ef4444; }
@keyframes tablonStatusPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(87, 204, 152, 0.7); }
  50% { box-shadow: 0 0 0 6px rgba(87, 204, 152, 0); }
}
@keyframes tablonBellShake {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}

/* Estado generando: borde pulsante en TODO el círculo */
.ag-tablon-circle.streaming {
  animation: tablonCirclePulse 1.4s ease-in-out infinite;
}
@keyframes tablonCirclePulse {
  0%, 100% {
    box-shadow:
      0 10px 28px rgba(0, 0, 0, 0.45),
      0 0 0 0 rgba(87, 204, 152, 0.5),
      inset 0 -8px 20px rgba(0, 0, 0, 0.18);
  }
  50% {
    box-shadow:
      0 10px 28px rgba(0, 0, 0, 0.45),
      0 0 0 12px rgba(87, 204, 152, 0),
      inset 0 -8px 20px rgba(0, 0, 0, 0.18);
  }
}

/* Sesiones archivadas */
.ag-tablon-circle.archived {
  opacity: 0.45;
  filter: grayscale(0.6);
}

/* Tooltip de hover (preview de mensajes) */
.ag-tablon-tooltip {
  position: absolute;
  z-index: 1500;
  width: 320px;
  max-width: 90vw;
  padding: 12px 14px;
  background: var(--card-bg, #162330);
  border: 1px solid var(--accent-dim, #3fa37a);
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  color: var(--text, #e8eef5);
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
}
.ag-tablon-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
.ag-tablon-tooltip .tt-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text, #e8eef5);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ag-tablon-tooltip .tt-meta {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim, #94a8be);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ag-tablon-tooltip .tt-meta .pill {
  background: rgba(87, 204, 152, 0.15);
  color: var(--accent, #57cc98);
  padding: 1px 6px;
  border-radius: 8px;
}
.ag-tablon-tooltip .tt-msgs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.ag-tablon-tooltip .tt-msg {
  padding: 6px 8px;
  background: rgba(15, 25, 35, 0.6);
  border-left: 2px solid var(--accent-dim, #3fa37a);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-dim, #94a8be);
  max-height: 60px;
  overflow: hidden;
}
.ag-tablon-tooltip .tt-msg .role {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent, #57cc98);
  margin-bottom: 2px;
}
.ag-tablon-tooltip .tt-msg.user .role { color: #fbbf24; }
.ag-tablon-tooltip .tt-cta {
  font-size: 10px;
  text-align: center;
  color: var(--accent, #57cc98);
  font-weight: 600;
  margin-top: 4px;
}

/* Toolbar flotante del tablón (zoom controls) */
.ag-tablon-toolbar {
  position: fixed;          /* fixed para poder desplazarla con CSS variable */
  bottom: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: var(--card-bg, #162330);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 8px;
  transition: right 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 200;
}
.ag-tablon-tool-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-dim, #94a8be);
  border-radius: 4px;
  cursor: pointer;
}
.ag-tablon-tool-btn:hover {
  background: rgba(87, 204, 152, 0.12);
  color: var(--accent, #57cc98);
}
.ag-tablon-zoom-display {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim, #94a8be);
  min-width: 38px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
/* Cuando el drawer del tablón está abierto, desplazar la toolbar a la izquierda
   para que no quede tapada. La var --ag-drawer-width la setea el JS. */
body.ag-drawer-open .ag-tablon-toolbar {
  right: calc(var(--ag-drawer-width, 480px) + 14px);
}
/* También el minimap debe correrse */
body.ag-drawer-open .ag-tablon-minimap {
  right: calc(var(--ag-drawer-width, 480px) + 12px);
}

/* Minimap del tablón (post Deep Research workflows: minimap esquina + toggle) */
.ag-tablon-minimap {
  position: fixed;          /* fixed para que el shift por drawer-open funcione */
  top: 80px;
  right: 12px;
  z-index: 150;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: right 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.ag-tablon-minimap[hidden] { display: none; }

/* Command palette (Ctrl+K) */
.ag-cmd-palette {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
}
.ag-cmd-palette.open { display: flex; }
.ag-cmd-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 25, 35, 0.45);
  backdrop-filter: blur(2px);
}
.ag-cmd-box {
  position: relative;
  width: 560px;
  max-width: 92vw;
  background: var(--card-bg, #ffffff);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.30);
  overflow: hidden;
}
.ag-cmd-input {
  width: 100%;
  padding: 16px 18px;
  font-size: 15px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text, #1F1F1F);
  border-bottom: 1px solid var(--border, #E6E6E6);
}
.ag-cmd-input::placeholder { color: var(--text-muted, #6b8096); }
.ag-cmd-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px 0;
}
.ag-cmd-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted, #6b8096);
  font-size: 13px;
}
.ag-cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text, #1F1F1F);
}
.ag-cmd-item:hover, .ag-cmd-item.selected {
  background: var(--accent-light, #E8F8F0);
}
.ag-cmd-item.selected {
  border-left: 3px solid var(--accent, #57CC98);
  padding-left: 15px;
}
.ag-cmd-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex-shrink: 0;
}
.ag-cmd-title {
  flex: 1;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ag-cmd-meta {
  font-size: 11px;
  color: var(--text-muted, #6b8096);
  white-space: nowrap;
}
.ag-cmd-footer {
  display: flex;
  gap: 16px;
  padding: 8px 18px;
  background: var(--bg-3, #F5F5F5);
  border-top: 1px solid var(--border, #E6E6E6);
  font-size: 11px;
  color: var(--text-muted, #6b8096);
}
.ag-cmd-footer kbd {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  margin-right: 3px;
}

/* MCP modal */
.ag-mcp-section {
  margin: 18px 0;
  padding: 12px 14px;
  background: var(--bg-3, #1e2f3f);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 8px;
}
.ag-mcp-section h3 {
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim, #94a8be);
  margin: 0 0 10px;
  font-weight: 700;
}
.ag-mcp-empty {
  padding: 12px;
  color: var(--text-muted, #6b8096);
  font-size: 13px;
  text-align: center;
}
.ag-mcp-item, .ag-mcp-preset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card-bg, #162330);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 6px;
  margin-bottom: 8px;
}
.ag-mcp-info { flex: 1; min-width: 0; }
.ag-mcp-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #e8eef5);
}
.ag-mcp-meta {
  font-size: 11px;
  color: var(--text-muted, #6b8096);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ag-mcp-warn {
  font-size: 10px;
  color: #fbbf24;
  margin-top: 4px;
}
.ag-mcp-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ag-mcp-ok { color: var(--accent, #57cc98); font-size: 11px; font-weight: 600; }
.ag-mcp-fail { color: #ef4444; font-size: 11px; font-weight: 600; }
.ag-mcp-unknown { color: var(--text-muted, #6b8096); font-size: 11px; }
.ag-mcp-remove { padding: 4px 10px; font-size: 11px; }

/* Botón pill MCP */
.ag-btn-mcp {
  font-size: 12px;
  padding: 0 10px;
  height: 32px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.10);
  color: #6366f1;
  border: 1px solid rgba(99, 102, 241, 0.4);
}
.ag-btn-mcp:hover {
  background: rgba(99, 102, 241, 0.18);
  border-color: #6366f1;
}
/* Botón pill Skills */
.ag-btn-skills {
  font-size: 12px;
  padding: 0 10px;
  height: 32px;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.10);
  color: #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.4);
}
.ag-btn-skills:hover {
  background: rgba(168, 85, 247, 0.18);
  border-color: #a855f7;
}
/* Botón pill Demo (rosa fuerte para distinguir de Tour) */
.ag-btn-demo {
  font-size: 12px;
  padding: 0 10px;
  height: 32px;
  border-radius: 999px;
  background: rgba(236, 72, 153, 0.10);
  color: #ec4899;
  border: 1px solid rgba(236, 72, 153, 0.4);
}
.ag-btn-demo:hover {
  background: rgba(236, 72, 153, 0.18);
  border-color: #ec4899;
}
/* Botón pill Importar (cyan/azul para distinguir) */
.ag-btn-import {
  font-size: 12px;
  padding: 0 10px;
  height: 32px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.10);
  color: #0ea5e9;
  border: 1px solid rgba(14, 165, 233, 0.4);
}
.ag-btn-import:hover {
  background: rgba(14, 165, 233, 0.18);
  border-color: #0ea5e9;
}

/* Items del modal de importación */
.ag-import-item {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ag-import-item:hover {
  background: rgba(14, 165, 233, 0.06);
  border-color: rgba(14, 165, 233, 0.3);
}
.ag-import-item input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: #0ea5e9;
}
.ag-import-item-body { flex: 1; min-width: 0; }
.ag-import-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ag-import-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.ag-import-item-snippet {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Squircle marcado como demo activa (ring rosa pulsante para destacarlo
   sobre el ring verde de estado normal). Usa data-attribute en lugar de
   modificar el ring de estado existente. */
.ag-tablon-circle.tour-demo-active {
  outline: 3px solid #ec4899;
  outline-offset: 4px;
  animation: tourDemoActivePulse 1.6s ease-in-out infinite;
}
@keyframes tourDemoActivePulse {
  0%, 100% { outline-color: #ec4899; }
  50%      { outline-color: rgba(236, 72, 153, 0.4); }
}

/* Tabs Skills + Hooks */
.ag-sh-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border, #2a3f55);
  margin-bottom: 14px;
}
.ag-sh-tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim, #94a8be);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
}
.ag-sh-tab.active {
  color: var(--accent, #57cc98);
  border-bottom-color: var(--accent, #57cc98);
}
.ag-sh-pane[hidden] { display: none; }

.ag-sh-skill-editor {
  background: var(--bg-3, #1e2f3f);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 6px;
  padding: 12px;
  margin: 12px 0;
}
.ag-sh-edit, .ag-sh-delete { padding: 4px 10px; font-size: 11px; }
.ag-sh-delete:hover { color: #ef4444; border-color: #ef4444; }

.ag-sh-hook-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.ag-sh-hook-name {
  width: 150px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim, #94a8be);
  font-family: 'JetBrains Mono', monospace;
}
.ag-sh-hook-cmd {
  flex: 1;
  background: var(--bg, #0f1923);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 4px;
  padding: 5px 8px;
  color: var(--text, #e8eef5);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.ag-sh-hook-save { padding: 4px 10px; font-size: 11px; }

/* V3.1: Diff visual para tool_use Edit/Write */
.ag-diff {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11.5px;
  line-height: 1.45;
  background: var(--bg, #0f1923);
  border-radius: 6px;
  overflow: hidden;
}
.ag-diff-file {
  padding: 6px 10px;
  background: var(--bg-3, #1e2f3f);
  border-bottom: 1px solid var(--border, #2a3f55);
  color: var(--text-dim, #94a8be);
  font-size: 11px;
  font-weight: 600;
}
.ag-diff-newfile {
  background: rgba(87, 204, 152, 0.18);
  color: var(--accent, #57cc98);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ag-diff-body {
  max-height: 360px;
  overflow-y: auto;
}
.ag-diff-line {
  display: flex;
  white-space: pre;
}
.ag-diff-marker {
  width: 22px;
  flex-shrink: 0;
  text-align: center;
  color: var(--text-muted, #6b8096);
  font-weight: 700;
  user-select: none;
}
.ag-diff-text { flex: 1; padding-right: 8px; }
.ag-diff-line.add { background: rgba(46, 160, 67, 0.20); }
.ag-diff-line.add .ag-diff-marker { color: #2ea043; }
.ag-diff-line.add .ag-diff-text { color: #aaf2c4; }
.ag-diff-line.del { background: rgba(248, 81, 73, 0.18); }
.ag-diff-line.del .ag-diff-marker { color: #f85149; }
.ag-diff-line.del .ag-diff-text { color: #ffcdc7; text-decoration: line-through; opacity: 0.85; }
.ag-diff-line.ctx { color: var(--text-muted, #6b8096); }
.ag-tool-error-banner {
  background: rgba(239, 68, 68, 0.10);
  border-left: 3px solid #ef4444;
  color: #b91c1c;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 8px;
  font-family: 'JetBrains Mono', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
}
.ag-tool-detail-raw {
  background: var(--bg, #0f1923);
  padding: 8px 10px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-dim, #94a8be);
  margin: 0;
  max-height: 360px;
  overflow-y: auto;
}

/* Slash help modal table */
.ag-slash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ag-slash-table td {
  padding: 6px 8px;
  vertical-align: top;
  border-bottom: 1px solid var(--border, #2a3f55);
}
.ag-slash-table td:first-child {
  white-space: nowrap;
  width: 1%;
}
.ag-slash-table code {
  background: var(--accent-tint, rgba(87, 204, 152, 0.08));
  color: var(--accent, #57cc98);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  margin-right: 3px;
}

/* Drawer lateral (al hacer click en un círculo) */
/* V4: chip "+N" cuando un agente colapsa sus hijos */
.ag-tc-collapsed {
  position: absolute;
  bottom: -10px;
  right: -10px;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 14px;
  background: rgba(15, 25, 35, 0.85);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.ag-tablon-drawer {
  position: fixed;
  top: 60px;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 92vw;
  min-width: 360px;
  background: var(--card-bg, #162330);
  border-left: 1px solid var(--border, #2a3f55);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.5);
  z-index: 1800;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.ag-tablon-drawer.open { transform: translateX(0); }
/* V4: handle de resize en el borde izquierdo del drawer */
.ag-tablon-drawer-resize {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 5px;
  cursor: ew-resize;
  background: transparent;
  z-index: 5;
  transition: background 0.15s;
}
.ag-tablon-drawer-resize:hover {
  background: rgba(87, 204, 152, 0.4);
}
.ag-tablon-drawer-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  background: rgba(15, 25, 35, 0.7);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 50%;
  color: var(--text-dim, #94a8be);
  font-size: 16px;
  cursor: pointer;
  z-index: 10;
}
.ag-tablon-drawer-close:hover {
  color: #ef4444;
  border-color: #ef4444;
}
.ag-tablon-drawer-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Aquí se monta un AgentPanel reutilizado */
}

/* Hint discreto que muestra qué modelo eligió el auto-router */
.ag-auto-routing-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  margin: 4px 0 6px;
  padding: 3px 9px;
  background: rgba(87, 204, 152, 0.08);
  border: 1px solid rgba(87, 204, 152, 0.25);
  border-radius: 12px;
  color: var(--accent, #57cc98);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.ag-auto-routing-hint strong {
  color: var(--text, #e8eef5);
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

/* Badge de novedades de Claude (toolbar) */
.ag-updates-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.18), rgba(251, 191, 36, 0.06));
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 6px;
  color: #fbbf24;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  font-family: inherit;
  animation: agUpdatesPulse 2.4s ease-in-out infinite;
}
.ag-updates-badge:hover {
  background: rgba(251, 191, 36, 0.25);
  border-color: #fbbf24;
}
@keyframes agUpdatesPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.0); }
  50% { box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.15); }
}

.ag-updates-block {
  max-height: 50vh;
  overflow-y: auto;
  background: var(--bg, #0f1923);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.55;
  margin: 12px 0;
  color: var(--text, #e8eef5);
}
.ag-updates-block h3 {
  margin: 14px 0 8px;
  font-size: 14px;
  color: var(--accent, #57cc98);
}
.ag-updates-block a {
  color: var(--accent, #57cc98);
  text-decoration: underline;
}
.ag-updates-block blockquote {
  border-left: 3px solid var(--accent-dim, #3fa37a);
  margin: 6px 0;
  padding: 2px 10px;
  color: var(--text-dim, #94a8be);
  font-size: 12px;
}
.ag-panel-close {
  background: transparent;
  border: none;
  color: var(--text-muted, #6b8096);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
}
.ag-panel-close:hover { color: #ef4444; background: rgba(239,68,68,0.1); }

/* Subheader: working directory */
.ag-panel-wd {
  padding: 4px 10px;
  font-size: 10px;
  color: var(--text-muted, #6b8096);
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg, #0f1923);
  border-bottom: 1px solid var(--border, #2a3f55);
  display: flex;
  align-items: center;
  gap: 6px;
}
.ag-panel-wd.dangerous { color: #f59e0b; }

/* ─── Mensajes ──────────────────────────────────────────── */
.ag-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border, #2a3f55) transparent;
}
.ag-panel-messages::-webkit-scrollbar { width: 6px; }
.ag-panel-messages::-webkit-scrollbar-thumb { background: var(--border, #2a3f55); border-radius: 3px; }

.ag-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 100%;
}
.ag-msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--text-muted, #6b8096);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.ag-msg.user .ag-msg-header { color: #64b5f6; }
.ag-msg.assistant .ag-msg-header { color: var(--accent, #57cc98); }
.ag-msg.error .ag-msg-header { color: #ef4444; }

.ag-msg-body {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  word-wrap: break-word;
  color: var(--text, #e8eef5);
}
.ag-msg.user .ag-msg-body {
  background: rgba(100,181,246,0.08);
  border-left: 2px solid #64b5f6;
}
.ag-msg.assistant .ag-msg-body {
  background: rgba(87,204,152,0.06);
  border-left: 2px solid var(--accent, #57cc98);
}
.ag-msg.error .ag-msg-body {
  background: rgba(239,68,68,0.08);
  border-left: 2px solid #ef4444;
  color: #ef4444;
}
.ag-msg.streaming .ag-msg-body::after {
  content: '▊';
  animation: agBlink 1s infinite;
  color: var(--accent, #57cc98);
}

/* Acciones por mensaje (assistant): copy / retry — visibles en hover */
.ag-msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 160ms cubic-bezier(.2,.8,.2,1), transform 160ms cubic-bezier(.2,.8,.2,1);
}
.ag-msg.assistant:hover .ag-msg-actions,
.ag-msg.assistant:focus-within .ag-msg-actions {
  opacity: 1;
  transform: translateY(0);
}
.ag-msg-action {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border, #2a3f55);
  background: rgba(15, 25, 35, 0.6);
  color: var(--text-muted, #6b8096);
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.ag-msg-action:hover {
  background: rgba(87, 204, 152, 0.15);
  color: var(--accent, #57cc98);
  border-color: rgba(87, 204, 152, 0.4);
}
@keyframes agBlink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.ag-msg-body p { margin: 0 0 6px; }
.ag-msg-body p:last-child { margin-bottom: 0; }
.ag-msg-body code {
  background: rgba(0,0,0,0.3); padding: 1px 4px;
  border-radius: 3px; font-size: 11px; font-family: 'JetBrains Mono', monospace;
}
.ag-msg-body pre {
  background: rgba(0,0,0,0.35); padding: 8px 10px;
  border-radius: 5px; overflow-x: auto; margin: 4px 0; font-size: 11px;
}
.ag-msg-body pre code { background: transparent; padding: 0; }
.ag-msg-body ul, .ag-msg-body ol { margin: 3px 0 6px 18px; }
.ag-msg-body strong { color: var(--text, #e8eef5); font-weight: 600; }
.ag-msg-body a { color: var(--accent, #57cc98); text-decoration: underline; }

/* ─── Tool uses ─────────────────────────────────────────── */
.ag-tool {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px;
  background: var(--bg-3, #1e2f3f);
  border-left: 2px solid;
  border-radius: 0 5px 5px 0;
  font-size: 11px;
  margin-left: 8px;
}
.ag-tool.success { border-left-color: var(--accent, #57cc98); }
.ag-tool.error { border-left-color: #ef4444; }
.ag-tool.pending { border-left-color: var(--warning, #f59e0b); }
.ag-tool.denied { border-left-color: #ef4444; background: rgba(239,68,68,0.05); }

.ag-tool-head {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.ag-tool-icon {
  width: 18px; height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  background: var(--bg, #0f1923);
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.ag-tool-icon.bash { color: #f59e0b; }
.ag-tool-icon.read { color: #64b5f6; }
.ag-tool-icon.write { color: var(--accent, #57cc98); }
.ag-tool-icon.edit { color: var(--accent, #57cc98); }
.ag-tool-icon.grep, .ag-tool-icon.glob { color: #c084fc; }
.ag-tool-icon.web { color: #06b6d4; }
.ag-tool-icon.task { color: #ec4899; }
.ag-tool-icon.todo { color: #fbbf24; }
.ag-tool-icon.skill { color: #a78bfa; }
.ag-tool-icon.other { color: var(--text-dim, #94a8be); }

.ag-tool-name { font-weight: 600; color: var(--text, #e8eef5); }
.ag-tool-summary { color: var(--text-dim, #94a8be); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-tool-status {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}
.ag-tool-status.success { background: rgba(87,204,152,0.15); color: var(--accent, #57cc98); }
.ag-tool-status.error { background: rgba(239,68,68,0.15); color: #ef4444; }
.ag-tool-status.pending { background: rgba(245,158,11,0.15); color: var(--warning, #f59e0b); }
.ag-tool-status.denied { background: rgba(239,68,68,0.2); color: #ef4444; }

.ag-tool-detail {
  display: none;
  margin-top: 4px;
  padding: 6px 8px;
  background: var(--bg, #0f1923);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  color: var(--text-dim, #94a8be);
}
.ag-tool.expanded .ag-tool-detail { display: block; }

/* ─── Attachments (chips + botón + dropzone) ──────────────── */
.ag-attach-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg-3, #1e2f3f);
  border-top: 1px solid var(--border, #2a3f55);
  max-height: 110px;
  overflow-y: auto;
}
.ag-attach-list[hidden] { display: none; }

.ag-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 8px;
  background: var(--card-bg, #162330);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 14px;
  font-size: 11px;
  color: var(--text, #e8eef5);
  max-width: 220px;
}
.ag-attach-chip-icon {
  font-size: 11px;
  line-height: 1;
  flex-shrink: 0;
  filter: saturate(0.85);
}
.ag-attach-chip-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.ag-attach-chip-size {
  font-size: 10px;
  color: var(--text-muted, #6b8096);
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
}
.ag-attach-chip-remove {
  background: transparent;
  border: none;
  color: var(--text-muted, #6b8096);
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
  line-height: 1;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}
.ag-attach-chip-remove:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

.ag-attach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: var(--bg, #0f1923);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 5px;
  color: var(--text-dim, #94a8be);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}
.ag-attach-btn:hover {
  color: var(--accent, #57cc98);
  border-color: var(--accent, #57cc98);
}

/* Overlay de dropzone (oculto por defecto, visible cuando se arrastran files) */
.ag-attach-dropzone-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(15, 25, 35, 0.85);
  z-index: 10;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.ag-attach-dropzone-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 30px;
  border: 2px dashed var(--accent, #57cc98);
  border-radius: 10px;
  color: var(--accent, #57cc98);
  font-size: 13px;
  font-weight: 600;
  background: rgba(87, 204, 152, 0.06);
}
.ag-panel.ag-attach-dropzone-active .ag-attach-dropzone-overlay {
  display: flex;
}

/* ─── Input ──────────────────────────────────────────────── */
.ag-panel-input {
  display: flex;
  gap: 6px;
  padding: 8px;
  background: var(--bg-3, #1e2f3f);
  border-top: 1px solid var(--border, #2a3f55);
  flex-shrink: 0;
  align-items: flex-end;
}
.ag-panel-textarea {
  flex: 1;
  background: var(--bg, #0f1923);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 5px;
  color: var(--text, #e8eef5);
  font-size: 12px;
  font-family: inherit;
  padding: 6px 8px;
  resize: none;
  min-height: 32px;
  max-height: 150px;
  line-height: 1.4;
}
.ag-panel-textarea:focus {
  outline: none;
  border-color: var(--accent, #57cc98);
}

.ag-send-btn, .ag-cancel-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
}
.ag-send-btn { background: var(--accent, #57cc98); color: #0f1923; }
.ag-send-btn:hover { opacity: 0.9; }
.ag-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
/* Stop state: send se transforma en Stop durante streaming.
   Mismo estilo gradient sutil que Tour pero en rojo (acción destructiva). */
.ag-send-btn.streaming {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.18) 0%, rgba(239, 68, 68, 0.08) 100%);
  border: 1px solid rgba(239, 68, 68, 0.6);
  color: #ef4444;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.ag-send-btn.streaming:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
}
.ag-send-btn.streaming:disabled {
  opacity: 1;
  cursor: pointer;
}
.ag-cancel-btn { background: transparent; color: #ef4444; border: 1px solid #ef4444; }

/* ─── Footer ────────────────────────────────────────────── */
.ag-panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  background: var(--bg, #0f1923);
  border-top: 1px solid var(--border, #2a3f55);
  font-size: 10px;
  color: var(--text-muted, #6b8096);
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

/* ─── Empty state ────────────────────────────────────────── */
.ag-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted, #6b8096);
  gap: 14px;
  padding: 20px;
  text-align: center;
}
.ag-empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dim, #94a8be);
}
.ag-empty-desc { font-size: 13px; max-width: 480px; line-height: 1.5; }

/* ─── Modal nueva sesión ─────────────────────────────────── */
.ag-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,25,35,0.85);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.ag-overlay.open { display: flex; }
.ag-modal {
  width: 540px;
  max-width: 92%;
  background: var(--card-bg, #162330);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 10px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ag-modal h2 { font-size: 18px; font-weight: 600; margin: 0; }
.ag-field { display: flex; flex-direction: column; gap: 5px; }
.ag-field label { font-size: 12px; color: var(--text-muted, #6b8096); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.ag-field input, .ag-field select, .ag-field textarea {
  padding: 8px 10px;
  background: var(--bg, #0f1923);
  border: 1px solid var(--border, #2a3f55);
  border-radius: 5px;
  color: var(--text, #e8eef5);
  font-size: 13px;
  font-family: inherit;
}
.ag-field textarea { resize: vertical; min-height: 60px; }
.ag-field-hint { font-size: 11px; color: var(--text-muted, #6b8096); margin-top: 2px; }
.ag-field-hint.danger { color: #f59e0b; }

.ag-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ─── Toast ──────────────────────────────────────────────── */
.ag-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 18px;
  background: var(--card-bg, #162330);
  border: 1px solid var(--border, #2a3f55);
  border-left: 3px solid var(--accent, #57cc98);
  border-radius: 8px;
  color: var(--text, #e8eef5);
  font-size: 13px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  z-index: 2000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.2s;
  max-width: 360px;
}
.ag-toast.show { opacity: 1; transform: translateY(0); }
.ag-toast.error { border-left-color: #ef4444; }
.ag-toast.warning { border-left-color: #f59e0b; }

/* Responsive */
@media (max-width: 900px) {
  .ag-grid.layout-grid2 {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 600px) {
  .ag-grid.layout-grid2 { grid-template-rows: 1fr; }
  .ag-panel:not(.focused) { display: none; }
}

/* ════════════════════════════════════════════════════════════════
   SLASH COMMANDS — popover de autocomplete + modales
   Replica visual del CLI de Claude Code (paleta dark coherente).
   ════════════════════════════════════════════════════════════════ */

/* ─── Popover de autocomplete ──────────────────────────────────── */
.ag-slash-popover {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 8px;
  right: 8px;
  max-height: 360px;
  overflow-y: auto;
  background: #0f1923;
  border: 1px solid #2a3f55;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
  z-index: 50;
  padding: 4px;
  scrollbar-width: thin;
  scrollbar-color: #2a3f55 transparent;
}
.ag-slash-popover::-webkit-scrollbar { width: 6px; }
.ag-slash-popover::-webkit-scrollbar-thumb { background: #2a3f55; border-radius: 3px; }

.ag-slash-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.08s;
}
.ag-slash-item:hover,
.ag-slash-item.selected {
  background: linear-gradient(90deg, rgba(87,204,152,0.12), rgba(87,204,152,0.04));
  outline: 1px solid rgba(87,204,152,0.35);
}
.ag-slash-icon {
  width: 16px;
  height: 16px;
  color: #94a8be;
  justify-self: center;
}
.ag-slash-item.selected .ag-slash-icon { color: #57cc98; }
.ag-slash-body { min-width: 0; }
.ag-slash-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: #e8eef5;
  font-weight: 600;
}
.ag-slash-arghint {
  font-weight: 400;
  color: #6b8096;
  font-size: 11px;
  font-style: italic;
}
.ag-slash-desc {
  font-size: 11.5px;
  color: #94a8be;
  margin-top: 2px;
  line-height: 1.35;
}
.ag-slash-cat {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #6b8096;
  background: rgba(255,255,255,0.04);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ─── Chip visual de feedback efímero ──────────────────────────── */
.ag-slash-chip-host {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  z-index: 60;
}
.ag-slash-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(87,204,152,0.16);
  border: 1px solid rgba(87,204,152,0.45);
  color: #b0eccd;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.ag-slash-chip.fade-out {
  opacity: 0;
  transform: translateY(-6px);
}

/* ─── Modal genérico para slash commands ───────────────────────── */
.ag-slash-modal {
  width: auto;
  max-width: 720px;
}
.ag-slash-modal h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ag-slash-modal h2 i { width: 18px; height: 18px; }
.ag-modal-sub {
  font-weight: 400;
  font-size: 12px;
  color: #6b8096;
  margin-left: 6px;
}

/* ─── /context grid ────────────────────────────────────────────── */
.ag-context-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.ag-context-card {
  background: #0f1923;
  border: 1px solid #2a3f55;
  border-radius: 8px;
  padding: 12px 14px;
}
.ag-context-card.span2 { grid-column: 1 / -1; }
.ag-context-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #6b8096;
  margin-bottom: 6px;
}
.ag-context-value {
  font-size: 18px;
  font-weight: 600;
  color: #e8eef5;
}
.ag-context-bar {
  margin-top: 8px;
  height: 8px;
  background: #1a2735;
  border-radius: 4px;
  overflow: hidden;
}
.ag-context-bar-fill {
  height: 100%;
  background: #57cc98;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.ag-context-sub {
  margin-top: 6px;
  font-size: 11px;
  color: #94a8be;
}
.ag-context-suggestions {
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(87,204,152,0.06);
  border: 1px solid rgba(87,204,152,0.25);
  border-radius: 8px;
}
.ag-context-sug-title {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  color: #b0eccd;
}
.ag-context-sug-title i { width: 14px; height: 14px; }
.ag-context-suggestions ul { margin: 0; padding-left: 22px; }
.ag-context-suggestions li {
  font-size: 12px;
  color: #cfdaeb;
  margin-bottom: 4px;
  line-height: 1.4;
}

/* ─── /diff modal ──────────────────────────────────────────────── */
.ag-diff-modal-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  margin-top: 10px;
}
.ag-diff-files {
  background: #0f1923;
  border: 1px solid #2a3f55;
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 480px;
  overflow-y: auto;
}
.ag-diff-files-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #6b8096;
  margin-bottom: 8px;
}
.ag-diff-files-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ag-diff-files-list li {
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: #cfdaeb;
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ag-diff-files-list .ag-diff-flag {
  display: inline-block;
  min-width: 24px;
  font-weight: 700;
  color: #f59e0b;
  font-size: 10.5px;
  text-align: center;
}
.ag-diff-files-list .ag-diff-empty { color: #6b8096; font-style: italic; }
.ag-diff-text {
  background: #0f1923;
  border: 1px solid #2a3f55;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  line-height: 1.45;
  color: #cfdaeb;
  max-height: 480px;
  overflow: auto;
  white-space: pre;
  margin: 0;
}
.ag-diff-text .da { color: #5cd093; background: rgba(87,204,152,0.06); }
.ag-diff-text .dr { color: #ef6b6b; background: rgba(239,107,107,0.06); }
.ag-diff-text .dh { color: #94a8be; font-weight: 600; }

/* ─── /permissions modal ───────────────────────────────────────── */
.ag-perm-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 380px;
  overflow-y: auto;
}
.ag-perm-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  background: #0f1923;
  border: 1px solid #2a3f55;
  border-radius: 6px;
}
.ag-perm-name {
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  color: #e8eef5;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ag-perm-cat {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #6b8096;
  background: rgba(255,255,255,0.04);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-weight: 500;
}
.ag-perm-desc {
  font-size: 11px;
  color: #94a8be;
  margin-top: 3px;
}
.ag-perm-toggle {
  display: flex;
  gap: 0;
  background: #1a2735;
  border-radius: 6px;
  padding: 2px;
}
.ag-perm-opt {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  padding: 4px 10px;
  font-size: 11.5px;
  color: #94a8be;
  border-radius: 4px;
  transition: all 0.1s;
}
.ag-perm-opt input[type=radio] {
  display: none;
}
.ag-perm-opt:has(input:checked) {
  background: #2a3f55;
  color: #e8eef5;
}
.ag-perm-opt:has(input[value=allow]:checked) {
  color: #5cd093;
}
.ag-perm-opt:has(input[value=deny]:checked) {
  color: #ef6b6b;
}

/* ─── /skills modal ────────────────────────────────────────────── */
.ag-skill-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 480px;
  overflow-y: auto;
}
.ag-skill-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: #0f1923;
  border: 1px solid #2a3f55;
  border-radius: 8px;
}
.ag-skill-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(87,204,152,0.1);
  border-radius: 8px;
  color: #57cc98;
}
.ag-skill-icon i { width: 16px; height: 16px; }
.ag-skill-name {
  font-size: 13px;
  color: #e8eef5;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ag-skill-scope {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.ag-skill-scope.local {
  color: #57cc98;
  background: rgba(87,204,152,0.12);
  border: 1px solid rgba(87,204,152,0.3);
}
.ag-skill-scope.user {
  color: #94a8be;
  background: rgba(148,168,190,0.08);
  border: 1px solid rgba(148,168,190,0.2);
}
.ag-skill-desc {
  font-size: 12px;
  color: #cfdaeb;
  margin-top: 3px;
  line-height: 1.4;
}
.ag-skill-meta {
  font-size: 10.5px;
  color: #6b8096;
  font-family: 'JetBrains Mono', monospace;
  margin-top: 4px;
}
.ag-skill-actions {
  display: flex;
  gap: 4px;
}

/* ─── Slash help table ─────────────────────────────────────────── */
.ag-slash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.ag-slash-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #2a3f55;
  vertical-align: top;
}
.ag-slash-table td:first-child {
  white-space: nowrap;
  color: #94a8be;
  font-family: 'JetBrains Mono', monospace;
}
.ag-slash-table td:last-child {
  color: #cfdaeb;
}

/* ============================================================
   CLI Parity badge (toolbar) — verde / ámbar / rojo / gris
   ============================================================ */
.ag-parity-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  color: #cfdaeb;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease;
}
.ag-parity-badge:hover { background: rgba(255, 255, 255, 0.08); }
.ag-parity-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #6c7d92;
}
.ag-parity-badge.ok        { color: #57CC98; border-color: rgba(87, 204, 152, 0.35); }
.ag-parity-badge.ok .ag-parity-dot        { background: #57CC98; }
.ag-parity-badge.minor_gap { color: #F0B543; border-color: rgba(240, 181, 67, 0.45); }
.ag-parity-badge.minor_gap .ag-parity-dot { background: #F0B543; }
.ag-parity-badge.major_gap { color: #E5484D; border-color: rgba(229, 72, 77, 0.45); }
.ag-parity-badge.major_gap .ag-parity-dot { background: #E5484D; animation: ag-parity-pulse 1.6s ease-in-out infinite; }
.ag-parity-badge.unknown   { color: #94a8be; border-color: rgba(148, 168, 190, 0.25); }
@keyframes ag-parity-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
@keyframes ag-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Modal de paridad */
.ag-parity-modal { max-width: 720px; }
.ag-parity-versions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}
.ag-parity-vbox {
  border: 1px solid #2a3f55;
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
}
.ag-parity-vbox h4 {
  margin: 0 0 4px 0;
  font-size: 11px;
  color: #94a8be;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ag-parity-vbox .v-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  color: #e5edf7;
}
.ag-parity-features {
  margin-top: 10px;
  border: 1px solid #2a3f55;
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.18);
  max-height: 220px;
  overflow-y: auto;
  font-size: 12.5px;
}
.ag-parity-features h4 {
  margin: 0 0 6px 0;
  font-size: 11.5px;
  color: #cfdaeb;
}
.ag-parity-features ul { margin: 0; padding-left: 18px; }
.ag-parity-features li { margin: 2px 0; color: #cfdaeb; }
.ag-parity-changelog {
  margin-top: 10px;
  border: 1px solid #2a3f55;
  border-radius: 8px;
  padding: 10px 12px;
  background: #0e1726;
  max-height: 220px;
  overflow: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: #b9c8db;
  white-space: pre-wrap;
  word-break: break-word;
}
