:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --brand: #e11d48;
  --brand-dark: #be123c;
  --text: #1f2937;
  --muted: #6b7280;
  --user-bubble: #e11d48;
  --bot-bubble: #f0f0f5;
  --border: #e5e7eb;
}

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

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

.app {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  font-size: 26px;
  background: linear-gradient(135deg, var(--brand), #f43f5e);
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
}
.brand-text h1 { font-size: 18px; font-weight: 700; }
.brand-text p { font-size: 12.5px; color: var(--muted); }
.model-badge {
  background: #fff1f2;
  color: var(--brand-dark);
  border: 1px solid #fecdd3;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
}
.tenant-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 12px;
  padding: 6px 12px;
}
.tenant-picker label { font-size: 12px; color: var(--brand-dark); font-weight: 600; }
.tenant-picker select {
  border: none; background: transparent;
  font-size: 13px; font-weight: 600;
  color: var(--text); outline: none; cursor: pointer;
  font-family: inherit; max-width: 160px;
}

/* Chat window */
.chat-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.welcome-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.welcome-card h2 { font-size: 18px; margin-bottom: 8px; color: var(--brand-dark); }
.welcome-card p { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: transform .1s, background .2s;
}
.chip:hover { background: #ffe4e6; transform: translateY(-1px); }

/* Bubbles */
.msg { display: flex; gap: 10px; max-width: 85%; }
.msg.bot { align-self: flex-start; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.msg.bot .avatar { background: #e2e8f0; }
.msg.user .avatar { background: var(--brand); }
.bubble {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.bot .bubble { background: var(--bot-bubble); border-top-left-radius: 4px; }
.msg.user .bubble { background: var(--user-bubble); color: #fff; border-top-right-radius: 4px; }

.typing { display: flex; gap: 5px; padding: 8px 4px; }
.typing span {
  width: 8px; height: 8px; border-radius: 50%;
  background: #9ca3af;
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity:.3 } 40% { opacity:1 } }

/* Composer */
.composer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
#input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 12px 16px;
  font-size: 14.5px;
  resize: none;
  font-family: inherit;
  outline: none;
  max-height: 120px;
  line-height: 1.4;
  background: #fafafa;
}
#input:focus { border-color: var(--brand); background: #fff; }
.send-btn {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px; height: 44px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.send-btn:hover { background: var(--brand-dark); }
.send-btn:disabled { background: #fca5a5; cursor: not-allowed; }

/* Status bar */
.statusbar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.spacer { flex: 1; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; }
.dot.busy { background: #f59e0b; }

/* Mobile */
@media (max-width: 600px) {
  .msg { max-width: 92%; }
  .brand-text p { display: none; }
}
