:root {
  color: #15211a;
  background: #f1f5f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --green: #176b4a;
  --green-dark: #0d4c34;
  --green-soft: #e8f3ed;
  --line: #dce5de;
  --muted: #6a786f;
  --panel: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(75, 155, 113, 0.13), transparent 34rem),
    #f1f5f0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.login-view {
  width: min(92vw, 430px);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 8px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  margin-bottom: 24px;
}

.brand-mark svg {
  width: 100%;
  fill: var(--green);
}

.brand-mark .spark {
  fill: #f4b942;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.login-view h1 {
  margin: 0;
  font-size: clamp(32px, 7vw, 44px);
  letter-spacing: -0.04em;
}

.login-description {
  margin: 14px 0 32px;
  color: var(--muted);
}

.login-view form {
  display: grid;
  gap: 10px;
}

.login-view label {
  font-size: 14px;
  font-weight: 650;
}

.login-view input {
  width: 100%;
  padding: 15px 16px;
  border: 1px solid #cbd7ce;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  color: #16241b;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.login-view input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(23, 107, 74, 0.12);
}

.primary-button {
  border: 0;
  border-radius: 12px;
  padding: 15px 18px;
  background: var(--green);
  color: white;
  font-weight: 700;
  transition: background 0.18s, transform 0.18s;
}

.primary-button:hover {
  background: var(--green-dark);
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: #b13b35;
  font-size: 13px;
}

.login-note {
  margin: 18px 0 0;
  color: #7a867e;
  font-size: 12px;
  text-align: center;
}

.chat-view {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  background: var(--panel);
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px max(20px, calc((100vw - 920px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.brand-inline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 6px var(--green-soft);
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--muted);
  font-size: 13px;
}

.text-button {
  padding: 6px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--green);
}

.text-button:hover {
  background: var(--green-soft);
}

.mode-banner {
  padding: 9px 20px;
  background: #fff7dc;
  color: #6d5721;
  font-size: 12px;
  text-align: center;
}

.messages {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 34px 24px 150px;
  overflow-y: auto;
}

.message {
  display: flex;
  gap: 13px;
  margin-bottom: 28px;
}

.message.user-message {
  justify-content: flex-end;
}

.avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--green);
  color: white;
  font-size: 14px;
  font-weight: 750;
}

.message-content {
  max-width: min(720px, calc(100vw - 92px));
  color: #263229;
  line-height: 1.78;
}

.message-content p {
  margin: 0 0 10px;
}

.user-message .message-content {
  padding: 11px 15px;
  border-radius: 16px 16px 4px 16px;
  background: var(--green);
  color: white;
  line-height: 1.65;
}

.quick-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 15px;
}

.quick-questions button {
  padding: 8px 12px;
  border: 1px solid #cbded2;
  border-radius: 999px;
  background: #f7faf8;
  color: var(--green-dark);
  font-size: 13px;
}

.quick-questions button:hover {
  border-color: var(--green);
  background: var(--green-soft);
}

.sources {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.sources-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.source-card {
  margin: 6px 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafcfb;
}

.source-card summary {
  cursor: pointer;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 650;
}

.source-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.typing {
  display: flex;
  gap: 5px;
  padding-top: 8px;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #92a299;
  animation: pulse 1s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.composer-area {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 24px 12px;
  background: linear-gradient(transparent, white 20%, white);
}

.composer {
  width: min(100%, 850px);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 8px 8px 8px 16px;
  border: 1px solid #cbd8cf;
  border-radius: 17px;
  background: white;
  box-shadow: 0 12px 35px rgba(41, 70, 52, 0.13);
}

.composer:focus-within {
  border-color: var(--green);
  box-shadow: 0 12px 35px rgba(41, 70, 52, 0.13), 0 0 0 3px rgba(23, 107, 74, 0.08);
}

.composer textarea {
  flex: 1;
  max-height: 150px;
  padding: 7px 0;
  border: 0;
  resize: none;
  outline: none;
  color: #19251d;
  line-height: 1.5;
}

.composer button {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: white;
}

.composer button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.composer button svg {
  width: 21px;
  fill: currentColor;
}

.composer-area > p {
  margin: 8px auto 0;
  color: #859087;
  font-size: 11px;
  text-align: center;
}

.fatal-view {
  min-height: 100vh;
  display: grid;
  place-content: center;
  padding: 24px;
  text-align: center;
}

@media (max-width: 640px) {
  .topbar {
    padding-inline: 18px;
  }

  .user-actions span {
    display: none;
  }

  .messages {
    padding: 25px 16px 145px;
  }

  .composer-area {
    padding-inline: 12px;
  }
}

