/* Botón flotante (FAB) que abre Portia: abajo a la derecha, translúcido (glass). */
.portia-launcher, .portia-panel { --core-muelle: linear(0.0, 0.08, 0.271, 0.503, 0.729, 0.915, 1.049, 1.129, 1.161, 1.158, 1.132, 1.095, 1.057, 1.024, 0.999, 0.983, 0.975, 0.974, 0.977, 0.982, 0.988, 0.994, 0.999, 1.002, 1.004, 1.004, 1.004, 1.003, 1.002, 1.001, 1); }
.portia-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1250;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background: var(--favicon-gradient);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--shadow-color) 30%, transparent);
  /* Al cerrarse el panel, el botón reaparece cuando el panel ya se ha recogido dentro de él. */
  transition: opacity 0.16s ease 0.3s, box-shadow var(--transition), background var(--transition);
}
/* Sobre el degradado, el logo va en blanco. */
.portia-launcher svg path { stroke: var(--core-ink); }
.portia-launcher svg .core-nucleo { fill: var(--core-ink); }


/* Con Portia activo el botón «Índice» de la wiki (móvil, abajo a la derecha) se apila
   justo encima del FAB (alto 52px + 24px de margen + hueco), que si no lo taparía.
   Con Portia desactivado el lanzador no existe y el botón ocupa la esquina. */
@media (max-width: 900px) {
  body:has(#portia-launcher) .wiki-nav-toggle { bottom: 90px; }
}

.portia-launcher svg {
  width: 26px;
  height: 26px;
}

.portia-launcher:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 14px 30px color-mix(in srgb, var(--shadow-color) 36%, transparent);
  background: var(--favicon-gradient-hover);
}

/* Al abrirse el panel, el botón se contrae y se funde "dentro" de la gota. */
.portia-launcher.active { opacity: 0; pointer-events: none; transition: opacity 0.22s ease 0.08s, box-shadow var(--transition), background var(--transition); }

.portia-panel {
  --core-boton: 52px;                     /* lado del botón: de ahí nace y ahí se recoge */
  --core-ease: cubic-bezier(0.32, 0.72, 0, 1);
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1200;
  width: 380px;
  height: 560px;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--bg2);
  box-shadow: 0 24px 60px color-mix(in srgb, var(--shadow-color) 34%, transparent);
  overflow: hidden;
  /* Cerrado: el panel ES el botón. Se recorta a su cuadrado (esquina inferior derecha) y, al abrir,
     el recorte crece hasta el panel entero: una sola forma que se expande, sin escalar el contenido
     (nada se deforma). El margen negativo del estado abierto deja ver la sombra. */
  clip-path: inset(calc(100% - var(--core-boton)) 0 0 calc(100% - var(--core-boton)) round var(--radius-sm));
  visibility: hidden;
  pointer-events: none;
  will-change: clip-path;
  /* Al cerrar, el recorte empieza a recogerse YA (curva de salida): con la curva de entrada
     anterior el panel se quedaba casi entero, en blanco, y luego desaparecía de golpe. */
  transition: clip-path 0.38s cubic-bezier(0.4, 0, 0.2, 1), border-radius 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0s linear 0.38s, height 0.24s ease, width 0.24s ease;
}
.portia-panel.open {
  visibility: visible;
  pointer-events: auto;
  border-radius: 20px;
  clip-path: inset(-80px round 20px);
  transition: clip-path 0.55s var(--core-ease), border-radius 0.55s var(--core-ease), height 0.24s ease, width 0.24s ease;
}
/* Velo del color del botón: mientras la forma es pequeña se ve el degradado del botón, que se
   disuelve al crecer y reaparece al recogerse. */
.portia-panel::before {
  content: ''; position: absolute; inset: 0; z-index: 10; pointer-events: none;
  background: var(--favicon-gradient); opacity: 1;
  transition: opacity 0.2s ease 0.08s;   /* al recogerse se tiñe pronto del color del botón */
}
.portia-panel.open::before { opacity: 0; transition: opacity 0.2s ease 0.02s; }
/* El contenido aparece cuando la forma ya tiene sitio y se va primero al cerrar. */
.portia-panel > * { opacity: 0; transition: opacity 0.12s ease; }
.portia-panel.open > * { opacity: 1; transition: opacity 0.28s ease 0.16s; }

