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

:root {
  --brand: #e04a2f;
  --brand-dark: #b83a22;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-secondary: #6b7280;
  --user-bubble: #e04a2f;
  --user-text: #ffffff;
  --agent-bubble: #ffffff;
  --agent-text: #1a1a1a;
  --shadow: 0 1px 3px rgba(0,0,0,.12);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: var(--brand);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
header h1 { font-size: 1rem; font-weight: 600; letter-spacing: .02em; }
header .subtitle { font-size: .75rem; opacity: .85; margin-top: 2px; }
header .header-left { display: flex; flex-direction: column; }
#user-info { font-size: .8rem; opacity: .9; }
#logout-btn {
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.4);
  color: #fff;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .8rem;
  margin-left: 12px;
  transition: background .15s;
}
#logout-btn:hover { background: rgba(255,255,255,.3); }

/* ── Login screen ── */
#login-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 40px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,.1);
  max-width: 380px;
  width: 90%;
}
.login-card h2 { font-size: 1.4rem; margin-bottom: 8px; }
.login-card p { color: var(--text-secondary); margin-bottom: 28px; font-size: .9rem; }
.btn-primary {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  padding: 12px 28px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}
.btn-primary:hover { background: var(--brand-dark); }

/* ── Chat screen ── */
#chat-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg-row {
  display: flex;
  padding: 0 20px;
}
.msg-row.user { justify-content: flex-end; }
.msg-row.agent { justify-content: flex-start; }

.bubble {
  max-width: 72%;
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.55;
  font-size: .92rem;
  box-shadow: var(--shadow);
}
.msg-row.user .bubble {
  background: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}
.msg-row.agent .bubble {
  background: var(--agent-bubble);
  color: var(--agent-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}

.bubble p { margin-bottom: .5em; }
.bubble p:last-child { margin-bottom: 0; }

/* Citations */
.citations {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--text-secondary);
}
.citations strong { display: block; margin-bottom: 4px; color: var(--text); }
.citations a {
  color: var(--brand);
  text-decoration: none;
  display: block;
  margin-bottom: 6px;
  font-size: .82rem;
  line-height: 1.4;
}
.citations a:hover { text-decoration: underline; }
sup.cite-ref { color: var(--brand); font-size: .7em; font-weight: 600; }
a.inline-cite { color: var(--brand); font-size: .8em; font-weight: 600; text-decoration: none; vertical-align: super; }
a.inline-cite:hover { text-decoration: underline; }

/* Feedback */
.feedback-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.fb-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: .8rem;
  color: var(--text-secondary);
  transition: all .15s;
}
.fb-btn:hover { border-color: var(--brand); color: var(--brand); }
.fb-btn.active-pos { background: #d1fae5; border-color: #10b981; color: #065f46; }
.fb-btn.active-neg { background: #fee2e2; border-color: #ef4444; color: #991b1b; }

/* Typing indicator */
.typing .bubble { display: flex; align-items: center; gap: 6px; min-width: 60px; }
.dot { width: 8px; height: 8px; background: var(--text-secondary); border-radius: 50%; animation: bounce .9s infinite; }
.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

/* Starter prompts */
#starter-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 16px;
}
.prompt-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: .82rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all .15s;
  box-shadow: var(--shadow);
}
.prompt-chip:hover { border-color: var(--brand); color: var(--brand); }

/* Input area */
#input-area {
  padding: 14px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
#message-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .92rem;
  resize: none;
  height: 44px;
  max-height: 120px;
  overflow-y: auto;
  font-family: inherit;
  line-height: 1.4;
  outline: none;
  transition: border-color .15s;
}
#message-input:focus { border-color: var(--brand); }
#send-btn {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 44px;
  height: 44px;
  cursor: pointer;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
#send-btn:hover { background: var(--brand-dark); }
#send-btn:disabled { background: var(--border); cursor: not-allowed; }

/* Toast */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1a1a1a;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: .85rem;
  transition: transform .25s;
  z-index: 100;
}
#toast.show { transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }
