/* ==========================================================================
   MOTOLECTRON AI: customer support chat (assets/js/support-chat.js)
   Bottom-left launcher + panel. Theme tokens only, so Light and Dark follow
   the site (the theme switch is a whole-page view transition: no colour
   transitions here). Motion is opacity/translate only: no press, bounce,
   spring or endless animation. z-index 100036 sits above the cart drawer's
   backdrop (100035) and below the drawer (100045), so it can never cover it.
   ========================================================================== */
.moto-chat {
  --moto-chat-size: 52px;
  --moto-chat-gap: 12px;
  --moto-chat-left: max(20px, calc(env(safe-area-inset-left, 0px) + 16px));
  --moto-chat-bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  --moto-chat-ease: var(--ix-ease-out, cubic-bezier(0.22, 1, 0.36, 1));
  /* The panel's wash: the logo's red at the top, fading into the panel. The
     header repeats it over scrolled messages, so one length has to fit both. */
  --moto-chat-wash: color-mix(in srgb, var(--moto-red-solid) 34%, var(--moto-panel));
  --moto-chat-wash-height: 300px;
  --moto-chat-wash-bg: linear-gradient(180deg, var(--moto-chat-wash), var(--moto-panel)) top / 100% var(--moto-chat-wash-height) no-repeat var(--moto-panel);
  --moto-chat-wash-at-head: 79%; /* how far the wash has faded by the header's lower edge */
  /* What sits on it: a step lighter in dark, where a shadow can't show */
  --moto-chat-surface: color-mix(in srgb, var(--moto-text) 7%, var(--moto-panel));
  --moto-chat-surface-hover: color-mix(in srgb, var(--moto-text) 5%, var(--moto-chat-surface));
  --moto-chat-shadow: 0 1px 2px -1px var(--moto-shadow-color), 0 3px 12px -4px var(--moto-shadow-color);
  font-family: inherit;
  color: var(--moto-text);
}

[data-theme="light"] .moto-chat {
  --moto-chat-wash: color-mix(in srgb, var(--moto-red-solid) 20%, var(--moto-panel));
  --moto-chat-surface: var(--moto-panel);
}

.moto-chat *,
.moto-chat *::before,
.moto-chat *::after {
  box-sizing: border-box;
}

.moto-chat-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Launcher
   -------------------------------------------------------------------------- */
.moto-chat-launcher {
  --moto-chat-raise: 0px;
  position: fixed;
  left: var(--moto-chat-left);
  bottom: var(--moto-chat-bottom);
  z-index: 100036;
  display: grid;
  place-items: center;
  width: var(--moto-chat-size);
  height: var(--moto-chat-size);
  margin: 0;
  padding: 0;
  border: 1px solid var(--moto-border);
  border-radius: 50%;
  background: var(--moto-sidebar);
  color: var(--moto-text);
  cursor: pointer;
  box-shadow:
    0 10px 24px -12px var(--moto-shadow-color),
    0 0 22px -8px var(--moto-red-glow);
  transform: translateY(calc(-1 * (var(--moto-chat-lift, 0px) + var(--moto-chat-raise))));
  transition:
    transform 220ms var(--moto-chat-ease),
    box-shadow 220ms var(--moto-chat-ease),
    border-color 220ms var(--moto-chat-ease),
    opacity 200ms ease,
    visibility 0s linear 0s;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .moto-chat-launcher:hover {
    --moto-chat-raise: 2px;
    border-color: var(--moto-border-hover);
    box-shadow:
      0 14px 28px -12px var(--moto-shadow-color),
      0 0 26px -8px var(--moto-red-glow);
  }
}

/* No press motion: a click keeps the launcher exactly where it is */
.moto-chat-launcher:active {
  transform: translateY(calc(-1 * (var(--moto-chat-lift, 0px) + var(--moto-chat-raise))));
}

.moto-chat-launcher:focus {
  outline: none;
}

.moto-chat-launcher:focus-visible {
  outline: 2px solid var(--moto-red);
  outline-offset: 3px;
}

.moto-chat-launcher-icon {
  grid-area: 1 / 1;
  position: relative;
  display: grid;
  place-items: center;
  transition: opacity 150ms ease;
}

.moto-chat-launcher-icon.is-close,
.moto-chat.is-open .moto-chat-launcher-icon.is-chat {
  opacity: 0;
}

.moto-chat.is-open .moto-chat-launcher-icon.is-close {
  opacity: 1;
}

