/* ============================================================================
   Centella Agent — Capa de overrides estilo Miro / Claude
   ============================================================================
   Este archivo se carga DESPUÉS de agent.css para rediseñar todo el módulo
   con paleta clara, "floating surfaces", sombras suaves y tipografía Noto Sans.

   Mantenemos toda la estructura HTML/JS intacta — solo cambiamos colores,
   bordes, sombras, padding, tipografía. No rompe el módulo, solo lo afina.

   Inspirado en Mirotone (design system de Miro) y claude.ai.
   ============================================================================ */

/* ─── Tokens Miro ────────────────────────────────────────────── */
.ag-root,
#ag-new-overlay,
.ag-overlay,
.ag-toast,
.ag-tablon-drawer,
.ag-tablon-tooltip {
  --text: #1F1F1F;
  --text-strong: #050038;
  --text-dim: #4A4A4A;
  --text-muted: #696580;
  --text-subtle: #9B97B0;
  --bg: #FFFFFF;
  --bg-3: #F5F5F5;
  --bg-canvas: #FAFAFA;
  --card-bg: #FFFFFF;
  --border: #E6E6E6;
  --border-strong: rgba(0, 0, 0, 0.16);
  /* Verde Centella es el brand color del programa, NO azul */
  --accent: #57CC98;
  --accent-dim: #3FA37A;
  --accent-light: #E8F8F0;
  --accent-tint: rgba(87, 204, 152, 0.08);
  --danger: #F24726;
  --warning: #F59F00;
  --success: #2D7B5C;
  --shadow-pill: 0 8px 24px rgba(0, 0, 0, 0.10);
  --shadow-menu: 0 10px 30px rgba(0, 0, 0, 0.14);
  --shadow-tooltip: 0 6px 18px rgba(0, 0, 0, 0.18);
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.06);
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 100px;
  font-family: 'Noto Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Tipografía global del módulo */
.ag-root,
.ag-root * {
  font-family: inherit;
}

/* ─── ROMPER ENCAPSULACIÓN del <main class="main"> ──────────────
   El base.html mete todo el contenido en <main class="main"> que tiene
   padding 32px 40px. Para el módulo agent queremos que el tablón sea full
   bleed (de un borde a otro de la ventana), así que comemos ese padding
   con margin negativo + ajustamos altura/ancho. */
main.main:has(> .ag-root) {
  /* Tras el refactor del layout viewport-fit (style.css 20260505c) el body
     ya no scrollea y .main tiene height:100% del viewport. .ag-root se
     posiciona fixed (top:60px) — solo necesitamos limpiar paddings y
     overflows residuales. */
  padding: 0 !important;
  margin-top: 0 !important;
  height: 100% !important;
  overflow: hidden !important;
}

/* ─── Root container — TODO ES UN TABLÓN ───────────────────────── */
.ag-root {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  padding: 0;
  gap: 0;
  margin: 0;
  overflow: hidden;
  /* Tablón gris sólido (mismo color que el módulo /tableros: #F5F5F5),
     sin patrón de puntos */
  background-color: #F5F5F5;
  background-image: none;
}

/* Body wrapper: ahora "transparente" al layout, sus hijos flotan en .ag-root */
.ag-body {
  display: contents;
}

/* ─── TOOLBAR — wrapper lógico transparente ─────────────────────
   Estilo Miro: en lugar de un header gigante, dividimos en 3 pills
   pequeñas independientes. .ag-toolbar usa display:contents para
   que sus hijos (.ag-pill-*) se posicionen como si fueran hijos
   directos del .ag-root. */
.ag-toolbar {
  display: contents;
}

/* ─── PILLS flotantes (pequeñas, redondeadas, sutiles) ──────── */
.ag-pill {
  position: absolute;
  top: 12px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  background: var(--card-bg);
  border-radius: 999px;          /* fully rounded — pill */
  box-shadow: var(--shadow-pill);
  border: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
}

/* Pill 1: identidad (top-left) */
.ag-pill-identity {
  left: 12px;
  padding: 0 14px 0 14px;
  font-weight: 600;
  color: var(--ink);
}
.ag-pill-identity .ag-pill-icon {
  width: 16px;
  height: 16px;
  color: var(--accent);
  flex-shrink: 0;
}
.ag-pill-identity .ag-pill-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.ag-pill-identity .ag-status-pill {
  margin-left: 4px;
  font-size: 10px;
  padding: 2px 8px;
}

/* Pill 2: acciones (top-right) — antes había una pill central de layouts
   pero el módulo solo usa el Tablón ahora, así que la pill central se
   eliminó.
   Se desplaza a la izquierda cuando el drawer del tablón está abierto
   para no quedar tapado por él. */
