:root {
  --green: #087c45;
  --green-dark: #075b35;
  --green-light: #e8f6ed;
  --yellow: #f4d64b;
  --ink: #1e293b;
  --muted: #667085;
  --border: #e3e9e5;
  --white: #ffffff;
  --background: #f4f8f5;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #e1f3e7, transparent 38%),
    var(--background);
}

.navbar {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 6%;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--green-dark);
  text-decoration: none;
}

.brand-logo,
.bot-avatar {
  display: grid;
  place-items: center;
  color: white;
  background: var(--green);
  font-weight: bold;
  border-radius: 13px;
}

.brand-logo {
  width: 60px;
  height: 60px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  border-radius: 0;
  background: transparent;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 19px;
  letter-spacing: 1px;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

#language {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: white;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

.container {
  width: min(1150px, 92%);
  margin: 45px auto;
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  align-items: center;
  gap: 48px;
}

.welcome {
  padding: 12px 0;
}

.eyebrow {
  display: inline-block;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 17px;
}

.welcome h1 {
  color: var(--green-dark);
  font-size: clamp(32px, 4vw, 49px);
  line-height: 1.12;
  margin-bottom: 17px;
}

#welcome-text {
  color: var(--muted);
  line-height: 1.8;
  font-size: 16px;
}

.topics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 27px 0;
}

.topic-button {
  min-height: 80px;
  padding: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: white;
  color: var(--green-dark);
  text-align: left;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}

.topic-button:hover,
.topic-button:focus-visible {
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px #087c4515;
}

.topic-icon {
  width: 37px;
  height: 37px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--green-light);
  font-size: 19px;
}

.topic-label {
  font-size: 13px;
  line-height: 1.4;
}

.info-note {
  padding: 13px;
  background: #fffbea;
  border-left: 4px solid var(--yellow);
  border-radius: 6px;
  color: #685c26;
  font-size: 12px;
  line-height: 1.7;
}

.chat-card {
  min-width: 0;
  overflow: hidden;
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 60px #123d2410;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 19px;
  border-bottom: 1px solid var(--border);
}

.bot-avatar {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: white;
  border: 1px solid #e3e9e5;
  border-radius: 12px;
  overflow: hidden;
}
.bot-logo {
  width: 100%;
  height: 100%;
  padding: 3px;
  object-fit: contain;
}

.chat-header h2 {
  font-size: 16px;
  color: var(--green-dark);
}

.chat-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  background: #22c55e;
  border-radius: 50%;
}

.clear-button {
  min-width: 52px;
  padding: 6px 8px;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: white;
  color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
}

.clear-button:hover {
  background: var(--green-light);
  border-color: var(--green);
}

.clear-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--muted);
  line-height: 1;
}

.chat-messages {
  position: relative;
  height: 340px;
  overflow-y: auto;
  padding: 20px;
  background: #fcfdfc;
  scroll-padding-top: 10px;
}

.message {
  display: flex;
  margin-bottom: 15px;
  animation: message-fade-in 0.22s ease-out;
}