/* Ampliado (escritorio y tablet): el panel crece desde su esquina, sin llegar a pantalla completa. */
.portia-panel.maximized {
  width: min(960px, calc(100vw - 48px));
  height: min(820px, calc(100vh - 48px));
}
.portia-panel.maximized.open {
  transition: clip-path 0.55s var(--core-ease), border-radius 0.55s var(--core-ease), height 0.5s cubic-bezier(0.22, 1, 0.36, 1), width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.portia-maximizar .portia-ico-reducir,
.portia-panel.maximized .portia-maximizar .portia-ico-ampliar { display: none; }
.portia-panel.maximized .portia-maximizar .portia-ico-reducir { display: block; }
.portia-panel.maximized .portia-bubble { max-width: 78ch; }

.portia-backdrop { display: none; }
.portia-backdrop[hidden] { display: none !important; }

.portia-panel.collapsed {
  height: 62px;
}

.portia-header {
  min-height: 62px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid color-mix(in srgb, var(--surface-white) 12%, transparent);
  user-select: none;
}

.portia-brand,
.portia-actions,
.portia-meta {
  display: flex;
  align-items: center;
}

.portia-brand {
  gap: 9px;
}

.portia-mark {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.portia-mark svg {
  width: 22px;
  height: 22px;
}

.portia-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  background: var(--favicon-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.portia-actions {
  gap: 4px;
}

.portia-icon-btn,
.portia-send {
  border: none;
  background: transparent;
  color: var(--text2);
  transition: color var(--transition), background var(--transition);
}

.portia-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.portia-icon-btn:hover {
  background: color-mix(in srgb, var(--surface-white) 10%, transparent);
  color: var(--text);
}

.portia-icon-btn svg,
.portia-send svg {
  width: 16px;
  height: 16px;
}

.portia-icon-btn.spinning svg {
  animation: portiaSpin 0.8s linear infinite;
}

.portia-body {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.portia-panel.collapsed .portia-body {
  display: none;
}

.portia-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.portia-message {
  max-width: 88%;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.portia-message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.portia-message.assistant {
  align-self: flex-start;
}

.portia-bubble {
  padding: 11px 12px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.45;
  background: color-mix(in srgb, var(--surface-white) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--surface-white) 10%, transparent);
}

.portia-message.user .portia-bubble {
  color: var(--core-ink);
  background: var(--favicon-gradient);
  /* El degradado cubre también el borde: con el origen por defecto se repetía en los 1 px laterales. */
  background-origin: border-box;
  border-color: transparent;
}

/* Respuestas de Core: párrafos, listas, código y tablas (portiaRenderMarkdown). */
.portia-bubble p { margin: 0 0 6px; }
.portia-bubble ul,
.portia-bubble ol { margin: 4px 0 6px 18px; }
.portia-bubble > :last-child { margin-bottom: 0; }
.portia-bubble code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--accent-soft);
}

/* Con una tabla, la burbuja usa todo el ancho del panel y la tabla desplaza dentro. */
.portia-message.assistant:has(.portia-tabla) { max-width: 100%; }
.portia-tabla {
  margin: 6px 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.portia-tabla table {
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.portia-tabla th,
.portia-tabla td {
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.portia-tabla th {
  font-weight: 600;
  white-space: nowrap;
  background: var(--table-head-bg);
}
.portia-tabla td { min-width: 72px; }

.portia-meta {
  gap: 8px;
  color: var(--text3);
  font-size: 10px;
}

.portia-meta button {
  border: none;
  background: transparent;
  color: inherit;
  font-size: inherit;
}

.portia-meta button:hover {
  color: var(--text);
}

.portia-suggestions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 14px 12px;
}

.portia-suggestions button {
  border: 1px solid color-mix(in srgb, var(--surface-white) 12%, transparent);
  background: color-mix(in srgb, var(--surface-white) 5%, transparent);
  color: var(--text2);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 11px;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.portia-suggestions button:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--favicon-c2) 30%, transparent);
  background: var(--core-campo-bg);
}

.portia-typing {
  height: 22px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 16px 8px;
}

/* Oculto no ocupa sitio: así el perfil queda junto al campo de texto (antes dejaba un hueco de 30 px). */
.portia-typing.hidden {
  display: none;
}

.portia-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text2);
  animation: portiaTyping 1s infinite ease-in-out;
}

.portia-typing span:nth-child(2) { animation-delay: 0.12s; }
.portia-typing span:nth-child(3) { animation-delay: 0.24s; }