.ag-pill-actions {
  right: 12px;
  padding: 4px 4px 4px 8px;
  gap: 4px;
  transition: right 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
body.ag-drawer-open .ag-pill-actions {
  right: calc(var(--ag-drawer-width, 480px) + 12px);
}
.ag-pill-actions .ag-btn {
  height: 36px;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 13px;
}

/* Mobile: las pills se mantienen arriba pero más compactas */
@media (max-width: 900px) {
  .ag-pill-identity { left: 12px; }
  .ag-pill-actions { right: 12px; }
  .ag-pill-identity .ag-pill-title { font-size: 12px; }
}
.ag-toolbar h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.ag-toolbar h1 i {
  color: var(--accent);
}

/* Status pill — más sutil */
.ag-status-pill {
  font-size: 11px;
  padding: 4px 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: var(--r-pill);
}
.ag-status-pill.ok {
  background: #E5F5EE;
  color: var(--success);
  border: 1px solid transparent;
}
.ag-status-pill.bad {
  background: #FDECE7;
  color: var(--danger);
  border: 1px solid transparent;
}
.ag-status-pill::before { opacity: 0.7; }

/* Toggle de layouts (segmented control estilo Miro) */
.ag-mode-toggle {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 0;
  overflow: hidden;
}
.ag-mode-toggle button {
  padding: 6px 14px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  border-radius: var(--r-sm);
  transition: all 120ms ease-out;
}
.ag-mode-toggle button:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}
.ag-mode-toggle button.active {
  background: var(--card-bg);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-soft);
}

/* Botones generales */
.ag-btn {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 14px;
  font-weight: 500;
  transition: all 120ms ease-out;
}
.ag-btn:hover {
  background: var(--bg-3);
  border-color: var(--border-strong);
  color: var(--text);
}
.ag-btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 600;
}
.ag-btn.primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: white;
}

/* ─── SIDEBAR (panel oscuro pegado al borde izquierdo) ────────────────
   Mismo lenguaje visual que el drawer del chat: contenedor flush al
   borde de la pantalla (sin gap), tema oscuro, redimensionable. */
.ag-sidebar {
  position: fixed;          /* fixed para ignorar el padding del main */
  top: 60px;                 /* debajo de la barra global del 60px */
  left: 0;
  bottom: 0;
  width: var(--ag-sidebar-width, 260px);
  min-width: 200px;
  max-width: 480px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  /* Tema oscuro propio (override del miro light por scope ↓) */
  background: #0F1923;
  border: none;
  border-right: 1px solid #1F2D3D;
  border-radius: 0;
  box-shadow: 6px 0 18px rgba(0, 0, 0, 0.18);
  overflow: visible;         /* para que el handle de resize no se corte */
}
/* Tablón viewport: dejar hueco a la izquierda para que la sidebar no lo tape */
.ag-tablon {
  margin-left: var(--ag-sidebar-width, 260px);
  width: calc(100% - var(--ag-sidebar-width, 260px));
}
/* Pills: empujarlas a la derecha del sidebar para que no las tape */
.ag-pill-identity {
  left: calc(var(--ag-sidebar-width, 260px) + 12px) !important;
}
/* Empty state del tablón centrado en el área visible (no detrás del sidebar) */
.ag-tablon-empty {
  /* ya tiene transform translate(-50%, -50%) — la cámara del tablón ya está
     dentro del .ag-tablon que tiene margin-left, así que se centra solo */
}
/* ─── Tema OSCURO scopeado al sidebar ─── */
.ag-sidebar {
  --text: #E8EEF5;
  --text-dim: #94A8BE;
  --text-muted: #6B8096;
  --text-subtle: #5A6B7E;
  --bg: #0F1923;
  --bg-3: #1B2A3A;
  --card-bg: #162330;
  --border: #1F2D3D;
  --border-strong: #2A3F55;
  --accent: #57CC98;
  --accent-light: rgba(87, 204, 152, 0.15);
  --accent-tint: rgba(87, 204, 152, 0.08);
  color: var(--text);
}
/* Tab "Proyectos": agrupación de sesiones por proyecto, header collapsable */
.ag-sidebar-project-group {
  margin-bottom: 12px;
}
.ag-sidebar-project-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--proj-color, #57CC98) 18%, transparent) 0%,
    transparent 100%
  );
  border-left: 3px solid var(--proj-color, #57CC98);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.ag-sidebar-project-header:hover {
  background: color-mix(in srgb, var(--proj-color, #57CC98) 12%, transparent);
}
.ag-sidebar-project-name {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.ag-sidebar-project-stats {
  display: flex;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 600;
}
.ag-sidebar-project-stat {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 999px;
}
.ag-sidebar-project-stat.stale {
  background: rgba(245, 159, 0, 0.2);
  color: #F0B842;
}
.ag-sidebar-project-stat.pinned {
  background: rgba(87, 204, 152, 0.2);
  color: #7ED9B0;
}
.ag-sidebar-project-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
}
.ag-sidebar-project-children {
  padding-left: 6px;
  margin-top: 4px;
}
.ag-sidebar-project-group.collapsed .ag-sidebar-project-children {
  display: none;
}
.ag-sidebar-project-empty {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-subtle);
  font-style: italic;
}
/* Handle de resize (clavado al borde derecho del sidebar) */
.ag-sidebar-resize {
  position: absolute;
  top: 0;
  right: -3px;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
  background: transparent;
  z-index: 5;
  transition: background 0.15s;
}
.ag-sidebar-resize:hover,
.ag-sidebar-resize.dragging {
  background: rgba(87, 204, 152, 0.4);
}
/* Linea sutil de estado del CLI (sustituye a la antigua pill flotante).
   Vive en la parte superior del sidebar, no ocupa apenas. */
.ag-sidebar-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  flex-shrink: 0;
}
.ag-sidebar-meta-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #57CC98;
  box-shadow: 0 0 6px rgba(87, 204, 152, 0.6);
  flex-shrink: 0;
}
.ag-sidebar-meta-dot.bad {
  background: #F24726;
  box-shadow: 0 0 6px rgba(242, 71, 38, 0.6);
}
.ag-sidebar-meta-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Botón "Nueva sesión" en el TOP del sidebar */
.ag-sidebar-new-top {
  margin: 4px 10px 8px;
  padding: 9px 12px;
  background: #57CC98;
  color: #0F1923;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.12s;
  flex-shrink: 0;
}
.ag-sidebar-new-top:hover {
  background: #6EE0AB;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(87, 204, 152, 0.3);
}
.ag-sidebar-header {
  background: transparent;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 4px 14px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ag-sidebar-count {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
/* Tabs (Anclados / Otros) */
.ag-sidebar-tabs {
  display: flex;
  padding: 8px 8px 0;
  gap: 4px;
  flex-shrink: 0;
}
.ag-sidebar-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 10px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 7px 7px 0 0;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  border-bottom: 2px solid transparent;
}
.ag-sidebar-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}
.ag-sidebar-tab.active {
  color: #7ED9B0;
  border-bottom-color: #57CC98;
  background: rgba(87, 204, 152, 0.08);
}
.ag-tab-count {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}
.ag-sidebar-tab.active .ag-tab-count {
  background: rgba(87, 204, 152, 0.2);
  color: #7ED9B0;
}
.ag-sidebar-list {
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  border-top: 1px solid var(--border);
}
.ag-sidebar-list::-webkit-scrollbar { width: 8px; }
.ag-sidebar-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}
.ag-sidebar-empty {
  color: var(--text-subtle);
  padding: 16px 12px;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}