@keyframes message-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message p {
  max-width: 100%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* Wraps the bubble, timestamp and copy button in a column */
.bubble-wrap {
  max-width: 92%;
  display: flex;
  flex-direction: column;
}

.message-time {
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.75;
}

.user-message .message-time {
  text-align: right;
}
.bot-message .message-time {
  text-align: left;
}

.copy-button {
  display: none;
  align-self: flex-start;
  margin-top: 5px;
  padding: 3px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.bot-message:hover .copy-button {
  display: block;
}

.copy-button:hover {
  color: var(--green);
  border-color: var(--green);
}

.bot-message p {
  color: #2d3a30;
  background: #edf6f0;
  border-top-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(8, 124, 69, 0.08);
}

/* AI response bubble — block element so markdown can nest inside */
.bot-bubble {
  max-width: 100%;
  padding: 12px 16px;
  border-radius: 18px;
  border-top-left-radius: 4px;
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: anywhere;
  color: #2d3a30;
  background: #edf6f0;
  box-shadow: 0 1px 3px rgba(8, 124, 69, 0.08);
}

/* Markdown elements rendered inside .bot-bubble */
.bot-bubble .md-heading {
  font-weight: 700;
  color: var(--green-dark);
  margin: 10px 0 4px;
  font-size: 14px;
}
.bot-bubble .md-heading:first-child { margin-top: 0; }

.bot-bubble .md-para {
  margin-bottom: 8px;
}
.bot-bubble .md-para:last-child { margin-bottom: 0; }

.bot-bubble .md-list {
  padding-left: 20px;
  margin: 4px 0 8px;
}
.bot-bubble .md-list:last-child { margin-bottom: 0; }

.bot-bubble li {
  margin-bottom: 4px;
  line-height: 1.6;
}

.bot-bubble a {
  color: var(--green-dark);
  font-weight: 600;
  text-decoration: underline;
  word-break: break-all;
}
.bot-bubble a:hover { color: var(--green); }

/* Markdown table */
.bot-bubble hr {
  border: none;
  border-top: 1px solid #c8dece;
  margin: 10px 0;
}
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
  overflow-x: auto;
  display: block;
}

.bot-bubble .md-table th,
.bot-bubble .md-table td {
  border: 1px solid #c8dece;
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
  line-height: 1.5;
}

.bot-bubble .md-table th {
  background: #d4edd9;
  font-weight: 700;
  color: var(--green-dark);
  white-space: nowrap;
}

.bot-bubble .md-table tbody tr:nth-child(even) {
  background: #f4faf6;
}

/* Avatar shown beside each bot bubble */
.bot-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
  align-self: flex-start;
  margin-right: 8px;
  padding: 2px;
  background: white;
  border: 1px solid var(--border);
}

.bot-message p a {
  color: var(--green-dark);
  font-weight: 600;
  text-decoration: underline;
  word-break: break-all;
}

.bot-message p a:hover {
  color: var(--green);
}

/* Typing indicator */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: #edf6f0;
  border-radius: 18px;
  border-top-left-radius: 4px;
}

.typing-bubble span {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  animation: typing-bounce 1.1s infinite ease-in-out;
  opacity: 0.5;
}

.typing-bubble span:nth-child(2) {
  animation-delay: 0.18s;
}
.typing-bubble span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.user-message {
  justify-content: flex-end;
}

.user-message p {
  color: white;
  background: var(--green);
  border-top-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(8, 124, 69, 0.28);
}

.suggestion-area {
  padding: 13px 17px 5px;
  border-top: 1px solid var(--border);
  transition:
    opacity 0.3s ease,
    max-height 0.3s ease,
    padding 0.3s ease;
  overflow: hidden;
  max-height: 200px;
}

.suggestion-area.suggestions-hidden {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-color: transparent;
  pointer-events: none;
}

#suggestion-label {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 11px;
}

.quick-questions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.quick-button {
  padding: 7px 10px;
  background: white;
  border: 1px solid #cfe3d5;
  border-radius: 20px;
  color: var(--green-dark);
  font-size: 11px;
  cursor: pointer;
}

.quick-button:hover {
  background: var(--green-light);
}

.chat-input-area {
  display: flex;
  gap: 9px;
  padding: 13px 16px;
}

#user-input {
  flex: 1;
  min-width: 0;
  padding: 13px;
  border: 1px solid #d6e0d9;
  border-radius: 10px;
  outline: none;
  font-size: 14px;
}

#user-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px #087c4512;
}

#send-button {
  padding: 0 17px;
  border: none;
  border-radius: 10px;
  background: var(--green);
  color: white;
  font-weight: bold;
  cursor: pointer;
}

#send-button:hover {
  background: var(--green-dark);
}

.chat-footer {
  padding: 0 16px 15px;
  text-align: center;
  color: #929b95;
  font-size: 10px;
}

footer {
  padding: 20px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  line-height: 1.8;
}

@media (max-width: 850px) {
  .container {
    grid-template-columns: 1fr;
    gap: 25px;
    margin-top: 28px;
  }

  .welcome h1 {
    font-size: 38px;
  }

  .chat-messages {
    height: 320px;
  }
}

