:root {
  --brand: #00b2a9;       /* turquesa ABANCA */
  --brand-dark: #008e87;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1b2733;
  --ink-soft: #5b6b7a;
  --bot: #eef4f5;
  --user: #00b2a9;
  --user-ink: #ffffff;
  --line: #e3e8ee;
  --danger: #e2483d;
  --shadow: 0 6px 24px rgba(20, 40, 60, 0.08);
}

* { box-sizing: border-box; }

/* El atributo [hidden] debe ocultar siempre, aunque la clase declare display. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app {
  max-width: 760px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  box-shadow: var(--shadow);
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #fbfcfd);
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--brand); display: inline-block; align-self: center;
}
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: .5px; }
.brand-sub { color: var(--ink-soft); font-size: 13px; }
.topbar-actions { display: flex; gap: 8px; }

.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand-dark); }
.chip[aria-pressed="false"] { color: var(--ink-soft); }
.chip.ghost { color: var(--ink-soft); }

/* Selector de idioma (reutiliza el aspecto de .chip) */
.lang-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%235b6b7a' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* Chat */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.msg { display: flex; max-width: 82%; }
.msg .bubble {
  padding: 11px 15px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 15.5px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.bot { align-self: flex-start; }
.msg.bot .bubble {
  background: var(--bot);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.msg.user { align-self: flex-end; }
.msg.user .bubble {
  background: var(--user);
  color: var(--user-ink);
  border-bottom-right-radius: 4px;
}

/* Texto aclaratorio: se muestra en otro color y NO se lee en voz alta */
.bubble .aclaracion {
  display: block;
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-style: italic;
  border-left: 3px solid var(--line);
  padding-left: 8px;
}

/* typing */
.typing .bubble { display: flex; gap: 4px; align-items: center; }
.typing .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ink-soft);
  opacity: .4; animation: blink 1.2s infinite;
}
.typing .dot:nth-child(2) { animation-delay: .2s; }
.typing .dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity:.3 } 40% { opacity:1 } }

/* status */
.status {
  text-align: center; color: var(--ink-soft);
  font-size: 13px; padding: 6px;
}
.status.rec { color: var(--danger); font-weight: 600; }

/* Composer */
.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.text-input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 15px;
  outline: none;
}
.text-input:focus { border-color: var(--brand); }
.send {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: .15s;
}
.send:hover { background: var(--brand-dark); }
.send:disabled { opacity: .5; cursor: default; }

.mic {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: .15s;
  flex-shrink: 0;
}
.mic:hover { border-color: var(--brand); }
.mic.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(226,72,61,.5); }
  70% { box-shadow: 0 0 0 12px rgba(226,72,61,0); }
  100% { box-shadow: 0 0 0 0 rgba(226,72,61,0); }
}
.mic:disabled { opacity: .4; cursor: default; }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(15,30,45,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
}
.modal-box {
  background: #fff; border-radius: 14px;
  max-width: 640px; width: 100%; max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 17px; margin: 0; }
.modal-close { border: none; background: none; font-size: 26px; cursor: pointer; color: var(--ink-soft); line-height: 1; }
.legal-text {
  margin: 0; padding: 18px 20px; overflow-y: auto;
  white-space: pre-wrap; font-family: inherit; font-size: 14px;
  color: var(--ink-soft); line-height: 1.55;
}

@media (max-width: 480px) {
  .brand-sub { display: none; }
  .msg { max-width: 90%; }
}
