:root {
  --bg: #0f172a;
  --panel: #111c33;
  --bubble-user: #2563eb;
  --bubble-remy: #1e293b;
  --text: #e5e9f0;
  --muted: #8a97ad;
  --accent: #2dd4bf;
  --danger: #f87171;
}

* { box-sizing: border-box; }

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

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(env(safe-area-inset-top), 10px) 14px 10px;
  background: var(--panel);
  border-bottom: 1px solid #1f2c47;
}
.topbar .title { font-weight: 700; }
.topbar .status { font-size: 12px; color: var(--muted); flex: 1; }
.topbar .status.ok { color: var(--accent); }
.topbar .status.err { color: var(--danger); }
.ghost {
  background: transparent;
  border: 1px solid #2a3a5c;
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

/* ---- chat ---- */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user { align-self: flex-end; background: var(--bubble-user); border-bottom-right-radius: 4px; }
.msg.remy { align-self: flex-start; background: var(--bubble-remy); border-bottom-left-radius: 4px; }
.msg.system { align-self: center; background: transparent; color: var(--muted); font-size: 13px; }
.msg.error { align-self: flex-start; background: #3a1b1f; color: var(--danger); }
.msg.remy.pending::after { content: "▍"; color: var(--muted); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---- composer ---- */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--panel);
  border-top: 1px solid #1f2c47;
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 160px;
  background: #0c1426;
  color: var(--text);
  border: 1px solid #25324f;
  border-radius: 18px;
  padding: 10px 14px;
  font: inherit;
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
.send, .mic {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  font-size: 18px;
  cursor: pointer;
}
.send { background: var(--accent); color: #06241f; }
.mic { background: #1e293b; color: var(--muted); touch-action: none; user-select: none; }
.mic:disabled { opacity: 0.45; cursor: not-allowed; }
.mic.rec { background: var(--danger); color: #2a0d0d; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }

/* ---- Live (hands-free) toggle ---- */
.ghost.live.on { background: var(--accent); border-color: var(--accent); color: #06241f; font-weight: 600; }
.ghost.live.hot { background: var(--danger); border-color: var(--danger); color: #2a0d0d; animation: livepulse 1s ease-in-out infinite; }
@keyframes livepulse { 50% { opacity: 0.6; } }

/* ---- login ---- */
body.login {
  justify-content: center;
  align-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid #1f2c47;
  border-radius: 16px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { margin: 0; }
.login-card .muted { margin: 0; color: var(--muted); font-size: 14px; }
.login-card input {
  background: #0c1426;
  color: var(--text);
  border: 1px solid #25324f;
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
  background: var(--accent);
  color: #06241f;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.login-card .error { display: none; color: var(--danger); font-size: 13px; margin: 0; }
