:root {
  --brand-dark: #031F46;
  --brand-med:  #1D3960;
  --brand-cyan: #00EAFF;
  --brand-orange: #F7931E;
  --bg: #ffffff;
  --surface: #f5f7fa;
  --border: #d8dee8;
  --text: #1a2230;
  --muted: #5b6678;
  --danger: #c0392b;
  /* Chat estilo WhatsApp con tinte Trebe */
  --chat-bg: #e9eef4;
  --bubble-out: #d4f0ff;     /* saliente (lo mío) — cian claro */
  --bubble-in: #ffffff;      /* entrante (traducción del otro) */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  font-weight: 300;
  background: var(--bg);
  color: var(--text);
}

h1 { margin: 0; font-weight: 600; color: var(--brand-dark); font-size: 1.5rem; }
.sig-cyan { color: var(--brand-cyan); }
.h1-underline { width: 64px; height: 4px; background: var(--brand-orange); border-radius: 2px; margin: 0.45rem 0; }
.sub { color: var(--muted); font-weight: 200; margin: 0; }
.hint { font-size: 0.75rem; color: var(--muted); }

button { font-family: inherit; cursor: pointer; }
button.primary {
  background: var(--brand-dark); color: #fff; border: none; border-radius: 10px;
  padding: 0.65rem 1.4rem; font-size: 1rem; font-weight: 600; transition: background 0.15s;
}
button.primary:hover { background: #052a5e; }
button.primary.big { width: 100%; padding: 0.8rem; font-size: 1.05rem; }
button.secondary {
  background: transparent; color: var(--brand-med); border: 1.5px solid var(--border);
  border-radius: 9px; padding: 0.45rem 0.9rem; font-size: 0.88rem; font-weight: 500;
}
button.secondary:hover { border-color: var(--brand-med); }
button.secondary.small { padding: 0.35rem 0.7rem; font-size: 0.82rem; }

/* Cajas de texto con el MISMO estilo que los combos (select) */
select,
.setup-card input[type="text"],
.setup-card input[type="password"] {
  background: var(--bg); color: var(--text); border: 1.5px solid var(--border);
  border-radius: 9px; padding: 0.5rem 0.65rem; font-family: inherit; font-size: 0.95rem; font-weight: 300; width: 100%;
}
select:focus,
.setup-card input[type="text"]:focus,
.setup-card input[type="password"]:focus { outline: none; border-color: var(--brand-cyan); }
.setup-card input::placeholder { color: var(--muted); font-weight: 300; }

/* ───────────── Modal de configuración / conexión ───────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3, 31, 70, 0.5);
  display: flex; align-items: center; justify-content: center; padding: 1.2rem;
}
.modal-overlay[hidden] { display: none; }
.setup-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(3, 31, 70, 0.3);
  width: min(640px, 100%); max-height: 96vh; overflow-y: auto;
  padding: 1.6rem 1.8rem; display: flex; flex-direction: column; gap: 0.9rem;
}
.setup-head { margin-bottom: 0.2rem; }
/* Campos en dos columnas para que quepa todo sin scroll */
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem 1.1rem; }
@media (max-width: 520px) { .setup-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); font-weight: 400; }
.field[hidden] { display: none; } /* el display:flex anularía el atributo hidden */
.setup-status { margin: 0; font-size: 0.9rem; color: var(--brand-med); min-height: 1.2rem; text-align: center; }

.share-box {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand-orange);
  border-radius: 10px; padding: 0.7rem 0.9rem; display: flex; flex-direction: column; gap: 0.4rem;
}
.share-box[hidden] { display: none; }
.share-label { color: var(--brand-med); font-weight: 500; font-size: 0.85rem; }
.share-row { display: flex; gap: 0.5rem; align-items: center; }
.share-link { color: var(--brand-dark); font-weight: 500; text-decoration: none; word-break: break-all; flex: 1; font-size: 0.85rem; }
.share-link:hover { text-decoration: underline; }

