:root {
  --color-primary: #7c3aed;
  --color-on-primary: #ffffff;
  --color-secondary: #6366f1;
  --color-accent: #ec4899;
  --color-accent-ink: #9d174d;
  --color-background: #faf5ff;
  --color-foreground: #0f172a;
  --color-muted: #f7f3fd;
  --color-border: #efe7fc;
  --color-ring: #7c3aed;
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-text-secondary: #334155;
  --color-ink: #0f172a;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;
  --space-6: 64px;
  --space-7: 96px;
  --font-heading: "Outfit", sans-serif;
  --font-body: "Work Sans", sans-serif;
  --radius: 20px;
  --header-offset: 88px;
  --shadow-soft: 0 16px 40px rgba(15, 23, 42, 0.08);
  --shadow-block: 8px 8px 0 #0f172a;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-offset);
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 12%, rgba(124, 58, 237, 0.16), transparent 28%),
    radial-gradient(circle at 92% 0%, rgba(236, 72, 153, 0.14), transparent 24%),
    var(--color-background);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
}

img,
canvas,
video {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
}

button,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--color-ring);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: 12px;
  z-index: 20;
  transform: translateY(-140%);
  background: var(--color-ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  text-decoration: none;
}

.skip-link:focus {
  transform: none;
}

.wrap {
  width: min(1120px, 100%);
  margin-inline: auto;
  padding-inline: 16px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px 16px;
  background: rgba(250, 245, 255, 0.92);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  text-decoration: none;
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.site-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  color: var(--color-text-secondary);
}

.site-nav a:hover {
  background: #fff;
  color: var(--color-primary);
}

.header-cta {
  margin-left: auto;
  flex-shrink: 0;
}

.hero {
  padding-block: 48px 32px;
}

.hero-grid {
  display: grid;
  gap: 32px;
  align-items: center;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: #fff;
  color: var(--color-accent-ink);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kicker-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin: 0;
}

.hero-copy {
  container-type: inline-size;
}

.hero h1 {
  font-size: min(72px, 8.2cqi);
  font-weight: 700;
  white-space: nowrap;
}

.lede {
  max-width: 42ch;
  margin: 20px 0 0;
  color: var(--color-text-secondary);
  font-size: 18px;
}

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}

.mode-chip,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 2px solid transparent;
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 180ms var(--ease-out), background-color 180ms var(--ease-out), color 180ms var(--ease-out), border-color 180ms var(--ease-out);
}

.mode-chip {
  background: #fff;
  border-color: #ddd6fe;
  color: var(--color-foreground);
}

.mode-chip:hover,
.btn:hover {
  transform: translateY(-2px);
}

.mode-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: 4px 4px 0 #0f172a;
}

.btn-primary:hover {
  background: #6d28d9;
}

.btn-ghost {
  background: #fff;
  border-color: var(--color-foreground);
  color: var(--color-foreground);
}

.btn-ghost:hover {
  background: var(--color-foreground);
  color: #fff;
}

.prompt-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  margin-top: 16px;
  min-height: 64px;
  padding: 10px 10px 10px 20px;
  border-radius: 18px;
  background: #fff;
  border: 2px solid var(--color-foreground);
  box-shadow: var(--shadow-block);
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: transform 180ms var(--ease-out);
}

.prompt-cta:hover {
  transform: translate(-2px, -2px);
}

.prompt-cta span:first-child {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 18px;
}

.prompt-cta .btn {
  pointer-events: none;
}

.icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.hero-stage {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 12px;
  min-height: 420px;
}

.stage-main,
.stage-side article {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  border: 2px solid var(--color-foreground);
  background: #fff;
  box-shadow: var(--shadow-block);
}

.stage-main {
  background:
    linear-gradient(160deg, rgba(124, 58, 237, 0.2), rgba(236, 72, 153, 0.12)),
    #fff;
}

.stage-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  min-height: 280px;
}

.stage-side {
  display: grid;
  gap: 12px;
}

.stage-side img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  min-height: 140px;
}

.stage-label {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
}

.caps {
  padding-block: 16px 48px;
}

.cap-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 16px;
  list-style: none;
  background: #fff;
  border: 2px solid var(--color-border);
  border-radius: 24px;
}

.cap-list li {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--color-muted);
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 600;
}

.section {
  padding-block: 48px;
}

.section-head {
  margin-bottom: 32px;
}

.section-head h2 {
  font-size: clamp(36px, 5vw, 56px);
}

.section-head p {
  margin: 12px 0 0;
  color: var(--color-text-secondary);
}

.agent-grid,
.lab-grid,
.gallery-grid {
  display: grid;
  gap: 16px;
}

