/* <tabby-chat>: Tabby Plus illustration on a dark card. */

tabby-chat {
  display: block;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  --tc-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.tc-panel {
  display: flex;
  flex-direction: column;
  background: #fff;
  color: var(--text);
  border-radius: 28px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 40px 80px -24px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

/* Header */

.tc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--surface-muted);
}

.tc-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
  font-size: 1rem;
}

.tc-head strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.2;
}

.tc-head small {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Thread */

.tc-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 16px 8px;
  background: #fbfbfc;
}

.tc-msg {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

.tc-me {
  align-self: flex-end;
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px 18px 6px 18px;
  background: var(--violet);
  color: #fff;
  font-weight: 600;
}

.tc-ai {
  align-self: flex-start;
  width: 92%;
  padding: 12px 14px;
  border-radius: 18px 18px 18px 6px;
  background: #fff;
  border: 1px solid var(--border);
}

.tc-ai p {
  margin: 0;
  color: var(--text-secondary);
}

/* Chart inside the answer */

.tc-chart {
  margin-top: 10px;
  padding: 10px 12px 8px;
  border-radius: 14px;
  background: var(--surface-muted);
}

.tc-chart-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
}

.tc-band-label {
  color: var(--green);
}

.tc-chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  margin-top: 14px;
}

.tc-chart .band {
  fill: rgba(22, 163, 74, 0.13);
}

.tc-chart .line {
  fill: none;
  stroke: var(--violet);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.tc-chart .dot {
  fill: var(--violet);
}

.tc-chart .dot-high {
  fill: #e11d48;
}

.tc-chart .value {
  font-size: 9px;
  font-weight: 600;
  fill: var(--muted);
  text-anchor: middle;
}

.tc-chart .value-last {
  font-size: 10px;
  font-weight: 800;
  fill: var(--violet);
}

.tc-months {
  display: flex;
  justify-content: space-between;
  padding: 4px 4px 0;
  font-size: 0.66rem;
  color: var(--faint);
}

/* Source and result chips */

.tc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tc-chips span {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--violet-soft);
  color: var(--violet);
  font-size: 0.7rem;
  font-weight: 700;
}

.tc-chips .ok {
  background: var(--green-soft);
  color: var(--green);
}

.tc-chips .warn {
  background: #fff1f2;
  color: #e11d48;
}

/* Photo message */

.tc-photo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
}

.tc-paper {
  position: relative;
  display: grid;
  align-content: start;
  gap: 4px;
  width: 44px;
  height: 56px;
  padding: 7px 6px;
  border-radius: 6px;
  background: #fbfaf7;
  transform: rotate(-4deg);
  overflow: hidden;
}

.tc-paper span {
  height: 3px;
  border-radius: 2px;
  background: #d4d4d8;
}

.tc-paper .tc-paper-head {
  height: 4px;
  width: 70%;
  background: #52525b;
}

.tc-paper .short {
  width: 60%;
}

.tc-paper .tc-paper-beam {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 14px;
  border-radius: 0;
  background: linear-gradient(180deg, transparent, rgba(124, 58, 237, 0.3));
  border-bottom: 1.5px solid #8b5cf6;
  animation: tc-beam 2.4s ease-in-out infinite alternate;
}

@keyframes tc-beam {
  from {
    transform: translateY(-14px);
  }
  to {
    transform: translateY(56px);
  }
}

/* Composer */

.tc-composer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 12px 12px;
  padding: 6px 6px 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
}

.tc-camera {
  width: 18px;
  height: 14px;
  border: 2px solid var(--faint);
  border-radius: 4px;
  position: relative;
}

.tc-camera::after {
  content: '';
  position: absolute;
  inset: 2px 4px;
  border: 1.5px solid var(--faint);
  border-radius: 50%;
}

.tc-input {
  flex: 1;
  font-size: 0.8rem;
  color: var(--faint);
}

.tc-send {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--violet);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
}

/* Messages arrive one by one when the card scrolls into view. Calm, no overshoot. */

tabby-chat.will-play .tc-msg {
  opacity: 0;
  transform: translateY(10px);
}

tabby-chat.will-play .tc-chart .line {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

tabby-chat.will-play.is-shown .tc-msg {
  opacity: 1;
  transform: none;
  transition:
    opacity 500ms var(--tc-ease),
    transform 500ms var(--tc-ease);
  transition-delay: calc(150ms + var(--d) * 700ms);
}

tabby-chat.will-play.is-shown .tc-chart .line {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1100ms var(--tc-ease) 1100ms;
}

@media (prefers-reduced-motion: reduce) {
  .tc-paper .tc-paper-beam {
    animation: none;
    transform: translateY(24px);
  }
}

@media (max-width: 640px) {
  tabby-chat {
    max-width: 360px;
  }
  .tc-msg {
    font-size: 0.8rem;
  }
}