.portia-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px 10px;
  border-top: 1px solid color-mix(in srgb, var(--surface-white) 12%, transparent);
}

.portia-input-area textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  border: 1px solid color-mix(in srgb, var(--surface-white) 12%, transparent);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--core-campo-bg);
  outline: none;
}

.portia-input-area textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}

.portia-send {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  color: var(--core-ink);
  background: var(--favicon-gradient);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.portia-send:hover {
  background: var(--favicon-gradient-hover);
}

.portia-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.portia-legal {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 0 14px 12px;
  color: var(--text2);
  opacity: 0.6;
  font-size: 10px;
}

.portia-legal svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  margin-top: 1px;
}

@keyframes portiaTyping {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@keyframes portiaSpin {
  to { transform: rotate(360deg); }
}

@media (max-width: 640px) {
  /* Móvil: el fondo queda bloqueado mientras Core está abierto y no hay modo ampliado. */
  html.core-panel-bloqueo,
  body.core-panel-bloqueo { overflow: hidden; overscroll-behavior: none; }
  .portia-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1190;
    background: color-mix(in srgb, var(--shadow-color) 45%, transparent);
    opacity: 0;
    pointer-events: none;
    touch-action: none;
    transition: opacity 0.3s ease;
  }
  .portia-panel.open ~ .portia-backdrop { opacity: 1; pointer-events: auto; }
  .portia-maximizar { display: none; }
  .portia-messages { overscroll-behavior: contain; }
  .portia-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: min(560px, calc(100vh - 16px));
    border-radius: 20px 20px 0 0;
    /* En móvil, hoja inferior con deslizamiento vertical (sin la transformación desde el botón). */
    clip-path: none;
    transform-origin: bottom center;
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.32s, height 0.24s ease;
  }
  .portia-panel::before { display: none; }
  .portia-panel > * { opacity: 1; transition: none; }
  .portia-panel.open { transform: translateY(0); clip-path: none; transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), height 0.24s ease; }
}

@media (prefers-reduced-motion: reduce) {
  .portia-icon-btn.spinning svg,
  .portia-typing span {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

/* Icono de Core: anillo abierto (la «C») con un núcleo. Azules por token, sin colores en el SVG. */

.core-grad-start { stop-color: var(--favicon-c1); }
.core-grad-mid { stop-color: var(--favicon-c2); }
.core-grad-end { stop-color: var(--favicon-c3); }
.core-nucleo { fill: var(--favicon-c2); }

/* ── Core+ (solo Administrador) ──────────────────────────────────────────────
   Se activa con el botón «+» de la cabecera (corePanelAlternarPlus). La raíz #portia-root
   recibe .core-plus y redefine los tokens de Core: todo lo que pinta en azul (botón flotante,
   velo, nombre, logo, burbujas, enviar, campo) pasa a degradados rojos sin tocar cada regla. */
#portia-root.core-plus {
  --favicon-c1: var(--core-plus-c1); --favicon-c2: var(--core-plus-c2); --favicon-c3: var(--core-plus-c3);
  --favicon-gradient: var(--core-plus-gradient);
  --favicon-gradient-hover: var(--core-plus-gradient-hover);
  --core-campo-bg: color-mix(in srgb, var(--core-plus-c2) 6%, var(--bg2));
  --accent: var(--core-plus-c2);
}

/* Nombre: «Core» + signo «+» en superíndice, solo visible en Core+. */
.portia-name-plus {
  display: inline-block; margin-left: 1px; font-size: 0.85em; vertical-align: super; line-height: 0;
  color: var(--favicon-c3); -webkit-text-fill-color: var(--favicon-c3); /* el padre recorta el degradado al texto: el «+» lleva color propio */
  opacity: 0; transform: scale(0.2); max-width: 0;
  transition: opacity 0.25s ease, transform 0.45s var(--core-muelle, ease), max-width 0.3s ease;
}
#portia-root.core-plus .portia-name-plus { opacity: 1; transform: scale(1); max-width: 1em; }

/* Botón «+» (a la izquierda de Ampliar): un más; encendido, relleno con el degradado. */
.portia-plus-btn:hover { color: var(--core-plus-c2); }
.portia-plus-btn[aria-pressed="true"] {
  color: var(--core-ink);
  background: var(--favicon-gradient);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--core-plus-c2) 35%, transparent);
}
.portia-plus-btn svg { transition: transform 0.45s var(--core-muelle, ease); }
.portia-plus-btn:hover svg { transform: rotate(90deg); }
.portia-plus-btn[aria-pressed="true"] svg { transform: rotate(45deg); }   /* encendido, el «+» se vuelve «×» para salir */
.portia-plus-btn[aria-pressed="true"]:hover svg { transform: rotate(135deg); }

