:root {
  --bg: #0c0f24;
  --bg2: #141a3a;
  --card: #1c2350;
  --accent: #8a5cff;     /* violeta aurora */
  --accent2: #2fd6e8;    /* cian aurora */
  --text: #eef2fb;
  --muted: #9aa6d0;
  --user: #5a3fd6;
  --bot: #1f2752;
  --ok: #2ecc71;
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(120% 80% at 50% -10%, #1a2746 0%, var(--bg) 55%);
  color: var(--text);
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
}

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: linear-gradient(180deg, rgba(20,29,51,.95), rgba(20,29,51,.6));
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 46px; height: 46px; border-radius: 14px; object-fit: cover;
  box-shadow: 0 6px 18px rgba(138,92,255,.45);
  border: 1.5px solid rgba(47,214,232,.4);
}
.brand h1 { font-size: 19px; margin: 0; letter-spacing: .2px; }
.status { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.status.live { color: var(--accent); }
.status.thinking { color: var(--accent2); }

.icon-btn {
  background: rgba(255,255,255,.06); border: none; color: var(--text);
  width: 42px; height: 42px; border-radius: 12px; font-size: 18px; cursor: pointer;
}
.icon-btn.small { width: 46px; height: 46px; font-size: 20px; }
.icon-btn:active { transform: scale(.94); }

/* ---- Chat ---- */
.chat {
  flex: 1; overflow-y: auto; padding: 18px 14px 8px;
  display: flex; flex-direction: column; gap: 12px;
}
.msg {
  max-width: 82%; padding: 11px 14px; border-radius: 16px; line-height: 1.45;
  font-size: 15.5px; white-space: pre-wrap; word-wrap: break-word; animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 5px; }
.msg.bot  { align-self: flex-start; background: var(--bot); border-bottom-left-radius: 5px; }
.msg .tip {
  display: block; margin-top: 8px; padding-top: 8px; font-size: 13.5px;
  color: #ffd9a8; border-top: 1px dashed rgba(255,217,168,.3);
}
.msg .speak-again {
  margin-top: 6px; font-size: 12px; color: var(--muted); cursor: pointer;
  background: none; border: none; padding: 0;
}
.welcome { text-align: center; color: var(--muted); margin: auto 10px; font-size: 14px; line-height: 1.6; }
.welcome b { color: var(--text); }

.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2){ animation-delay: .2s } .typing span:nth-child(3){ animation-delay: .4s }
@keyframes blink { 0%,80%,100%{ opacity:.3 } 40%{ opacity:1 } }

/* ---- Interim (lo que el micro va captando) ---- */
.interim {
  margin: 0 14px; padding: 8px 14px; font-size: 14px; color: var(--accent);
  font-style: italic; opacity: .9;
}

/* ---- Composer ---- */
.composer {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(0deg, var(--bg2), rgba(20,29,51,0));
}
.mic {
  width: 60px; height: 60px; min-width: 60px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 22px rgba(138,92,255,.45); font-size: 26px; color: #fff;
  transition: transform .1s;
}
.mic:active { transform: scale(.92); }
.mic.listening { animation: pulse 1.2s infinite; background: linear-gradient(135deg, #ff4d4d, #ff7a3c); }
@keyframes pulse { 0%{ box-shadow: 0 0 0 0 rgba(255,77,77,.5) } 70%{ box-shadow: 0 0 0 16px rgba(255,77,77,0) } }

.text-form { flex: 1; display: flex; align-items: center; background: var(--card); border-radius: 26px; padding: 4px 4px 4px 16px; }
.text-form input {
  flex: 1; background: none; border: none; color: var(--text); font-size: 15px; outline: none; min-width: 0;
}
.text-form input::placeholder { color: var(--muted); }
.send {
  width: 42px; height: 42px; min-width: 42px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent2); color: #fff; font-size: 16px;
}
.send:active { transform: scale(.92); }

/* ---- Settings sheet ---- */
.sheet {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(5,9,18,.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-inner {
  width: 100%; max-width: 540px; max-height: 92dvh; overflow-y: auto;
  background: var(--bg2); border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px);
  animation: slideup .25s ease;
}
@keyframes slideup { from { transform: translateY(100%); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.field > span { font-size: 13.5px; color: var(--muted); }
.field input[type=text], .field input[type=password], .field select {
  background: var(--card); border: 1px solid rgba(255,255,255,.08); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font-size: 15px; outline: none; width: 100%;
}
.field small { font-size: 12px; color: var(--muted); }
.field small a { color: var(--accent2); }
.field.row { gap: 8px; }
.field.row input[type=range] { width: 100%; accent-color: var(--accent); }
.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.field.check span { color: var(--text); font-size: 14.5px; }

.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn { flex: 1; padding: 14px; border-radius: 14px; border: none; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--card); color: var(--muted); }
.btn:active { transform: scale(.97); }

[hidden] { display: none !important; }
