:root {
  --bg: #0e1116;
  --bg-elev: #161b22;
  --bg-input: #1c232d;
  --line: #232b36;
  --text: #e6edf3;
  --muted: #8b97a6;
  --accent: #7c5cff;
  --accent-2: #4b7bff;
  --me: #2a3550;
  --bot: #161b22;
  --danger: #ff6b6b;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior: none;
}

.view { height: 100dvh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
#login { align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 20px; padding: 36px 26px;
}
.logo { font-size: 52px; line-height: 1; }
.login-card h1 { margin: 12px 0 4px; font-size: 26px; letter-spacing: .5px; }
.sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
input, textarea, button { font: inherit; }
#login-form input {
  background: var(--bg-input); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 14px 16px; font-size: 16px; outline: none;
}
#login-form input:focus { border-color: var(--accent); }
#login-btn {
  margin-top: 6px; padding: 14px; border: 0; border-radius: 12px; font-size: 16px;
  font-weight: 600; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
#login-btn:disabled { opacity: .6; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; }

/* ---------- Chat ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--bg-elev); border-bottom: 1px solid var(--line);
}
.title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #3fb950; box-shadow: 0 0 8px #3fb950; }
.actions button {
  background: transparent; border: 0; color: var(--muted); font-size: 20px;
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
}
.actions button:hover { background: var(--bg-input); color: var(--text); }

#messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.msg { max-width: 84%; padding: 11px 14px; border-radius: 16px; line-height: 1.45;
  white-space: pre-wrap; word-wrap: break-word; font-size: 15.5px; }
.msg.me { align-self: flex-end; background: var(--me); border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: var(--bot); border: 1px solid var(--line);
  border-bottom-left-radius: 5px; }
.msg.bot.error { border-color: var(--danger); color: #ffd2d2; }

.typing { align-self: flex-start; display: flex; gap: 5px; padding: 14px 16px;
  background: var(--bot); border: 1px solid var(--line); border-radius: 16px;
  border-bottom-left-radius: 5px; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--muted);
  animation: blink 1.3s infinite both; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.composer {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--bg-elev); border-top: 1px solid var(--line);
}
#input {
  flex: 1; resize: none; max-height: 140px; background: var(--bg-input);
  border: 1px solid var(--line); color: var(--text); border-radius: 14px;
  padding: 12px 14px; font-size: 16px; outline: none; line-height: 1.4;
}
#input:focus { border-color: var(--accent); }
#send-btn {
  flex: 0 0 auto; width: 46px; height: 46px; border: 0; border-radius: 14px;
  color: #fff; font-size: 18px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
#send-btn:disabled { opacity: .5; }