/* Botón flotante en Core+: insignia «+». */
#portia-root.core-plus .portia-launcher::after {
  content: '+'; position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; font: 700 13px/1 var(--font-display); color: var(--core-plus-c2);
  background: var(--bg2); box-shadow: 0 2px 6px color-mix(in srgb, var(--shadow-color) 30%, transparent);
}

/* Aviso legal: el texto cambia con el modo. */
.portia-legal-plus,
#portia-root.core-plus .portia-legal-core { display: none; }
#portia-root.core-plus .portia-legal-plus { display: inline; }

/* Decisión del propietario (nov 2026): las animaciones del chat (apertura y agua de Core+) se ven
   aunque el sistema tenga activado «reducir movimiento» (Windows: «Efectos de animación» desactivados),
   como en el resto de webs. */
/* Transición Core ↔ Core+: el nuevo color CAE como agua por el panel (core-panel.js crea
   .core-liquido). Una lámina con el borde ondulado (un cuadrado enorme muy redondeado que gira
   mientras baja) cubre el panel de arriba abajo, el tema cambia debajo cuando está cubierto y el
   agua sigue cayendo hasta salir por abajo; una segunda lámina más clara da profundidad y unas
   gotas se adelantan. Medidas relativas al panel con --alto (su alto en px, lo pone core-panel.js; antes eran
   unidades de contenedor cqh, que Safari no aplicaba dentro de @keyframes y el agua no caía), así vale
   igual en normal, ampliado y móvil. Solo transform y opacity (GPU). */
.core-liquido {
  position: absolute; inset: 0; z-index: 11; pointer-events: none; overflow: hidden;
  border-radius: inherit;
  --liquido: var(--core-plus-gradient);
  --liquido-dur: 1.25s;
}
.core-liquido.is-core { --liquido: var(--core-azul-gradient); }
.portia-panel > .core-liquido { opacity: 1; transition: none; }   /* no hereda el fundido del contenido */
.core-liquido-lamina {
  position: absolute; left: -70%; bottom: 100%; width: 240%; aspect-ratio: 1;
  border-radius: 43% 45% 44% 46%;
  background: var(--liquido);
  box-shadow: inset 0 -18px 30px color-mix(in srgb, var(--surface-white) 22%, transparent);
  animation: coreLiquidoCae var(--liquido-dur) cubic-bezier(0.55, 0.05, 0.4, 1) forwards;
  will-change: transform;
}
.core-liquido-lamina.is-trasera {
  left: -60%; opacity: 0.45; border-radius: 46% 42% 45% 43%;
  animation-duration: calc(var(--liquido-dur) * 1.08); animation-delay: -0.06s;
  filter: saturate(1.2) brightness(1.15);
}
.core-liquido-gota {
  position: absolute; top: -14px; width: 9px; height: 13px;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: var(--liquido); opacity: 0;
  animation: coreLiquidoGota calc(var(--liquido-dur) * 0.55) cubic-bezier(0.5, 0, 0.9, 0.6) forwards;
}
.core-liquido-gota:nth-child(3) { left: 14%; animation-delay: 0s; }
.core-liquido-gota:nth-child(4) { left: 38%; animation-delay: 0.07s; transform: scale(0.7); }
.core-liquido-gota:nth-child(5) { left: 61%; animation-delay: 0.03s; }
.core-liquido-gota:nth-child(6) { left: 82%; animation-delay: 0.11s; transform: scale(0.8); }

@keyframes coreLiquidoCae {
  0%   { transform: translateY(0) rotate(0deg); }
  48%  { transform: translateY(calc(var(--alto, 560px) + 6%)) rotate(70deg); }   /* panel cubierto: aquí cambia el tema */
  100% { transform: translateY(calc(var(--alto, 560px) + 102%)) rotate(150deg); } /* el agua sale por abajo */
}
@keyframes coreLiquidoGota {
  0%   { opacity: 0; translate: 0 0; }
  15%  { opacity: 0.95; }
  100% { opacity: 0.9; translate: 0 calc(var(--alto, 560px) + 20px); }
}

