:root {
  --bg: #f5f7f9;
  --card: #ffffff;
  --ink: #1a1d21;
  --muted: #5c6570;
  --accent: #0b5d8f;
  --accent-ink: #ffffff;
  --bubble-visitor: #0b5d8f;
  --bubble-bot: #e8f1f7;
  --border: #d8dde3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.chat-wrap {
  max-width: 640px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  box-shadow: 0 0 24px rgba(0,0,0,0.05);
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 3px solid var(--accent);
  background: var(--card);
}
.chat-header .eyebrow {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 4px;
}
.chat-header h1 {
  font-size: 18px;
  margin: 0;
  letter-spacing: -.01em;
}

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

.bubble {
  max-width: 80%;
  padding: 11px 15px;
  border-radius: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  font-size: 15px;
}
.bubble.visitor {
  align-self: flex-end;
  background: var(--bubble-visitor);
  color: white;
  border-bottom-right-radius: 4px;
}
.bubble.bot {
  align-self: flex-start;
  background: var(--bubble-bot);
  border-bottom-left-radius: 4px;
}
.bubble.system {
  align-self: center;
  background: #fdf4e3;
  color: #8a5a00;
  font-size: 0.9em;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--card);
}
.chat-form textarea {
  flex: 1;
  resize: none;
  padding: 11px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 15px;
  font-family: inherit;
}
.chat-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.chat-form button {
  width: auto;
  padding: 0 20px;
  border-radius: 20px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  font-size: 15px;
  cursor: pointer;
}
.chat-form button:hover { opacity: 0.92; }
.chat-form button:disabled { opacity: 0.5; cursor: default; }

.status {
  text-align: center;
  color: var(--muted);
  font-size: 0.85em;
  min-height: 18px;
  margin: 4px 0 8px;
}

[hidden] { display: none !important; }

.mail-bar {
  padding: 0 16px 10px;
  background: var(--card);
  text-align: center;
}
.mail-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: 20px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.mail-button:hover { background: var(--bubble-bot); }

/* The separate "Mail this conversation" page */
.chat-wrap.mail-page { height: auto; min-height: 100vh; }
.mail-content {
  flex: 1;
  padding: 20px;
}
.mail-content section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mail-content p { margin: 0; line-height: 1.55; font-size: 15px; }
.mail-content input[type="text"],
.mail-content input[type="email"],
.mail-content textarea {
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 15px;
  font-family: inherit;
  background: var(--card);
  color: var(--ink);
}
.mail-content textarea { resize: vertical; min-height: 96px; }
.share-consent {
  display: flex;
  gap: 8px;
  font-size: 14px;
  line-height: 1.45;
  align-items: flex-start;
}
.share-buttons { display: flex; gap: 10px; align-items: center; }
.share-buttons button,
.button-link {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  border-radius: 20px;
  border: 1.5px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}
.share-buttons .secondary {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.share-buttons button:disabled { opacity: 0.5; cursor: default; }
.mail-content p.share-error { color: #8a5a00; min-height: 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.notice {
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
  margin: 0;
  padding: 0 20px 6px;
  background: var(--card);
}
/* Phones only: the disclaimer stays where it is at the start, and goes
   away once the visitor has sent a first message, to give the chat the room. */
@media (max-width: 640px) {
  .chat-wrap.started .notice { display: none; }
}

footer.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 0 14px;
  background: var(--card);
}
footer.site-footer a { color: var(--muted); }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --card: #1c2024;
    --ink: #f2f0ec;
    --muted: #9aa3ad;
    --bubble-bot: #26343e;
    --border: #2e3338;
  }
  .mail-button { color: #7fc1ea; border-color: #7fc1ea; }
}
