* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0b0b12;
  --panel: #14141f;
  --bubble-me: #2b3a67;
  --bubble-ia: #1c1c2a;
  --text: #e8e8f0;
  --muted: #8a8aa0;
  --accent: #7c5cff;
  --accent2: #ff5c8a;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--panel);
  border-bottom: 1px solid #26263a;
  flex: 0 0 auto;
}

.hdr-left { display: flex; align-items: center; gap: 12px; }

.orb {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #a48cff, var(--accent) 40%, #2a1f66);
  box-shadow: 0 0 18px rgba(124, 92, 255, .8), inset 0 0 12px rgba(255,255,255,.25);
  animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 14px rgba(124,92,255,.7), inset 0 0 12px rgba(255,255,255,.25); }
  50% { transform: scale(1.08); box-shadow: 0 0 26px rgba(255,92,138,.9), inset 0 0 16px rgba(255,255,255,.4); }
}

.titles { display: flex; flex-direction: column; line-height: 1.2; }
.name { font-weight: 700; font-size: 18px; letter-spacing: .5px; }
.status { font-size: 12px; color: var(--muted); }
.status.ok { color: #5fd68a; }

#resetBtn {
  background: none;
  border: 1px solid #2f2f45;
  color: var(--muted);
  font-size: 18px;
  width: 34px; height: 34px;
  border-radius: 10px;
  cursor: pointer;
}
#resetBtn:active { background: #26263a; }

main#chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.msg.user {
  align-self: flex-end;
  background: var(--bubble-me);
  border-bottom-right-radius: 4px;
}
.msg.ia {
  align-self: flex-start;
  background: var(--bubble-ia);
  border: 1px solid #2a2a3d;
  border-bottom-left-radius: 4px;
}

.chips {
  display: flex;
  gap: 8px;
  padding: 0 14px 10px;
  overflow-x: auto;
  flex: 0 0 auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid #2e2e46;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.chips button:active { border-color: var(--accent); color: var(--text); }

footer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid #26263a;
  flex: 0 0 auto;
}

textarea#input {
  flex: 1;
  resize: none;
  background: #0f0f18;
  border: 1px solid #2e2e46;
  border-radius: 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 11px 14px;
  max-height: 120px;
  outline: none;
}
textarea#input:focus { border-color: var(--accent); }

#sendBtn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  color: white;
  width: 46px; height: 46px;
  border-radius: 14px;
  font-size: 18px;
  cursor: pointer;
  flex: 0 0 auto;
}
#sendBtn:active { transform: scale(.94); }
#sendBtn:disabled { opacity: .4; }

.typing {
  position: fixed;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bubble-ia);
  border: 1px solid #2a2a3d;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.typing[hidden] { display: none; }
.typing span {
  width: 5px; height: 5px;
  background: var(--muted);
  border-radius: 50%;
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,100% { opacity: .2 } 50% { opacity: 1 } }
