:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --text: #e8eef7;
  --muted: #9aa8bc;
  --accent: #3dbf8d;
  --accent-hover: #52d4a2;
  --mic: #c45c3d;
  --mic-hot: #e07050;
  --user-bg: #1e4a3a;
  --bot-bg: #1e2a3d;
  --border: #2d3d54;
  --error: #ff6b6b;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.login-card {
  margin: auto;
  width: min(440px, 92vw);
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.login-card h1 { margin: 0 0 0.5rem; font-size: 1.75rem; }
.subtitle { color: var(--muted); margin: 0 0 1.5rem; font-size: 1rem; }
label { display: block; margin-bottom: 0.4rem; font-weight: 600; }
input, textarea, button { font: inherit; }

input, textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

input:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.1rem;
  background: var(--accent);
  color: #072016;
  font-weight: 700;
}

button:hover:not(:disabled) { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
#login-btn { width: 100%; margin-top: 1rem; padding: 0.95rem; }
.error { color: var(--error); margin-top: 0.75rem; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.badge {
  margin-left: 0.4rem;
  font-size: 0.75rem;
  color: var(--accent);
  background: #16352b;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.topbar-actions { display: flex; gap: 0.4rem; }
.topbar-actions button {
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
  padding: 0.45rem 0.65rem;
}
.topbar-actions button[aria-pressed="true"] {
  background: #16352b;
  color: var(--accent);
}

.status {
  margin: 0;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.msg {
  max-width: min(720px, 100%);
  padding: 0.9rem 1.05rem;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user { align-self: flex-end; background: var(--user-bg); }
.msg.assistant { align-self: flex-start; background: var(--bot-bg); border: 1px solid var(--border); }
.msg.thinking { color: var(--muted); font-style: italic; }
.msg.error { background: #3a1f1f; border: 1px solid var(--error); color: #ffc9c9; }

.composer {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.composer textarea {
  resize: none;
  min-height: 3.2rem;
  max-height: 28vh;
}

.composer-btns {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.6rem;
}

.mic {
  background: var(--mic);
  color: #fff;
  min-height: 3.2rem;
}
.mic.hot { background: var(--mic-hot); }
.mic:disabled { background: var(--surface-2); color: var(--muted); }

@media (max-width: 600px) {
  html, body { font-size: 17px; }
  .topbar { gap: 0.4rem; }
  .topbar-actions button { padding: 0.45rem 0.5rem; }
}