/* El logo «salpica» al recibir el agua. */
.portia-panel.core-plus-anim .portia-mark { animation: corePlusLogo 0.9s var(--core-muelle, ease) 0.45s; }
@keyframes corePlusLogo {
  0% { transform: scale(1); }
  35% { transform: scale(1.3) rotate(-12deg); }
  100% { transform: scale(1) rotate(0); }
}


/* Lote de cambios de Core+: resumen, una fila por registro (antes → después) y un único «Aplicar». */
.portia-message.assistant:has(.core-lote) { max-width: 100%; width: 100%; }
.core-lote {
  margin-top: 8px; border-radius: 16px; overflow: hidden; font-size: 12px;
  background: var(--bg2);
  border: 1px solid color-mix(in srgb, var(--core-plus-c2) 28%, var(--border));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--core-plus-c2) 10%, transparent);
}
.core-lote-cabeza {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: color-mix(in srgb, var(--core-plus-c2) 7%, var(--bg2));
  border-bottom: 1px solid color-mix(in srgb, var(--core-plus-c2) 16%, var(--border));
}
.core-lote-titulos { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.core-lote-titulos strong { font-size: 13px; color: var(--text); }
.core-lote-titulos span { color: var(--text3); font-size: 11px; }
.core-lote-estado { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; color: var(--text2); background: var(--bg3); }
.core-lote.is-aplicada .core-lote-estado { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.core-lote.is-parcial .core-lote-estado { color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, transparent); }
.core-lote.is-aplicando .core-lote-estado { color: var(--core-plus-c2); }
.core-lote-ops { list-style: none; margin: 0; padding: 4px 0; }
.core-op { padding: 8px 12px; }
.core-op + .core-op { border-top: 1px solid var(--border); }
.core-op.is-fuera { opacity: 0.45; }
.core-op.is-fuera .core-op-campos { text-decoration: line-through; }
.core-op-cabeza { display: flex; align-items: center; gap: 8px; min-width: 0; }
.core-op-check { flex: none; width: 15px; height: 15px; margin: 0; accent-color: var(--core-plus-c2); cursor: pointer; }
.core-op-accion { flex: none; font-size: 10px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; }
.core-op-accion.is-editar { color: var(--core-plus-c3); background: color-mix(in srgb, var(--core-plus-c2) 12%, transparent); }
.core-op-accion.is-crear { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
:root[data-theme="dark"] .core-op-accion.is-editar { color: var(--core-plus-c1); }
.core-op-registro { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text); }
.core-op-tipo { font-weight: 400; color: var(--text3); }
.core-op-campos { list-style: none; margin: 6px 0 0 23px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.core-op-campos li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; line-height: 1.4; }
.core-op-campo { color: var(--text3); min-width: 92px; }
.core-op-antes { color: var(--text3); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text3) 60%, transparent); }
.core-op-flecha { color: var(--core-plus-c2); }
.core-op-despues { color: var(--text); font-weight: 400; padding: 0 5px; border-radius: 5px; background: color-mix(in srgb, var(--core-plus-c2) 9%, transparent); }
.core-op-res { flex: none; width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--core-ink); }
.core-op-res.is-ok { background: var(--green); }
.core-op-res.is-ko { background: var(--red); }
.core-op-error { margin: 4px 0 0 23px; color: var(--red); }
.core-lote-mas { display: block; width: 100%; text-align: left; border: none; border-top: 1px solid var(--border); background: transparent; cursor: pointer; padding: 8px 12px; color: var(--core-plus-c2); font-size: 12px; font-weight: 600; }
.core-lote-mas:hover { background: color-mix(in srgb, var(--core-plus-c2) 5%, transparent); }
.core-lote-acciones {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg3) 50%, var(--bg2));
}
.core-lote-nota { margin-right: auto; color: var(--text3); font-size: 11px; }
.core-lote-acciones button { border: none; border-radius: 10px; padding: 7px 14px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; flex: none; }
.core-lote-descartar { background: transparent; color: var(--text2); }
.core-lote-descartar:hover { color: var(--text); background: var(--bg3); }
.core-lote-aplicar { color: var(--core-ink); background: var(--core-plus-gradient); box-shadow: 0 4px 10px color-mix(in srgb, var(--core-plus-c2) 30%, transparent); }
.core-lote-aplicar:hover { background: var(--core-plus-gradient-hover); }
.core-lote-aplicar:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.core-lote.is-aplicando .core-lote-ops { opacity: 0.6; }

