@media (max-width: 880px) {
  body.pepper-mobile-open {
    overflow: hidden;
  }
  .chat-card {
    height: 360px;
  }
  .chat-card.is-mobile-fullscreen {
    position: fixed;
    top: var(--viewport-offset-top, 0);
    left: var(--viewport-offset-left, 0);
    right: auto;
    width: var(--viewport-width, 100vw);
    max-width: var(--viewport-width, 100vw);
    height: var(--viewport-height, 100vh);
    margin-top: 0;
    border-radius: 0;
    border: none;
    z-index: 1000;
    background: #f9fafb;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .chat-card.is-mobile-fullscreen .chat-header {
    padding-top: max(0.9rem, env(safe-area-inset-top));
    position: sticky;
    top: 0;
    z-index: 2;
  }
  .chat-card.is-mobile-fullscreen .chat-messages {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1rem;
  }
  .chat-card.is-mobile-fullscreen .chat-input-row {
    position: sticky;
    bottom: 0;
    z-index: 2;
    align-items: center;
    padding-bottom: max(0.7rem, env(safe-area-inset-bottom));
  }
  .chat-card.is-mobile-fullscreen .chat-input-row textarea {
    min-height: 44px;
    font-size: 16px;
  }
  .chat-card.is-mobile-fullscreen .chat-mobile-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .chat-voice-actions {
    gap: 0.35rem;
  }
  .chat-voice-button {
    padding: 0;
    font-size: 0;
  }
}

.chat-card {
  margin-top: 1rem;
  width: 100%;
  max-width: 100%;
  height: 420px;
  border-radius: 16px;
  border: 1px solid #e2e4ea;
  background: #f9fafb;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid #e2e4ea;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #ffffff;
  cursor: pointer;
}

.chat-title-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.chat-voice-actions {
  margin-left: auto;
  margin-right: 0.55rem;
  display: flex;
  align-items: center;
  min-width: 132px;
  justify-content: flex-end;
}

.chat-action-cluster {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.chat-action-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.22rem;
  justify-content: flex-start;
  width: 58px;
  min-width: 58px;
}

.chat-action-stack:first-child {
  margin-left: 0.18rem;
  transform: translateX(0.1rem);
}

.chat-action-stack:last-child {
  transform: translateX(-1.45rem);
}

.chat-voice-button {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.chat-voice-button:disabled {
  opacity: 0.42;
  cursor: default;
  box-shadow: none;
}

.chat-voice-button:not(:disabled):hover {
  transform: translateY(-1px);
}

.chat-voice-button::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.08) 34%, transparent 56%);
  opacity: 0.55;
  pointer-events: none;
}

