:root {
  --bg: #f1f3f9;
  --card: #ffffff;
  --ink: #1e2233;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --ok: #047857;
  --err: #b91c1c;
  --user-bub: #4f46e5;
  --bot-bub: #ffffff;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial,
    "Noto Nastaliq Urdu", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ================= login ================= */
.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 26px;
  box-shadow: 0 18px 45px rgba(30, 34, 51, 0.10);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-badge {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand.small .brand-badge { width: 36px; height: 36px; font-size: 18px; border-radius: 10px; }

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.brand .sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-hint {
  font-size: 13px;
  color: var(--muted);
  background: var(--brand-soft);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 14px 0 18px;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease;
  background: #fff;
  color: var(--ink);
}

.field input:focus { border-color: var(--brand); }

.login-error {
  background: #fef2f2;
  color: var(--err);
  border: 1px solid #fecaca;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 14px;
}

.btn-primary {
  width: 100%;
  padding: 12px 16px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }

.login-foot {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ================= chat ================= */
.chat-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 780px;
  margin: 0 auto;
  padding: 12px 12px 10px;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.head-text { display: flex; flex-direction: column; }
.head-text strong { font-size: 15px; }

.scope {
  font-size: 12px;
  color: var(--muted);
  max-width: 480px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 9px;
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
}

.btn-ghost:hover { background: var(--brand-soft); color: var(--brand); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--user-bub);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.msg.bot {
  align-self: flex-start;
  background: var(--bot-bub);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}

.msg.bot .tag {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.msg.typing { color: var(--muted); font-style: italic; }

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 2px 8px;
}

.chip {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--brand);
  font-size: 12.5px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.chip:hover { background: var(--brand-soft); border-color: var(--brand); }

.composer { padding-bottom: 2px; }

#msg-form { display: flex; gap: 8px; }

#msg-input {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  outline: none;
  background: var(--card);
  color: var(--ink);
}

#msg-input:focus { border-color: var(--brand); }

.send { width: auto; padding: 12px 22px; border-radius: 12px; }

.disclaimer {
  margin: 7px 2px 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 560px) {
  .chat-wrap { padding: 8px 8px 8px; }
  .msg { max-width: 92%; font-size: 14px; }
  .scope { max-width: 150px; }
  .send { padding: 12px 16px; }
}