.ag-sidebar-item {
  position: relative;
  border-radius: var(--r-md);
  padding: 9px 11px 9px 36px;   /* hueco izq para badge fuente */
  border: 1px solid transparent;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.12s;
}
.ag-sidebar-item:hover {
  background: var(--bg-3);
}
.ag-sidebar-item.open {
  background: rgba(87, 204, 152, 0.12);
  border-color: rgba(87, 204, 152, 0.3);
}
.ag-sidebar-item.pinned {
  background: rgba(87, 204, 152, 0.06);
}
.ag-sidebar-item-title {
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ag-sidebar-item-meta {
  color: var(--text-subtle);
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}
.ag-sidebar-item-meta .mode {
  background: rgba(87, 204, 152, 0.18);
  color: #7ED9B0;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9px;
}
.ag-sidebar-item-meta .mode.dangerous {
  background: rgba(245, 159, 0, 0.2);
  color: #F0B842;
}
.ag-sidebar-item-meta .wd {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Badge de fuente (web/CLI/native) — chip a la izquierda del item */
.ag-source-badge {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.ag-source-badge.cli {
  background: rgba(87, 204, 152, 0.18);
  color: #57CC98;
}
.ag-source-badge.web {
  background: rgba(120, 160, 230, 0.22);
  color: #9DB8E6;
}
.ag-source-badge.native {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}
.ag-source-badge svg, .ag-source-badge i { width: 12px; height: 12px; }
/* Acciones (pin/archive) — visibles al hover */
.ag-sidebar-item-actions {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.12s;
}
.ag-sidebar-item:hover .ag-sidebar-item-actions,
.ag-sidebar-item.pinned .ag-sidebar-item-actions {
  opacity: 1;
}
.ag-sidebar-item-action {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.12s;
}
.ag-sidebar-item-action:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}
.ag-sidebar-item-action.danger:hover {
  background: rgba(242, 71, 38, 0.2);
  color: #FF7A60;
}
.ag-sidebar-item-action.pin {
  color: var(--text-muted);
}
.ag-sidebar-item-action.pin.active,
.ag-sidebar-item-action.pin:hover {
  background: rgba(87, 204, 152, 0.2);
  color: #7ED9B0;
}
.ag-sidebar-item.pinned .ag-sidebar-item-action.pin {
  color: #7ED9B0;
  opacity: 1;
}
.ag-sidebar-item .pin-emoji { display: none; }   /* eliminamos el 📌 inline */
.ag-sidebar-footer {
  background: transparent;
  border-top: 1px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.ag-sidebar-new {
  background: rgba(87, 204, 152, 0.16);
  color: #7ED9B0;
  border: 1px solid rgba(87, 204, 152, 0.25);
  font-weight: 600;
}
.ag-sidebar-new:hover {
  background: var(--accent);
  color: #0F1923;
  border-color: transparent;
}
.ag-sidebar-purge {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 11px;
}
.ag-sidebar-purge:hover {
  color: var(--text);
  border-color: var(--text-muted);
}
.ag-sidebar-purge.danger {
  background: rgba(242, 71, 38, 0.08);
  color: #FF7A60;
  border-color: rgba(242, 71, 38, 0.35);
  font-weight: 600;
}
.ag-sidebar-purge.danger:hover {
  background: rgba(242, 71, 38, 0.18);
  color: #FF8F75;
  border-color: rgba(242, 71, 38, 0.6);
}

/* ─── PANELES (solo se usan dentro del drawer del tablón) ── */
.ag-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pill);
}

/* ─── Empty state del tablón (cuando no hay sesiones) ────── */
.ag-tablon-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 480px;
  max-width: 90vw;
  padding: 32px 28px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-pill);
  text-align: center;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.ag-tablon-empty[hidden] { display: none; }