/* ───────────── Chat ───────────── */
.chat { height: 100vh; display: flex; flex-direction: column; position: relative; }
.chat[hidden] { display: none; }

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 1rem; background: var(--brand-dark); color: #fff;
  border-bottom: 3px solid var(--brand-cyan);
}
.chat-peer { display: flex; align-items: center; gap: 0.7rem; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--brand-med);
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.peer-meta { display: flex; flex-direction: column; line-height: 1.2; }
.peer-name { font-weight: 600; font-size: 0.95rem; }
.peer-lang { font-size: 0.78rem; color: var(--brand-cyan); }
.chat-actions { display: flex; align-items: center; gap: 0.6rem; }
.hdr-lang {
  background: rgba(255,255,255,0.12); color: #fff; border: 1px solid rgba(255,255,255,0.35);
  border-radius: 8px; padding: 0.25rem 0.4rem; font-family: inherit; font-size: 0.78rem; font-weight: 400; width: auto;
}
.hdr-lang:focus { outline: none; border-color: var(--brand-cyan); }
.hdr-lang option { color: #1a2230; }
.status { font-size: 0.78rem; padding: 0.25rem 0.6rem; border-radius: 999px; border: 1.5px solid rgba(255,255,255,0.3); }
.status.ready { color: var(--brand-cyan); border-color: var(--brand-cyan); }
.status.warn { color: var(--brand-orange); border-color: var(--brand-orange); }
.icon-btn {
  background: rgba(255,255,255,0.12); border: none; color: #fff; width: 36px; height: 36px;
  border-radius: 50%; font-size: 1rem; display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255,255,255,0.22); }
.icon-btn.muted { background: var(--brand-orange); }
.icon-btn.danger:hover { background: var(--danger); }

.messages {
  flex: 1; overflow-y: auto; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.4rem;
  background-color: var(--chat-bg);
  background-image: radial-gradient(rgba(3,31,70,0.04) 1px, transparent 1px);
  background-size: 18px 18px;
}

.msg { display: flex; max-width: 78%; }
.msg.out { align-self: flex-end; }
.msg.in { align-self: flex-start; }
.bubble {
  position: relative; padding: 0.5rem 0.75rem 0.95rem; border-radius: 12px; font-size: 1rem;
  font-weight: 300; line-height: 1.4; box-shadow: 0 1px 1px rgba(3,31,70,0.12); word-wrap: break-word;
}
.msg.out .bubble { background: var(--bubble-out); border-top-right-radius: 3px; }
.msg.in .bubble { background: var(--bubble-in); border-top-left-radius: 3px; }
.bubble .meta { position: absolute; right: 0.6rem; bottom: 0.3rem; font-size: 0.62rem; color: var(--muted); }
.bubble .lang-tag {
  display: inline-block; font-size: 0.6rem; font-weight: 600; text-transform: uppercase;
  color: var(--brand-med); margin-bottom: 0.15rem; letter-spacing: 0.04em;
}
.msg.live .bubble { opacity: 0.72; font-style: italic; }
.msg.live .bubble .meta { content: '…'; }

.sys-msg {
  align-self: center; background: rgba(3,31,70,0.08); color: var(--brand-med);
  font-size: 0.78rem; padding: 0.25rem 0.7rem; border-radius: 999px; margin: 0.3rem 0;
}

.chat-foot { padding: 0.5rem 1rem; background: var(--surface); border-top: 1px solid var(--border); text-align: center; }
.mic-hint { font-size: 0.82rem; color: var(--muted); }
.mic-hint.muted { color: var(--brand-orange); }

.overlay {
  position: absolute; inset: 0; background: rgba(3,31,70,0.55);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.overlay[hidden] { display: none; }
.overlay-box {
  background: var(--bg); border-radius: 14px; padding: 1.6rem; text-align: center;
  max-width: 360px; display: flex; flex-direction: column; gap: 1rem;
}
.overlay-box p { margin: 0; color: var(--brand-dark); font-weight: 500; }