@media (max-width: 430px) {
  .navbar {
    padding: 12px 4%;
  }

  .brand strong {
    font-size: 16px;
  }

  .container {
    width: 94%;
    margin: 22px auto;
  }

  .welcome h1 {
    font-size: 32px;
  }

  #welcome-text {
    font-size: 14px;
  }

  .topics {
    gap: 8px;
    margin: 19px 0;
  }

  .topic-button {
    min-height: 75px;
    padding: 9px;
    gap: 7px;
  }

  .topic-icon {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }

  .topic-label {
    font-size: 11px;
  }

  .chat-messages {
    height: 300px;
    padding: 13px;
  }

  .chat-input-area {
    padding: 10px;
    gap: 6px;
  }

  #user-input {
    padding: 11px 9px;
    font-size: 12px;
  }

  #send-button {
    padding: 0 10px;
    font-size: 12px;
  }
}

.hemipt-contact {
  width: 50%;
  margin: 40px auto;
  padding: 25px;
  background: #ffffff;
  border: 1px solid #e2eae4;
  border-radius: 15px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.06);
}

.hemipt-contact h2 {
  color: #087a45;
  font-size: 24px;
  margin: 0 0 5px;
}

.contact-intro {
  color: #68756d;
  font-size: 13px;
  margin-bottom: 22px;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 15px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.contact-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: #eaf7ef;
  border-radius: 10px;
  font-size: 20px;
}

.contact-item h3 {
  margin: 0 0 4px;
  color: #17251d;
  font-size: 14px;
}

.contact-item p,
.contact-item a {
  color: #087a45;
  font-size: 12px;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.contact-item a:hover {
  text-decoration: underline;
}

/* Tablet and mobile screens */
@media (max-width: 768px) {
  .hemipt-contact {
    width: 95%;
    padding: 20px 15px;
  }

  .contact-grid {
    gap: 20px 10px;
  }

  .contact-item {
    gap: 8px;
  }

  .contact-icon {
    width: 35px;
    height: 35px;
    font-size: 17px;
  }

  .contact-item h3 {
    font-size: 13px;
  }

  .contact-item a {
    font-size: 11px;
  }
}

/* =====================================================
   SETTINGS BUTTON (navbar)
   ===================================================== */
.settings-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: white;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.settings-btn:hover {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-light);
}

/* =====================================================
   AI MODE BADGE (chat footer)
   ===================================================== */
.ai-mode-badge {
  font-size: 10px;
  color: var(--muted);
}

.ai-mode-badge.ai-active {
  color: var(--green);
  font-weight: 600;
}

.ai-error-note {
  font-size: 11px;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 6px 12px;
  margin: 0 20px 8px;
}

/* =====================================================
   SETTINGS MODAL
   ===================================================== */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.settings-overlay[hidden] { display: none; }

.settings-card {
  background: white;
  border-radius: 18px;
  padding: 28px;
  width: min(460px, 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.settings-header h2 {
  font-size: 18px;
  color: var(--green-dark);
}

.settings-close-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.settings-close-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.settings-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

.settings-status {
  min-height: 22px;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  padding: 0 8px;
  line-height: 22px;
}

.settings-status.status-ok {
  background: var(--green-light);
  color: var(--green-dark);
}

.settings-status.status-err {
  background: #fef2f2;
  color: #b91c1c;
}

.settings-field {
  margin-bottom: 20px;
}

.settings-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 7px;
  letter-spacing: 0.3px;
}

.key-input-row {
  display: flex;
  gap: 8px;
}

.key-input-row input {
  flex: 1;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-family: monospace;
  outline: none;
  color: var(--ink);
}

.key-input-row input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px #087c4512;
}

.toggle-key-btn {
  width: 42px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  color: var(--muted);
  cursor: pointer;
}

.toggle-key-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.settings-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.btn-save {
  flex: 1;
  padding: 11px;
  border: none;
  border-radius: 10px;
  background: var(--green);
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn-save:hover { background: var(--green-dark); }

.btn-remove {
  padding: 11px 18px;
  border: 1px solid #fca5a5;
  border-radius: 10px;
  background: white;
  color: #dc2626;
  font-size: 14px;
  cursor: pointer;
}

.btn-remove:hover {
  background: #fef2f2;
}

.settings-warning {
  font-size: 11px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.6;
}

.settings-warning code {
  background: #fef3c7;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 11px;
}

@media (max-width: 430px) {
  .settings-card {
    padding: 20px 16px;
  }
  .settings-actions {
    flex-direction: column;
  }
}
