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

body {
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #1f2328;
  background: #f7f8fa;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen { display: none; width: 100%; max-width: 760px; }
.screen.active { display: block; }

/* ----------------------------------------------------------------
   Login / New Password card
---------------------------------------------------------------- */
.card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 40px;
  margin: auto;
  max-width: 400px;
}

.card h1 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
}

.card .subtitle {
  color: #57606a;
  margin-bottom: 24px;
}

.card label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  margin-top: 16px;
}

.card input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}

.card input:focus { border-color: #3b82d4; }

.card button[type="submit"] {
  margin-top: 24px;
  width: 100%;
  padding: 10px;
  background: #3b82d4;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.card button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ----------------------------------------------------------------
   Error message
---------------------------------------------------------------- */
.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #b91c1c;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}

/* ----------------------------------------------------------------
   Chat screen
---------------------------------------------------------------- */
#chat-screen {
  flex-direction: column;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  background: #ffffff;
  border-left: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
}

#chat-screen.active {
  display: flex;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #ffffff;
}

.chat-title { font-weight: 600; font-size: 15px; }

#signout-btn {
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 13px;
  color: #57606a;
}

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

/* ----------------------------------------------------------------
   Message bubbles
---------------------------------------------------------------- */
.message { display: flex; flex-direction: column; max-width: 80%; }
.message.user { align-self: flex-end; align-items: flex-end; }
.message.assistant { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 10px 14px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.6;
}

.message.user .bubble { background: #3b82d4; color: #fff; border-bottom-right-radius: 4px; }
.message.assistant .bubble { background: #f7f8fa; border: 1px solid #e5e7eb; border-bottom-left-radius: 4px; }

.citations {
  margin-top: 6px;
  font-size: 12px;
  color: #57606a;
}

.citations summary { cursor: pointer; }
.citations ul { margin-top: 6px; padding-left: 16px; }
.citations li { margin-bottom: 4px; word-break: break-all; }

/* Loading dots */
.loading-dots span {
  display: inline-block;
  width: 6px; height: 6px;
  background: #57606a;
  border-radius: 50%;
  margin: 0 2px;
  animation: blink 1.2s infinite both;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

/* ----------------------------------------------------------------
   Input bar
---------------------------------------------------------------- */
.input-bar {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
}

#question-input {
  flex: 1;
  resize: none;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
}

#question-input:focus { border-color: #3b82d4; }

#send-btn {
  padding: 8px 20px;
  background: #3b82d4;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  align-self: flex-end;
}

#send-btn:disabled { opacity: 0.6; cursor: not-allowed; }
