:root {
  --bg: #070b16;
  --panel: #10182b;
  --panel2: #0c1322;
  --me: #1e3a8a;
  --them: #243044;
  --text: #eef3ff;
  --muted: #9aa8c7;
  --accent: #60a5fa;
  --ok: #34d399;
  --bad: #f87171;
  --line: #1c2740;
  --side: 320px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}
body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #14213d 0%, var(--bg) 55%);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
.shell {
  display: grid;
  grid-template-columns: var(--side) 1fr;
  height: 100vh;
  height: 100dvh;
  max-width: 1400px;
  margin: 0 auto;
  overflow: hidden;
}
.mobile-only { display: none; }
.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(8, 12, 24, 0.96);
  padding: 14px 12px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.brand-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
}
.brand p {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel h2 {
  margin: 0;
  font-size: 0.8rem;
  color: #dbe7ff;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.3;
}
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}
input, select, textarea, button { font: inherit; }
input, select, textarea {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 16px; /* evita zoom iOS */
  width: 100%;
  min-width: 0;
}
textarea {
  resize: none;
  min-height: 44px;
  max-height: 110px;
  line-height: 1.3;
}
.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.actions { display: flex; gap: 8px; }
.actions button { flex: 1; }
button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #04101f;
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
  min-height: 42px;
}
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 600;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 12px;
  background: #152038;
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.75rem;
  border: 1px solid var(--line);
  width: fit-content;
  max-width: 100%;
}
.pill.on { color: var(--ok); border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.08); }
.pill.off { color: var(--bad); border-color: rgba(248,113,113,.35); background: rgba(248,113,113,.08); }
.people-box {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel2);
  padding: 8px;
}
.people-list { display: flex; flex-direction: column; gap: 6px; }
.person {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  background: rgba(16,24,43,.8);
  font-size: 0.8rem;
}
.person .left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.person .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(52,211,153,.15);
  flex: 0 0 auto;
}
.person .name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 650;
}
.person .tag {
  font-size: 0.68rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px; flex: 0 0 auto;
}
.person.me {
  border-color: rgba(96,165,250,.55);
  background: rgba(30,58,138,.28);
}
.people-empty { color: var(--muted); font-size: 0.76rem; padding: 6px 2px; }
.people-count { color: var(--muted); font-size: 0.7rem; }
.voice-meta { color: var(--muted); font-size: 0.72rem; }
.voice-list {
  max-height: 220px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}
.voice-item {
  text-align: left;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 500;
  font-size: 0.78rem;
  line-height: 1.25;
  min-height: 44px;
}
.voice-item small {
  display: block; color: var(--muted); font-size: 0.7rem; margin-top: 2px; font-weight: 400;
}
.voice-item.active {
  border-color: rgba(96,165,250,.7);
  box-shadow: 0 0 0 1px rgba(96,165,250,.25) inset;
  background: rgba(30,58,138,.35);
}
.health {
  margin-top: auto;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
  padding-top: 4px;
  word-break: break-word;
}
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  height: 100dvh;
  padding: 12px;
  gap: 8px;
  overflow: hidden;
}
.topbar {
  display: none;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.topbar-info { min-width: 0; flex: 1; }
.topbar-title { font-weight: 750; font-size: 0.95rem; }
.topbar-sub {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-people {
  min-width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(16,24,43,.8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #cfe0ff;
}
.chat {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: rgba(10, 15, 28, 0.55);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.row { display: flex; }
.row.me { justify-content: flex-end; }
.row.them { justify-content: flex-start; }
.bubble {
  max-width: min(720px, 88%);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--them);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.row.me .bubble { background: var(--me); }
.bubble .who {
  font-size: 0.7rem; color: #c7d7ff; margin-bottom: 4px; font-weight: 700;
}
.bubble .raw, .bubble .fix {
  font-size: 0.75rem; color: #b7c5e6; margin-bottom: 3px;
}
.bubble .out { font-size: 0.98rem; line-height: 1.35; }
.bubble .meta { margin-top: 6px; font-size: 0.68rem; color: #8ea0c7; }
.typing {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0 2px;
}
.hidden { display: none !important; }
.bottom {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
}
.mode-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.live-hint {
  color: var(--muted);
  font-size: 0.72rem;
  padding: 0 2px;
  line-height: 1.25;
}
.composer {
  display: grid;
  grid-template-columns: 1fr 84px;
  gap: 8px;
  align-items: end;
}
.mic, .live {
  width: 100%;
  font-size: 0.88rem;
  font-weight: 700;
  background: #1d2a44;
  color: var(--text);
}
.live {
  background: #123524;
  border: 1px solid rgba(52,211,153,.35);
  color: #d1fae5;
}
.live.on {
  background: #065f46;
  animation: pulse 1.2s infinite;
  box-shadow: 0 0 0 1px rgba(52,211,153,.35) inset;
}
.mic.rec {
  background: #7f1d1d;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(248,113,113,.45); }
  70% { box-shadow: 0 0 0 12px rgba(248,113,113,0); }
  100% { box-shadow: 0 0 0 0 rgba(248,113,113,0); }
}
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 40;
}

/* ===== MOBILE ===== */
@media (max-width: 900px) {
  .mobile-only { display: inline-flex; }
  .shell {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(88vw, 340px);
    max-width: 100%;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform .2s ease;
    border-right: 1px solid var(--line);
    padding-top: calc(12px + var(--safe-t));
    padding-bottom: calc(12px + var(--safe-b));
    padding-left: calc(12px + var(--safe-l));
    padding-right: 12px;
    box-shadow: 12px 0 30px rgba(0,0,0,.35);
  }
  .sidebar.open { transform: translateX(0); }
  .backdrop[hidden] { display: none !important; }
  .backdrop:not([hidden]) { display: block; }
  .main {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: calc(8px + var(--safe-t)) 10px calc(8px + var(--safe-b));
    gap: 6px;
  }
  .topbar { display: flex; }
  .chat {
    border-radius: 14px;
    padding: 10px;
    gap: 8px;
  }
  .bubble {
    max-width: 92%;
    padding: 9px 10px;
  }
  .bubble .out { font-size: 0.95rem; }
  .mode-bar { gap: 6px; }
  .mic, .live {
    min-height: 46px;
    font-size: 0.86rem;
    padding: 8px 6px;
  }
  .composer { grid-template-columns: 1fr 76px; gap: 6px; }
  .composer button { min-height: 46px; }
  .voice-list { max-height: 160px; }
  .people-box { max-height: 140px; overflow: auto; }
  .health { font-size: 0.65rem; }
}

@media (max-width: 380px) {
  .mic, .live { font-size: 0.8rem; }
  .composer { grid-template-columns: 1fr 68px; }
  .topbar-title { font-size: 0.9rem; }
}
