:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --panel: #111c33;
  --card: #ffffff;
  --text: #e2e8f0;
  --text-dark: #0f172a;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --bubble-in: #1e293b;
  --bubble-out: #2563eb;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

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

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1e3a8a 0%, var(--bg) 55%);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- Auth ---------- */
.auth-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: rgba(17, 28, 51, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.brand { text-align: center; margin-bottom: 24px; }
.brand-logo { font-size: 40px; margin-bottom: 8px; }
.brand h1 { font-size: 24px; margin-bottom: 6px; }

.tabs {
  display: flex;
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 10px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.tab.active { background: var(--primary); color: #fff; }

.form { display: flex; flex-direction: column; gap: 16px; }

.form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

input {
  background: var(--bg);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.primary:disabled { opacity: 0.6; cursor: default; }

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.25);
  padding: 8px 12px;
  font-size: 13px;
}
.btn.ghost:hover { color: var(--text); border-color: var(--muted); }

.error {
  margin-top: 16px;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
}

/* ---------- Chat ---------- */
.chat-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  height: 100vh;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  background: rgba(17, 28, 51, 0.8);
  backdrop-filter: blur(10px);
}

.chat-title { display: flex; align-items: center; gap: 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.online { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.chat-user { display: flex; align-items: center; gap: 12px; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fade 0.18s ease;
}

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

.msg .meta { font-size: 11px; color: var(--muted); padding: 0 6px; }

.msg .bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
  background: var(--bubble-in);
  border-bottom-left-radius: 4px;
}

.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.out .bubble {
  background: var(--bubble-out);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: 4px;
}

.msg.system {
  align-self: center;
  max-width: 90%;
}
.msg.system .bubble {
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  border-radius: 8px;
}

.composer {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  background: rgba(17, 28, 51, 0.8);
}

.composer input { flex: 1; }
.composer .btn { width: 50px; font-size: 18px; }

@media (max-width: 600px) {
  .chat-screen { height: 100vh; }
  .msg { max-width: 85%; }
  .auth-card { padding: 24px 18px; }
}