.moto-chat-launcher-icon svg {
  display: block;
}

/* The logo's gauge, in the brand red (static: it never animates) */
.moto-chat-mark {
  display: block;
  width: 32px;
  margin-top: 2px; /* the arc is the heavy part: sit it optically centred */
  height: auto;
  color: var(--moto-red);
}

/* Stepped away (a dialog or the mobile menu is open, the cart drawer reaches
   this corner, or the hero's slide dots pass underneath) */
.moto-chat.is-suppressed .moto-chat-launcher,
.moto-chat.is-yielding .moto-chat-launcher {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    transform 220ms var(--moto-chat-ease),
    opacity 200ms ease,
    visibility 0s linear 200ms;
}

/* --------------------------------------------------------------------------
   Panel
   -------------------------------------------------------------------------- */
.moto-chat-panel {
  position: fixed;
  left: var(--moto-chat-left);
  bottom: calc(var(--moto-chat-bottom) + var(--moto-chat-size) + var(--moto-chat-gap) + var(--moto-chat-lift, 0px));
  z-index: 100036;
  display: flex;
  flex-direction: column;
  width: min(400px, var(--moto-chat-panel-max, 400px), calc(100vw - 2 * var(--moto-chat-left)));
  height: min(620px, calc(100dvh - var(--customer-header-offset, 136px) - var(--moto-chat-bottom) - var(--moto-chat-size) - var(--moto-chat-gap) - var(--moto-chat-lift, 0px) - 24px));
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--moto-border);
  border-radius: 20px;
  background: var(--moto-chat-wash-bg);
  color: var(--moto-text);
  box-shadow:
    0 24px 48px -20px var(--moto-shadow-color),
    0 2px 6px -2px var(--moto-shadow-color);
  opacity: 0;
  /* Closing: fades and drops 8px, quicker than it opened */
  transform: translateY(8px);
  transform-origin: bottom left;
  transition:
    opacity 200ms cubic-bezier(0.4, 0, 1, 1),
    transform 200ms cubic-bezier(0.4, 0, 1, 1);
}

.moto-chat-panel[hidden] {
  display: none;
}

/* Opening starts here (set for one frame by support-chat.js) */
.moto-chat-panel.is-entering-start {
  transform: translateY(16px) scale(0.98);
  transition: none;
}

.moto-chat.is-open .moto-chat-panel {
  opacity: 1;
  transform: none;
  transition:
    opacity 320ms var(--moto-chat-ease),
    transform 320ms var(--moto-chat-ease);
}

/* --------------------------------------------------------------------------
   Closed state: "Need help?" beside the launcher; its X dismisses it for the
   tab (support-chat.js)
   -------------------------------------------------------------------------- */
.moto-chat-hint {
  position: fixed;
  left: calc(var(--moto-chat-left) + var(--moto-chat-size) + 10px);
  bottom: var(--moto-chat-bottom);
  z-index: 100036;
  display: flex;
  align-items: flex-start;
  width: min(270px, calc(100vw - var(--moto-chat-left) - var(--moto-chat-size) - 26px));
  border: 1px solid var(--moto-border);
  border-radius: 14px 14px 14px 6px;
  background: var(--moto-panel);
  color: var(--moto-text);
  box-shadow:
    0 14px 30px -16px var(--moto-shadow-color),
    0 1px 3px -1px var(--moto-shadow-color);
  opacity: 0;
  transform: translateY(calc(6px - var(--moto-chat-lift, 0px)));
  transition:
    opacity 280ms var(--moto-chat-ease),
    transform 280ms var(--moto-chat-ease),
    visibility 0s linear 280ms;
  visibility: hidden;
}

.moto-chat-hint[hidden] {
  display: none;
}

.moto-chat-hint.is-shown {
  opacity: 1;
  visibility: visible;
  transform: translateY(calc(-1 * var(--moto-chat-lift, 0px)));
  transition:
    opacity 280ms var(--moto-chat-ease),
    transform 280ms var(--moto-chat-ease),
    visibility 0s linear 0s;
}

/* Never while the chat is open, or where the launcher steps away; when the
   chat closes it comes back (fades and rises 6px again). */
.moto-chat.is-open .moto-chat-hint,
.moto-chat.is-suppressed .moto-chat-hint,
.moto-chat.is-yielding .moto-chat-hint {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(calc(6px - var(--moto-chat-lift, 0px)));
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    visibility 0s linear 160ms;
}