.ag-tablon-empty .ag-tablon-empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 6px;
}
.ag-tablon-empty .ag-tablon-empty-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
  max-width: 380px;
}
.ag-panel.dangerous-wd {
  border-top: 3px solid var(--warning);
}
.ag-panel-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
}
.ag-panel-title {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}
.ag-panel-title:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--accent-light);
}
.ag-panel-mode-select,
.ag-panel-model-select {
  background: var(--card-bg);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--r-sm);
}
.ag-panel-mode-select:hover,
.ag-panel-model-select:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.ag-panel-mode-select.dangerous {
  color: #B07900;
  border-color: var(--warning);
  background: #FEF7E6;
}
.ag-panel-model-select {
  color: var(--accent);
}
.ag-panel-model-select option,
.ag-panel-model-select optgroup,
#ag-new-modelo option,
#ag-new-modelo optgroup {
  background: var(--card-bg);
  color: var(--text);
}
.ag-panel-close {
  color: var(--text-muted);
}
.ag-panel-close:hover {
  background: #FDECE7;
  color: var(--danger);
}
.ag-panel-wd {
  background: var(--bg-3);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  padding: 4px 12px;
}
.ag-panel-wd.dangerous {
  background: #FEF3E6;
  color: #B07900;
  border-bottom-color: var(--warning);
}

