:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #6d28d9;
  --primary-dark: #5b21b6;
  --in: #ffffff;
  --out: #ede9fe;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
button, input { font: inherit; }
button {
  border: 0;
  background: var(--primary);
  color: white;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: var(--primary-dark); }
button.secondary {
  background: #111827;
}
button.small {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 10px;
}
.hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .08);
}
.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #ede9fe;
  color: var(--primary);
  font-weight: 900;
}
.login-card h1 { margin: 18px 0 8px; }
.login-card p { color: var(--muted); }
.login-card label {
  display: block;
  margin-top: 16px;
  margin-bottom: 8px;
  font-weight: 700;
}
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.login-card button { width: 100%; margin-top: 20px; }
.error { color: #dc2626 !important; min-height: 22px; }

.topbar {
  height: 68px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.pill {
  display: inline-flex;
  align-items: center;
  margin-left: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 12px;
}
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: calc(100vh - 68px);
}
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--card);
  padding: 20px;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.sidebar h2, .chat h2 { margin: 0; }
.conversations { display: grid; gap: 10px; }
.conversation {
  width: 100%;
  text-align: left;
  background: #f9fafb;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}
.conversation:hover, .conversation.active {
  background: #ede9fe;
  border-color: #c4b5fd;
}
.conversation strong, .conversation span, .conversation small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conversation span { color: var(--muted); margin-top: 4px; }
.conversation small { color: var(--muted); margin-top: 8px; font-size: 12px; }
.empty-list {
  color: var(--muted);
  padding: 20px;
  background: #f9fafb;
  border-radius: 16px;
}
.chat { padding: 24px; }
.empty {
  height: 100%;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}
.hint code {
  background: #111827;
  color: white;
  border-radius: 10px;
  padding: 6px 8px;
}
.chat-panel {
  height: calc(100vh - 116px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 26px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}
.chat-head {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}
.chat-head p { margin: 6px 0 0; color: var(--muted); }
.messages {
  padding: 20px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
}
.message {
  max-width: 72%;
  padding: 12px 14px;
  border-radius: 18px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .05);
}
.message.in { align-self: flex-start; background: var(--in); border: 1px solid var(--line); }
.message.out { align-self: flex-end; background: var(--out); }
.message small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
.reply-box {
  padding: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.reply-box input {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-panel { height: 70vh; }
}