.agent-card,
.lab-card,
.gallery-card,
.faq-item {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.agent-card {
  padding: 16px;
}

.agent-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 16px;
  border: 2px solid var(--color-foreground);
  transition: transform 520ms var(--ease-out);
}

.agent-index {
  margin: 16px 0 0;
  color: var(--color-primary);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.agent-card h3,
.lab-card h3,
.gallery-card h3 {
  margin-top: 6px;
  font-size: 32px;
}

.agent-card p,
.lab-copy p,
.faq-item p {
  color: var(--color-text-secondary);
}

.checks {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.checks li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--color-text);
}

.checks .icon {
  margin-top: 2px;
  color: var(--color-primary);
}

.rag {
  margin-block: 16px 48px;
}

.rag-panel {
  display: grid;
  gap: 24px;
  padding: 24px;
  border-radius: 32px;
  background: var(--color-ink);
  color: #fff;
  box-shadow: var(--shadow-block);
}

.rag-panel h2 {
  font-size: clamp(28px, 3.4vw, 48px);
}

.rag-panel h2 + h2 {
  margin-top: 8px;
  color: #f9a8d4;
}

.rag-panel img {
  width: 100%;
  border-radius: 20px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: #fff;
}

.lab-card {
  display: grid;
  gap: 20px;
  padding: 20px;
  overflow: hidden;
}

.lab-card:nth-child(3n + 1) {
  border-top: 8px solid var(--color-primary);
}

.lab-card:nth-child(3n + 2) {
  border-top: 8px solid var(--color-secondary);
}

.lab-card:nth-child(3n) {
  border-top: 8px solid var(--color-accent);
}

.lab-copy h3 {
  font-size: clamp(28px, 3vw, 40px);
  margin-top: 8px;
}

.lab-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.media-frame,
#webcam-container,
#poseEstimation canvas {
  border-radius: 16px;
  overflow: hidden;
  background: var(--color-muted);
}

#webcam-container:empty,
#pose-canvas {
  min-height: 220px;
  background: linear-gradient(145deg, rgba(124, 58, 237, 0.14), rgba(236, 72, 153, 0.12));
}

#webcam-container canvas,
#pose-canvas {
  width: min(100%, 400px);
  height: auto;
  border-radius: 16px;
}

.output-card,
.output-card-pose {
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
  background: var(--color-muted);
  border: 1px solid var(--color-border);
}

.output-card h3,
.output-card-pose h3 {
  margin: 0 0 12px;
  font-size: 16px;
  letter-spacing: 0;
}

.face-shot {
  width: 100%;
  border-radius: 16px;
  border: 2px solid var(--color-foreground);
  object-fit: cover;
}

.gallery-card {
  padding: 12px;
}

.gallery-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 16px;
  transition: transform 520ms var(--ease-out);
}

.gallery-card h3 {
  margin: 12px 8px 8px;
  font-size: 22px;
}