/* Mensajes */
.ag-panel-messages {
  background: var(--bg-canvas);
  padding: 16px;
}
.ag-msg-body {
  border-radius: var(--r-md);
  padding: 10px 14px;
  border: 1px solid var(--border);
}
.ag-msg.user .ag-msg-body {
  background: var(--accent-light);
  color: var(--text);
  border-color: transparent;
  border-radius: 16px 16px 4px 16px;
}
.ag-msg.assistant .ag-msg-body {
  background: var(--card-bg);
  color: var(--text);
  border-color: var(--border);
  border-radius: 16px 16px 16px 4px;
}
.ag-msg-body code {
  background: var(--bg-3);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.ag-msg-body pre {
  background: #1F1F1F;
  color: #E6E6E6;
  padding: 12px;
  border-radius: var(--r-md);
}

/* Tool uses inline */
.ag-tool-use {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.ag-tool-use.success {
  border-left: 3px solid var(--success);
}
.ag-tool-use.error {
  border-left: 3px solid var(--danger);
}
.ag-tool-use.pending {
  border-left: 3px solid var(--accent);
}
.ag-tool-use.denied {
  border-left: 3px solid var(--warning);
}
.ag-tool-name {
  color: var(--text);
  font-weight: 600;
}
.ag-tool-summary {
  color: var(--text-muted);
}

/* Input textarea */
.ag-panel-input {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 10px;
}
.ag-panel-textarea {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 12px;
  font-size: 13px;
}
.ag-panel-textarea:focus {
  background: var(--card-bg);
  border-color: var(--accent);
  outline: none;
}
.ag-panel-textarea::placeholder {
  color: var(--text-subtle);
}
.ag-send-btn {
  background: var(--accent);
  color: white;
  font-weight: 600;
  border-radius: var(--r-md);
}
.ag-send-btn:hover {
  background: var(--accent-dim);
}
.ag-send-btn:disabled {
  background: var(--border);
  color: var(--text-subtle);
}

/* Footer del panel */
.ag-panel-footer {
  background: var(--bg-3);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  padding: 6px 12px;
}

/* ─── EMPTY STATE ────────────────────────────────────────────── */
.ag-empty {
  background: var(--card-bg);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
  color: var(--text-muted);
}
.ag-empty-title {
  color: var(--text);
  font-weight: 600;
}
.ag-empty-desc {
  color: var(--text-muted);
}

/* ─── TABLÓN (sin contenedor — full screen como background) ── */
.ag-tablon {
  position: absolute;
  inset: 0;       /* todo el .ag-root */
  z-index: 1;     /* DEBAJO de toolbar, sidebar y grid */
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}
.ag-tablon-viewport {
  position: absolute;
  inset: 0;
  /* Sin fondo propio: hereda el de .ag-root (los puntos) */
  background-color: transparent;
  background-image: none;
}
.ag-tablon-edges path {
  stroke: var(--accent);
  stroke-width: 1.5;
  opacity: 0.4;
  stroke-dasharray: 5 4;
}

/* Squircles de sesión: sin bordes, solo sombra suave */
.ag-tablon-circle {
  border: none;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.12),
    0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 500;
}
.ag-tablon-circle:hover {
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.18),
    0 0 0 3px rgba(87, 204, 152, 0.35);
}
.ag-tablon-circle.dragging {
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.25),
    0 0 0 4px rgba(87, 204, 152, 0.55);
}
.ag-tablon-circle.selected {
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.18),
    0 0 0 3px var(--accent, #57CC98);
}
.ag-tablon-circle .ag-tc-title {
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.ag-tablon-circle .ag-tc-preview {
  font-weight: 400;
}

/* Estado generando — pulse sutil verde Centella */
.ag-tablon-circle.streaming {
  animation: tablonCirclePulseMiro 1.6s ease-in-out infinite;
}
@keyframes tablonCirclePulseMiro {
  0%, 100% {
    box-shadow:
      0 4px 14px rgba(0, 0, 0, 0.12),
      0 0 0 0 rgba(87, 204, 152, 0.5);
  }
  50% {
    box-shadow:
      0 4px 14px rgba(0, 0, 0, 0.12),
      0 0 0 14px rgba(87, 204, 152, 0);
  }
}

/* Toolbar del tablón (zoom controls) — pill flotante Miro */
.ag-tablon-toolbar {
  background: var(--card-bg);
  border: none;
  box-shadow: var(--shadow-pill);
  border-radius: var(--r-lg);
  padding: 6px;
  gap: 2px;
}

/* Breadcrumb de fork — aparece bajo el header del drawer cuando la
   sesión es un fork (Deep Research worktrees Iteración 2 PARTE 3) */
.ag-fork-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(143, 163, 255, 0.08);
  border-bottom: 1px solid rgba(143, 163, 255, 0.18);
  font-size: 11px;
  color: var(--cl-text-secondary, #94A8BE);
  font-family: var(--cl-font-sans, inherit);
}
.ag-fork-bc-icon {
  color: #8FA3FF;
  display: flex;
  align-items: center;
}
.ag-fork-bc-link {
  color: #B6C3FF;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}
.ag-fork-bc-link:hover {
  text-decoration: underline;
}
.ag-fork-bc-sep {
  opacity: 0.5;
}
.ag-fork-bc-select {
  background: rgba(15, 25, 35, 0.7);
  color: var(--cl-text-secondary, #B6C3FF);
  border: 1px solid rgba(143, 163, 255, 0.3);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 10px;
  margin-left: 4px;
}

/* Badge "stale" en nodo del tablón — la sesión está detrás de project.current_version */
.ag-tablon-circle.stale {
  outline: 2px dashed rgba(245, 159, 0, 0.7);
  outline-offset: 4px;
}
.ag-tc-stale-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #F59F00;
  color: #1F1F1F;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Frame de proyecto en el tablón — rectángulo redondeado translúcido detrás
   de las sesiones del mismo proyecto. Estilo Miro/Figma frames. */
.ag-tablon-frame {
  position: absolute;
  pointer-events: none;        /* permite arrastrar nodos por encima */
  border: 1px solid color-mix(in srgb, var(--proj-color, #57CC98) 48%, transparent);
  background: color-mix(in srgb, var(--proj-color, #57CC98) 10%, transparent);
  border-radius: 28px;
  z-index: 0;                  /* detrás de los círculos (que tienen z-index implícito mayor) */
}
.ag-tablon-frame-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  pointer-events: auto;
  cursor: pointer;
  background: color-mix(in srgb, var(--proj-color, #57CC98) 18%, transparent);
  border-radius: 28px 28px 0 0;
}
.ag-tablon-frame-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--proj-color, #57CC98);
}
.ag-tablon-frame-title {
  font-size: 13px;
  font-weight: 700;
  color: #1F1F1F;
  letter-spacing: 0.01em;
  flex: 1;
}
.ag-tablon-frame-stats {
  display: flex;
  gap: 4px;
}
.ag-tablon-frame-stat {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  color: #1F1F1F;
}
.ag-tablon-frame-stat.stale {
  background: rgba(245, 159, 0, 0.85);
  color: #1F1F1F;
}

/* Help-pill: Tour + Demo, bottom-right ENCIMA del toolbar de zoom */
.ag-help-pill {
  position: fixed;
  right: 14px;
  bottom: 70px;          /* ~58px del toolbar (52h+6gap) + un colchón */
  z-index: 200;
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pill);
  transition: right 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
body.ag-drawer-open .ag-help-pill {
  right: calc(var(--ag-drawer-width, 480px) + 14px);
}
.ag-help-pill .ag-btn {
  height: 32px;
  font-size: 12px;
  padding: 0 12px;
  border-radius: 8px;
}
.ag-tablon-tool-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  color: var(--text-dim);
}
.ag-tablon-tool-btn:hover {
  background: var(--bg-3);
  color: var(--accent);
}
.ag-tablon-zoom-display {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding: 0 6px;
}

/* Tooltip del Tablón — estilo Miro (oscuro sobre fondo claro) */
.ag-tablon-tooltip {
  background: #1F1F1F;
  color: white;
  border: none;
  box-shadow: var(--shadow-tooltip);
  border-radius: var(--r-md);
  font-size: 12px;
  padding: 12px 14px;
}
.ag-tablon-tooltip .tt-title {
  color: white;
  font-weight: 600;
}
.ag-tablon-tooltip .tt-meta {
  color: #BFBFBF;
}
.ag-tablon-tooltip .tt-meta .pill {
  background: rgba(255, 255, 255, 0.12);
  color: #93B0FF;
  font-weight: 500;
}
.ag-tablon-tooltip .tt-msg {
  background: rgba(255, 255, 255, 0.06);
  color: #D9D9D9;
  border-left-color: var(--accent);
}
.ag-tablon-tooltip .tt-msg .role {
  color: #93B0FF;
}
.ag-tablon-tooltip .tt-cta {
  color: #93B0FF;
  font-weight: 500;
}

/* Drawer lateral — tema OSCURO scopeado, mismo lenguaje que sidebar */
.ag-tablon-drawer {
  --text: #E8EEF5;
  --text-dim: #94A8BE;
  --text-muted: #6B8096;
  --text-subtle: #5A6B7E;
  --bg: #0F1923;
  --bg-3: #1B2A3A;
  --bg-canvas: #0B141C;
  --card-bg: #162330;
  --border: #1F2D3D;
  --border-strong: #2A3F55;
  --accent: #57CC98;
  --accent-light: rgba(87, 204, 152, 0.15);
  --accent-tint: rgba(87, 204, 152, 0.08);
  background: #0F1923;
  border-left: 1px solid #1F2D3D;
  border-radius: 0;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  color: var(--text);
}
.ag-tablon-drawer-close {
  background: rgba(15, 25, 35, 0.85);
  border: 1px solid #1F2D3D;
  color: #94A8BE;
}
.ag-tablon-drawer-close:hover {
  background: rgba(242, 71, 38, 0.18);
  color: #FF7A60;
  border-color: rgba(242, 71, 38, 0.6);
}
/* Panel dentro del drawer — sin fondo blanco */
.ag-tablon-drawer .ag-panel {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  height: 100%;
}
.ag-tablon-drawer .ag-panel-header {
  background: #0F1923;
  border-bottom: 1px solid #1F2D3D;
}
.ag-tablon-drawer .ag-panel-title {
  color: #E8EEF5;
}
.ag-tablon-drawer .ag-panel-title:focus {
  background: rgba(87, 204, 152, 0.15);
  outline-color: #57CC98;
}
.ag-tablon-drawer .ag-panel-mode-select,
.ag-tablon-drawer .ag-panel-model-select {
  background: #1B2A3A;
  border-color: #2A3F55;
  color: #94A8BE;
}
.ag-tablon-drawer .ag-panel-mode-select:hover,
.ag-tablon-drawer .ag-panel-model-select:hover {
  border-color: #57CC98;
  color: #57CC98;
}
.ag-tablon-drawer .ag-panel-mode-select option,
.ag-tablon-drawer .ag-panel-model-select option,
.ag-tablon-drawer .ag-panel-mode-select optgroup,
.ag-tablon-drawer .ag-panel-model-select optgroup {
  background: #162330;
  color: #E8EEF5;
}
.ag-tablon-drawer .ag-panel-wd {
  background: #0B141C;
  color: #6B8096;
  border-bottom-color: #1F2D3D;
}
.ag-tablon-drawer .ag-panel-wd.dangerous {
  background: rgba(245, 159, 0, 0.12);
  color: #F0B842;
}
.ag-tablon-drawer .ag-panel-messages {
  background: #0B141C;
}
/* Chat estilo desktop: user a la derecha, assistant a la izquierda.
   Bubbles flotantes con max 78% del contenedor. */
.ag-tablon-drawer .ag-panel-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  overflow-y: auto;
  /* La barra de scroll vive solo aquí, dentro del contenedor del chat */
  scrollbar-gutter: auto;
}
.ag-tablon-drawer .ag-panel-messages::-webkit-scrollbar { width: 6px; }
.ag-tablon-drawer .ag-panel-messages::-webkit-scrollbar-track { background: transparent; }
.ag-tablon-drawer .ag-panel-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}
.ag-tablon-drawer .ag-msg {
  max-width: 78%;
  display: flex;
  flex-direction: column;
}
.ag-tablon-drawer .ag-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}
.ag-tablon-drawer .ag-msg.assistant {
  align-self: flex-start;
  align-items: flex-start;
}
.ag-tablon-drawer .ag-msg-header {
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 0 4px 2px;
}
.ag-tablon-drawer .ag-msg.user .ag-msg-body {
  background: rgba(87, 204, 152, 0.22);
  color: #E8EEF5;
  border: none;
  border-radius: 16px 16px 4px 16px;
  padding: 9px 14px;
  font-size: 13px;
  line-height: 1.5;
}
.ag-tablon-drawer .ag-msg.assistant .ag-msg-body {
  background: #162330;
  color: #E8EEF5;
  border: 1px solid #1F2D3D;
  border-radius: 16px 16px 16px 4px;
  padding: 9px 14px;
  font-size: 13px;
  line-height: 1.5;
}
/* Botón flotante "ir al final" */
.ag-scroll-bottom-btn {
  position: absolute;
  right: 18px;
  bottom: 88px;     /* encima del input area */
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(15, 25, 35, 0.92);
  border: 1px solid #2A3F55;
  color: #94A8BE;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s, background 0.15s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.ag-scroll-bottom-btn.visible {
  opacity: 1;
  pointer-events: auto;
}
.ag-scroll-bottom-btn:hover {
  background: rgba(87, 204, 152, 0.22);
  color: #7ED9B0;
  border-color: rgba(87, 204, 152, 0.4);
}
.ag-scroll-bottom-btn i { width: 14px; height: 14px; }
.ag-tablon-drawer .ag-msg-body code {
  background: #1F2D3D;
  color: #7ED9B0;
}
.ag-tablon-drawer .ag-tool-use {
  background: #162330;
  border-color: #1F2D3D;
  color: #94A8BE;
}
.ag-tablon-drawer .ag-tool-name {
  color: #E8EEF5;
}
.ag-tablon-drawer .ag-tool-summary {
  color: #94A8BE;
}
.ag-tablon-drawer .ag-panel-input {
  background: #0F1923;
  border-top-color: #1F2D3D;
}
.ag-tablon-drawer .ag-panel-textarea {
  background: #1B2A3A;
  color: #E8EEF5;
  border-color: #2A3F55;
}
.ag-tablon-drawer .ag-panel-textarea:focus {
  background: #162330;
  border-color: #57CC98;
}
.ag-tablon-drawer .ag-panel-textarea::placeholder {
  color: #5A6B7E;
}
.ag-tablon-drawer .ag-panel-footer {
  background: #0B141C;
  border-top-color: #1F2D3D;
  color: #6B8096;
}

/* ─── MODAL nueva sesión ────────────────────────────────────── */
.ag-overlay {
  background: rgba(15, 18, 23, 0.45);
  backdrop-filter: blur(2px);
}
.ag-modal {
  background: var(--card-bg);
  border: none;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-menu);
  color: var(--text);
}
.ag-modal h2 {
  color: var(--text);
  font-weight: 700;
}
.ag-field label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
}
.ag-field input,
.ag-field select,
.ag-field textarea {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
}
.ag-field input:focus,
.ag-field select:focus,
.ag-field textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-light);
}
.ag-field-hint {
  color: var(--text-subtle);
  font-size: 11px;
}
.ag-field-hint.danger {
  color: #B07900;
}

