/* forte.sicaja.com/asistente: el chat de Sava Forte, a pantalla completa (copia del de Sicaja Go). Sin librerias externas.
   El acento es el cian de Sicaja de la portada de Forte (#00BAE8); con texto blanco no se lee, por eso los botones llevan texto oscuro.
   Las variables se siguen llamando --verde para no tocar el resto de la hoja. */
:root {
  --verde: #00bae8; --verde-osc: #0077a3; --verde-suave: #e0f6fd;
  --fondo: #ffffff; --fondo-2: #f6f7f9; --lateral: #f3f5f7; --tarjeta: #ffffff;
  --texto: #1b2230; --tenue: #5b6474; --linea: #e3e7ec; --linea-2: #d3d9e0;
  --burbuja: #eef1f4; --codigo: #f1f3f6; --enlace: #0077a3; --sombra: 0 6px 24px rgba(16, 24, 40, .08);
  --peligro: #b42318;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --verde: #22c7f2; --verde-osc: #7fdcf7; --verde-suave: #0f2731;
    --fondo: #0f1115; --fondo-2: #15181e; --lateral: #13161b; --tarjeta: #181b21;
    --texto: #e6e9ee; --tenue: #9aa3b2; --linea: #262b33; --linea-2: #333a44;
    --burbuja: #22262e; --codigo: #1d2128; --enlace: #7fdcf7; --sombra: 0 6px 24px rgba(0, 0, 0, .35);
    --peligro: #f97066;
    color-scheme: dark;
  }
}
:root[data-tema="oscuro"] {
  --verde: #22c7f2; --verde-osc: #7fdcf7; --verde-suave: #0f2731;
  --fondo: #0f1115; --fondo-2: #15181e; --lateral: #13161b; --tarjeta: #181b21;
  --texto: #e6e9ee; --tenue: #9aa3b2; --linea: #262b33; --linea-2: #333a44;
  --burbuja: #22262e; --codigo: #1d2128; --enlace: #7fdcf7; --sombra: 0 6px 24px rgba(0, 0, 0, .35);
  --peligro: #f97066;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--fondo); color: var(--texto); font-size: 16px; line-height: 1.6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--enlace); }
button { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.salto { position: absolute; left: -999px; top: 8px; background: var(--tarjeta); padding: 8px 12px; z-index: 100; border-radius: 8px; }
.salto:focus { left: 8px; }
.oculto-visual { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--verde); outline-offset: 2px; }

.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ── lateral ── */
.lateral {
  width: 272px; flex: none; background: var(--lateral); border-right: 1px solid var(--linea);
  display: flex; flex-direction: column; padding: 14px 12px; gap: 10px; min-height: 0;
}
.lateral-cabeza { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 6px; }
.marca img { height: 32px; width: auto; display: block; }
:root[data-tema="oscuro"] .marca img, :root:not([data-tema="claro"]) .marca img { border-radius: 8px; }
@media (prefers-color-scheme: dark) { :root:not([data-tema="claro"]) .marca img { background: #fff; padding: 3px 6px; } }
:root[data-tema="oscuro"] .marca img { background: #fff; padding: 3px 6px; }
.nueva {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--linea-2); background: var(--tarjeta); font-weight: 600; font-size: 15px;
}
.nueva:hover { border-color: var(--verde); }
.historial { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 2px; margin: 4px -4px; padding: 0 4px; }
.historial h4 { margin: 12px 8px 4px; font-size: 12px; font-weight: 600; color: var(--tenue); text-transform: uppercase; letter-spacing: .04em; }
.historial .item { display: flex; align-items: center; border-radius: 10px; }
.historial .item:hover, .historial .item.activa { background: var(--burbuja); }
.historial .item a {
  flex: 1; min-width: 0; padding: 8px 10px; color: var(--texto); text-decoration: none; font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.historial .item button { visibility: hidden; border: 0; background: none; padding: 6px; margin-right: 4px; border-radius: 8px; cursor: pointer; color: var(--tenue); }
.historial .item:hover button, .historial .item.activa button, .historial .item button:focus-visible { visibility: visible; }
.historial .item button:hover { color: var(--peligro); }
.historial .item button svg { width: 16px; height: 16px; }
.historial .vacio { color: var(--tenue); font-size: 14px; padding: 8px 10px; }
.lateral-pie { border-top: 1px solid var(--linea); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.lateral-pie a, .enlace-boton {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; color: var(--texto); text-decoration: none;
  font-size: 14.5px; border: 0; background: none; cursor: pointer; text-align: left;
}
.lateral-pie a:hover, .enlace-boton:hover { background: var(--burbuja); }
.lateral-pie svg { width: 18px; height: 18px; color: var(--tenue); }
.enlace-boton { color: var(--tenue); font-size: 13.5px; }
.velo { display: none; }

/* ── principal ── */
.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--fondo); }
.cabeza {
  display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--linea); flex: none;
}
.titulo { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.titulo h1 { font-size: 16.5px; margin: 0; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.punto { width: 9px; height: 9px; border-radius: 50%; background: var(--verde); box-shadow: 0 0 0 3px var(--verde-suave); flex: none; }
.punto.apagado { background: #a3a9b3; box-shadow: none; }
.acciones-cabeza { display: flex; gap: 4px; }
.icono {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 0; background: none; cursor: pointer; color: var(--tenue);
}
.icono:hover { background: var(--burbuja); color: var(--texto); }
.icono .luna { display: none; }
:root[data-tema="oscuro"] .icono .sol { display: none; }
:root[data-tema="oscuro"] .icono .luna { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) .icono .sol { display: none; }
  :root:not([data-tema="claro"]) .icono .luna { display: block; }
}
.solo-movil { display: none; }

.conversacion { flex: 1; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.mensajes, .bienvenida { max-width: 780px; margin: 0 auto; padding: 0 20px; }
.mensajes { padding-bottom: 28px; }

/* bienvenida */
.bienvenida { padding-top: 7vh; padding-bottom: 24px; text-align: center; }
.bienvenida .logo-grande { width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 10px; display: block; }
.bienvenida h2 { font-size: clamp(24px, 4vw, 32px); line-height: 1.2; margin: 6px 0 8px; letter-spacing: -.01em; }
.bienvenida > p { color: var(--tenue); max-width: 560px; margin: 0 auto 26px; }
.preparando { max-width: 560px; margin: -10px auto 22px; padding: 10px 14px; border-radius: 12px; background: var(--verde-suave); font-size: 14.5px; }
.grupos { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; text-align: left; }
.grupo { display: flex; flex-direction: column; gap: 8px; }
.grupo h3 { font-size: 13px; font-weight: 600; margin: 0 2px 2px; color: var(--tenue); text-transform: uppercase; letter-spacing: .04em; }
.sugerencia {
  text-align: left; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--linea-2); background: var(--tarjeta); cursor: pointer;
  font-size: 15px; line-height: 1.35; transition: border-color .15s, background .15s;
}
.sugerencia:hover { border-color: var(--verde); background: var(--fondo-2); }

/* mensajes */
.msj { display: flex; gap: 14px; padding: 18px 0 4px; }
.msj.usuario { justify-content: flex-end; }
.msj.usuario .cuerpo {
  background: var(--burbuja); padding: 10px 16px; border-radius: 18px 18px 4px 18px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere;
}
.avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; margin-top: 2px;
  background: var(--verde); color: #0d1929; font-weight: 800; font-size: 13px; letter-spacing: -.02em;
}
.msj.asistente .cuerpo { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.3; margin: 18px 0 8px; }
.md h1 { font-size: 21px; } .md h2 { font-size: 19px; } .md h3 { font-size: 17px; } .md h4 { font-size: 16px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 24px; }
.md li { margin: 3px 0; }
.md li > ul, .md li > ol { margin: 4px 0; }
.md code { background: var(--codigo); border: 1px solid var(--linea); border-radius: 6px; padding: 1px 6px; font-size: .9em;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.md pre { background: var(--codigo); border: 1px solid var(--linea); border-radius: 10px; padding: 12px 14px; overflow-x: auto; margin: 0 0 12px; }
.md pre code { border: 0; padding: 0; background: none; }
.md blockquote { margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--verde); color: var(--tenue); }
.md hr { border: 0; border-top: 1px solid var(--linea); margin: 16px 0; }
.md .tabla { overflow-x: auto; margin: 0 0 12px; border: 1px solid var(--linea); border-radius: 10px; }
.md table { border-collapse: collapse; width: 100%; font-size: 15px; overflow-wrap: normal; word-break: normal; }
.md th { white-space: nowrap; }
.md th, .md td { padding: 8px 12px; border-bottom: 1px solid var(--linea); text-align: left; vertical-align: top; }
.md th { background: var(--fondo-2); font-weight: 600; }
.md tr:last-child td { border-bottom: 0; }
.md a { text-underline-offset: 2px; }
.md a.manual {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--linea-2); background: var(--fondo-2); font-size: 14.5px; line-height: 1.5; margin: 2px 0;
}
.md a.manual::before { content: ""; width: 14px; height: 14px; flex: none; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z'/%3E%3Cpath d='M4 21V5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z'/%3E%3Cpath d='M4 21V5'/%3E%3C/svg%3E") center / contain no-repeat; }
.md a.manual:hover { border-color: var(--verde); }

/* trabajando */
.estado { display: inline-flex; align-items: center; gap: 10px; color: var(--tenue); font-size: 14.5px; padding: 2px 0 8px; }
.puntos { display: inline-flex; gap: 4px; }
.puntos i { width: 6px; height: 6px; border-radius: 50%; background: var(--tenue); animation: salto 1.2s infinite ease-in-out; }
.puntos i:nth-child(2) { animation-delay: .15s; } .puntos i:nth-child(3) { animation-delay: .3s; }
@keyframes salto { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .puntos i { animation: none; } }
.cursor::after { content: "▍"; color: var(--verde); margin-left: 1px; animation: parpadeo 1s steps(1) infinite; }
@keyframes parpadeo { 50% { opacity: 0; } }

.herramientas-msj { display: flex; align-items: center; gap: 2px; margin: 6px 0 0 -6px; }
.herramientas-msj button {
  border: 0; background: none; color: var(--tenue); padding: 6px; border-radius: 8px; cursor: pointer; display: inline-grid; place-items: center;
}
.herramientas-msj button:hover { background: var(--burbuja); color: var(--texto); }
.herramientas-msj button.marcado { color: var(--verde-osc); }
.herramientas-msj svg { width: 17px; height: 17px; }
.herramientas-msj .nota { font-size: 13px; color: var(--tenue); margin-left: 6px; }
.siguientes { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; }
.siguientes button {
  border: 1px solid var(--linea-2); background: var(--tarjeta); border-radius: 999px; padding: 6px 13px; font-size: 14.5px; cursor: pointer; text-align: left;
}
.siguientes button:hover { border-color: var(--verde); }
.error-msj { color: var(--peligro); background: color-mix(in srgb, var(--peligro) 8%, transparent); border-radius: 10px; padding: 10px 14px; margin-top: 6px; }
.error-msj button { margin-left: 8px; border: 1px solid currentColor; background: none; color: inherit; border-radius: 8px; padding: 2px 10px; cursor: pointer; }

/* ── escribir ── */
.redactar { flex: none; padding: 8px 20px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: var(--fondo); }
.caja {
  max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 16px;
  border: 1px solid var(--linea-2); border-radius: 22px; background: var(--tarjeta); box-shadow: var(--sombra);
}
.caja:focus-within { border-color: var(--verde); }
.caja textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: none; color: var(--texto); font: inherit; font-size: 16px; line-height: 1.5;
  padding: 7px 0; max-height: 200px; min-height: 24px;
}
.caja textarea::placeholder { color: var(--tenue); }
.enviar {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--verde); color: #0d1929; cursor: pointer; display: grid; place-items: center; flex: none;
}
.enviar svg { stroke-width: 2.4; }
.enviar:disabled { background: var(--linea-2); color: var(--tenue); cursor: default; }
.enviar.detener { background: var(--texto); color: var(--fondo); }
.enviar.detener svg { fill: currentColor; stroke: none; }
.aviso { max-width: 780px; margin: 8px auto 0; font-size: 12.5px; line-height: 1.45; color: var(--tenue); text-align: center; }
.aviso a { color: var(--tenue); }

/* ── celular ── */
@media (max-width: 860px) {
  .solo-movil { display: inline-grid; }
  .lateral {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(300px, 86vw); transform: translateX(-102%);
    transition: transform .22s ease; box-shadow: var(--sombra);
  }
  .lateral.abierta { transform: none; }
  .velo { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30; }
  .velo[hidden] { display: none; }
  .cabeza { padding: 0 8px; }
  .titulo h1 { font-size: 16px; }
  .mensajes, .bienvenida { padding: 0 16px; }
  .redactar { padding-left: 12px; padding-right: 12px; }
  .grupos { grid-template-columns: 1fr; }
  .bienvenida { padding-top: 4vh; }
  .bienvenida > p { font-size: 15px; margin-bottom: 18px; }
  .msj { gap: 10px; }
  .msj.usuario .cuerpo { max-width: 90%; }
  .avatar { width: 26px; height: 26px; font-size: 12px; }
  .aviso { font-size: 11.5px; }
  .historial .item button { visibility: visible; }
}