.gallery-cta {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.faq-list {
  display: grid;
  gap: 12px;
}

.faq-item {
  padding: 0;
  overflow: hidden;
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 16px 20px;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 600;
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "";
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
  transform: rotate(45deg);
  flex-shrink: 0;
  transition: transform 200ms var(--ease-out);
}

.faq-item[open] summary::after {
  transform: rotate(225deg);
}

.faq-item p {
  margin: 0;
  padding: 0 20px 20px;
}

.faq-item[open] p {
  animation: faq-in 420ms var(--ease-out) both;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
  padding: 24px 16px 32px;
  color: var(--color-text-secondary);
  font-size: 14px;
}

.site-footer a {
  font-weight: 600;
  color: var(--color-foreground);
}

.hero-copy {
  animation: rise 280ms var(--ease-out) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 620ms var(--ease-out), transform 620ms var(--ease-out);
}

.reveal.is-in {
  opacity: 1;
  transform: none;
}

.stage-main.reveal {
  transition-delay: 80ms;
}

.stage-side article.reveal:nth-child(1) {
  transition-delay: 220ms;
}

.stage-side article.reveal:nth-child(2) {
  transition-delay: 360ms;
}

.stage-main.reveal.is-in {
  animation: floaty 5.5s ease-in-out 0.7s infinite;
}

.cap-list .reveal:nth-child(1) { transition-delay: 0.04s; }
.cap-list .reveal:nth-child(2) { transition-delay: 0.08s; }
.cap-list .reveal:nth-child(3) { transition-delay: 0.12s; }
.cap-list .reveal:nth-child(4) { transition-delay: 0.16s; }
.cap-list .reveal:nth-child(5) { transition-delay: 0.2s; }
.cap-list .reveal:nth-child(6) { transition-delay: 0.24s; }
.cap-list .reveal:nth-child(7) { transition-delay: 0.28s; }
.cap-list .reveal:nth-child(8) { transition-delay: 0.32s; }
.cap-list .reveal:nth-child(9) { transition-delay: 0.36s; }
.cap-list .reveal:nth-child(10) { transition-delay: 0.4s; }
.cap-list .reveal:nth-child(11) { transition-delay: 0.44s; }
.cap-list .reveal:nth-child(12) { transition-delay: 0.48s; }
.cap-list .reveal:nth-child(13) { transition-delay: 0.52s; }

.agent-grid .reveal:nth-child(1) { transition-delay: 0.06s; }
.agent-grid .reveal:nth-child(2) { transition-delay: 0.16s; }
.agent-grid .reveal:nth-child(3) { transition-delay: 0.26s; }

.lab-grid .reveal:nth-child(1) { transition-delay: 0.05s; }
.lab-grid .reveal:nth-child(2) { transition-delay: 0.14s; }
.lab-grid .reveal:nth-child(3) { transition-delay: 0.23s; }

.gallery-grid .reveal:nth-child(1) { transition-delay: 0.04s; }
.gallery-grid .reveal:nth-child(2) { transition-delay: 0.1s; }
.gallery-grid .reveal:nth-child(3) { transition-delay: 0.16s; }
.gallery-grid .reveal:nth-child(4) { transition-delay: 0.22s; }
.gallery-grid .reveal:nth-child(5) { transition-delay: 0.28s; }

.agent-card.reveal.is-in,
.gallery-card.reveal.is-in {
  transition: opacity 620ms var(--ease-out), transform 220ms var(--ease-out), box-shadow 220ms var(--ease-out);
}

.agent-card.reveal.is-in:hover,
.gallery-card.reveal.is-in:hover {
  transform: translateY(-6px);
}

.agent-card:hover img,
.gallery-card:hover img {
  transform: scale(1.05);
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes faq-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (min-width: 768px) {
  .wrap,
  .site-header,
  .site-footer {
    padding-inline: 24px;
  }

  .site-header {
    padding-block: 0;
    flex-wrap: nowrap;
  }

  .site-nav {
    margin-left: 12px;
  }

  .hero {
    padding-block: 72px 48px;
  }

  .hero-grid,
  .rag-panel,
  .lab-card {
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }

  .agent-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .lab-grid {
    grid-template-columns: 1fr;
  }

  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .section {
    padding-block: 80px;
  }
}

@media (min-width: 1024px) {
  .wrap,
  .site-header,
  .site-footer {
    padding-inline: 32px;
  }

  .gallery-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .lab-card:nth-child(even) .lab-copy {
    order: 2;
  }
}

@media (max-width: 767px) {
  .site-header {
    flex-wrap: wrap;
  }

  .site-nav {
    order: 3;
    width: 100%;
  }

  .hero-stage {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .stage-side {
    grid-template-columns: 1fr 1fr;
  }

  .stage-main img {
    min-height: 240px;
    max-height: 320px;
  }

  .stage-side img {
    height: 148px;
    min-height: 0;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.chat-open {
  overflow: hidden;
}

.chat-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
}

.chat-layer[hidden] {
  display: none;
}

.chat-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(15, 23, 42, 0.28);
  cursor: pointer;
}

.chat-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(400px, 100%);
  height: calc(100% - 24px);
  margin: 12px;
  overflow: hidden;
  background: var(--color-surface);
  border: 2px solid var(--color-foreground);
  border-radius: var(--radius);
  box-shadow: var(--shadow-block);
  font-size: 13px;
  animation: chat-in 280ms var(--ease-out);
}

.chat-panel-head,
.chat-thread-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  background: #fff;
}

.chat-panel-head {
  justify-content: space-between;
  gap: 8px;
}

.chat-panel-head > div:first-child {
  min-width: 0;
}

.chat-panel-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}

.chat-panel-actions .chat-icon-btn {
  width: 36px;
  height: 36px;
}

.chat-panel-actions .icon {
  width: 18px;
  height: 18px;
}

.chat-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-panel.is-full {
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
}

.chat-panel.is-full .chat-full-enter {
  display: none;
}

.chat-full-exit {
  display: none;
}

.chat-panel.is-full .chat-full-exit {
  display: block;
}

.chat-panel-head .kicker {
  margin-bottom: 8px;
}