/* ─── TOAST ─────────────────────────────────────────────────── */
.ag-toast {
  background: #1F1F1F;
  color: white;
  border: none;
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-tooltip);
  border-radius: var(--r-md);
  font-weight: 500;
}
.ag-toast.error { border-left-color: var(--danger); }
.ag-toast.warning { border-left-color: var(--warning); }

/* ─── BADGE de novedades ───────────────────────────────────── */
.ag-updates-badge {
  background: #FEF7E6;
  color: #B07900;
  border-color: #F0D070;
  font-weight: 600;
}
.ag-updates-badge:hover {
  background: #FCEFCC;
  border-color: var(--warning);
}

/* ─── Tour launch button ───────────────────────────────────── */
.tour-launch-btn {
  background: var(--accent-light);
  color: var(--accent);
  border-color: transparent;
  font-weight: 600;
}
.tour-launch-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ─── Auto-routing hint chip ───────────────────────────────── */
.ag-auto-routing-hint {
  background: var(--accent-light);
  border-color: transparent;
  color: var(--accent);
  font-weight: 600;
}
.ag-auto-routing-hint strong {
  color: var(--accent-dim);
}

/* ─── Adjuntos chips (si la sesión paralela los implementó) ── */
.ag-attach-chip,
.ag-attach-list .chip {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
}
.ag-attach-btn {
  background: transparent;
  color: var(--text-muted);
}
.ag-attach-btn:hover {
  background: var(--bg-3);
  color: var(--accent);
}

