*, *::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: 800px;
  margin: 0 auto;
  width: 100%;
}

/* Header */
.site-header {
  background: var(--color-primary);
  color: var(--white);
  padding: 0 20px;
  flex-shrink: 0;
}

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

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

.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(--white);
}

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

.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: var(--shadow);
}

.user-message .message-bubble {
  background: var(--color-primary);
  color: var(--white);
  border-radius: 16px 4px 16px 16px;
}

.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: 14px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: var(--shadow);
}

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

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

@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: var(--color-primary);
  color: var(--white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}

button#sendBtn:hover { background: var(--color-accent); }
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); }

/* 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;
}

/* 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; }
}
