:root {
  /* Paleta del logo de Galeb */
  --navy-deep: #00306B;
  --navy: #0054A6;
  --ice: #BFE3FF;
  --ice-soft: #EAF4FD;
  --accent: #00A8FF;
  --white: #FFFFFF;
  --muted: #7C93B5;
  --ink: #0B2447;
  --danger: #B3261E;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Montserrat', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--navy-deep);
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Ingreso ---------- */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background: radial-gradient(120% 80% at 50% 0%, var(--navy) 0%, var(--navy-deep) 70%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border-radius: 20px;
  padding: 28px 22px 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { width: 56px; height: 56px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--navy); }
.brand h1 { font-family: var(--font-display); font-weight: 700; font-size: 32px; line-height: 1; letter-spacing: -.01em; margin: 0; color: var(--navy-deep); }
.tagline { margin: 10px 0 22px; color: #46597A; }

label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--navy-deep); }
.login input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid #B9CCE6;
  border-radius: 12px;
  background: var(--white);
}
.login input:focus { border-color: var(--navy); outline: none; box-shadow: 0 0 0 3px var(--ice); }
#code { font-size: 26px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.hint { font-size: 13.5px; color: #46597A; margin: 8px 0 0; overflow-wrap: anywhere; }
.form-error { font-size: 14px; color: var(--danger); margin: 10px 0 0; font-weight: 500; }

.primary {
  width: 100%;
  margin-top: 18px;
  padding: 14px 16px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--navy-deep);
  font-weight: 600;
}
.primary:disabled { opacity: .6; cursor: default; }
.secondary {
  width: 100%;
  margin-top: 10px;
  padding: 12px 16px;
  border: 1.5px solid var(--navy);
  border-radius: 12px;
  background: var(--white);
  color: var(--navy);
  font-weight: 600;
}
.login-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.link { background: none; border: 0; padding: 6px 0; color: var(--navy); text-decoration: underline; font-size: 14px; }
.link:disabled { color: var(--muted); text-decoration: none; cursor: default; }

/* ---------- Chat ---------- */
.chat {
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--ice-soft);
}
.chat-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 10px 10px 14px;
  background: var(--navy-deep);
  color: var(--white);
}
.chat-header img { flex: none; }
.chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.chat-title strong { font-family: var(--font-display); font-weight: 700; font-size: 19px; }
.chat-title span { font-size: 13px; color: var(--ice); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-button {
  flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; color: var(--white); display: grid; place-items: center;
}
.icon-button svg, .send svg { fill: currentColor; }
.icon-button:hover { background: rgba(255, 255, 255, .12); }

.menu {
  position: absolute; top: calc(100% - 4px); right: 10px; z-index: 5;
  width: min(300px, calc(100vw - 20px));
  background: var(--white); color: var(--ink);
  border-radius: 14px; padding: 8px;
  box-shadow: 0 12px 34px rgba(10, 35, 68, .3);
}
.menu button {
  display: block; width: 100%; text-align: left; padding: 12px;
  border: 0; border-radius: 10px; background: none; color: var(--ink);
}
.menu button:hover { background: var(--ice-soft); }
.menu-email { margin: 0; padding: 10px 12px 8px; font-size: 13px; color: #46597A; overflow-wrap: anywhere; border-bottom: 1px solid var(--ice-soft); }
.menu-note { margin: 0; padding: 10px 12px; font-size: 13px; color: #46597A; }

.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.empty { margin: auto; color: #46597A; text-align: center; padding: 24px; }

.bubble {
  max-width: min(86%, 560px);
  padding: 9px 12px 6px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(10, 35, 68, .08);
}
.bubble a { color: inherit; text-decoration: underline; font-weight: 500; }
.bubble time { display: block; margin-top: 2px; font-size: 11px; text-align: right; opacity: .65; }
.bubble.out { align-self: flex-start; background: var(--white); border-bottom-left-radius: 5px; }
.bubble.in { align-self: flex-end; background: var(--navy); color: var(--white); border-bottom-right-radius: 5px; }
.bubble.pending { opacity: .7; }
.bubble.failed { background: #FBE9E7; color: var(--danger); cursor: pointer; }

.typing { align-self: flex-start; background: var(--white); border-radius: 16px; border-bottom-left-radius: 5px; padding: 13px 14px; display: flex; gap: 5px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; opacity: .6; } }

.push-card {
  margin: 0 10px 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--white);
  border: 1.5px solid var(--ice);
  box-shadow: 0 2px 8px rgba(0, 48, 107, .08);
}
.push-card p { margin: 0; font-size: 14.5px; }
.ios-steps { margin: 8px 0 0; padding-left: 22px; font-size: 14.5px; }
.ios-steps li { margin: 4px 0; }
.share-icon { fill: #007AFF; vertical-align: -3px; margin-left: 2px; }
.chrome-card {
  margin: 0 10px 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #FFF8E6;
  border: 1.5px solid #F2D58A;
  color: #4A3500;
}
.chrome-card p { margin: 0; font-size: 14.5px; }
.login .chrome-card { margin: 0 0 18px; }
.login .chrome-card .chrome-link { margin-top: 10px; }
a.primary { display: inline-block; text-align: center; text-decoration: none; }
.push-card-actions { display: flex; justify-content: flex-end; align-items: center; gap: 16px; margin-top: 10px; }
.primary.small { width: auto; margin-top: 0; padding: 9px 18px; font-size: 14.5px; }
.menu button:disabled { color: var(--muted); cursor: default; background: none; }

.banner { margin: 0; padding: 8px 14px; font-size: 13.5px; background: #FFF3D6; color: #5A3B00; text-align: center; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  background: var(--white);
  border-top: 1px solid #D3E2F3;
}
.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 140px;
  padding: 11px 14px;
  border: 1.5px solid #B9CCE6;
  border-radius: 22px;
  background: var(--white);
  line-height: 1.35;
}
.composer textarea:focus { border-color: var(--navy); outline: none; }
.send {
  flex: none; width: 46px; height: 46px; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--navy-deep); display: grid; place-items: center;
}
.send:disabled { background: #D3E2F3; color: var(--muted); cursor: default; }
.recorder { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.icon-button.dark { color: var(--muted); }
.icon-button.dark:hover { background: var(--ice-soft); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #E5383B; flex: none; animation: blink 1.2s infinite both; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.rec-hint { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }
