:root {
  --bg: #0b0f14;
  --panel: #131a23;
  --panel-2: #1b2430;
  --line: #26313f;
  --text: #e6edf3;
  --muted: #8aa0b4;
  --accent: #37d0a6;
  --accent-2: #2b9cff;
  --error: #ff6b6b;
  --me: #1f6feb;
  --them: #202a36;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #16202b 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  display: grid;
  place-items: start center;
  padding: 24px 16px;
}
.wrap { width: 100%; max-width: 520px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand-txt { flex: 1; }
.lang select {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; font-size: 13px; cursor: pointer;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px; color: #04140f;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.brand h1 { font-size: 20px; margin: 0; letter-spacing: .3px; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.card h2 { margin: 0 0 6px; font-size: 17px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
input:focus { border-color: var(--accent-2); }
button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04140f; font-weight: 600; border: 0;
  border-radius: 10px; padding: 12px; font-size: 15px; cursor: pointer;
}
button:disabled { opacity: .6; cursor: default; }
.link { background: none; color: var(--muted); padding: 4px 8px; font-weight: 400; }
.error { color: var(--error); font-size: 13px; margin: 4px 0 0; }

.chat-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.who { color: var(--accent); font-size: 13px; }
/* Ficha del agente (solo lectura) */
.agente { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.agente-head {
  width: 100%; display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); color: var(--text); border: 0;
  padding: 9px 11px; font-size: 13px; font-weight: 500; cursor: pointer; text-align: left;
}
.agente-head .chev { color: var(--muted); font-size: 11px; }
.agente-resumen { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
.agente-body { padding: 10px 12px 12px; }
.agente-body h3 {
  margin: 10px 0 5px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
}
.agente-body .ro { margin: 0; font-size: 11px; color: var(--accent); }
.lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.lista li { display: flex; align-items: center; gap: 7px; font-size: 13px; flex-wrap: wrap; }
.lista .tag {
  background: var(--them); color: var(--muted); border-radius: 5px;
  padding: 1px 6px; font-size: 11px;
}
.lista .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.lista .muted { color: var(--muted); font-size: 12px; }
.agente-body .pie { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

.messages {
  height: 46vh; min-height: 240px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 4px; margin-bottom: 12px;
}
.bubble {
  max-width: 78%; padding: 9px 12px; border-radius: 14px;
  white-space: pre-wrap; word-break: break-word; font-size: 14px;
}
.bubble.me { align-self: flex-end; background: var(--me); color: #fff; border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--them); border-bottom-left-radius: 4px; }
.send { flex-direction: row; gap: 8px; align-items: center; }
.send input { flex: 1; }
.send button { padding: 12px 18px; }
.attach {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 12px; font-size: 16px; line-height: 1; flex: 0 0 auto;
}
.attach:hover { border-color: var(--accent-2); }

/* Adjuntos pendientes de enviar */
.adjuntos { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 6px 4px 10px; font-size: 12px;
}
.chip-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-meta { color: var(--muted); font-size: 11px; }
.chip-x {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: 0 4px; font-size: 12px; line-height: 1;
}
.chip-x:hover { color: var(--error); }

/* Burbujas con fichero */
.bubble.file { max-width: 86%; display: flex; flex-direction: column; gap: 6px; }
.thumb {
  max-width: 100%; max-height: 260px; border-radius: 8px; display: block;
  background: var(--panel-2);
}
.file-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--muted); flex: 0 0 auto; }
.file-dl { margin-left: auto; color: var(--accent); flex: 0 0 auto; }
.bubble.me .file-size { color: rgba(255,255,255,.75); }
.bubble.me .file-dl { color: #fff; }

/* Soltar ficheros sobre el chat */
#chat.dropping { outline: 2px dashed var(--accent); outline-offset: 3px; }
.status { color: var(--muted); font-size: 12px; min-height: 16px; margin: 8px 0 0; }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; }
