/* #region zone:health.ai-progress.style — เส้นเวลาขั้นตอน AI: ไอคอนต่อขั้น วงหมุนนุ่ม ๆ เคอร์เซอร์พิมพ์ และพับเก็บ */
/* Calm by design for an older reader: one soft accent, slow motion, large text, words for every state. */
.ai-progress {
  display: grid;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-inner);
  background: var(--panel);
  box-shadow: var(--card-shadow);
  white-space: normal;
  animation: ai-in 280ms ease-out both;
}
.ai-progress__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 32px;
}
.ai-progress__title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  color: var(--accent-text);
}
.ai-progress__stop {
  flex: none;
}
/* The orb: a soft breathing dot in the accent colour while the AI works. */
.ai-orb {
  position: relative;
  flex: none;
  width: 14px;
  height: 14px;
  margin-inline: var(--sp-1);
  border-radius: 50%;
  background: var(--accent-grad);
}
.ai-orb::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.25;
  animation: ai-breathe 1.8s ease-in-out infinite;
}
.ai-steps {
  display: grid;
  gap: var(--sp-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.ai-step {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: var(--sp-3);
  transition:
    opacity 260ms ease-out,
    transform 260ms ease-out;
}
.ai-step.is-entering {
  opacity: 0;
  transform: translateY(8px);
}
/* The thread joining one step to the next. */
.ai-step:not(:last-child)::before {
  content: '';
  position: absolute;
  top: 40px;
  bottom: calc(-1 * var(--sp-3) + 4px);
  left: 17px;
  width: 2px;
  border-radius: 1px;
  background: var(--line);
}
.ai-step.is-done:not(:last-child)::before {
  background: var(--line-strong);
}
.ai-step__mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--acc-soft);
  color: var(--accent-text);
}
.ai-step__mark > span {
  grid-area: 1 / 1;
  display: grid;
  place-items: center;
  transition:
    opacity 220ms ease-out,
    transform 220ms ease-out;
}
.ai-step__tick {
  opacity: 0;
  transform: scale(0.6);
}
/* Active: a slow ring turns around the icon. */
.ai-step.is-active .ai-step__mark::after {
  content: '';
  position: absolute;
  inset: -3px;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  border-radius: 50%;
  animation: ai-spin 1.1s linear infinite;
}
.ai-step.is-done .ai-step__mark {
  background: var(--ok-soft);
  color: var(--ok-text);
}
.ai-step.is-done .ai-step__icon {
  opacity: 0;
  transform: scale(0.6);
}
.ai-step.is-done .ai-step__tick {
  opacity: 1;
  transform: none;
}
.ai-step.is-stopped .ai-step__mark {
  background: var(--panel2);
  color: var(--muted);
}
.ai-step__body {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding-top: 5px;
}
.ai-step__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-1) var(--sp-3);
}
.ai-step__title {
  font-weight: 600;
}
.ai-step__summary:not(:empty) {
  padding: 0 var(--sp-2);
  border-radius: var(--u-radius-pill);
  background: var(--ok-soft);
  color: var(--ok-text);
  font-size: 0.94rem;
}
.ai-step__say {
  color: var(--text);
  overflow-wrap: anywhere;
}
.ai-step.is-done .ai-step__say {
  color: var(--muted);
}
.ai-step__say.is-typing::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--accent);
  animation: ai-caret 0.9s steps(1) infinite;
}
.ai-step__live:not(:empty) {
  color: var(--muted);
  font-size: 0.94rem;
  overflow-wrap: anywhere;
}
.ai-progress.is-failed .ai-progress__title {
  color: var(--muted);
}
.ai-progress.is-failed .ai-orb {
  background: var(--muted);
}
.ai-progress.is-failed .ai-orb::after,
.ai-progress.is-failed .ai-step__mark::after {
  display: none;
}
/* The folded steps above an answer. */
.ai-fold {
  margin-bottom: var(--sp-3);
  white-space: normal;
  animation: ai-in 280ms ease-out both;
}
.ai-fold__toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--u-radius-pill);
  background: var(--panel);
  color: var(--ok-text);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.ai-fold__toggle::-webkit-details-marker {
  display: none;
}
.ai-fold__toggle:hover {
  background: var(--hover);
}
.ai-fold__chev {
  display: grid;
  color: var(--muted);
  transition: transform 200ms ease-out;
}
.ai-fold[open] .ai-fold__chev {
  transform: rotate(180deg);
}
.ai-fold[open] .ai-steps {
  margin-top: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-inner);
  background: var(--panel);
  animation: ai-in 220ms ease-out both;
}
.ai-answer {
  animation: ai-in 320ms ease-out both;
}
/* The bubble that holds the live steps is wide and frameless; the panel draws its own card. */
.bubble--progress {
  width: min(100%, 620px);
  max-width: 100%;
  padding: 0;
  background: transparent;
}
.bubble--answered {
  width: min(100%, 620px);
}
@keyframes ai-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes ai-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes ai-breathe {
  0%,
  100% {
    transform: scale(0.7);
    opacity: 0.35;
  }
  50% {
    transform: scale(1.15);
    opacity: 0.08;
  }
}
@keyframes ai-caret {
  50% {
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ai-step.is-entering {
    opacity: 1;
    transform: none;
  }
}
/* #endregion */
/* #region zone:health.assist.research.style — แถวปุ่มค้นงานวิจัยและรายการงานวิจัยที่อ้างอิง */
.research-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
}
.research-row .muted {
  font-size: 0.94rem;
}
.research-citations li + li {
  margin-top: var(--sp-2);
}
.research-meta {
  display: block;
  color: var(--muted);
}
/* #endregion */
