#talk-ai-overlay {
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

#talk-ai-overlay.talk-ai-open {
  opacity: 1;
}

.talk-ai-shell {
  position: absolute;
  inset: 0;
  margin: 0 auto;
  max-width: 100%;
  background: #030712;
}

@media (min-width: 768px) {
  .talk-ai-shell {
    max-width: 28rem;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
  }
}

.talk-ai-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  pointer-events: none;
}

.talk-ai-top-bar > * {
  pointer-events: auto;
}

.talk-ai-top-btn,
.talk-ai-nav-btn {
  display: flex;
  height: 2.5rem;
  width: 2.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.4);
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  transition:
    background 0.2s ease,
    color 0.2s ease,
    opacity 0.2s ease;
}

.talk-ai-top-btn:hover,
.talk-ai-nav-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
}

.talk-ai-nav-btn:disabled {
  cursor: default;
  opacity: 0.25;
  pointer-events: none;
}

.talk-ai-slides-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #030712;
}

.talk-ai-slide {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.talk-ai-slide.active {
  display: flex;
}

.talk-ai-slide-inner {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #0a0a0b;
}

.talk-ai-presentation-wrap {
  height: 100%;
  width: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.talk-ai-presentation-wrap > *:first-child {
  box-sizing: border-box;
}

.talk-ai-bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding: 0.55rem 0.75rem max(0.55rem, env(safe-area-inset-bottom));
  pointer-events: none;
}

.talk-ai-bottom-bar > * {
  pointer-events: auto;
}

.talk-ai-status-pill {
  display: inline-flex;
  min-width: 8.5rem;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.4);
  padding: 0.6rem 0.9rem;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.75rem;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
}

.talk-ai-status-dot {
  height: 0.45rem;
  width: 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
}

.talk-ai-dot {
  height: 6px;
  width: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
}

.talk-ai-dot.active {
  width: 18px;
  background: #a7f3d0;
}

.talk-ai-mic[data-state="listening"] {
  border-color: rgba(52, 211, 153, 0.6);
  background: rgba(52, 211, 153, 0.18);
  color: #a7f3d0;
}

.talk-ai-mic[data-state="processing"],
.talk-ai-mic[data-state="speaking"] {
  border-color: rgba(250, 204, 21, 0.6);
  background: rgba(250, 204, 21, 0.18);
  color: #fde68a;
}

.talk-ai-mic[data-state="muted"] .talk-ai-mic-icon {
  display: none;
}

.talk-ai-mic[data-state="muted"] .talk-ai-stop-icon {
  display: block;
}

[data-talk-ai-target="statusDot"][data-state="connecting"] {
  background: #facc15;
}

[data-talk-ai-target="statusDot"][data-state="connected"] {
  background: #34d399;
}

[data-talk-ai-target="statusDot"][data-state="error"] {
  background: #fb7185;
}

.talk-ai-skeleton {
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  padding: 2rem;
  background: linear-gradient(145deg, #111827, #020617);
}

.talk-ai-skeleton-bar,
.talk-ai-skeleton-card {
  border-radius: 1rem;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.07),
    rgba(255, 255, 255, 0.16),
    rgba(255, 255, 255, 0.07)
  );
  background-size: 200% 100%;
  animation: talk-ai-shimmer 1.4s infinite;
}

.talk-ai-skeleton-bar {
  height: 1rem;
  margin-bottom: 0.9rem;
}

.talk-ai-skeleton-title {
  height: 3rem;
  width: 78%;
  margin-top: 4rem;
}

.talk-ai-skeleton-card {
  height: 6rem;
  margin-top: 1rem;
}

@keyframes talk-ai-shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* ---- Mirror Card (in-viewport replace-in-place slide) ---- */
.talk-ai-mirror-slide .talk-ai-slide-inner {
  background: linear-gradient(160deg, #0b1220 0%, #0f172a 58%, #0b1120 100%);
}

.talk-ai-mirror-slide .talk-ai-presentation-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.25rem;
}

.talk-ai-mirror-slide .talk-ai-mirror {
  animation: talk-ai-mirror-enter 0.36s ease both;
}

@keyframes talk-ai-mirror-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.talk-ai-mirror {
  width: 100%;
  max-width: 30rem;
  margin: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.25rem;
  background: linear-gradient(160deg, rgba(17, 24, 39, 0.96), rgba(15, 23, 42, 0.96));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  padding: 1.1rem 1.15rem 1.25rem;
}

.talk-ai-mirror-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.talk-ai-mirror-title {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #bae6fd;
}

.talk-ai-mirror-stage {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

.talk-ai-mirror-rows {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.talk-ai-mirror-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  border-left: 3px solid rgba(56, 189, 248, 0.5);
  padding: 0.1rem 0 0.1rem 0.65rem;
}

.talk-ai-mirror-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.talk-ai-mirror-value {
  font-size: 0.95rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.92);
  word-break: break-word;
}