.moto-chat-hint-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 10px 2px 11px 13px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

/* The X: a quiet 28px target in the top-right corner */
.moto-chat-hint-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 6px 6px 0 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--moto-text-dim);
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .moto-chat-hint-close:hover {
    background: var(--moto-overlay);
    color: var(--moto-text);
  }
}

.moto-chat-hint-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--moto-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.moto-chat-hint-spark {
  color: var(--moto-red);
  font-size: 11px;
}

.moto-chat-hint-text {
  color: var(--moto-text-secondary);
  font-size: 12.5px;
  line-height: 1.45;
}

@media (hover: hover) and (pointer: fine) {
  .moto-chat-hint:hover {
    border-color: var(--moto-border-hover);
  }
}

.moto-chat-hint :is(button):focus {
  outline: none;
}

.moto-chat-hint :is(button):focus-visible {
  outline: 2px solid var(--moto-red);
  outline-offset: -2px;
}

/* Header */
.moto-chat-head {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 10px 8px 16px;
  background: var(--moto-chat-wash-bg); /* opaque, in step with the panel's: messages pass under it */
}

/* They fade out as they go, instead of stopping at a hard edge */
.moto-chat-head::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 16px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--moto-chat-wash) var(--moto-chat-wash-at-head), var(--moto-panel)), transparent);
  pointer-events: none;
}

.moto-chat-avatar {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff; /* the logo's own ground, in both themes */
  box-shadow: 0 2px 8px -3px var(--moto-shadow-color);
}

.moto-chat-avatar .moto-chat-mark {
  width: 26px;
  color: var(--moto-red-solid);
}

.moto-chat-head-text {
  flex: 1;
  min-width: 0;
}

.moto-chat-title {
  margin: 0;
  color: var(--moto-text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.moto-chat-subtitle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 2px 0 0;
  color: var(--moto-text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

.moto-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--moto-success);
}

.moto-chat-status-dot.is-off {
  background: var(--moto-muted);
}

.moto-chat-head-actions {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 2px;
}

.moto-chat-close,
.moto-chat-more {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--moto-text);
  cursor: pointer;
  transition: background-color 160ms ease;
}

.moto-chat-close:hover,
.moto-chat-more:hover {
  background: var(--moto-overlay);
}

/* Conversation */
/* Its own layer: the wash shows through, so below 1.5x the browser would
   redraw the log, shadows and all, on every frame of a scroll. On Vega 10 at
   1.25x that took 504 ms of GPU time on a test scroll; with this, 207 ms. */
.moto-chat-log {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  will-change: scroll-position;
  scrollbar-width: thin;
  scrollbar-color: var(--moto-border-subtle) transparent;
}

.moto-chat-log:focus {
  outline: none;
}

.moto-chat-msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 100%;
}

.moto-chat-msg.is-user {
  align-items: flex-end;
}

/* Who is speaking: small mark and name above a reply */
.moto-chat-from {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 -2px;
  color: var(--moto-text-secondary);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
}

.moto-chat-from-mark {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: var(--moto-chat-shadow);
}

.moto-chat-from-mark .moto-chat-mark {
  width: 13px;
  margin-top: 1px;
  color: var(--moto-red-solid);
}

.moto-chat-msg.is-bot + .moto-chat-msg.is-bot .moto-chat-from {
  display: none;
}

.moto-chat-msg.is-entering {
  animation: motoChatMsgIn 240ms var(--moto-chat-ease) both;
}

@keyframes motoChatMsgIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.moto-chat-bubble {
  max-width: 88%;
  margin: 0;
  padding: 10px 13px;
  border-radius: 16px 16px 16px 6px;
  background: var(--moto-chat-surface);
  box-shadow: var(--moto-chat-shadow);
  color: var(--moto-text-secondary);
  font-size: 13.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.moto-chat-bubble p {
  margin: 0;
}

.moto-chat-bubble p + p {
  margin-top: 6px;
}

.moto-chat-bubble strong {
  color: var(--moto-text);
  font-weight: 600;
}

.moto-chat-msg.is-bot .moto-chat-bubble {
  align-self: flex-start;
}

/* Not about Motolectron: the same neutral bubble, its title and icon in the
   warning colour (coloured text only, no tinted box). */
.moto-chat-warning-title {
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.moto-chat-warning-title svg {
  flex: none;
  margin-top: 2px;
  color: var(--moto-warning);
}

.moto-chat-bubble.is-warning .moto-chat-warning-title strong {
  color: var(--moto-warning);
}

.moto-chat-msg.is-user .moto-chat-bubble {
  max-width: 82%;
  border-radius: 16px 16px 6px 16px;
  background: var(--moto-red-solid);
  color: #ffffff;
}

/* Thinking: "✦ Thinking…" (or "Checking Motolectron information…" while the
   catalogue or orders are read) and three dots that only change opacity,
   0 / 120 / 240 ms apart: no bounce, a few calm cycles at most. */
.moto-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}

.moto-chat-thinking {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--moto-muted);
  font-size: 12.5px;
  font-weight: 500;
  animation: motoChatThinking 1400ms ease-in-out 4 alternate both;
}

