/* Chat — "Help now, not next month" home layout.
   Scoped under `.chat` like the landing's `.lp`, so these rules never leak
   elsewhere. Fixed hex values keep the landing palette (dark green #17251f,
   cream #f2efe6, coral #c2603e, sage #9fb8a9) consistent regardless of the
   browser's color scheme. */

.chat {
  font-family: 'Gabarito', system-ui, sans-serif;
  background: #17251f;
  color: #f2efe6;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Padding from the browser viewport, like the landing page: safe-area
     insets (notch/home-indicator on viewport-fit=cover devices) so the
     topbar and composer never sit under the OS chrome. */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
/* App-shell behaviour: the chat is exactly viewport height (100dvh, flex
   column, inner scroll areas), so the document never has room to scroll
   down — but overscroll chaining is intentionally left at the default so a
   pull-down at the top still triggers the browser's native pull-to-refresh. */
:where(.chat) header,
:where(.chat) main {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0;
}
.chat h1 { font-family: 'Gabarito', system-ui, sans-serif; }
.chat a { color: #f2efe6; }

/* ── Top bar ── */
.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px 6px;
}
.chat-logo {
  font-weight: 900;
  font-size: 21px;
  letter-spacing: -0.02em;
  color: #f2efe6;
  text-decoration: none;
}
.chat-logo:hover { opacity: 0.75; }
.chat-logo-dot { color: #c2603e; }
.chat-matches-link {
  font-size: 13.5px;
  font-weight: 700;
  color: #9fb8a9;
  background: rgba(242, 239, 232, 0.07);
  border: 1px solid rgba(242, 239, 232, 0.2);
  border-radius: 999px;
  padding: 7px 14px;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.chat-matches-link:hover {
  color: #f2efe6;
  border-color: #c2603e;
  background: rgba(194, 96, 62, 0.14);
}

/* ── Scroll area ── */
.chat-main {
  flex: 1;
  min-height: 0;
  /* Definite height (the .chat shell is exactly 100dvh), so this flex column
     and its children resolve against a fixed size. #chat-home and
     #messages-wrap are siblings here: they are mutually exclusive (a fresh
     visitor sees home, anyone with history sees the wrap), whichever is
     visible fills the area via flex-grow, and neither is ever painted over
     the other. */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 8px 20px 0;
}
.chat-home {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 20px 4px 6px;
}
.chat-home[hidden],
.chat .messages-wrap[hidden] { display: none; }

/* ── Hero ── */
.chat-hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-hero-title {
  margin: 0;
  font-weight: 800;
  font-size: 42px;
  line-height: 1;
  letter-spacing: -0.03em;
  color: #f2efe6;
}
.chat-hero-accent { color: #c2603e; }
.chat-hero-sub {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.5;
  color: #9fb8a9;
  max-width: 340px;
}

/* ── Category cards ── */
.chat-categories {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.chat .chat-category {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  font-family: 'Gabarito', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #17251f;
  background: #f2efe6;
  border: none;
  border-radius: 999px;
  padding: 15px 24px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.chat .chat-category:hover {
  background: #e8b49a;
  transform: translateY(-1px);
}
.chat-category-arrow { color: #c2603e; font-weight: 700; flex-shrink: 0; }

/* ── Trust bar ── */
.chat-trustbar {
  margin-top: auto;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 12px;
  color: #9fb8a9;
}

/* ── Composer ── */
.chat .composer {
  flex-shrink: 0;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 20px 24px;
}
.composer-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(242, 239, 232, 0.07);
  border: 1px solid rgba(242, 239, 232, 0.2);
  border-radius: 999px;
  padding: 6px 6px 6px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer-pill:focus-within {
  border-color: #c2603e;
  box-shadow: 0 0 0 3px rgba(194, 96, 62, 0.18);
}
.chat .composer-form {
  flex: 1;
  min-width: 0;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat #msg-input {
  flex: 1;
  min-width: 0;
  min-height: 0;
  border: none;
  background: transparent;
  font-family: 'Gabarito', system-ui, sans-serif;
  font-size: 14.5px;
  color: #f2efe6;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
  padding: 8px 0;
}
.chat #msg-input::placeholder { color: #9fb8a9; }
.chat #send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  padding: 0;
  color: #f2efe6;
  background: #c2603e;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, opacity 0.2s;
  opacity: 0.5;
}
.chat #send-btn.ready { opacity: 1; }
.chat #send-btn:hover { background: #9e4a2e; transform: translateY(-1px); }
.chat #send-btn:disabled { opacity: 0.5; cursor: wait; }
.chat #send-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

/* Mic / voice */
.chat .mic-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  max-width: 38px;
  min-height: 38px;
  max-height: 38px;
  aspect-ratio: 1;
  flex: none;
  padding: 0;
  border-radius: 50%;
  background: rgba(242, 239, 232, 0.07);
  border: 1.5px solid rgba(242, 239, 232, 0.34);
  color: #c7d6cd;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}
.chat .mic-btn:hover { border-color: rgba(242, 239, 232, 0.5); color: #f2efe6; }
.chat .mic-btn:disabled { opacity: 0.5; cursor: wait; }
.chat .mic-btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chat .mic-btn.connecting,
.chat .mic-btn.listening {
  background: #c2603e;
  border-color: #c2603e;
  color: #f2efe6;
  animation: chatMicPulse 1.3s ease-in-out infinite;
}
.chat .mic-btn.speaking {
  background: #9fb8a9;
  border-color: #9fb8a9;
  color: #17251f;
  box-shadow: 0 0 0 3px #c2603e;
}
@keyframes chatMicPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(194, 96, 62, 0.35); }
  50% { box-shadow: 0 0 0 8px rgba(194, 96, 62, 0); }
}

/* ── Conversation (after the home state) ── */
.chat .messages-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 8px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
.chat .msg {
  display: flex;
  align-items: flex-start;
  max-width: 100%;
  animation: chatMsgIn 0.3s ease-out both;
}
.chat .msg.user {
  justify-content: flex-end;
  align-items: flex-end;
}
.chat .msg.user .msg-bubble { margin-left: auto; }
.chat .messages-wrap::-webkit-scrollbar { width: 6px; }
.chat .messages-wrap::-webkit-scrollbar-track { background: transparent; }
.chat .messages-wrap::-webkit-scrollbar-thumb { background: rgba(242, 239, 232, 0.18); border-radius: 3px; }

@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.chat .msg-bubble {
  min-width: 0;
  max-width: 82%;
  overflow-wrap: break-word;
  word-break: break-word;
  padding: 13px 18px;
  font-size: 15px;
  line-height: 1.65;
  border-radius: 20px;
}
.chat .msg.avi .msg-bubble {
  font-family: 'Gabarito', system-ui, sans-serif;
  background: rgba(242, 239, 232, 0.09);
  color: #f2efe6;
  border-bottom-left-radius: 6px;
}
.chat .msg.avi .msg-bubble p  { margin: 0 0 0.6em; }
.chat .msg.avi .msg-bubble p:last-child { margin-bottom: 0; }
.chat .msg.avi .msg-bubble h3,
.chat .msg.avi .msg-bubble h4 {
  margin: 0.9em 0 0.35em;
  font-weight: 800;
  line-height: 1.3;
  color: #f2efe6;
}
.chat .msg.avi .msg-bubble h3 { font-size: 17px; }
.chat .msg.avi .msg-bubble h4 { font-size: 16px; }
.chat .msg.avi .msg-bubble ul,
.chat .msg.avi .msg-bubble ol { margin: 0.4em 0 0.6em 1.2em; padding: 0; }
.chat .msg.avi .msg-bubble li { margin-bottom: 0.25em; }
.chat .msg.avi .msg-bubble strong { font-weight: 700; color: #f2efe6; }
.chat .msg.avi .msg-bubble em { font-style: italic; }
.chat .msg.avi .msg-bubble a { color: #c2603e; }
.chat .msg.avi .msg-bubble code {
  font-family: 'Instrument Mono', ui-monospace, monospace;
  font-size: 0.85em;
  background: rgba(242, 239, 232, 0.1);
  border-radius: 5px;
  padding: 1px 6px;
}
.chat .msg.user .msg-bubble {
  background: #c2603e;
  color: #f2efe6;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.chat .msg.user .msg-bubble .msg-bubble-note {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(242, 239, 232, 0.28);
  font-size: 11px;
  line-height: 1.4;
  opacity: 0.8;
}

/* ── Chat-ended divider ── */
.chat .chat-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 2px;
  animation: chatMsgIn 0.3s ease-out both;
}
.chat .chat-divider-line { flex: 1; height: 1px; background: rgba(242, 239, 232, 0.18); }
.chat .chat-divider-content {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px 8px;
  font-size: 12px;
  line-height: 1.4;
  color: #9fb8a9;
}
.chat .chat-divider-topic { font-weight: 700; color: #e8b49a; }

/* Match link surfaced in the stream when a real match is found */
.chat .msg-match {
  display: flex;
  justify-content: flex-start;
  animation: chatMsgIn 0.3s ease-out both;
}
.chat .msg-match-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: #17251f;
  background: #f2efe6;
  border-radius: 999px;
  padding: 10px 18px;
  text-decoration: none;
  transition: background 0.15s, transform 0.15s;
}
.chat .msg-match-link:hover { background: #e8b49a; transform: translateY(-1px); }

/* ── Typing indicator ── */
.chat .typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 0;
  width: fit-content;
  background: transparent;
  border: none;
  box-shadow: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s;
}
.chat .typing-indicator.visible { opacity: 1; visibility: visible; }
.chat .typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c2603e;
  animation: chatTyping 1.2s ease-in-out infinite;
}
.chat .typing-dot:nth-child(2) { animation-delay: 0.15s; }
.chat .typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Voice status pill */
.chat .voice-status-pill {
  display: none;
  font-family: 'Gabarito', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #e8b49a;
  background: rgba(194, 96, 62, 0.16);
  border-radius: 999px;
  padding: 5px 11px;
  margin: 10px auto 0;
  width: fit-content;
}
.chat .voice-status-pill:not(:empty) { display: inline-flex; align-items: center; gap: 6px; }
.chat .voice-status-pill.speaking { background: rgba(159, 184, 169, 0.18); color: #9fb8a9; }
.chat .voice-status-pill.connecting { background: rgba(194, 96, 62, 0.16); color: #e8b49a; }
.chat .voice-status-pill .vsp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: chatPulse 1.5s ease-in-out infinite;
}
@keyframes chatPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

/* ── Responsive ── */
@media (max-width: 760px) {
  .chat-topbar { padding: 16px 16px 4px; }
  .chat-main { padding: 4px 16px 0; }
  .chat-hero-title { font-size: 38px; }
  .chat-home { gap: 22px; }
  .chat .composer { padding: 6px 16px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat .msg,
  .chat .msg-match { animation: none; }
  .chat .typing-dot,
  .chat .mic-btn.connecting,
  .chat .mic-btn.listening { animation: none; }
}