.chat-voice-button::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.chat-voice-button-call {
  background: linear-gradient(180deg, #d9b08d 0%, #bf6d47 100%);
  color: #ffffff;
}

.chat-voice-button-call::after {
  background: radial-gradient(circle, rgba(191, 109, 71, 0.22), transparent 68%);
}

.chat-voice-button-call.is-listening {
  background: linear-gradient(180deg, #d8c5a8 0%, #8a6a52 100%);
  box-shadow: 0 0 0 3px rgba(191, 109, 71, 0.14), 0 4px 14px rgba(15, 23, 42, 0.16);
}

.chat-voice-button-call.is-listening::after {
  opacity: 1;
  transform: scale(1.18);
}

.chat-voice-button-end {
  background: linear-gradient(180deg, #f87171 0%, #b91c1c 100%);
  color: #ffffff;
}

.chat-voice-button-end::after {
  background: radial-gradient(circle, rgba(239, 68, 68, 0.2), transparent 68%);
}

.chat-contact-button {
  background: linear-gradient(180deg, #dbeceb 0%, #0f5f70 100%);
  color: #ffffff;
}

.chat-contact-button::after {
  background: radial-gradient(circle, rgba(15, 95, 112, 0.2), transparent 68%);
}

.chat-assistant-button {
  background: linear-gradient(180deg, #60a5fa 0%, #1d4ed8 100%);
  color: #ffffff;
}

.chat-assistant-button::after {
  background: radial-gradient(circle, rgba(59, 130, 246, 0.2), transparent 68%);
}

.chat-voice-button.is-disabled-mode {
  opacity: 0.65;
}

.chat-voice-core {
  position: relative;
  z-index: 1;
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  text-shadow: none;
}

.chat-voice-svg {
  width: 12px;
  height: 12px;
  line-height: 1;
  filter: none;
}

.chat-voice-beta {
  font-size: 0.56rem;
  letter-spacing: 0.03em;
  color: #64748b;
  line-height: 1.08;
  white-space: nowrap;
  min-height: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
}

.chat-voice-label,
.chat-mode-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.08rem;
  justify-content: flex-start;
}

.chat-voice-label,
.chat-mode-label {
  width: 58px;
}

.chat-voice-label span,
.chat-mode-label span {
  display: block;
}

.chat-voice-label span:first-child,
.chat-mode-label span:first-child {
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0;
}

.chat-voice-label span:nth-child(2) {
  font-size: 0.52rem;
  letter-spacing: 0;
}

.chat-voice-label span:nth-child(3) {
  font-size: 0.5rem;
  letter-spacing: 0.02em;
}

.chat-mode-label span:nth-child(2) {
  font-size: 0.52rem;
  letter-spacing: 0;
}

.chat-mode-label span:nth-child(3) {
  font-size: 0.5rem;
  letter-spacing: 0.02em;
}

.chat-orb {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #e0f2fe, #2563eb);
  box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.18);
  flex-shrink: 0;
  position: relative;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.chat-orb::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.24);
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.chat-title-main {
  font-size: 0.9rem;
  font-weight: 600;
}

.chat-title-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 1em;
  letter-spacing: 0.01em;
  transition: color 180ms ease;
}

.chat-title-sub[data-state="connecting"] { color: #475569; }

.chat-title-sub[data-state="available"],
.chat-title-sub[data-state="ready"] { color: #1f2937; }

.chat-title-sub[data-state="processing"] { color: #111827; }

.chat-title-sub[data-state="error"] { color: #991b1b; }

.chat-title-sub[data-state="handoff"] { color: #1f2937; }

.chat-title-sub[data-state="relay"] { color: #a16207; }

.chat-title-sub[data-state="checking"] { color: #166534; }

.chat-mobile-close {
  border: 1px solid var(--border);
  background: #ffffff;
  color: #374151;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.76rem;
  cursor: pointer;
  display: none;
}

.chat-messages {
  flex: 1;
  padding: 0.8rem 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background: #f9fafb;
}

.message-row {
  display: flex;
  width: 100%;
}

.message-row.assistant { justify-content: flex-start; }

.message-row.user { justify-content: flex-end; }

.message-row.event { justify-content: center; }

.message-bubble {
  max-width: 72%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  line-height: 1.4;
  border-radius: 16px;
  position: relative;
  display: inline-flex;
  flex-direction: column;
  gap: 0.2rem;
}

.message-bubble.assistant {
  background: #e5e7eb;
  color: #111827;
  border-bottom-left-radius: 4px;
}

.message-bubble.user {
  background: #dbeafe;
  color: #0f172a;
  border-bottom-right-radius: 4px;
}

.message-event {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  color: #64748b;
  font-size: 0.72rem;
  line-height: 1.2;
  text-align: center;
  max-width: 82%;
}

.message-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  align-self: flex-end;
}

.message-ticks {
  display: inline-flex;
  align-items: center;
  gap: 0.08rem;
}

.message-tick {
  color: #9ca3af;
  opacity: 0.95;
  transition: color 180ms ease, opacity 180ms ease;
}

.message-tick.is-active { color: #86efac; }

.message-tick.is-error { color: #dc2626; }

.message-status-label { color: var(--text-muted); }

.message-meta[data-status="processing"] .message-status-label { color: #374151; }

.message-meta[data-status="responded"] .message-status-label { color: #166534; }

.message-meta[data-status="error"] .message-status-label { color: #b91c1c; }

.chat-input-row {
  border-top: 1px solid var(--border);
  background: #ffffff;
  padding: 0.55rem 0.7rem;
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
}

.chat-input-row textarea {
  flex: 1;
  resize: none;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0.45rem 0.75rem;
  font-family: var(--font-main);
  font-size: 0.9rem;
  min-height: 40px;
  max-height: 80px;
  outline: none;
  background: #f9fafb;
}

@media (max-width: 880px) {
  .chat-input-row textarea {
    font-size: 16px;
  }
}

.chat-input-row textarea:focus {
  border-color: var(--link);
  background: #ffffff;
}

.chat-input-row button {
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.45);
}

.chat-input-row button:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

.chat-orb.state-connecting {
  background: radial-gradient(circle at 30% 30%, #f0f9ff, #3b82f6);
  animation: orb-connect 1.3s ease-in-out infinite;
}

.chat-orb.state-connecting::after {
  opacity: 1;
  border-color: rgba(59, 130, 246, 0.35);
}

.chat-orb.state-idle {
  opacity: 1;
  background: radial-gradient(circle at 30% 30%, #ffffff, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.chat-orb.state-idle::after {
  opacity: 1;
  transform: scale(1);
}

.chat-orb.state-typing {
  background: radial-gradient(circle at 30% 30%, #eff6ff, #1d4ed8);
  animation: orb-processing 0.9s linear infinite;
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.14);
}

.chat-orb.state-typing::after {
  opacity: 1;
  border-color: rgba(37, 99, 235, 0.38);
  animation: orb-ring 1.2s ease-out infinite;
}

.chat-orb.state-ready {
  background: radial-gradient(circle at 30% 30%, #ffffff, #2563eb);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
  animation: orb-ready 1.8s ease-in-out infinite;
}

.chat-orb.state-ready::after {
  opacity: 1;
  border-color: rgba(37, 99, 235, 0.28);
  transform: scale(1.08);
}

.chat-orb.state-error {
  background: radial-gradient(circle at 30% 30%, #fef2f2, #b91c1c);
  box-shadow: 0 0 0 4px rgba(185, 28, 28, 0.1);
}

.chat-orb.state-error::after {
  opacity: 1;
  border-color: rgba(185, 28, 28, 0.28);
}

.chat-orb.state-handoff {
  background: radial-gradient(circle at 30% 30%, #f0fdf4, #22c55e);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
  animation: orb-handoff 1.5s ease-in-out infinite;
}

.chat-orb.state-handoff::after {
  opacity: 1;
  border-color: rgba(34, 197, 94, 0.32);
  transform: scale(1.08);
}

.chat-orb.state-relay {
  background: radial-gradient(circle at 30% 30%, #fefce8, #eab308);
  box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.08);
  animation: orb-relay 1.7s ease-in-out infinite;
}

.chat-orb.state-relay::after {
  opacity: 1;
  border-color: rgba(234, 179, 8, 0.24);
  transform: scale(1.03);
}

.chat-orb.state-checking {
  background: radial-gradient(circle at 30% 30%, #ecfdf5, #16a34a);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.08);
  animation: orb-checking 1.6s ease-in-out infinite;
}

.chat-orb.state-checking::after {
  opacity: 1;
  border-color: rgba(34, 197, 94, 0.24);
  transform: scale(1.05);
}

@keyframes orb-connect {
  0%   { transform: scale(1); opacity: 0.8; }
  50%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

@keyframes orb-processing {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.12); }
  100% { transform: rotate(360deg) scale(1); }
}

@keyframes orb-ring {
  0%   { transform: scale(0.9); opacity: 0.75; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}

@keyframes orb-ready {
  0%   { transform: scale(1); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08); }
  50%  { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.18); }
  100% { transform: scale(1); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08); }
}

@keyframes orb-handoff {
  0%   { transform: scale(1); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.08); }
  50%  { transform: scale(1.08); box-shadow: 0 0 0 7px rgba(34, 197, 94, 0.18); }
  100% { transform: scale(1); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.08); }
}

@keyframes orb-relay {
  0%   { transform: scale(1); box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.06); }
  50%  { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(234, 179, 8, 0.14); }
  100% { transform: scale(1); box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.06); }
}

@keyframes orb-checking {
  0%   { transform: scale(1); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.06); }
  50%  { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.14); }
  100% { transform: scale(1); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.06); }
}

/* =====================================================================
   Unified floaty launcher + open/close states (one pill on every page).
   The chat card is hidden until the pill opens it, so every surface shows
   the same bottom-right Nancy launcher and routes into this one engine.
   ===================================================================== */

.pepper-launcher {
  position: fixed;
  right: 22px;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px 7px 14px;
  border-radius: 999px;
  background: rgba(248, 251, 252, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(15, 95, 112, 0.22);
  color: #1f2933;
  box-shadow: 0 16px 40px rgba(31, 41, 51, 0.18);
}

.pepper-launcher-orb {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #ffffff, #2563eb);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  animation: pepper-orb-breathe 2.1s ease-in-out infinite;
}

@keyframes pepper-orb-breathe {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.86); opacity: 0.82; }
}

.pepper-launcher-name {
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  color: #1f2933;
}

.pepper-launcher-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.pepper-launcher-btn svg {
  width: 18px;
  height: 18px;
}

.pepper-launcher-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.pepper-launcher-call {
  background: linear-gradient(180deg, #d9b08d 0%, #bf6d47 100%);
}

.pepper-launcher-chat {
  background: linear-gradient(180deg, #2f7d8a 0%, #155f70 100%);
}

.pepper-launcher-hidden {
  display: none !important;
}

/* Card is hidden until the launcher opens it. Using :not(.pepper-open) so the
   open state never sets display and therefore never fights the mobile-fullscreen
   grid layout via specificity. */
.pepper-embed:not(.pepper-open) .chat-card {
  display: none;
}

/* Desktop / tablet: open as a floating panel bottom-right (mobile uses the
   existing is-mobile-fullscreen lock untouched). */
@media (min-width: 881px) {
  .pepper-embed.pepper-open .chat-card {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1190;
    width: 384px;
    max-width: calc(100vw - 40px);
    height: 560px;
    max-height: calc(100vh - 40px);
    margin-top: 0;
    box-shadow: 0 20px 55px rgba(15, 23, 42, 0.32);
  }

  .pepper-embed.pepper-open .chat-mobile-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* ---- Header polish + call relocation (call now lives on the launcher pill) ---- */

/* Nancy title must stay readable regardless of the page's inherited text color. */
.chat-title-main {
  color: #1f2933;
}

/* Nice branded accent on the chat header. */
.chat-header {
  background: linear-gradient(120deg, rgba(37, 99, 235, 0.07), rgba(191, 109, 71, 0.07));
  border-bottom: 1px solid rgba(15, 95, 112, 0.18);
  box-shadow: inset 0 3px 0 0 #bf6d47;
}

/* The call button moved to the floaty pill, so hide it in the header (keep Contact Surya). */
.chat-action-cluster .chat-action-stack:first-child {
  display: none;
}

/* The content pages load site.css which has a global `button { padding: 12px 23px }`. The launcher
   buttons never declared padding, so that global leaked in and stretched the pill on those pages.
   Pin the launcher's own elements explicitly (higher specificity, scoped to the pill). */
.pepper-launcher .pepper-launcher-btn {
  padding: 0;
  width: 36px;
  height: 36px;
  flex: none;
}
.pepper-launcher .pepper-launcher-name { flex: none; }
.pepper-launcher .pepper-launcher-orb { flex: none; }
