:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --surface2: #21262d;
  --border:   #30363d;
  --text:     #e6edf3;
  --muted:    #8b949e;
  --accent:   #38bdf8;
  --user-bg:  #1d4ed8;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Login Screen ── */
#login-screen {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

#login-box {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.login-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.login-title { font-size: 22px; font-weight: 700; color: var(--text); }
.login-sub   { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

#login-form { width: 100%; display: flex; flex-direction: column; gap: 10px; }

.input-wrap input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  padding: 13px 16px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}
.input-wrap input::placeholder { color: var(--muted); }
.input-wrap input:focus { border-color: var(--accent); }

.login-error {
  font-size: 13px;
  color: #f87171;
  text-align: center;
}

.login-btn {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  background: var(--accent);
  color: #0d1117;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.login-btn:hover { opacity: 0.88; }

/* ── Logout button ── */
#logout-btn {
  color: var(--muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s;
}
#logout-btn:hover { color: var(--text); }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 680px;
  margin: 0 auto;
}

/* ── Header ── */
#header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.header-name   { font-size: 15px; font-weight: 600; line-height: 1.2; }
.header-status { font-size: 11px; color: var(--accent); margin-top: 2px; }

/* ── Messages ── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#messages::-webkit-scrollbar { width: 3px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.msg { display: flex; animation: fadeIn 0.18s ease; }
.msg.user { justify-content: flex-end; }
.msg.bot  { justify-content: flex-start; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.msg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.msg.user .msg-bubble {
  background: var(--user-bg);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.bot .msg-bubble {
  background: var(--surface2);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* Typing animation */
.typing-dots { display: flex; gap: 5px; align-items: center; padding: 4px 2px; }
.typing-dots span {
  width: 7px; height: 7px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce 1.3s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-7px); opacity: 1; }
}

.status-text { font-size: 11px; color: var(--muted); }
.status-text.active { color: var(--accent); }

/* ── Chips ── */
#chips-bar {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
  -ms-overflow-style: none;
  scrollbar-width: none;
}
#chips-bar::-webkit-scrollbar { display: none; }

.chip {
  white-space: nowrap;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 13px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.chip:hover, .chip:active { background: var(--surface); border-color: var(--accent); }

/* ── Input bar ── */
#inputbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 22px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  padding: 10px 16px;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.45;
  transition: border-color 0.15s;
}
#input::placeholder { color: var(--muted); }
#input:focus { border-color: var(--accent); }

#send {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
}
#send:hover { transform: scale(1.08); }
#send.disabled { opacity: 0.35; pointer-events: none; }
#send svg { width: 18px; height: 18px; fill: #0d1117; margin-left: 2px; }
#send { user-select: none; -webkit-user-select: none; }