/* ─── Historial / Rewind (V3.4 — Esc-Esc style) ─────────────── */
.ag-panel-history {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--r-md);
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 120ms ease;
  margin-left: 4px;
}
.ag-panel-history:hover {
  background: var(--accent-tint);
  color: var(--accent-dim);
  border-color: var(--accent);
}

/* Overlay panel del historial — se posiciona dentro del .ag-panel
   como una columna flotante sobre los mensajes. */
.ag-history-panel {
  position: absolute;
  top: 56px;
  right: 8px;
  bottom: 70px;
  width: 360px;
  max-width: calc(100% - 24px);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-menu);
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 16px));
  opacity: 0;
  pointer-events: none;
  transition: transform 200ms ease, opacity 160ms ease;
  z-index: 8;
}
.ag-history-panel.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}
.ag-history-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-strong);
  font-weight: 600;
  font-size: 13px;
}
.ag-history-title {
  flex: 1;
}
.ag-history-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-3);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-weight: 500;
}
.ag-history-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
}
.ag-history-close:hover {
  background: var(--bg-3);
  color: var(--text-strong);
}
.ag-history-hint {
  padding: 10px 14px;
  font-size: 11.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
  line-height: 1.4;
}
.ag-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.ag-history-loading,
.ag-history-error,
.ag-history-empty {
  padding: 20px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.ag-history-error {
  color: var(--danger);
}
.ag-history-item {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-bottom: 8px;
  transition: all 120ms ease;
}
.ag-history-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-soft);
}
.ag-history-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.ag-history-ts {
  font-weight: 500;
}
.ag-history-ver {
  background: var(--accent-tint);
  color: var(--accent-dim);
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-size: 10px;
}
.ag-history-files-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  color: var(--text-muted);
  font-weight: 500;
}
.ag-history-latest {
  background: var(--success);
  color: white;
  font-size: 9px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.ag-history-label {
  font-size: 12px;
  color: var(--accent-dim);
  font-weight: 600;
  margin-bottom: 4px;
}
.ag-history-snippet {
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-style: italic;
}
.ag-history-files {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.ag-history-fpath {
  font-size: 10.5px;
  background: rgba(87, 204, 152, 0.08);
  border: 1px solid rgba(87, 204, 152, 0.2);
  color: var(--accent-dim);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-family: 'JetBrains Mono', 'Consolas', monospace;
}
.ag-history-more {
  font-size: 10.5px;
  color: var(--text-muted);
  padding: 1px 4px;
}
.ag-history-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.ag-history-action {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: var(--r-md);
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  transition: all 120ms ease;
}
.ag-history-action:hover {
  border-color: var(--accent);
  color: var(--accent-dim);
}
.ag-history-rewind {
  flex: 1;
  justify-content: center;
}
.ag-history-rewind:hover {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-dim);
}

/* Cuando el panel está abierto, dar margen al contenedor de mensajes
   para que no quede oculto detrás del overlay. Solo cuando el panel
   tiene clase .ag-history-open. */
.ag-panel.ag-history-open .ag-panel-messages {
  padding-right: 380px;
  transition: padding 200ms ease;
}
@media (max-width: 900px) {
  .ag-panel.ag-history-open .ag-panel-messages {
    padding-right: 16px;
  }
  .ag-history-panel {
    width: calc(100% - 24px);
  }
}

/* Modal de confirmación del rewind */
.ag-rewind-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 0, 56, 0.45);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ag-rewind-fade 160ms ease;
}
@keyframes ag-rewind-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.ag-rewind-modal {
  background: var(--card-bg);
  border-radius: var(--r-lg);
  padding: 24px 28px;
  max-width: 440px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
}
.ag-rewind-modal h3 {
  margin: 0 0 12px 0;
  font-size: 18px;
  color: var(--text-strong);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}
.ag-rewind-warn {
  margin: 0 0 14px 0;
  padding: 10px 12px;
  background: rgba(242, 71, 38, 0.08);
  border: 1px solid rgba(242, 71, 38, 0.25);
  border-radius: var(--r-md);
  color: var(--danger);
  font-size: 12.5px;
}
.ag-rewind-summary {
  margin: 0 0 14px 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
}
.ag-rewind-summary li {
  margin-bottom: 4px;
}
.ag-rewind-snippet {
  background: var(--bg-3);
  padding: 10px 12px;
  border-radius: var(--r-md);
  border-left: 3px solid var(--accent);
  color: var(--text-dim);
  font-size: 12px;
  font-style: italic;
  margin-bottom: 16px;
  line-height: 1.5;
}
.ag-rewind-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.ag-rewind-actions .ag-btn {
  min-width: 100px;
}

/* ─── Scrollbars sutiles ──────────────────────────────────── */
.ag-root ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.ag-root ::-webkit-scrollbar-track {
  background: transparent;
}
.ag-root ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.ag-root ::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
  background-clip: padding-box;
  border: 2px solid transparent;
}