.chat-panel-head h2 {
  overflow: hidden;
  font-size: 22px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-history {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 16px;
  overflow: auto;
}

.chat-history[hidden] {
  display: none;
}

.chat-history-back {
  align-self: flex-start;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-primary);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chat-history-empty {
  margin: 24px 0;
  color: var(--color-text-secondary);
  text-align: center;
}

.chat-history-item {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.chat-history-open {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 2px solid var(--color-border);
  border-radius: 16px;
  background: var(--color-muted);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-history-open:hover {
  border-color: var(--color-primary);
  background: #fff;
}

.chat-history-open strong,
.chat-history-open small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-history-open strong {
  font-family: var(--font-heading);
  font-size: 13px;
}

.chat-history-open small {
  margin-top: 2px;
  color: var(--color-text-secondary);
  font-size: 12px;
}

.chat-history-delete {
  flex-shrink: 0;
  width: 36px;
  border: 2px solid var(--color-border);
  border-radius: 16px;
  background: #fff;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.chat-history-delete:hover {
  border-color: #b91c1c;
  color: #b91c1c;
}

.chat-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 2px solid var(--color-foreground);
  border-radius: 999px;
  background: #fff;
  color: var(--color-foreground);
  cursor: pointer;
}

.chat-icon-btn:hover {
  background: var(--color-foreground);
  color: #fff;
}

.chat-picker {
  display: grid;
  gap: 10px;
  padding: 16px;
  overflow: auto;
}

.chat-picker[hidden] {
  display: none;
}

.chat-agent {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 2px solid var(--color-border);
  border-radius: 16px;
  background: var(--color-muted);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-agent:hover {
  border-color: var(--color-primary);
  background: #fff;
}

.chat-agent img,
.chat-thread-bar img {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 14px;
}

.chat-agent strong,
.chat-thread-bar strong {
  display: block;
  font-family: var(--font-heading);
  font-size: 15px;
  letter-spacing: -0.03em;
}

.chat-agent small,
.chat-thread-bar span {
  display: block;
  color: var(--color-text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.chat-thread[hidden] {
  display: none;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow: auto;
  background:
    radial-gradient(circle at 100% 0%, rgba(124, 58, 237, 0.08), transparent 36%),
    var(--color-background);
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
}

.chat-bubble > p {
  margin: 0;
  white-space: pre-wrap;
}

.chat-md p {
  margin: 0 0 8px;
}

.chat-md p:last-child {
  margin-bottom: 0;
}

.chat-md h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.chat-md ul {
  margin: 0 0 8px;
  padding-left: 18px;
}

.chat-md a {
  color: var(--color-primary);
}

.chat-md code {
  font-family: ui-monospace, monospace;
  font-size: 0.92em;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.06);
}

.chat-md pre {
  margin: 0 0 8px;
  padding: 10px;
  overflow: auto;
  border-radius: 12px;
  background: var(--color-ink);
  color: #fff;
}

.chat-md pre code {
  padding: 0;
  background: none;
  color: inherit;
}

.chat-turn {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  max-width: 100%;
}

.chat-trace {
  width: min(100%, 520px);
  max-height: 220px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  background: #fff;
  color: var(--color-text-secondary);
  font-size: 12px;
}

.chat-trace summary {
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--color-foreground);
}

.chat-think {
  margin-top: 8px;
}

.chat-tool {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--color-muted);
}

.chat-tool-name {
  margin: 0 0 6px;
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--color-foreground);
}

.chat-tool pre {
  margin: 0;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 12px;
}

.chat-tool pre:empty {
  display: none;
}

.chat-bubble-agent {
  align-self: flex-start;
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--color-border);
}

.chat-table {
  max-width: 100%;
  margin: 0 0 8px;
  overflow-x: auto;
}

.chat-md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.chat-md th,
.chat-md td {
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.chat-md th {
  background: var(--color-muted);
  font-weight: 600;
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.chat-bubble-typing {
  align-self: flex-start;
  color: var(--color-text-secondary);
  background: #fff;
  border: 1px solid var(--color-border);
}

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
}

.chat-chips[hidden] {
  display: none;
}

.chat-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border: 2px solid #ddd6fe;
  border-radius: 999px;
  background: #fff;
  color: var(--color-foreground);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chat-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--color-border);
  background: #fff;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 2px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-muted);
  color: var(--color-text);
  font: inherit;
}

.chat-form input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.chat-form .btn {
  flex-shrink: 0;
  font-size: 13px;
}

.chat-form .is-stop {
  background: var(--color-foreground);
}

.chat-form .is-stop::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: currentColor;
}

.chat-writing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 1em;
  margin-top: 6px;
}

.chat-writing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.3;
  animation: chat-write 1s infinite ease-in-out;
}

.chat-writing i:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-writing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chat-write {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes chat-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 767px) {
  .chat-panel {
    width: 100%;
    height: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