.moto-chat-thinking-spark {
  color: var(--moto-red);
  font-size: 11px;
}

@keyframes motoChatThinking {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

.moto-chat-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.moto-chat-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--moto-muted);
  opacity: 0.3;
  animation: motoChatDot 600ms ease-in-out 8 alternate both;
}

.moto-chat-dots span:nth-child(2) { animation-delay: 120ms; }
.moto-chat-dots span:nth-child(3) { animation-delay: 240ms; }

@keyframes motoChatDot {
  to { opacity: 0.9; }
}

/* Quick actions (greeting) */
.moto-chat-quick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.moto-chat-chips,
.moto-chat-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.moto-chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  padding: 7px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--moto-chat-surface);
  box-shadow: var(--moto-chat-shadow);
  color: var(--moto-text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition:
    background-color 180ms ease,
    transform 180ms var(--moto-chat-ease);
}

.moto-chat-chip.is-quick {
  border-radius: 12px;
  padding: 9px 12px;
}

.moto-chat-chip-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--moto-muted);
  transition: transform 180ms var(--moto-chat-ease), color 180ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .moto-chat-chip:hover {
    background: var(--moto-chat-surface-hover);
    transform: translateY(-1px);
  }

  .moto-chat-chip:hover .moto-chat-chip-icon {
    color: var(--moto-text);
    transform: translateX(1px);
  }
}

/* Links and small actions under an answer */
.moto-chat-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  margin: 0;
  padding: 5px 10px;
  border: 1px solid var(--moto-border);
  border-radius: 999px;
  background: transparent;
  color: var(--moto-text-secondary);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.moto-chat-link-arrow {
  display: grid;
  place-items: center;
  color: var(--moto-muted);
}

.moto-chat-link.is-button {
  border-color: transparent;
  background: var(--moto-red-solid);
  color: #ffffff;
}

.moto-chat-link:hover {
  border-color: var(--moto-border-hover);
  background: var(--moto-overlay);
  color: var(--moto-text);
}

.moto-chat-link.is-button:hover {
  border-color: transparent;
  background: var(--moto-red-solid);
  color: #ffffff;
  opacity: 0.9;
}

/* Product / order results */
.moto-chat-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.moto-chat-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--moto-chat-surface);
  box-shadow: var(--moto-chat-shadow);
  color: var(--moto-text);
  text-decoration: none;
  transition: background-color 160ms ease;
}

.moto-chat-card:hover {
  background: var(--moto-chat-surface-hover);
  color: var(--moto-text);
}

.moto-chat-card-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.moto-chat-card-title {
  overflow: hidden;
  color: var(--moto-text);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.moto-chat-card-meta {
  color: var(--moto-muted);
  font-size: 12px;
  line-height: 1.35;
}

.moto-chat-card-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  gap: 2px;
  color: var(--moto-text);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.moto-chat-card-side span {
  color: var(--moto-success);
  font-size: 11.5px;
  font-weight: 500;
}

.moto-chat-card-side.is-out span {
  color: var(--moto-red);
}

/* Product result: photo, name, details, "View product" */
.moto-chat-card.is-product {
  justify-content: flex-start;
  padding: 8px 12px 8px 8px;
}

.moto-chat-card.is-product .moto-chat-card-main {
  flex: 1;
}

.moto-chat-card-media {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  overflow: hidden;
  border-radius: 9px;
  background: var(--moto-panel-inset);
}

.moto-chat-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.moto-chat-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
  color: var(--moto-text-secondary);
  font-size: 11.5px;
  font-weight: 600;
}

.moto-chat-card-cta svg {
  color: var(--moto-muted);
  transition: transform 180ms var(--moto-chat-ease);
}

