/* =================================================================
   ออมสิน AI — answer thread (under the hero). Not in Figma: built from the
   page's language — Google Sans, ink #2A2A2A, pink #ED008C + brand gradient,
   white cards (1px #EBEBEB) and #FFEEF8 tints, radius 12–20, 1140 container.
   ================================================================= */
.s-ai-thread {
  --ait-pink: var(--gsb-pink);
  /* small pink TEXT: #ED008C is 4.2:1 on white / 3.7:1 on #FFEEF8 — this is ≥ 4.8:1 on both */
  --ait-pink-text: #C4006F;
  --ait-pink-soft: #FFF6FB;
  --ait-pink-line: #F9CFE6;
  --ait-hover-t: 520ms;           /* card/chip hovers: same duration + --ease-out both ways */
  --ait-card-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 18px 40px -26px rgba(42, 42, 42, 0.22);
  --ait-grad-diag: linear-gradient(135deg, #ED008C 0%, #FD266E 56.7%, #FC8555 100%);
  --ait-main: minmax(0, 1fr);
  --ait-side: 340px;
}

/* ---------------- section + open/close ---------------- */
.s-ai-thread[data-section="ai-thread"] {
  position: relative;
  background:
    radial-gradient(900px 260px at 50% 0, rgba(237, 0, 140, 0.07), transparent 70%),
    linear-gradient(180deg, #FFF7FB 0, #FFFFFF 320px);
  color: var(--ink);
}
.s-ai-thread .ait-shell {
  display: grid;
  grid-template-rows: 0fr;
  grid-template-columns: minmax(0, 1fr);
  opacity: 0;
  transition:
    grid-template-rows var(--t-slow) var(--ease-out),
    opacity 360ms var(--ease-out);
}
.s-ai-thread.is-open .ait-shell { grid-template-rows: 1fr; opacity: 1; }
.s-ai-thread.is-closing .ait-shell { transition-duration: 420ms, 260ms; }
.s-ai-thread .ait-body { min-height: 0; overflow: hidden; }
.s-ai-thread.is-settled .ait-body { overflow: visible; }
.s-ai-thread .ait-container { padding-top: 56px; padding-bottom: 88px; }

/* ---------------- header ---------------- */
.s-ai-thread .ait-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 36px;
  border-bottom: 1px solid var(--line);
}
.s-ai-thread .ait-head__title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.s-ai-thread .ait-head h2 {
  font-size: 24px;
  line-height: 1.3;
  font-weight: var(--fw-semibold);
  color: var(--ink);
}
.s-ai-thread .ait-grad-text {
  background: var(--gsb-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

/* ---------------- avatar (sparkle orb) ---------------- */
.s-ai-thread .ait-avatar {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ait-grad-diag);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(237, 0, 140, 0.55);
}
.s-ai-thread .ait-avatar svg { width: 20px; height: 22px; position: relative; z-index: 1; }
.s-ai-thread .ait-avatar--sm { width: 32px; height: 32px; box-shadow: 0 4px 12px -4px rgba(237, 0, 140, 0.5); }
.s-ai-thread .ait-avatar--sm svg { width: 16px; height: 17px; }
.s-ai-thread .ait-avatar.is-thinking {
  background: linear-gradient(135deg, #ED008C, #FD266E, #FC8555, #ED008C);
  background-size: 300% 300%;
  animation: ait-blob 2.4s var(--ease-in-out) infinite, ait-hue 3s linear infinite;
}
.s-ai-thread .ait-avatar.is-thinking::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(237, 0, 140, 0.35);
  animation: ait-halo 1.6s var(--ease-out) infinite;
}
@keyframes ait-halo { 70%, 100% { box-shadow: 0 0 0 10px rgba(237, 0, 140, 0); } }
.s-ai-thread .ait-avatar.is-thinking svg { animation: ait-twinkle 1.4s var(--ease-in-out) infinite; }
@keyframes ait-blob {
  0%, 100% { border-radius: 50%; }
  25% { border-radius: 58% 42% 55% 45% / 45% 55% 45% 55%; }
  50% { border-radius: 44% 56% 42% 58% / 58% 44% 56% 42%; }
  75% { border-radius: 55% 45% 60% 40% / 42% 58% 44% 56%; }
}
@keyframes ait-hue { to { background-position: 300% 0; } }
@keyframes ait-twinkle {
  0%, 100% { transform: scale(1) rotate(0); opacity: 1; }
  50% { transform: scale(0.82) rotate(-12deg); opacity: 0.85; }
}

/* ---------------- turns ---------------- */
.s-ai-thread .ait-turns { display: flex; flex-direction: column; gap: 64px; }
.s-ai-thread .ait-turn {
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-margin-top: 96px;
}
.s-ai-thread .ait-turn + .ait-turn { padding-top: 0; }

.s-ai-thread .ait-q { display: flex; justify-content: flex-end; }
.s-ai-thread .ait-q__bubble {
  max-width: min(680px, 78%);
  padding: 14px 20px;
  border-radius: 20px 20px 6px 20px;
  background: var(--gsb-pink-tint);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.5;
  font-weight: var(--fw-medium);
  overflow-wrap: anywhere;
  animation: ait-bubble 420ms var(--ease-out) both;
  transform-origin: 100% 100%;
}
@keyframes ait-bubble {
  from { opacity: 0; transform: translate(10px, 8px) scale(0.97); }
}

.s-ai-thread .ait-a {
  display: grid;
  grid-template-columns: var(--ait-main) var(--ait-side);
  gap: 24px 32px;
  align-items: start;
}
.s-ai-thread .ait-main { min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.s-ai-thread .ait-wide { grid-column: 1 / -1; min-width: 0; }
.s-ai-thread .ait-wide:empty, .s-ai-thread .ait-after:empty { display: none; }

/* ---------------- answer card ---------------- */
.s-ai-thread .ait-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 28px 14px;
  box-shadow: var(--ait-card-shadow);
  animation: ait-up 460ms var(--ease-out) 80ms both;
}
/* focus lands here after every ask (tabindex=-1, not operable) so the next Tab continues
   inside the answer; no ring — the presenter's Enter must not leave a halo on the card */
.s-ai-thread .ait-card:focus,
.s-ai-thread .ait-card:focus-visible { outline: 0; }
/* keep focused controls clear of the floating nav bar (top) and the sticky composer (phones) */
.s-ai-thread a,
.s-ai-thread button,
.s-ai-thread [tabindex] { scroll-margin-top: 96px; scroll-margin-bottom: 24px; }
.s-ai-thread .ait-card__head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.s-ai-thread .ait-card__who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.s-ai-thread .ait-card__who strong { font-size: 16px; line-height: 1.3; font-weight: var(--fw-semibold); }
.s-ai-thread .ait-stage {
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--ink-4);
  background: linear-gradient(90deg, #8A8A8A 0%, #8A8A8A 35%, #ED008C 50%, #8A8A8A 65%, #8A8A8A 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: ait-shine 1.8s linear infinite;
}
.s-ai-thread .ait-stage.is-swap { animation: ait-shine 1.8s linear infinite, ait-stage-in 320ms var(--ease-out); }
@keyframes ait-shine { from { background-position: 125% 0; } to { background-position: -125% 0; } }
@keyframes ait-stage-in { from { opacity: 0; transform: translateY(4px); } }

.s-ai-thread .ait-answer { min-height: 24px; }
.s-ai-thread .ait-prose {
  font-size: 17px;
  line-height: 1.75;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.s-ai-thread .ait-prose > * + * { margin-top: 12px; }
.s-ai-thread .ait-prose strong { font-weight: var(--fw-semibold); color: #1E1E1E; }
.s-ai-thread .ait-prose ul { display: flex; flex-direction: column; gap: 6px; }
.s-ai-thread .ait-prose li { position: relative; padding-left: 24px; }
.s-ai-thread .ait-prose li::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0.72em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ait-grad-diag);
}
.s-ai-thread .ait-muted { color: var(--ink-4); font-size: 15px; }
.s-ai-thread .ait-caret {
  display: inline-block;
  width: 2px;
  height: 1.15em;
  margin-left: 3px;
  vertical-align: -0.2em;
  border-radius: 2px;
  background: var(--ait-pink);
  animation: ait-blink 1s steps(1) infinite;
}
@keyframes ait-blink { 50% { opacity: 0; } }

/* skeleton */
.s-ai-thread .ait-skel { display: flex; flex-direction: column; gap: 12px; padding: 4px 0 8px; }
.s-ai-thread .ait-skel i,
.s-ai-thread .ait-rel--skel i,
.s-ai-thread .ait-bcard--skel i,
.s-ai-thread .ait-map__skel {
  display: block;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, #F3F3F5 0%, #F3F3F5 30%, #FCE4F1 50%, #F3F3F5 70%, #F3F3F5 100%);
  background-size: 300% 100%;
  animation: ait-shimmer 1.6s linear infinite;
}
.s-ai-thread .ait-skel i:nth-child(1) { width: 94%; }
.s-ai-thread .ait-skel i:nth-child(2) { width: 86%; animation-delay: 0.1s; }
.s-ai-thread .ait-skel i:nth-child(3) { width: 58%; animation-delay: 0.2s; }
@keyframes ait-shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }

/* sources */
.s-ai-thread .ait-sources {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 22px;
}
.s-ai-thread .ait-sources__label { font-size: 13px; font-weight: var(--fw-medium); color: var(--ink-4); margin-right: 2px; }
.s-ai-thread .ait-sources__list { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.s-ai-thread .ait-sources__list li { min-width: 0; max-width: 100%; animation: ait-up 360ms var(--ease-out) both; animation-delay: calc(var(--d, 0ms) + 120ms); }
.s-ai-thread .ait-source {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  height: 34px;
  padding: 0 12px 0 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid transparent;
  font-size: 13px;
  color: var(--ink-2);
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.s-ai-thread .ait-source__n {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  color: var(--ait-pink-text);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  box-shadow: 0 0 0 1px var(--line);
}
.s-ai-thread .ait-source__t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.s-ai-thread .ait-source svg { flex: none; width: 13px; height: 13px; color: var(--ink-5); transition: transform var(--t-fast) var(--ease-out), color var(--t-fast); }
.s-ai-thread .ait-source:active { transform: scale(0.97); }

/* CTA */
.s-ai-thread .ait-cta { margin-top: 22px; }

/* card footer: stop / actions */
.s-ai-thread .ait-card__foot {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid #F1F1F1;
}
.s-ai-thread .ait-actions { display: flex; align-items: center; gap: 12px; width: 100%; }
.s-ai-thread .ait-actions__btns { display: flex; align-items: center; gap: 2px; margin-left: -8px; }
.s-ai-thread .ait-actions__note { font-size: 13px; color: var(--ink-4); }
.s-ai-thread .ait-actions__note.is-pop { animation: ait-stage-in 300ms var(--ease-out); }
.s-ai-thread .ait-icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--ink-4);
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.s-ai-thread .ait-icon-btn svg { width: 19px; height: 19px; }
.s-ai-thread .ait-icon-btn:active { transform: scale(0.92); }
.s-ai-thread .ait-icon-btn[aria-pressed="true"] { color: var(--ait-pink); background: var(--gsb-pink-tint); }
.s-ai-thread .ait-icon-btn[aria-pressed="true"] svg { animation: ait-pop 360ms var(--ease-spring); }
.s-ai-thread .ait-icon-btn.is-done { color: #1A9E55; }
@keyframes ait-pop { 40% { transform: scale(1.25) rotate(-8deg); } }
.s-ai-thread .ait-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 4px);
  transition: opacity var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.s-ai-thread .ait-icon-btn:focus-visible .ait-tip,
.s-ai-thread .ait-icon-btn.is-done .ait-tip { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- buttons ---------------- */
.s-ai-thread .ait-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--r-12);
  font-size: 14px;
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), box-shadow var(--t-med) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.s-ai-thread .ait-btn svg { width: 18px; height: 18px; flex: none; transition: transform var(--t-med) var(--ease-out); }
.s-ai-thread .ait-btn--primary {
  height: 48px;
  padding: 0 22px;
  background: var(--gsb-pink-2);
  border: 1px solid var(--gsb-pink-2);
  color: #fff;
  font-size: 16px;
}
.s-ai-thread .ait-btn--secondary { border: 1px solid var(--gsb-pink-2); color: var(--ait-pink-text); background: #fff; }
.s-ai-thread .ait-btn--ghost { background: var(--gsb-pink-tint); color: var(--ait-pink-text); }
.s-ai-thread .ait-btn:disabled { opacity: 0.55; cursor: default; pointer-events: none; font-variant-numeric: tabular-nums; }
.s-ai-thread .ait-btn--sm { height: 36px; padding: 0 14px; font-size: 13px; }
.s-ai-thread .ait-btn--sm svg { width: 16px; height: 16px; }
.s-ai-thread .ait-btn--stop {
  height: 36px;
  padding: 0 14px 0 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 13.5px;
  animation: ait-up 300ms var(--ease-out) 400ms both;
}
.s-ai-thread .ait-btn--stop svg { width: 14px; height: 14px; color: var(--ait-pink); }

/* ---------------- related (aside) ---------------- */
.s-ai-thread .ait-side { min-width: 0; }
.s-ai-thread .ait-side__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 14px;
  font-size: 15px;
  font-weight: var(--fw-semibold);
  color: var(--ink);
}
.s-ai-thread .ait-side__title svg { width: 18px; height: 18px; color: var(--ait-pink); }
.s-ai-thread .ait-related { display: flex; flex-direction: column; gap: 12px; }
.s-ai-thread .ait-rel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px 18px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  transition: transform var(--ait-hover-t) var(--ease-out), border-color var(--ait-hover-t) var(--ease-out);
}
/* hover shadows fade in on a pseudo-element (opacity only) instead of animating box-shadow */
.s-ai-thread .ait-rel::after,
.s-ai-thread .ait-chip::after,
.s-ai-thread .ait-bcard::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--ait-hover-t) var(--ease-out);
}
.s-ai-thread .ait-rel::after,
.s-ai-thread .ait-bcard::after { box-shadow: var(--shadow-md); }
.s-ai-thread .ait-chip::after { box-shadow: 0 6px 16px -10px rgba(237, 0, 140, 0.45); }
.s-ai-thread a.ait-rel:active { transform: scale(0.985); transition-duration: 160ms; }
.s-ai-thread .ait-rel--skel { gap: 10px; pointer-events: none; }
.s-ai-thread .ait-rel--skel i:nth-child(1) { width: 64px; height: 20px; border-radius: 10px; }
.s-ai-thread .ait-rel--skel i:nth-child(2) { width: 88%; }
.s-ai-thread .ait-rel--skel i:nth-child(3) { width: 100%; height: 11px; }
.s-ai-thread .ait-rel--skel i:nth-child(4) { width: 70%; height: 11px; }
.s-ai-thread .ait-rel__title {
  font-size: 15px;
  line-height: 1.4;
  font-weight: var(--fw-semibold);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.s-ai-thread .ait-rel__sum {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.s-ai-thread .ait-rel__go {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--ait-pink-text);
}
.s-ai-thread .ait-rel__go svg { width: 14px; height: 14px; transition: transform var(--t-med) var(--ease-out); }

/* category badges */
.s-ai-thread .ait-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: var(--fw-semibold);
  line-height: 1;
  background: var(--ait-b-bg, #F2F2F4);
  color: var(--ait-b-fg, var(--ink-3));
}
.s-ai-thread .ait-cat--loan { --ait-b-bg: #FFEEF8; --ait-b-fg: #D4007D; }
.s-ai-thread .ait-cat--deposit { --ait-b-bg: #EAF0FF; --ait-b-fg: #2F55C7; }
.s-ai-thread .ait-cat--lottery { --ait-b-bg: #FBF3DF; --ait-b-fg: #8C6A18; }
.s-ai-thread .ait-cat--card { --ait-b-bg: #F2ECFF; --ait-b-fg: #6A3FD0; }
.s-ai-thread .ait-cat--insurance { --ait-b-bg: #E8F7EE; --ait-b-fg: #18743F; }
.s-ai-thread .ait-cat--investment { --ait-b-bg: #E9EBFA; --ait-b-fg: #1D2471; }
.s-ai-thread .ait-cat--service { --ait-b-bg: #EEF1F4; --ait-b-fg: #4B5563; }
.s-ai-thread .ait-cat--digital { --ait-b-bg: #FFEEF1; --ait-b-fg: #C21A50; }
.s-ai-thread .ait-cat--business { --ait-b-bg: #FFF0E8; --ait-b-fg: #A94A17; }
.s-ai-thread .ait-cat--government { --ait-b-bg: #E9EBFA; --ait-b-fg: #1D2471; }
.s-ai-thread .ait-cat--promotion { --ait-b-bg: #FFEFEA; --ait-b-fg: #B83A22; }
.s-ai-thread .ait-cat--news { --ait-b-bg: #F2F2F4; --ait-b-fg: #555; }
.s-ai-thread .ait-cat--overview { --ait-b-bg: #F2F2F4; --ait-b-fg: #555; }

/* ---------------- follow-up chips ---------------- */
.s-ai-thread .ait-fups { display: flex; flex-direction: column; gap: 12px; }
.s-ai-thread .ait-fups__label { font-size: 13px; font-weight: var(--fw-medium); color: var(--ink-4); }
/* follow-ups still loading (between answer_complete and done) */
.s-ai-thread .ait-fups--skel { flex-direction: row; flex-wrap: wrap; gap: 8px; pointer-events: none; animation: ait-up 300ms var(--ease-out) both; }
.s-ai-thread .ait-fups--skel i {
  display: block;
  height: 42px;
  width: 220px;
  max-width: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, #F3F3F5 0%, #F3F3F5 30%, #FCE4F1 50%, #F3F3F5 70%, #F3F3F5 100%);
  background-size: 300% 100%;
  animation: ait-shimmer 1.6s linear infinite;
}
.s-ai-thread .ait-fups--skel i:nth-child(2) { width: 180px; animation-delay: 0.1s; }
.s-ai-thread .ait-fups--skel i:nth-child(3) { width: 250px; animation-delay: 0.2s; }
.s-ai-thread .ait-fups__list { display: flex; flex-wrap: wrap; gap: 8px; }
.s-ai-thread .ait-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  max-width: 100%;
  padding: 8px 12px 8px 12px;
  border-radius: var(--r-pill);
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.35;
  text-align: left;
  position: relative;
  animation: ait-up 380ms var(--ease-out) both;
  animation-delay: calc(var(--d, 0ms) + 180ms);
  transition: background-color var(--ait-hover-t) var(--ease-out), color var(--ait-hover-t) var(--ease-out), border-color var(--ait-hover-t) var(--ease-out), transform 160ms var(--ease-out);
}
.s-ai-thread .ait-chip__ic { flex: none; display: grid; place-items: center; width: 16px; height: 16px; color: var(--gsb-coral); }
.s-ai-thread .ait-chip__ic svg { width: 14px; height: 15px; transition: transform var(--ait-hover-t) var(--ease-out); }
.s-ai-thread .ait-chip > svg { flex: none; width: 14px; height: 14px; color: var(--ink-5); margin-left: -2px; transition: transform var(--ait-hover-t) var(--ease-out), color var(--ait-hover-t) var(--ease-out); }
.s-ai-thread .ait-chip:active { transform: scale(0.97); }

/* ---------------- errors ---------------- */
.s-ai-thread .ait-error {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--ait-pink-soft);
  border: 1px solid var(--ait-pink-line);
  animation: ait-up 380ms var(--ease-out) both;
}
.s-ai-thread .ait-error.is-partial { margin-top: 18px; }
.s-ai-thread .ait-error__icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #fff; color: var(--ait-pink); }
.s-ai-thread .ait-error__icon svg { width: 22px; height: 22px; }
.s-ai-thread .ait-error__txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.s-ai-thread .ait-error__txt strong { font-size: 15px; font-weight: var(--fw-semibold); line-height: 1.45; }
.s-ai-thread .ait-error__txt span { font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }

/* ---------------- branch widget ---------------- */
.s-ai-thread .ait-branches {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--ait-card-shadow);
}
.s-ai-thread .ait-branches__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.s-ai-thread .ait-branches__title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.s-ai-thread .ait-branches__ic { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--gsb-pink-tint); color: var(--ait-pink); }
.s-ai-thread .ait-branches__ic svg { width: 22px; height: 22px; }
.s-ai-thread .ait-branches h3 { font-size: 18px; line-height: 1.35; font-weight: var(--fw-semibold); }
.s-ai-thread .ait-branches__title p { font-size: 13.5px; color: var(--ink-4); margin-top: 2px; }
.s-ai-thread .ait-branches__grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; height: 440px; }
.s-ai-thread .ait-map {
  position: relative;
  min-height: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #EEF0F3;
  isolation: isolate;
}
.s-ai-thread .ait-map__skel { position: absolute; inset: 0; height: auto; border-radius: 0; }
.s-ai-thread .ait-map__fallback { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; font-size: 14px; color: var(--ink-4); }
.s-ai-thread .ait-map__fallback svg { width: 28px; height: 28px; color: var(--ait-pink); }
.s-ai-thread .ait-blist {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 6px 2px 2px;
  scrollbar-width: thin;
  scrollbar-color: #E2E2E2 transparent;
}
.s-ai-thread .ait-bcard {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 14px 14px 14px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  animation: ait-up 360ms var(--ease-out) both;
  animation-delay: var(--d, 0ms);
  transition: border-color var(--ait-hover-t) var(--ease-out), background-color var(--ait-hover-t) var(--ease-out), box-shadow var(--ait-hover-t) var(--ease-out);
}
.s-ai-thread .ait-bcard.is-active { border-color: var(--ait-pink); background: var(--ait-pink-soft); box-shadow: 0 0 0 3px rgba(237, 0, 140, 0.08); }
.s-ai-thread .ait-bcard--skel { flex-direction: column; gap: 10px; cursor: default; }
.s-ai-thread .ait-bcard--skel i:nth-child(1) { width: 55%; }
.s-ai-thread .ait-bcard--skel i:nth-child(2) { width: 90%; height: 11px; }
.s-ai-thread .ait-bcard--skel i:nth-child(3) { width: 40%; height: 11px; }
.s-ai-thread .ait-bcard__n {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ait-grad-diag);
  color: #fff;
  font-size: 12.5px;
  font-weight: var(--fw-semibold);
}
.s-ai-thread .ait-bcard__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.s-ai-thread .ait-bcard__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.s-ai-thread .ait-bcard__name { font-size: 15px; line-height: 1.4; font-weight: var(--fw-semibold); text-align: left; color: var(--ink); padding-top: 2px; }
.s-ai-thread .ait-bcard__dist {
  flex: none;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--gsb-pink-tint);
  color: #D4007D;
  font-size: 12px;
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}
.s-ai-thread .ait-bcard__addr { font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.s-ai-thread .ait-bcard__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-4); }
.s-ai-thread .ait-bcard__meta > * { display: inline-flex; align-items: center; gap: 5px; }
.s-ai-thread .ait-bcard__meta svg { width: 14px; height: 14px; flex: none; }
.s-ai-thread .ait-bcard__meta a { color: var(--ink-3); }
.s-ai-thread .ait-bcard__svc { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.s-ai-thread .ait-bcard__svc span { padding: 3px 8px; border-radius: 6px; background: var(--surface-3); font-size: 11.5px; color: var(--ink-3); }
.s-ai-thread .ait-bcard__dir {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  margin-top: 4px;
  min-height: 32px;
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--ait-pink-text);
}
.s-ai-thread .ait-bcard__dir svg { width: 15px; height: 15px; transition: transform var(--t-med) var(--ease-out); }
.s-ai-thread .ait-bempty { padding: 16px; font-size: 14px; color: var(--ink-2); line-height: 1.6; }
.s-ai-thread .ait-bempty a { color: var(--ait-pink-text); text-decoration: underline; }
.s-ai-thread .ait-branches.is-empty .ait-branches__grid,
.s-ai-thread .ait-branches.is-failed .ait-branches__grid { height: auto; grid-template-columns: 1fr; }
.s-ai-thread .ait-branches.is-empty .ait-map,
.s-ai-thread .ait-branches.is-failed .ait-map { display: none; }

/* Leaflet skin */
.s-ai-thread .leaflet-container { font-family: var(--font); background: #EEF0F3; }
.s-ai-thread .leaflet-tile-pane { filter: saturate(0.55) brightness(1.03) contrast(0.96); }
.s-ai-thread .leaflet-control-zoom { border: 0 !important; box-shadow: 0 4px 14px -4px rgba(42, 42, 42, 0.25) !important; border-radius: 12px !important; overflow: hidden; }
.s-ai-thread .leaflet-control-zoom a { width: 36px !important; height: 36px !important; line-height: 34px !important; color: var(--ink) !important; font-size: 18px !important; }
.s-ai-thread .leaflet-control-attribution { font-size: 10px; background: rgba(255, 255, 255, 0.8) !important; border-radius: 8px 0 0 0; }
.s-ai-thread .ait-pin { background: none; border: 0; }
.s-ai-thread .ait-pin__b {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  background: var(--ait-grad-diag);
  border: 2.5px solid #fff;
  box-shadow: 0 6px 14px -4px rgba(237, 0, 140, 0.6);
  transition: transform var(--t-med) var(--ease-spring);
}
.s-ai-thread .ait-pin__b span { transform: rotate(45deg); color: #fff; font-size: 13px; font-weight: var(--fw-bold); }
.s-ai-thread .ait-me span {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2F6BFF;
  border: 3px solid #fff;
  box-shadow: 0 0 0 0 rgba(47, 107, 255, 0.45);
  animation: ait-me 2s var(--ease-out) infinite;
}
@keyframes ait-me { 70% { box-shadow: 0 0 0 14px rgba(47, 107, 255, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 107, 255, 0); } }
.s-ai-thread .ait-popup .leaflet-popup-content-wrapper { border-radius: 14px; box-shadow: 0 12px 28px -10px rgba(42, 42, 42, 0.35); }
.s-ai-thread .ait-popup .leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.5; color: var(--ink-2); display: flex; flex-direction: column; gap: 2px; min-width: 180px; }
.s-ai-thread .ait-popup .leaflet-popup-content strong { color: var(--ink); font-size: 14px; font-weight: var(--fw-semibold); }

/* ---------------- composer ---------------- */
.s-ai-thread .ait-dock { margin-top: 56px; z-index: 20; }
.s-ai-thread .ait-composer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 8px 18px;
  border-radius: var(--r-16);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 14px 36px -22px rgba(42, 42, 42, 0.3);
  transition: border-color var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out);
}
.s-ai-thread .ait-composer:focus-within {
  border-color: rgba(237, 0, 140, 0.45);
  box-shadow: 0 0 0 4px rgba(237, 0, 140, 0.09), 0 14px 36px -22px rgba(237, 0, 140, 0.35);
}
.s-ai-thread .ait-composer.is-listening { border-color: var(--ait-pink); }
.s-ai-thread .ait-composer__icon { flex: none; display: grid; place-items: center; width: 24px; color: var(--ait-pink); }
.s-ai-thread .ait-composer__icon svg { width: 20px; height: 22px; }
.s-ai-thread .ait-composer__input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 6px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 17px;
  color: var(--ink);
}
.s-ai-thread .ait-composer__input::placeholder { color: var(--ink-5); opacity: 1; }
.s-ai-thread .ait-composer__input:focus-visible { outline: 0; }
.s-ai-thread .ait-mic {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  color: var(--ink-3);
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.s-ai-thread .ait-mic svg { width: 22px; height: 22px; position: relative; z-index: 1; }
.s-ai-thread .ait-mic.is-recording { color: #fff; background: var(--ait-pink); }
.s-ai-thread .ait-mic.is-recording::before,
.s-ai-thread .ait-mic.is-recording::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--ait-pink);
  opacity: 0.35;
  animation: ait-ring 1.4s var(--ease-out) infinite;
}
.s-ai-thread .ait-mic.is-recording::after { animation-delay: 0.7s; }
@keyframes ait-ring { from { transform: scale(1); opacity: 0.4; } to { transform: scale(1.55); opacity: 0; } }
.s-ai-thread .ait-send {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--gsb-pink-2);
  color: #fff;
  transition: background-color var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.s-ai-thread .ait-send svg { grid-area: 1 / 1; width: 22px; height: 22px; transition: opacity var(--t-fast) var(--ease-out), transform var(--t-med) var(--ease-spring); }
.s-ai-thread .ait-send__stop { opacity: 0; transform: scale(0.5); }
.s-ai-thread .ait-send.is-stop { background: var(--ink); }
.s-ai-thread .ait-send.is-stop .ait-send__go { opacity: 0; transform: scale(0.5); }
.s-ai-thread .ait-send.is-stop .ait-send__stop { opacity: 1; transform: none; }
.s-ai-thread .ait-disclaimer { margin-top: 12px; text-align: center; font-size: 12.5px; line-height: 1.5; color: var(--ink-5); }
.s-ai-thread .ait-disclaimer a { color: var(--ink-4); text-decoration: underline; text-underline-offset: 2px; }

/* ---------------- toast (voice errors; host appended to body) ---------------- */
.s-ai-thread.ait-toast-host {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}
.s-ai-thread .ait-toast {
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  animation: ait-up 300ms var(--ease-out) both;
  transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
}
.s-ai-thread .ait-toast.is-out { opacity: 0; transform: translateY(8px); }

/* ---------------- staggered reveal ---------------- */
.s-ai-thread .ait-in { animation: ait-up 460ms var(--ease-out) both; animation-delay: var(--d, 0ms); }
@keyframes ait-up { from { opacity: 0; transform: translateY(10px); } }

/* ---------------- hover (pointer devices) ---------------- */
@media (hover: hover) and (pointer: fine) {
  .s-ai-thread .ait-btn--ghost:hover { background: #FFE0F2; }
  .s-ai-thread .ait-btn--primary:hover { background: #D6007E; border-color: #D6007E; box-shadow: var(--shadow-pink); }
  .s-ai-thread .ait-btn--primary:hover svg { transform: translateX(3px); }
  .s-ai-thread .ait-btn--secondary:hover { background: var(--gsb-pink-tint); }
  .s-ai-thread .ait-btn--secondary:hover svg { transform: rotate(-40deg); }
  .s-ai-thread .ait-btn--stop:hover { border-color: var(--ait-pink); color: var(--ait-pink-text); }
  .s-ai-thread .ait-source:hover { background: var(--gsb-pink-tint); color: var(--ait-pink-text); }
  .s-ai-thread .ait-source:hover svg { color: var(--ait-pink); transform: translate(2px, -2px); }
  .s-ai-thread .ait-icon-btn:hover { background: var(--surface-3); color: var(--ink); }
  .s-ai-thread .ait-icon-btn:hover .ait-tip { opacity: 1; transform: translate(-50%, 0); transition-delay: 250ms; }
  .s-ai-thread .ait-icon-btn[aria-pressed="true"]:hover { background: #FFE0F2; color: var(--ait-pink); }
  .s-ai-thread a.ait-rel:hover { transform: translateY(-3px); border-color: var(--ait-pink-line); will-change: transform; }
  .s-ai-thread a.ait-rel:hover::after,
  .s-ai-thread .ait-chip:hover::after,
  .s-ai-thread .ait-bcard:not(.ait-bcard--skel):hover::after { opacity: 1; }
  .s-ai-thread a.ait-rel:hover .ait-rel__go svg { transform: translateX(4px); }
  .s-ai-thread .ait-chip:hover { border-color: var(--ait-pink-line); background: var(--ait-pink-soft); color: var(--ait-pink-text); }
  .s-ai-thread .ait-chip:hover .ait-chip__ic svg { transform: rotate(-14deg) scale(1.1); }
  .s-ai-thread .ait-chip:hover > svg { color: var(--ait-pink); transform: translateX(3px); }
  .s-ai-thread .ait-bcard:not(.ait-bcard--skel):hover { border-color: var(--ait-pink-line); }
  .s-ai-thread .ait-bcard__name:hover { color: var(--ait-pink-text); }
  .s-ai-thread .ait-bcard__dir:hover svg { transform: translate(2px, -2px); }
  .s-ai-thread .ait-bcard__meta a:hover { color: var(--ait-pink-text); }
  .s-ai-thread .ait-pin:hover .ait-pin__b { transform: rotate(-45deg) scale(1.12); }
  .s-ai-thread .ait-mic:not(.is-recording):hover { background: var(--surface-3); color: var(--ink); }
  .s-ai-thread .ait-send:hover { box-shadow: var(--shadow-pink); }
  .s-ai-thread .ait-send:not(.is-stop):hover .ait-send__go { transform: translateY(-2px); }
  .s-ai-thread .ait-disclaimer a:hover { color: var(--ait-pink-text); }
}

/* ---------------- responsive ---------------- */
@media (max-width: 1279px) {
  .s-ai-thread { --ait-side: 300px; }
  .s-ai-thread .ait-branches__grid { grid-template-columns: minmax(0, 1fr) 360px; }
}

@media (max-width: 1023px) {
  .s-ai-thread .ait-container { padding-top: 44px; padding-bottom: 72px; }
  .s-ai-thread .ait-a { grid-template-columns: minmax(0, 1fr); }
  .s-ai-thread .ait-related { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .s-ai-thread .ait-branches__grid { grid-template-columns: minmax(0, 1fr) 320px; height: 420px; }
}

@media (max-width: 767px) {
  .s-ai-thread .ait-container { padding-top: 32px; padding-bottom: 20px; }
  .s-ai-thread .ait-head { margin-bottom: 24px; padding-bottom: 16px; }
  .s-ai-thread .ait-head h2 { font-size: 19px; }
  .s-ai-thread .ait-head .ait-btn { height: 40px; padding: 0 12px; font-size: 13px; }
  .s-ai-thread .ait-turns { gap: 44px; }
  .s-ai-thread .ait-turn { gap: 16px; }
  .s-ai-thread .ait-q__bubble { max-width: 88%; font-size: 16px; padding: 12px 16px; }
  .s-ai-thread .ait-card { padding: 18px 18px 8px; border-radius: 18px; }
  .s-ai-thread .ait-card__head { margin-bottom: 14px; }
  .s-ai-thread .ait-avatar { width: 36px; height: 36px; }
  .s-ai-thread .ait-prose { font-size: 16px; line-height: 1.72; }
  .s-ai-thread .ait-source__t { max-width: 200px; }
  .s-ai-thread .ait-btn--primary { width: 100%; }
  .s-ai-thread .ait-card__foot { margin-top: 16px; padding-top: 6px; }
  .s-ai-thread .ait-icon-btn { width: 44px; height: 44px; }
  .s-ai-thread .ait-fups { padding: 0; }
  .s-ai-thread .ait-chip { min-height: 44px; }
  .s-ai-thread .ait-fups--skel i { height: 44px; }
  /* the composer docks to the viewport bottom here (~76px tall) */
  .s-ai-thread .ait-turns a,
  .s-ai-thread .ait-turns button,
  .s-ai-thread .ait-turns [tabindex] { scroll-margin-top: 84px; scroll-margin-bottom: 112px; }
  .s-ai-thread .ait-btn--stop { height: 44px; padding: 0 18px 0 14px; }
  .s-ai-thread .ait-bcard__dir { min-height: 40px; }

  /* related: swipeable row with a peeking next card */
  .s-ai-thread .ait-related {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-inline: calc(-1 * var(--gutter));
    padding: 2px var(--gutter) 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    scrollbar-width: none;
  }
  .s-ai-thread .ait-related::-webkit-scrollbar { display: none; }
  .s-ai-thread .ait-rel { flex: 0 0 78%; scroll-snap-align: start; }

  .s-ai-thread .ait-branches { padding: 14px; border-radius: 18px; }
  .s-ai-thread .ait-branches__head { flex-wrap: wrap; }
  .s-ai-thread .ait-branches__head .ait-btn { height: 40px; }
  .s-ai-thread .ait-branches__grid { grid-template-columns: 1fr; height: auto; }
  .s-ai-thread .ait-map { height: 260px; }
  .s-ai-thread .ait-blist { overflow: visible; padding: 0; }

  /* follow-up composer docks to the bottom of the viewport while the thread is in view */
  .s-ai-thread .ait-dock {
    position: sticky;
    bottom: 0;
    margin: 36px calc(-1 * var(--gutter)) 0;
    padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.88);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid rgba(42, 42, 42, 0.06);
  }
  .s-ai-thread .ait-composer { padding: 5px 5px 5px 14px; box-shadow: 0 8px 24px -16px rgba(42, 42, 42, 0.35); }
  .s-ai-thread .ait-composer__input { height: 44px; font-size: 16px; }
  .s-ai-thread .ait-mic, .s-ai-thread .ait-send { width: 44px; height: 44px; }
  .s-ai-thread .ait-disclaimer { margin-top: 10px; padding-bottom: 12px; font-size: 11.5px; }
}

@media (max-width: 479px) {
  .s-ai-thread .ait-head .ait-btn span { display: none; }
  .s-ai-thread .ait-head .ait-btn { width: 40px; padding: 0; }
  .s-ai-thread .ait-rel { flex-basis: 84%; }
  .s-ai-thread .ait-error { flex-wrap: wrap; }
  .s-ai-thread .ait-error .ait-btn { width: 100%; }
}

/* active map pin */
.s-ai-thread .ait-pin.is-active { z-index: 1000 !important; }
.s-ai-thread .ait-pin.is-active .ait-pin__b { transform: rotate(-45deg) scale(1.18); box-shadow: 0 0 0 5px rgba(237, 0, 140, 0.18), 0 8px 18px -4px rgba(237, 0, 140, 0.7); }
.s-ai-thread .ait-card__foot:empty { display: none; }
