/* ============================================================
   Mobile continuation — phone-first chat + lead capture sheet.
   Deep red primary on warm surfaces (Stitch design language).
   ============================================================ */

.m-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--surface);
  font-size: 16px;
}

/* ---------- Centered utility (loading / error) ---------- */

.m-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.m-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid var(--surface-highest);
  border-top-color: var(--primary);
  animation: m-spin 0.9s linear infinite;
}

@keyframes m-spin {
  to {
    transform: rotate(360deg);
  }
}

.m-error-card {
  background: #fff;
  border: 1px solid var(--surface-highest);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 26px 24px;
  text-align: center;
  max-width: 420px;
  font-size: 17px;
}

/* ---------- Header ---------- */

.m-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(120deg, var(--primary), var(--primary-container));
  color: var(--on-primary);
  flex-shrink: 0;
}

.m-head-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--on-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-lang-select {
  min-height: 44px;
  max-width: 118px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: #fff;
  color: var(--on-surface);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
}

.m-lead-btn {
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.12);
  color: var(--on-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.m-lead-btn:active {
  background: rgba(255, 255, 255, 0.24);
}

/* ---------- Messages ---------- */

.m-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  -webkit-overflow-scrolling: touch;
}

.m-page .bubble {
  max-width: 86%;
  font-size: 16px;
  padding: 11px 14px;
}

.m-msg-content {
  white-space: pre-wrap;
}

.m-sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(27, 28, 28, 0.14);
  font-size: 12.5px;
  color: var(--on-surface-variant);
}

.m-sources-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
}

.m-sources ul {
  margin: 4px 0 0;
  padding-inline-start: 18px;
}

.m-escalate {
  max-width: 86%;
  margin: 2px 0 10px;
  padding: 11px 14px;
  border-radius: var(--radius);
  border-inline-start: 4px solid var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 14.5px;
  font-weight: 600;
  margin-inline-end: auto;
}

/* Topics / suggestions */

.m-topics {
  margin-top: 14px;
}

.m-topics-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.m-topics-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block: 8px;
}

.m-page .chip {
  font-size: 14px;
  padding: 9px 16px;
  min-height: 44px;
}

/* Typing indicator */

.m-typing {
  color: var(--on-surface-variant);
  font-style: italic;
}

.m-dots span {
  animation: m-blink 1.2s infinite;
}

.m-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.m-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes m-blink {
  0%,
  80%,
  100% {
    opacity: 0.2;
  }
  40% {
    opacity: 1;
  }
}

/* Send error + retry */

.m-chat-error {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-block: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #ffe1e1;
  color: var(--error);
  font-size: 14px;
}

/* ---------- Lead banner ---------- */

.m-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 10px 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--secondary-soft);
  color: var(--on-surface);
  box-shadow: var(--shadow-1);
  flex-shrink: 0;
}

.m-banner-text {
  flex: 1;
  font-size: 13.5px;
  line-height: 1.35;
}

.m-banner-cta {
  min-height: 40px;
  padding: 6px 14px;
  font-size: 13.5px;
  white-space: nowrap;
}

.m-banner-close {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--on-surface-variant);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.m-banner-close:active {
  background: rgba(27, 28, 28, 0.08);
}

/* ---------- Input bar + footer ---------- */

.m-inputbar {
  display: flex;
  gap: 8px;
  padding: 10px 12px 6px;
  border-top: 1px solid var(--surface-highest);
  background: var(--surface-low);
  flex-shrink: 0;
}

.m-input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 10px 14px;
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  background: #fff;
  color: var(--on-surface);
  font-family: inherit;
  font-size: 16px;
}

.m-input::placeholder {
  color: var(--outline);
}

.m-input:focus {
  border-color: var(--primary);
  outline: 2px solid var(--primary-soft);
}

.m-send {
  min-height: 48px;
  padding-inline: 18px;
  font-size: 15px;
}

.m-foot {
  padding: 4px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface-low);
  color: var(--on-surface-variant);
  font-size: 13px;
  text-align: center;
  flex-shrink: 0;
}

/* ---------- Lead bottom sheet ---------- */

.m-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(27, 28, 28, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.m-sheet {
  width: min(560px, 100%);
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(27, 28, 28, 0.25);
  animation: m-sheet-up 200ms ease-out;
}

@keyframes m-sheet-up {
  from {
    transform: translateY(40px);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.m-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.m-sheet-head h2 {
  margin: 0;
  font-size: 20px;
  color: var(--primary);
}

.m-sheet-close {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--surface-container);
  color: var(--on-surface-variant);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.m-lead-intro {
  font-size: 14px;
  color: var(--on-surface-variant);
  margin-bottom: 14px;
}

.m-lead-form .field-label {
  margin-bottom: 12px;
}

.m-lead-form .input {
  margin-top: 5px;
  font-weight: 400;
}

.m-lead-req {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}

.m-lead-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 420px) {
  .m-lead-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.m-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 6px 0 14px;
  padding: 12px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  background: var(--surface-low);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--on-surface);
  cursor: pointer;
}

.m-consent input {
  width: 22px;
  height: 22px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.m-lead-submit {
  width: 100%;
  min-height: 52px;
  font-size: 17px;
}

/* Thanks state */

.m-lead-thanks {
  text-align: center;
  padding: 26px 12px 16px;
}

.m-lead-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #dcf1de;
  color: #1c5e26;
  font-size: 34px;
  font-weight: 800;
  margin-bottom: 14px;
}

.m-lead-thanks p {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 18px;
}