@media (hover: hover) and (pointer: fine) {
  .moto-chat-card.is-product:hover .moto-chat-card-cta svg {
    transform: translate(1px, -1px);
  }
}

/* Results rise in one after another (40-60 ms apart) */
.moto-chat-msg.is-entering .moto-chat-cards > li {
  animation: motoChatCardIn 280ms var(--moto-chat-ease) both;
  animation-delay: calc(80ms + var(--i, 0) * 50ms);
}

@keyframes motoChatCardIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* A file, in the parts of shadcn's Attachment (support-chat.js attachmentHtml). State
   lives in data-state: idle, uploading, processing, done or error. */
.moto-attachment-group {
  display: flex;
  flex: none;
  gap: 8px;
  margin: 12px 12px 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.moto-attachment-group::-webkit-scrollbar {
  display: none;
}

.moto-attachment-group[hidden] {
  display: none;
}

/* In the conversation: on the customer's side, the row ending at the right */
.moto-attachment-group.is-sent {
  width: 100%;
  margin: 0;
}

.moto-attachment-group.is-sent > :first-child {
  margin-left: auto;
}

.moto-attachment {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  width: 224px;
  max-width: 100%;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--moto-border);
  border-radius: 12px;
  background: var(--moto-panel-soft);
  color: var(--moto-text);
  scroll-snap-align: start;
}

.moto-attachment-group:not(.is-sent) > .moto-attachment:only-child {
  flex: 1 1 auto;
  width: auto;
}

.moto-attachment[data-orientation="vertical"] {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 148px;
}

.moto-attachment__media {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--moto-panel-inset);
  color: var(--moto-muted);
  transition: opacity 200ms ease;
}

.moto-attachment__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.moto-attachment[data-orientation="vertical"] .moto-attachment__media {
  width: 100%;
  height: 104px;
}

.moto-attachment__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.moto-attachment__title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.moto-attachment__description {
  overflow: hidden;
  color: var(--moto-muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The trigger covers the card; the actions sit above it, so both can be pressed */
.moto-attachment__trigger {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: zoom-in;
}

a.moto-attachment__trigger {
  cursor: pointer;
}

.moto-attachment__trigger:focus {
  outline: none;
}

.moto-attachment__trigger:focus-visible {
  outline: 2px solid var(--moto-red);
  outline-offset: -2px;
}

@media (hover: hover) and (pointer: fine) {
  .moto-attachment__trigger:hover {
    background: var(--moto-overlay);
  }
}

.moto-attachment__actions {
  position: relative;
  z-index: 2;
  flex: none;
  display: flex;
  gap: 2px;
}

.moto-attachment__action {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--moto-muted);
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease;
}

.moto-attachment__action[hidden] {
  display: none;
}

.moto-attachment__action:hover {
  background: var(--moto-overlay);
  color: var(--moto-text);
}

.moto-attachment__action:focus {
  outline: none;
}

.moto-attachment__action:focus-visible {
  outline: 2px solid var(--moto-red);
  outline-offset: 1px;
}

.moto-attachment:is([data-state="idle"], [data-state="uploading"], [data-state="processing"]) .moto-attachment__media {
  opacity: 0.6;
}

/* The title shimmers only while a file is working, and stops by itself */
.moto-attachment:is([data-state="uploading"], [data-state="processing"]) .moto-attachment__title {
  background: linear-gradient(90deg, var(--moto-text) 30%, var(--moto-muted) 50%, var(--moto-text) 70%) 0 0 / 220% 100%;
  color: transparent;
  animation: motoAttachmentShimmer 1400ms linear 60;
  -webkit-background-clip: text;
  background-clip: text;
}

@keyframes motoAttachmentShimmer {
  from { background-position: 110% 0; }
  to { background-position: -110% 0; }
}

/* The reason is in words, so the state does not rest on colour */
.moto-attachment[data-state="error"] {
  border-color: var(--moto-danger-border);
  background: var(--moto-danger-bg);
}

.moto-attachment[data-state="error"] .moto-attachment__description {
  display: -webkit-box;
  color: var(--moto-danger);
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

@media (prefers-reduced-motion: reduce) {
  .moto-attachment:is([data-state="uploading"], [data-state="processing"]) .moto-attachment__title {
    background: none;
    color: var(--moto-text);
    animation: none;
  }
}

/* Files dragged over the panel. It lets the pointer through, so moving across it
   does not read as leaving the panel. */
.moto-chat-drop {
  position: absolute;
  inset: 8px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1.5px dashed var(--moto-border-hover);
  border-radius: 14px;
  background: var(--moto-panel);
  pointer-events: none;
}

.moto-chat-drop[hidden] {
  display: none;
}

.moto-chat-drop-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--moto-panel-soft);
  color: var(--moto-text);
}

