.chat-stage {
  margin: 0;
  scroll-margin-top: 6.25rem;
  padding: clamp(32px, 5vw, 72px) clamp(14px, 2.2vw, 28px) clamp(28px, 4vw, 52px);
}
.chat-window {
  position: relative;
  border: 1px solid #dedfe0;
  border-radius: 18px;
  background: white;
}
[data-chat-pause] {
  position: absolute;
  right: 4px;
  top: 4px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
}
[data-chat-pause]:hover { color: var(--ink); background: #f2f3f3; }
[data-chat-pause] svg { width: 16px; height: 16px; }
[data-chat-pause] svg:last-child, [data-chat-paused] [data-chat-pause] svg:first-child { display: none; }
[data-chat-paused] [data-chat-pause] svg:last-child { display: block; }
.chat-window [hidden] { display: none; }
.chat-transcript { max-width: 46rem; margin: auto; padding: clamp(20px, 3vw, 36px) clamp(14px, 2.4vw, 28px); }
.chat-scenes { display: grid; }
.chat-window[data-chat-enhanced] { padding: 14px 0 72px; }
.chat-composer {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(42.5rem, calc(100% - 28px));
  min-height: 52px;
  padding: 8px 9px 8px 17px;
  border: 1px solid #cbdfe6;
  border-radius: 26px;
  color: var(--ink);
  background: #f4f9fb;
}
[data-chat-typing] .chat-composer { bottom: 50%; transform: translate(-50%, 50%); }
.chat-draft { flex: 1; min-width: 0; font-size: .9375rem; line-height: 1.5; overflow-wrap: anywhere; }
[data-chat-demo]:not([data-chat-has-draft]) .chat-draft::before { content: attr(data-placeholder); color: var(--muted); }
.chat-draft-value { white-space: pre-wrap; }
[data-chat-has-draft] .chat-draft-value::after { content: ''; border-left: 1px solid var(--accent); }
.chat-composer > svg, .chat-mic, .chat-submit { flex: none; }
.chat-composer > svg, .chat-mic { color: #566d77; }
.chat-mic, .chat-submit { display: grid; place-items: center; }
.chat-submit { width: 36px; height: 36px; border-radius: 50%; color: #315e70; background: #dfedf2; }
.chat-submit svg:last-child, [data-chat-has-draft] .chat-submit svg:first-child { display: none; }
[data-chat-has-draft] .chat-submit { color: white; background: var(--accent); }
[data-chat-has-draft] .chat-submit svg:last-child { display: block; }
[data-chat-scene] { display: grid; align-content: start; gap: 20px; }
.chat-question {
  justify-self: end;
  max-width: 88%;
  margin: 0;
  padding: 10px 16px;
  border-radius: 18px 18px 5px 18px;
  background: #f2f3f3;
  color: var(--ink);
  font-size: .9375rem;
  line-height: 1.55;
}
.chat-draft-value strong, .chat-question strong { color: #126b88; font-weight: 600; }
.chat-pending, .chat-answer { font-size: .9375rem; line-height: 1.6; }
.chat-pending { display: flex; align-self: start; align-items: center; gap: 10px; color: var(--muted); }
.chat-answer p { margin: 0; }
.chat-ranking { margin: 9px 0; padding-left: 1.55rem; width: min(100%, 18rem); }
.chat-ranking li { padding: 2px 0 2px 3px; border-bottom: 1px solid #eeeeef; }
.chat-ranking li::marker { color: #616a6d; font-size: .8125rem; font-variant-numeric: tabular-nums; }
.chat-ranking li b { float: right; margin-left: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.chat-ranking li:first-child { color: #086785; font-weight: 600; }
.chat-recommendation { font-weight: 550; }
.chat-window:not([data-chat-enhanced]) [data-chat-scene] + [data-chat-scene] { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 24px; }

/* Reserve the tallest scene's height even while the playback script is loading.
   If it never loads, the two static scenes can still be scrolled horizontally. */
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  .chat-window:not([data-chat-enhanced]) { padding: 14px 0 72px; }
  .chat-window:not([data-chat-enhanced]) .chat-scenes {
    grid-auto-flow: column;
    grid-auto-columns: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }
  .chat-window:not([data-chat-enhanced]) [data-chat-scene] { scroll-snap-align: start; }
  .chat-window:not([data-chat-enhanced]) [data-chat-scene] + [data-chat-scene] { border: 0; margin: 0; padding: 0; }
}
[data-chat-enhanced] .chat-reply { display: grid; }
[data-chat-enhanced] [data-chat-scene], [data-chat-enhanced] .chat-reply > * { grid-area: 1 / 1; }
[data-chat-enhanced] [data-chat-scene] { align-content: center; }
/* Keep both complete transcripts in reading order throughout playback. */
[data-chat-concealed] { clip-path: inset(50%); pointer-events: none; user-select: none; }

@media (prefers-reduced-motion: no-preference) {
  .chat-composer { transition: bottom .24s ease, transform .24s ease; }
  [data-chat-enhanced] [data-chat-scene]:not([data-chat-concealed]) .chat-question:not([data-chat-concealed]),
  [data-chat-enhanced] [data-chat-answer]:not([data-chat-concealed]) { animation: chat-arrive .26s ease-out both; }
  [data-chat-enhanced] .chat-pending img { animation: chat-query .9s ease-in-out infinite alternate; }
  [data-chat-demo][data-chat-suspended] :is(.chat-question, .chat-answer, .chat-pending img) { animation-play-state: paused; }
  @keyframes chat-arrive { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
  @keyframes chat-query { from { opacity: .45; } to { opacity: 1; } }
}
@media (max-width: 38rem) {
  [data-chat-enhanced] .chat-transcript { padding-top: 36px; }
  .chat-composer { width: calc(100% - 16px); gap: 8px; padding-left: 12px; }
  .chat-mic { display: none; }
  .chat-question { max-width: 96%; }
}
@media (max-width: 38rem) and (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  .chat-transcript { padding-top: 36px; }
}