/* Perfil de la conversación: desplegable en el hueco de la cuarta sugerencia (chat en blanco) y,
   empezada la conversación, su nombre junto a «Core» (ya no se cambia hasta una nueva). */
.portia-perfil {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; font-size: 11px;
  color: var(--text3); border: 1px dashed color-mix(in srgb, var(--favicon-c2) 40%, var(--border));
}
.portia-perfil select {
  border: none; background: var(--core-campo-bg); font-family: inherit; font-size: 11px; font-weight: 600; line-height: 1.2;
  padding: 4px 8px; border-radius: 999px; cursor: pointer;
}
/* Desplegable del perfil con el color del agente: azul oscuro (Core) o granate oscuro (Core+). */
.portia-perfil select { color: var(--core-perfil-ink); }
#portia-root { --core-perfil-ink: var(--core-azul-oscuro); }
#portia-root.core-plus { --core-perfil-ink: var(--core-plus-granate); }
:root[data-theme="dark"] #portia-root { --core-perfil-ink: var(--favicon-c1); }

.core-op-accion.is-borrar { color: var(--red); background: color-mix(in srgb, var(--red) 13%, transparent); }
.core-op-baja { color: var(--red); }

/* Cabecera del lote: «Cambio propuesto» + registro principal; a la derecha, su ID. */
.core-lote-titulos span { color: var(--text2); font-size: 12px; font-weight: 400; }
.core-lote-derecha { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.core-lote-id { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--core-plus-c3); }
:root[data-theme="dark"] .core-lote-id { color: var(--core-plus-c1); }

/* Menos aire entre las sugerencias (y el perfil) y el campo de texto. */
.portia-suggestions { padding-bottom: 4px; }

/* ── Apertura y cierre del chat (escritorio y tablet) ─────────────────────────
   Abrir: la forma sigue creciendo desde el botón (clip-path), pero ahora el panel además
   «aterriza» con un muelle (sube y crece un poco y se asienta) y su contenido entra en
   cascada: cabecera, mensajes, sugerencias una a una, campo de texto y aviso.
   Cerrar: el de siempre (el recorte se recoge en el botón). La versión con el panel encogiéndose
   dejaba un rectángulo blanco a medio cerrar; se retiró (nov 2026). Solo transform y opacity (GPU). */
@media (min-width: 641px) {
  .portia-panel { transform-origin: bottom right; }
  /* «backwards»: al terminar, el panel queda sin transform (no interfiere con el agua de Core+). */
  .portia-panel.open { animation: corePanelAterriza 0.7s var(--core-muelle) backwards; }

  /* Cascada del contenido al abrir. */
  .portia-panel.open .portia-header { animation: corePanelEntra 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.14s both; }
  .portia-panel.open .portia-messages { animation: corePanelEntra 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both; }
  .portia-panel.open .portia-suggestions > * { animation: corePanelEntra 0.45s cubic-bezier(0.22, 1, 0.36, 1) both; }
  .portia-panel.open .portia-suggestions > :nth-child(1) { animation-delay: 0.24s; }
  .portia-panel.open .portia-suggestions > :nth-child(2) { animation-delay: 0.29s; }
  .portia-panel.open .portia-suggestions > :nth-child(3) { animation-delay: 0.34s; }
  .portia-panel.open .portia-suggestions > :nth-child(4) { animation-delay: 0.39s; }
  .portia-panel.open .portia-input-area { animation: corePanelEntra 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both; }
  .portia-panel.open .portia-legal { animation: corePanelEntra 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.38s both; }
  /* El logo de la cabecera da un giro corto al llegar. */
  .portia-panel.open .portia-mark { animation: corePanelLogo 0.8s var(--core-muelle) 0.18s both; }
}

@keyframes corePanelAterriza {
  0%   { transform: translateY(14px) scale(0.92); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes corePanelEntra {
  from { opacity: 0; transform: translateY(10px); filter: blur(2px); }
  to   { opacity: 1; transform: none; filter: none; }
}
@keyframes corePanelLogo {
  from { transform: rotate(-120deg) scale(0.6); }
  to   { transform: none; }
}