.moto-chat-drop-title {
  margin: 0;
  color: var(--moto-text);
  font-size: 15px;
  font-weight: 600;
}

.moto-chat-drop-text {
  margin: 0;
  color: var(--moto-muted);
  font-size: 12.5px;
}

/* Photo viewer: full screen, like a gallery app. Always dark (the dialog
   carries data-theme="dark", so the tokens below are the dark ones in either
   site theme). A soft, static wash of the photo's own colours behind it, a top
   bar (back, file name, ⋯ menu), the photo large in the middle. It fades in
   and the photo rises 8px; nothing scales or moves at rest. */
.moto-chat-viewer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: var(--moto-black);
  color: var(--moto-text);
}

.moto-chat-viewer::backdrop {
  background: var(--moto-backdrop);
}

.moto-chat-viewer[open] {
  display: block;
  animation: motoChatFade 220ms ease both;
}

/* The photo's colours, blurred once and darkened: depth without effects. */
.moto-chat-viewer-wash {
  position: absolute;
  inset: -12%;
  background-position: center;
  background-size: cover;
  filter: blur(70px) saturate(1.2);
  opacity: 0.45;
  pointer-events: none;
}

.moto-chat-viewer-wash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--moto-backdrop);
}

.moto-chat-viewer-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 72px;
  padding: 0 22px 0 26px;
}

.moto-chat-viewer-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--moto-text);
}

.moto-chat-viewer-title svg {
  flex-shrink: 0;
}

.moto-chat-viewer-name {
  overflow: hidden;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.moto-chat-viewer-btn {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--moto-text);
  cursor: pointer;
  transition: background-color 180ms ease;
}

.moto-chat-viewer-btn:hover {
  background: var(--moto-overlay-strong);
}

.moto-chat-viewer-actions {
  position: relative;
}

.moto-chat-viewer-menu,
.moto-chat-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--moto-border);
  border-radius: 12px;
  background: var(--moto-panel-soft);
  box-shadow: 0 16px 32px -16px var(--moto-shadow-color);
  animation: motoChatMsgIn 160ms var(--moto-chat-ease, ease-out) both;
}

.moto-chat-viewer-menu[hidden],
.moto-chat-menu[hidden] {
  display: none;
}

.moto-chat-viewer-item,
.moto-chat-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--moto-text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms ease;
}

/* "Image copied" and friends: a small note at the bottom, then it fades */
.moto-chat-viewer-toast {
  position: absolute;
  left: 50%;
  bottom: 28px;
  z-index: 3;
  margin: 0;
  padding: 9px 16px;
  border: 1px solid var(--moto-border);
  border-radius: 999px;
  background: var(--moto-panel-soft);
  color: var(--moto-text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 12px 28px -14px var(--moto-shadow-color);
  transform: translateX(-50%);
  animation: motoChatFade 180ms ease both;
}

.moto-chat-viewer-toast[hidden] {
  display: none;
}

.moto-chat-viewer-item svg,
.moto-chat-menu-item svg {
  color: var(--moto-muted);
}

.moto-chat-viewer-item:hover,
.moto-chat-menu-item:hover:not(:disabled) {
  background: var(--moto-overlay);
  color: var(--moto-text);
}

/* A reply is on its way: it would land in the new chat */
.moto-chat-menu-item:disabled {
  opacity: 0.45;
  cursor: default;
}

.moto-chat-viewer-stage {
  position: absolute;
  inset: 72px 0 32px;
  z-index: 1;
  display: grid;
  place-items: center;
}

/* support-chat.js sizes it to fill the stage (up to 90% of the width),
   keeping its shape and enlarging a small copy; these limits are the
   fallback. */
.moto-chat-viewer-img {
  display: block;
  max-width: 90vw;
  max-height: calc(100dvh - 160px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 24px 60px -24px var(--moto-shadow-color);
  cursor: default;
}

.moto-chat-viewer[open] .moto-chat-viewer-img {
  animation: motoChatViewerIn 260ms var(--moto-chat-ease, ease-out) both;
}

@keyframes motoChatViewerIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.moto-chat-viewer :is(button, a):focus {
  outline: none;
}

.moto-chat-viewer :is(button, a):focus-visible {
  outline: 2px solid var(--moto-red);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .moto-chat-viewer-top {
    height: 60px;
    gap: 8px;
    padding: 0 10px 0 6px;
  }

  .moto-chat-viewer-name {
    font-size: 15px;
  }

  .moto-chat-viewer-stage {
    inset: 60px 0 24px;
  }
}

/* Talk to staff */
.moto-chat-contact {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
  background: var(--moto-chat-surface);
  box-shadow: var(--moto-chat-shadow);
}

.moto-chat-contact-status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--moto-border);
  color: var(--moto-text-secondary);
  font-size: 12.5px;
  font-weight: 500;
}

