: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; }

/* El atributo `hidden` del HTML se apoya en una regla `display:none` de la hoja
   del NAVEGADOR, así que cualquier regla propia que fije `display` —y aquí hay
   varias: .modal, label, .bio-btn, .adjuntos— se la come y el elemento sigue
   viéndose. Pasó de verdad: el aviso de la cámara salía al entrar en la web y el
   botón Cancelar no lo cerraba, porque ponía `hidden` pero el CSS lo seguía
   pintando. Esta regla tiene que ir ANTES que las demás y con `!important`. */
[hidden] { display: none !important; }
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; }

/* Casilla de "confiar en este dispositivo" */
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; }
.trusted-note { color: var(--accent); margin: 12px 0 0; }

/* Entrar con biometría: acción principal cuando está disponible. */
.bio-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin: 12px 0 0; padding: 12px;
  background: var(--panel-2); border: 1px solid var(--accent);
  color: var(--accent); font-size: 15px; font-weight: 500;
}
.bio-btn:hover { background: rgba(55, 208, 166, .1); }

/* Acción destructiva: en rojo, pequeña y al final. Discreta a propósito, para
   que nadie la pulse por descuido, pero siempre localizable. */
.danger-link {
  display: block; width: 100%; margin: 14px 0 0; padding: 8px;
  background: none; border: 0; color: var(--error);
  font-size: 12px; font-weight: 400; opacity: .75; cursor: pointer;
}
.danger-link:hover { opacity: 1; text-decoration: underline; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 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);
}
.audio { width: 100%; min-width: 220px; height: 40px; display: block; }
.attach.grabando {
  border-color: var(--error); color: var(--error);
  animation: latido 1.1s ease-in-out infinite;
}
@keyframes latido { 50% { opacity: .45; } }

.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; }
.privacy {
  margin: 10px auto 0; max-width: 44ch; font-size: 11px; line-height: 1.45;
  color: var(--muted); opacity: .85; text-align: center;
}

/* Campo del código + botón de cámara */
.totp-row { display: flex; gap: 8px; align-items: stretch; }
.totp-row input { flex: 1; }
.scan {
  flex: 0 0 auto; padding: 0 14px; font-size: 18px; line-height: 1;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}
.scan:hover { border-color: var(--accent); }

/* Visor de la cámara */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .82);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; width: 100%; max-width: 420px; text-align: center;
}
.modal-title { margin: 0 0 12px; font-size: 14px; }
.modal-box video {
  width: 100%; max-height: 60vh; border-radius: 12px;
  background: #000; object-fit: cover; display: block;
}
.modal-msg { min-height: 18px; margin: 10px 0 4px; font-size: 12px; color: var(--muted); }
.modal-note {
  margin: 0 0 10px; font-size: 12px; line-height: 1.5;
  color: var(--muted); text-align: left;
}
.modal-acciones { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.modal-acciones .link { flex: 0 0 auto; }
.modal-acciones button[id="scan-aceptar"] { flex: 1; padding: 11px; font-size: 14px; }
