:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #8b92a3;
  --accent: #5b8cff;
  --accent-ink: #ffffff;
  --danger: #ef5a5a;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.shell {
  width: 100%;
  max-width: 420px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 24px;
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
}

.view { flex: 1; display: flex; flex-direction: column; }
.hidden { display: none !important; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card.center {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  margin-top: 40px;
}

.form { display: flex; flex-direction: column; gap: 12px; }
.form.hidden { display: none; }

input[type="text"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
}
input:focus { border-color: var(--accent); }

#login-code {
  text-align: center;
  letter-spacing: 4px;
  font-size: 20px;
}

.gender-pick { display: flex; gap: 16px; padding: 4px 2px; font-size: 14px; color: var(--muted); }
.gender-pick label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
}
button[type="submit"], .primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.danger { background: var(--danger); color: white; }
.small { padding: 6px 12px; font-size: 13px; }

.muted { color: var(--muted); font-size: 14px; margin: 0; }
.error { color: var(--danger); font-size: 13px; margin: 0; min-height: 16px; }

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--muted);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}
.msg.mine { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg.system { align-self: center; color: var(--muted); font-size: 12px; background: none; }

.chat-input {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.chat-input input { flex: 1; }