.moto-chat-contact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--moto-text);
  font-size: 13px;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: background-color 160ms ease;
}

.moto-chat-contact-row + .moto-chat-contact-row {
  border-top: 1px solid var(--moto-border);
}

.moto-chat-contact-row svg {
  flex-shrink: 0;
  color: var(--moto-muted);
}

.moto-chat-contact-row:hover {
  background: var(--moto-overlay);
  color: var(--moto-text);
}

/* Composer: [attach] [mic] [question] [send], with the attachment preview and
   one status line (errors, "Listening…") above it */
.moto-chat-composer {
  position: relative;
  flex-shrink: 0;
  background: var(--moto-panel);
}

/* Messages fade out above it too, instead of stopping at a hard edge */
.moto-chat-composer::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  height: 16px;
  background: linear-gradient(180deg, transparent, var(--moto-panel));
  pointer-events: none;
}

.moto-chat-form {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 8px 12px 12px;
}

.moto-chat-tool {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--moto-muted);
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .moto-chat-tool:hover {
    border-color: var(--moto-border);
    background: var(--moto-overlay);
    color: var(--moto-text);
  }
}

/* The question field: attach inside its left end, the microphone inside its
   right end */
.moto-chat-field {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
}

.moto-chat-field .moto-chat-input {
  width: 100%;
  padding-left: 44px;
  padding-right: 46px;
}

.moto-chat-field .moto-chat-tool {
  position: absolute;
  top: 4px;
  width: 34px;
  height: 34px;
}

.moto-chat-field .moto-chat-tool.is-attach {
  left: 4px;
}

.moto-chat-field .moto-chat-tool.is-mic {
  right: 4px;
}

/* Listening: the microphone turns brand red (no pulse) */
.moto-chat-tool.is-mic.is-listening {
  border-color: var(--moto-red);
  background: var(--moto-red-glow);
  color: var(--moto-red);
}

.moto-chat-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 14px 0;
  color: var(--moto-text-secondary);
  font-size: 12.5px;
  line-height: 1.45;
  animation: motoChatFade 200ms ease both;
}

.moto-chat-note[hidden] {
  display: none;
}

.moto-chat-note.is-error {
  color: var(--moto-danger);
}

.moto-chat-note.is-listening {
  color: var(--moto-text);
  font-weight: 500;
}

@keyframes motoChatFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* A small three-bar level while listening: opacity only, a bounded run */
.moto-chat-wave {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 12px;
}

.moto-chat-wave span {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: var(--moto-red);
  opacity: 0.35;
  animation: motoChatDot 520ms ease-in-out 40 alternate both;
}

.moto-chat-wave span:nth-child(1) { height: 60%; }
.moto-chat-wave span:nth-child(2) { animation-delay: 120ms; }
.moto-chat-wave span:nth-child(3) { height: 75%; animation-delay: 240ms; }

.moto-chat-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  margin: 0;
  padding: 0 16px;
  border: 1px solid var(--moto-border);
  border-radius: 999px;
  background: var(--moto-panel-inset);
  color: var(--moto-text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.moto-chat-input::placeholder {
  color: var(--moto-muted);
  opacity: 1;
}

.moto-chat-input:focus {
  border-color: var(--moto-border-hover);
  box-shadow: var(--ix-focus-ring, 0 0 0 4px var(--moto-red-glow));
}

.moto-chat-send {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--moto-red-solid);
  color: #ffffff;
  cursor: pointer;
  transition: opacity 160ms ease;
}

.moto-chat-send:hover:not(:disabled) {
  opacity: 0.88;
}

.moto-chat-send:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Keyboard focus everywhere inside the panel */
.moto-chat-panel :is(a, button):focus {
  outline: none;
}

