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

:root {
  --color-primary: #2d5016;
  --color-accent: #4a7c28;
  --color-light: #6aab3a;
  --color-pale: #eef5e8;
  --color-bg: #f5f0e8;
  --text-dark: #1a1a1a;
  --text-mid: #444;
  --text-light: #777;
  --border: #ddd;
  --white: #fff;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

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

.page-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 640px) {
  body {
    background: #1a2236;
  }
  .page-wrapper {
    box-shadow: 0 8px 48px rgba(0,0,0,0.45);
  }
}

/* Header */
.site-header {
  background: linear-gradient(160deg, var(--color-primary) 0%, var(--color-accent) 100%);
  color: var(--white);
  padding: 0 20px;
  flex-shrink: 0;
  box-shadow: 0 2px 16px rgba(0,0,0,0.18);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-initials {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.logo-img {
  height: 44px;
  width: auto;
  border-radius: 6px;
  display: block;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.logo-sub {
  font-size: 12px;
  opacity: 0.75;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  background: rgba(255,255,255,0.12);
  padding: 5px 12px;
  border-radius: 20px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7ed957;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Disclaimer */
.disclaimer-banner {
  background: #fff8e1;
  border-bottom: 1px solid #ffe082;
  color: #5c4200;
  font-size: 12px;
  text-align: center;
  padding: 8px 40px 8px 20px;
  flex-shrink: 0;
  position: relative;
}

.banner-dismiss {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 16px;
  line-height: 1;
  color: #5c4200;
  cursor: pointer;
  opacity: 0.6;
  padding: 2px 4px;
}

.banner-dismiss:hover { opacity: 1; }

/* Chat area */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
  background: transparent;
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 85%;
}

.bot-message {
  align-self: flex-start;
}

.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.user-message .message-avatar {
  background: var(--color-accent);
}

.message-bubble {
  background: var(--color-pale);
  border-radius: 4px 16px 16px 16px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dark);
  box-shadow: 0 2px 12px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.04);
}

.user-message .message-bubble {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  color: var(--white);
  border-radius: 16px 4px 16px 16px;
  border: none;
}

.message-bubble p { margin-bottom: 8px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble ul, .message-bubble ol { padding-left: 18px; margin: 6px 0 8px; }
.message-bubble li { margin-bottom: 4px; }
.message-bubble h3, .message-bubble h4, .message-bubble h5 { font-size: 14px; font-weight: 700; margin: 10px 0 4px; }
.message-bubble hr { border: none; border-top: 1px solid rgba(0,0,0,0.12); margin: 8px 0; }
.message-bubble h3:first-child, .message-bubble h4:first-child, .message-bubble h5:first-child { margin-top: 0; }
.message-bubble a { color: var(--color-primary); text-decoration: underline; word-break: break-all; }
.user-message .message-bubble a { color: rgba(255,255,255,0.9); }

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  align-self: flex-start;
}

.typing-bubble {
  background: var(--color-pale);
  border-radius: 4px 16px 16px 16px;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.04);
}

.typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-bubble span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  animation: bounce 1.2s infinite;
  flex-shrink: 0;
}

.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

.typing-slow-msg {
  font-size: 12px;
  color: var(--text-mid);
  font-style: italic;
  opacity: 0;
  transition: opacity 0.5s ease;
}

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Input area */
.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 16px 20px 12px;
  background: var(--white);
  flex-shrink: 0;
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  color: var(--text-dark);
  transition: border-color 0.2s;
}

textarea:focus {
  border-color: var(--color-accent);
}

textarea::placeholder {
  color: var(--text-light);
}

button#sendBtn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: var(--white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

button#sendBtn:hover { opacity: 0.88; box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
button#sendBtn:active { transform: scale(0.94); }
button#sendBtn:disabled {
  background: var(--border);
  cursor: not-allowed;
  transform: none;
}

.input-hint {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 6px;
  text-align: center;
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.clear-btn:hover { color: var(--text-mid); }

.install-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #eff6ff;
  border-top: 1px solid #bfdbfe;
  padding: 10px 16px;
  font-size: 13px;
  color: #1e40af;
}

.install-banner span { flex: 1; }

.install-add {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.install-add:hover { background: #1d4ed8; }

.install-dismiss {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: #93c5fd;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
}

.install-dismiss:hover { color: #1e40af; }

/* Footer */
.site-footer {
  background: var(--color-primary);
  color: rgba(255,255,255,0.65);
  font-size: 11px;
  text-align: center;
  padding: 10px 20px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.powered-by {
  font-size: 10px;
  opacity: 0.5;
}

.powered-by a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Message entrance animation */
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.message, .typing-indicator { animation: msg-in 0.2s ease-out; }

/* Welcome state */
.welcome-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  gap: 12px;
}
.welcome-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.18);
}
.welcome-logo-img {
  height: 68px;
  width: auto;
  border-radius: 10px;
  margin-bottom: 4px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.welcome-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
}
.welcome-msg {
  font-size: 14px;
  color: var(--text-mid);
  max-width: 360px;
  line-height: 1.6;
}
.welcome-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 420px;
  margin-top: 8px;
}
.chip {
  padding: 11px 18px;
  border: 1.5px solid var(--color-primary);
  border-radius: 24px;
  background: #fff;
  color: var(--color-primary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.chip:hover {
  background: var(--color-pale);
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

@media (max-width: 600px) {
  .message { max-width: 95%; }
  .status-badge { display: none; }
}
