.back { text-decoration: none; }
.back:hover { color: var(--text); }

.intro .card-icon { --accent: var(--green); }

.chat-panel {
  margin-top: 16px;
  padding: 20px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Botones */
.btn {
  padding: 10px 18px;
  border: 1px solid var(--green);
  border-radius: 10px;
  background: var(--green);
  color: var(--bg);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-ghost {
  background: transparent;
  color: var(--green);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-link:hover { color: var(--text); }

.btn:focus-visible,
.btn-link:focus-visible,
input:focus-visible,
textarea:focus-visible,
.msg a:focus-visible,
.table-wrap:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* Campos */
input,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

textarea { resize: vertical; min-height: 64px; }

/* Acceso */
.access-form { max-width: 420px; }

.access-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.error-text {
  margin: 8px 0 0;
  color: var(--orange);
  font-size: 0.9rem;
}

/* Conversación */
.chat-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 280px;
  max-height: 60dvh;
  overflow-y: auto;
  padding: 16px 0;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
}

/* Texto plano: mensajes del usuario y errores */
.msg p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg a { color: var(--green); }

.msg .msg-action {
  display: inline-block;
  margin-top: 8px;
  font-weight: 600;
}

/* Respuestas del agente renderizadas desde Markdown (HTML sanitizado en chat.js) */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 8px; white-space: normal; }
.md h1, .md h2, .md h3, .md h4 { margin: 12px 0 6px; font-size: 1rem; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 20px; }
.md li + li { margin-top: 2px; }
.md strong { color: var(--text); }
/* Enlaces que DOMPurify dejó sin destino (no https): se muestran como texto */
.md a:not([href]) { color: inherit; }
.md code {
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--panel-2);
  font-family: var(--mono);
  font-size: 0.85em;
}
.md hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 4px 0 8px;
}

.md table {
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.md th,
.md td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.md th {
  color: var(--muted);
  font-weight: 500;
  border-bottom-color: var(--border-strong);
}

.msg-user {
  align-self: flex-end;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
}

.msg-bot {
  align-self: flex-start;
  border: 1px solid var(--border);
}

.msg-error {
  align-self: flex-start;
  border: 1px solid color-mix(in srgb, var(--orange) 50%, var(--border));
  color: var(--orange);
}

.msg-pending p { color: var(--muted); }

.composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

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

@media (max-width: 480px) {
  .msg { max-width: 100%; }
  .composer-actions .btn { flex: 1; }
}