.moto-chat-panel :is(a, button):focus-visible {
  outline: 2px solid var(--moto-red);
  outline-offset: 2px;
}

.moto-chat-contact-row:focus-visible {
  outline-offset: -2px;
}

/* --------------------------------------------------------------------------
   Tablet: a little narrower
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .moto-chat-panel {
    width: min(360px, var(--moto-chat-panel-max, 360px), calc(100vw - 2 * var(--moto-chat-left)));
  }
}

/* The page behind a full-screen chat stays where it was. html keeps a gutter
   for the scrollbar, which a narrow desktop window would show beside the chat. */
html.moto-chat-locked {
  overflow: hidden;
  scrollbar-gutter: auto;
}

/* --------------------------------------------------------------------------
   Phones, upright or on their side: the whole screen, and the header's X
   closes it. support-chat.js keeps it inside the visible area when the
   keyboard opens (--moto-chat-vv-*), since a fixed panel would sit under it.
   -------------------------------------------------------------------------- */
@media (max-width: 600px), (max-height: 500px) {
  .moto-chat {
    --moto-chat-size: 48px;
    --moto-chat-left: max(16px, calc(env(safe-area-inset-left, 0px) + 12px));
    --moto-chat-bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px));
    --moto-chat-wash-height: clamp(280px, 44dvh, 400px);
    --moto-chat-wash-at-head: 81%;
  }

  /* Over the site header (100030). The cart drawer can't be under it: on a
     phone, opening the drawer closes the chat (update() in support-chat.js). */
  .moto-chat-panel {
    z-index: 100040;
    top: var(--moto-chat-vv-top, 0px);
    left: 0;
    right: 0;
    bottom: auto;
    width: 100%;
    height: var(--moto-chat-vv-height, 100dvh);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(8px);
    transform-origin: bottom center;
  }

  .moto-chat-panel.is-entering-start {
    transform: translateY(16px);
  }

  .moto-chat-head {
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    padding-right: 6px;
  }

  .moto-chat-close,
  .moto-chat-more {
    width: 44px;
    height: 44px;
  }

  /* iPhones zoom the page when a field under 16px takes focus */
  .moto-chat-input {
    font-size: 16px;
  }

  .moto-chat-chip.is-quick {
    min-height: 48px;
    padding: 12px 14px;
  }

  .moto-chat-hint-text {
    font-size: 12px;
  }

  .moto-chat.is-open .moto-chat-launcher {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 200ms ease, visibility 0s linear 200ms;
  }

  /* The footer's last line can scroll clear of the launcher
     (its 24px plus the 48px launcher and its 16px gap) */
  body:has(> .moto-chat) .moto-footer__bottom {
    padding-bottom: 88px;
  }
}

/* Upright there is room for one full-width list; on its side, two columns */
@media (max-width: 600px) {
  .moto-chat-quick {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --------------------------------------------------------------------------
   Reduced motion: fades only, short; the typing dots stand still
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .moto-chat-launcher,
  .moto-chat-launcher:hover,
  .moto-chat-launcher:active {
    --moto-chat-raise: 0px;
    transition: opacity 120ms ease, visibility 0s linear 0s;
  }

  .moto-chat-panel,
  .moto-chat.is-open .moto-chat-panel {
    transform: none;
    transition: opacity 120ms ease;
  }

  .moto-chat-msg.is-entering {
    animation: none;
  }

  .moto-chat-chip,
  .moto-chat-chip:hover {
    transform: none;
  }

  .moto-chat-dots span,
  .moto-chat-wave span,
  .moto-chat-thinking {
    animation: none;
    opacity: 0.8;
  }

  .moto-chat-panel.is-entering-start {
    transform: none;
  }

  .moto-chat-hint,
  .moto-chat-hint.is-shown {
    transform: translateY(calc(-1 * var(--moto-chat-lift, 0px)));
    transition: opacity 120ms ease, visibility 0s linear 0s;
  }

  .moto-chat-msg.is-entering .moto-chat-cards > li,
  .moto-chat-note,
  .moto-chat-viewer[open],
  .moto-chat-viewer[open]::backdrop,
  .moto-chat-viewer[open] .moto-chat-viewer-img,
  .moto-chat-viewer-menu,
  .moto-chat-menu {
    animation: none;
  }

  .moto-chat-chip:hover .moto-chat-chip-icon,
  .moto-chat-card.is-product:hover .moto-chat-card-cta svg {
    transform: none;
  }
}