.talk-ai-mirror-contact {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.talk-ai-mirror-contact-head {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fde68a;
  margin-bottom: 0.6rem;
}

.talk-ai-mirror-contact-head.is-confirmed {
  color: #6ee7b7;
}

.talk-ai-mirror-contact-head.is-needs-correction {
  color: #fca5a5;
}

/* A contact detail whose latest correction failed validation: the saved value
   stays, but the row flags that the visitor needs to repeat it. */
.talk-ai-mirror-row.is-needs-correction {
  border-left-color: rgba(248, 113, 113, 0.85);
}

.talk-ai-mirror-row.is-needs-correction .talk-ai-mirror-hint {
  color: rgba(248, 113, 113, 0.9);
  font-style: normal;
}

.talk-ai-mirror-contact .talk-ai-mirror-row {
  border-left-color: rgba(250, 204, 21, 0.55);
}

@keyframes talk-ai-mirror-flash {
  0% {
    background: rgba(56, 189, 248, 0.16);
  }
  100% {
    background: transparent;
  }
}

.talk-ai-mirror-flash {
  animation: talk-ai-mirror-flash 0.7s ease-out;
  border-radius: 0.35rem;
}

/* Stage-sectioned canvas */
.talk-ai-mirror-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.talk-ai-mirror-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.talk-ai-mirror-section-label {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(186, 230, 253, 0.7);
}

/* Active capture: the slot the AI is currently working on. */
.talk-ai-mirror-row.is-active {
  border-left-color: rgba(250, 204, 21, 0.9);
}

.talk-ai-mirror-row.is-pending {
  border-left-color: rgba(250, 204, 21, 0.9);
  animation: talk-ai-mirror-pulse 1.6s ease-in-out infinite;
}

@keyframes talk-ai-mirror-pulse {
  0%,
  100% {
    box-shadow: -3px 0 0 0 rgba(250, 204, 21, 0);
    background: transparent;
  }
  50% {
    box-shadow: -3px 0 12px 0 rgba(250, 204, 21, 0.35);
    background: rgba(250, 204, 21, 0.07);
  }
}

.talk-ai-mirror-row.is-pending .talk-ai-mirror-label {
  color: rgba(253, 224, 71, 0.85);
}

/* Live question text shown while a slot is pending. */
.talk-ai-mirror-hint {
  font-size: 0.82rem;
  line-height: 1.35;
  color: rgba(253, 224, 71, 0.85);
  font-style: italic;
  word-break: break-word;
  white-space: pre-line;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
}

/* Pending -> captured resolution flash. */
@keyframes talk-ai-mirror-captured {
  0% {
    background: rgba(110, 231, 183, 0.22);
    border-left-color: rgba(110, 231, 183, 0.9);
  }
  100% {
    background: transparent;
    border-left-color: rgba(56, 189, 248, 0.5);
  }
}

.talk-ai-mirror-row.is-captured {
  animation: talk-ai-mirror-captured 1.1s ease-out;
  border-radius: 0.35rem;
}

/* ==========================================================================
   Card 1 — Explanation Card entrance motion.

   IMPORTANT: the hidden start state lives ONLY inside the .tai-card--enter
   classes (via the `both` fill of these keyframes). So if this stylesheet is
   absent (e.g. the node smoke test, or a CSS load failure) or the controller
   does not add .tai-card--enter, the card renders fully visible. The motion
   plays once on first paint; the controller never re-adds the class on
   progressive fill or finalize, so it never replays.
   ========================================================================== */
@keyframes tai-card-rise {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes tai-card-item-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.tai-card--enter {
  animation: tai-card-rise 360ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  will-change: transform, opacity;
}

.tai-card--enter .tai-card-kicker {
  animation: tai-card-item-rise 320ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: 40ms;
}

.tai-card--enter .tai-card-title {
  animation: tai-card-item-rise 340ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: 80ms;
}

/* Staggered cascade for the list/grid items of each layout. nth-child delays
   keep the renderer free of per-item inline state. */
.tai-card--enter .tai-stagger-group > * {
  animation: tai-card-item-rise 340ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.tai-card--enter .tai-stagger-group > *:nth-child(1) { animation-delay: 130ms; }
.tai-card--enter .tai-stagger-group > *:nth-child(2) { animation-delay: 185ms; }
.tai-card--enter .tai-stagger-group > *:nth-child(3) { animation-delay: 240ms; }
.tai-card--enter .tai-stagger-group > *:nth-child(4) { animation-delay: 295ms; }
.tai-card--enter .tai-stagger-group > *:nth-child(5) { animation-delay: 350ms; }
.tai-card--enter .tai-stagger-group > *:nth-child(6) { animation-delay: 405ms; }
.tai-card--enter .tai-stagger-group > *:nth-child(n + 7) { animation-delay: 460ms; }

/* Both guards force full content with no motion. The disable hook
   (data-disable-card-animation="true" on the controller root) is used by
   dev/test and a visitor escape hatch. */
@media (prefers-reduced-motion: reduce) {
  .tai-card--enter,
  .tai-card--enter .tai-card-kicker,
  .tai-card--enter .tai-card-title,
  .tai-card--enter .tai-stagger-group > * {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

[data-disable-card-animation="true"] .tai-card--enter,
[data-disable-card-animation="true"] .tai-card--enter .tai-card-kicker,
[data-disable-card-animation="true"] .tai-card--enter .tai-card-title,
[data-disable-card-animation="true"] .tai-card--enter .tai-stagger-group > * {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

/* ==========================================================================
   Card 4 — Speech-Synced Card Reveal (flagged, client-side).

   SAFETY-FIRST: the hidden start state exists ONLY under the controller-added
   parent class `.speech-reveal-active`. The renderer marks items with
   `data-speech-reveal-item` but applies NO hidden state, so flag off, CSS
   absent, reduced-motion, or any controller failure all render the full card.
   The controller adds `.speech-reveal-active` only when the flag is on, the
   card is finalized, and the layout is reveal-eligible; it then advances
   `.is-revealed` on each item to bring it in, and snaps everything visible on
   any exit/uncertainty.
   ========================================================================== */
.speech-reveal-active [data-speech-reveal-item] {
  transition: opacity 420ms cubic-bezier(0.2, 0.7, 0.2, 1),
    transform 420ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.speech-reveal-active [data-speech-reveal-item]:not(.is-revealed) {
  opacity: 0;
  transform: translateY(8px);
}

.speech-reveal-active [data-speech-reveal-item].is-revealed {
  opacity: 1;
  transform: none;
}

/* Managed reveal cards must not ALSO play the Card 1 item stagger, or items
   would double-animate. One parent class suppresses the entrance stagger for
   the item group only (the card chrome/kicker/title entrance is unaffected). */
.speech-reveal-managed.tai-card--enter .tai-stagger-group > *,
.speech-reveal-managed .tai-card--enter .tai-stagger-group > * {
  animation: none !important;
}

/* Reduced motion: never hide content for reveal, and don't transition. */
@media (prefers-reduced-motion: reduce) {
  .speech-reveal-active [data-speech-reveal-item],
  .speech-reveal-active [data-speech-reveal-item]:not(.is-revealed) {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ==========================================================================
   M2/M3b — Media-proof slot (image proof + video poster).

   SAFETY-FIRST: hidden/fade states live ONLY here in CSS. The renderer never
   hides the <img> or the text fallback inline, so if this stylesheet is absent
   (the node smoke test, a load failure) the image AND its fallback both show
   rather than nothing. The image is visible by default; the fade-in is an
   enhancement applied once the controller adds `.loaded` on the image's `load`
   event. On `error` the controller sets data-media-failed on the slot, which
   hides the broken image and reveals the in-markup text fallback.
   ========================================================================== */
@keyframes tai-media-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.tai-media-img.loaded {
  animation: tai-media-fade-in 360ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.tai-media-fallback {
  display: none;
}

.tai-media-slot[data-media-failed="true"] .tai-media-img {
  display: none;
}

.tai-media-slot[data-media-failed="true"] .tai-media-fallback {
  display: flex;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 600;
  color: color-mix(in srgb, var(--text, #111827) 82%, transparent);
  background: color-mix(in srgb, var(--accent, #6366f1) 8%, var(--surface, #fff));
}

/* Tap-to-play affordance over the video poster. The player itself is mounted
   lazily by the controller into a separate lightbox (never inline <video>). */
.tai-media-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #fff;
  background: color-mix(in srgb, #000 46%, transparent);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  transition: transform 160ms ease, background 160ms ease;
}

.tai-media-play:hover,
.tai-media-play:focus-visible {
  transform: scale(1.07);
  background: color-mix(in srgb, var(--accent, #6366f1) 70%, #000);
}

.tai-media-play-icon {
  display: grid;
  place-items: center;
  margin-left: 3px;
}

.tai-media-duration {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: color-mix(in srgb, #000 58%, transparent);
}

/* Lazy-mounted video lightbox/player. Built by the controller via DOM APIs
   (NOT through sanitized card HTML), so no inline <video> enters sanitized
   content and no sanitizer <video> allowance is needed. */
.tai-video-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 11, 18, 0.86);
  backdrop-filter: blur(4px);
}

.tai-video-lightbox-inner {
  position: relative;
  width: min(960px, 100%);
  max-height: 86vh;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}

.tai-video-lightbox-inner video,
.tai-video-lightbox-inner iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  object-fit: contain;
  background: #000;
}

.tai-video-lightbox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
}

.tai-video-lightbox-close:hover,
.tai-video-lightbox-close:focus-visible {
  background: rgba(0, 0, 0, 0.8);
}

@media (prefers-reduced-motion: reduce) {
  .tai-media-img.loaded,
  .tai-media-play {
    animation: none !important;
    transition: none !important;
  }
}
