.site-chat-toggle {
  position: fixed;
  right: 40px;
  bottom: 42px;
  z-index: 1200;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  overflow: visible;
  border: 1px solid rgba(125, 211, 252, .18);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 26%, rgba(125, 211, 252, .2), transparent 30%),
    radial-gradient(circle at 68% 74%, rgba(124, 58, 237, .18), transparent 44%),
    rgba(5, 11, 24, .78);
  color: #e6fbff;
  cursor: pointer;
  box-shadow:
    0 18px 54px rgba(0, 0, 0, .46),
    0 0 32px rgba(94, 234, 212, .13),
    inset 0 0 0 1px rgba(255, 255, 255, .045);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
}

.site-chat-toggle::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 18px rgba(125, 211, 252, .06);
  pointer-events: none;
}

.site-chat-toggle::after {
  content: '';
  position: absolute;
  inset: -7px;
  border: 4px solid rgba(45, 212, 191, .82);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(94, 234, 212, .16);
  opacity: .94;
  pointer-events: none;
  transition: border-color .2s ease, box-shadow .2s ease, opacity .2s ease;
}

.site-chat-toggle:hover {
  border-color: rgba(94, 234, 212, .7);
  transform: translateY(-3px) scale(1.025);
  background:
    radial-gradient(circle at 34% 26%, rgba(125, 211, 252, .26), transparent 32%),
    radial-gradient(circle at 68% 74%, rgba(124, 58, 237, .24), transparent 46%),
    rgba(5, 11, 24, .9);
  box-shadow: 0 22px 70px rgba(0, 0, 0, .5), 0 0 42px rgba(94, 234, 212, .24), inset 0 0 0 1px rgba(255, 255, 255, .06);
}

.site-chat-toggle:hover::after {
  border-color: rgba(94, 234, 212, .96);
  box-shadow: 0 0 26px rgba(94, 234, 212, .34);
  opacity: 1;
}

.site-chat-toggle-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: transparent;
}

.site-chat-toggle-mark svg {
  width: 50px;
  height: 50px;
  display: block;
  overflow: visible;
}

.site-chat-planet-orbit {
  transform-origin: center;
  animation: site-chat-orbit-drift 6s ease-in-out infinite;
  transition: transform .35s ease;
}

.site-chat-toggle:hover .site-chat-planet-orbit {
  animation-play-state: paused;
  transform: rotate(-10deg) scale(1.035);
}

@keyframes site-chat-orbit-drift {
  0%, 100% { transform: rotate(-18deg); }
  50% { transform: rotate(-12deg); }
}

.site-chat-planet {
  fill: url("#siteChatPlanet");
  filter: drop-shadow(0 0 5px rgba(94, 234, 212, .45));
}

.site-chat-planet-ring {
  fill: none;
  stroke: rgba(226, 246, 255, .82);
  stroke-width: 2;
  stroke-linecap: round;
}

.site-chat-planet-ring-back {
  stroke: rgba(125, 211, 252, .5);
}

.site-chat-planet-ring-front {
  stroke: #facc15;
}

.site-chat-planet-shade {
  fill: none;
  stroke: rgba(6, 16, 22, .36);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.site-chat-spark {
  fill: #facc15;
  filter: drop-shadow(0 0 3px rgba(250, 204, 21, .5));
}

.site-chat-toggle-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.site-chat {
  position: fixed;
  right: 40px;
  bottom: 118px;
  width: min(430px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 116px));
  z-index: 1201;
  display: none;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: 8px;
  background:
    radial-gradient(circle at 20% 0%, rgba(94, 234, 212, .14), transparent 34%),
    radial-gradient(circle at 100% 14%, rgba(167, 139, 250, .12), transparent 34%),
    linear-gradient(180deg, rgba(10, 15, 27, .98), rgba(4, 8, 18, .985));
  box-shadow: 0 30px 90px rgba(0, 0, 0, .54), 0 0 0 1px rgba(255, 255, 255, .035) inset;
  backdrop-filter: blur(20px);
}

.site-chat.open {
  display: grid;
  animation: site-chat-in .16s ease-out;
}

@keyframes site-chat-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.site-chat-header {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .075);
  background: linear-gradient(135deg, rgba(94, 234, 212, .08), rgba(255, 255, 255, .02));
}

.site-chat-avatar {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(94, 234, 212, .3);
  border-radius: 50%;
  padding: 1px;
  background: rgba(5, 11, 24, .72);
  box-shadow: 0 10px 30px rgba(94, 234, 212, .16);
}

.site-chat-avatar svg {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  background: transparent;
}

.site-chat-title {
  color: #f4f7ff;
  font: 900 .94rem/1.2 Inter, system-ui, sans-serif;
  letter-spacing: 0;
}

.site-chat-context {
  margin-top: 4px;
  color: #93a1bd;
  font: 700 .68rem/1.35 Inter, system-ui, sans-serif;
}

.site-chat-context::before {
  content: '';
}

.site-chat-close {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  background: rgba(255, 255, 255, .045);
  color: #9aa7c2;
  cursor: pointer;
  font-size: 1.2rem;
}

.site-chat-close:hover {
  color: #f4f7ff;
  border-color: rgba(94, 234, 212, .32);
}

.site-chat-messages {
  min-height: 270px;
  overflow-y: auto;
  padding: 16px 14px 12px;
  scroll-behavior: smooth;
}

.site-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
}

.site-chat-suggestion {
  border: 1px solid rgba(94, 234, 212, .18);
  border-radius: 8px;
  background: rgba(94, 234, 212, .075);
  color: #dce6ff;
  padding: 8px 10px;
  font: 800 .74rem/1 Inter, system-ui, sans-serif;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}

.site-chat-suggestion:hover {
  border-color: rgba(94, 234, 212, .46);
  color: #5eead4;
  background: rgba(94, 234, 212, .12);
  transform: translateY(-1px);
}

.site-chat-message {
  margin: 0 0 12px;
  padding: 11px 12px;
  border-radius: 8px;
  color: #dce6ff;
  font: 450 .88rem/1.58 Inter, system-ui, sans-serif;
  overflow-wrap: anywhere;
  white-space: normal;
}

.site-chat-message h3 {
  margin: 0 0 6px;
  color: #f4f7ff;
  font: 780 .9rem/1.28 Inter, system-ui, sans-serif;
}

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

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

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

.site-chat-message li {
  margin: 4px 0;
}

.site-chat-message li::marker {
  color: #5eead4;
}

.site-chat-message strong {
  color: #eef5ff;
  font-weight: 680;
}

.site-chat-message code {
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 6px;
  padding: 1px 5px;
  background: rgba(255, 255, 255, .07);
  color: #7dd3fc;
  font: 700 .82em/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.site-chat-message a {
  color: #5eead4;
  text-decoration: none;
  border-bottom: 1px solid rgba(94, 234, 212, .35);
}

.site-chat-message a:hover {
  color: #a7f3d0;
  border-bottom-color: currentColor;
}

.site-chat-entities {
  display: grid;
  gap: 7px;
  margin: -4px 34px 14px 0;
}

.site-chat-entity-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(94, 234, 212, .16);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(94, 234, 212, .075), rgba(125, 211, 252, .035));
  color: #eef5ff;
  text-decoration: none;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.site-chat-entity-card:hover {
  transform: translateY(-1px);
  border-color: rgba(94, 234, 212, .4);
  background: linear-gradient(135deg, rgba(94, 234, 212, .12), rgba(125, 211, 252, .065));
}

.site-chat-entity-card.wide { grid-template-columns: 58px minmax(0, 1fr) 26px; }

.site-chat-entity-logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 7px;
  background: rgba(255, 255, 255, .94);
}

.site-chat-entity-logo img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
}

.site-chat-entity-card.wide .site-chat-entity-logo { width: 58px; }
.site-chat-entity-card.wide .site-chat-entity-logo img { width: 50px; height: 32px; }

.site-chat-entity-logo.fallback::after {
  content: '✦';
  color: #0f766e;
  font-size: 1rem;
}

.site-chat-entity-logo.fallback img { display: none; }
.site-chat-entity-body { min-width: 0; display: grid; gap: 3px; }
.site-chat-entity-name { overflow: hidden; color: #f4f7ff; font: 800 .79rem/1.2 Inter, system-ui, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.site-chat-entity-meta { overflow: hidden; color: #93a1bd; font: 650 .65rem/1.25 Inter, system-ui, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.site-chat-entity-arrow { color: #5eead4; font: 800 1rem/1 Inter, system-ui, sans-serif; text-align: center; }

.site-chat-message.user {
  margin-left: 56px;
  background: linear-gradient(135deg, rgba(94, 234, 212, .18), rgba(125, 211, 252, .08));
  border: 1px solid rgba(94, 234, 212, .28);
  color: #f4f7ff;
  font-weight: 540;
}

.site-chat-message.assistant {
  margin-right: 34px;
  background: rgba(255, 255, 255, .058);
  border: 1px solid rgba(255, 255, 255, .095);
}

.site-chat-message.intro {
  position: relative;
  background: linear-gradient(135deg, rgba(94, 234, 212, .115), rgba(167, 139, 250, .085));
  border-color: rgba(94, 234, 212, .2);
}

.site-chat-message.error {
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(239, 68, 68, .24);
  color: #fecaca;
}

.site-chat-interrupted {
  margin-top: 10px !important;
  padding-top: 9px;
  border-top: 1px solid rgba(251, 191, 36, .24);
  color: #fcd34d;
  font-size: .74rem;
  font-weight: 650;
}

.site-chat-message.thinking {
  display: block;
  min-width: 190px;
  max-width: 260px;
  padding: 12px;
}

.site-chat-thinking-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.site-chat-thinking-mark {
  width: 20px;
  height: 20px;
  border-radius: 7px;
  border: 2px solid rgba(94, 234, 212, .28);
  border-top-color: #5eead4;
  animation: site-chat-spin .9s linear infinite;
  flex: 0 0 auto;
}

.site-chat-thinking-text {
  color: #dce6ff;
  font: 800 .78rem/1 Inter, system-ui, sans-serif;
}

.site-chat-thinking-bar {
  height: 3px;
  margin-top: 11px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, .08);
}

.site-chat-thinking-bar span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, #5eead4, #7dd3fc);
  animation: site-chat-progress 1.15s ease-in-out infinite;
}

@keyframes site-chat-spin {
  to { transform: rotate(360deg); }
}

@keyframes site-chat-progress {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(250%); }
}

.site-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  background: linear-gradient(180deg, rgba(255, 255, 255, .015), rgba(94, 234, 212, .04));
}

.site-chat-input {
  min-width: 0;
  resize: none;
  height: 44px;
  max-height: 130px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  padding: 12px;
  background: rgba(4, 9, 18, .76);
  color: #f4f7ff;
  font: 500 .88rem/1.35 Inter, system-ui, sans-serif;
}

.site-chat-input:focus {
  outline: none;
  border-color: rgba(94, 234, 212, .54);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, .08);
}

.site-chat-send {
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: linear-gradient(135deg, #5eead4, #7dd3fc);
  color: #061016;
  font: 900 .82rem/1 Inter, system-ui, sans-serif;
  cursor: pointer;
}

.site-chat-send:disabled,
.site-chat-input:disabled {
  cursor: wait;
  opacity: .62;
}

[data-theme="light"] .site-chat-toggle {
  border-color: rgba(13, 147, 115, .34);
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, .88), transparent 34%),
    radial-gradient(circle at 70% 74%, rgba(96, 165, 250, .16), transparent 46%),
    rgba(220, 252, 247, .78);
  color: #052522;
  box-shadow: 0 18px 46px rgba(13, 147, 115, .2), 0 0 28px rgba(20, 184, 166, .16), inset 0 0 0 1px rgba(255, 255, 255, .52);
}

[data-theme="light"] .site-chat-toggle-mark {
  background: transparent;
}

[data-theme="light"] .site-chat-toggle::after {
  border-color: rgba(13, 148, 136, .78);
  box-shadow: 0 0 18px rgba(13, 147, 115, .2);
}

[data-theme="light"] .site-chat {
  border-color: rgba(13, 147, 115, .22);
  background:
    radial-gradient(circle at 20% 0%, rgba(20, 184, 166, .16), transparent 34%),
    radial-gradient(circle at 100% 14%, rgba(96, 165, 250, .12), transparent 34%),
    linear-gradient(180deg, #f8fffd, #e8fbf7);
  box-shadow: 0 30px 80px rgba(15, 118, 110, .18), 0 0 0 1px rgba(255, 255, 255, .7) inset;
  backdrop-filter: none;
}

[data-theme="light"] .site-chat-header {
  border-bottom-color: rgba(13, 147, 115, .16);
  background: linear-gradient(135deg, rgba(20, 184, 166, .12), rgba(255, 255, 255, .5));
}

[data-theme="light"] .site-chat-avatar {
  border-color: rgba(13, 147, 115, .28);
  background: rgba(255, 255, 255, .62);
}

[data-theme="light"] .site-chat-title {
  color: #09211f;
}

[data-theme="light"] .site-chat-context {
  color: #4b6863;
}

[data-theme="light"] .site-chat-close {
  color: #4b6863;
  border-color: rgba(13, 147, 115, .18);
  background: rgba(255, 255, 255, .58);
}

[data-theme="light"] .site-chat-close:hover {
  color: #0d9373;
  border-color: rgba(13, 147, 115, .34);
}

[data-theme="light"] .site-chat-suggestion {
  border-color: rgba(13, 147, 115, .2);
  background: rgba(20, 184, 166, .09);
  color: #123b37;
}

[data-theme="light"] .site-chat-suggestion:hover {
  border-color: rgba(13, 147, 115, .42);
  color: #0d9373;
  background: rgba(20, 184, 166, .14);
}

[data-theme="light"] .site-chat-message {
  color: #163a36;
}

[data-theme="light"] .site-chat-message h3,
[data-theme="light"] .site-chat-message strong {
  color: #09211f;
}

[data-theme="light"] .site-chat-message code {
  border-color: rgba(13, 147, 115, .16);
  background: rgba(13, 147, 115, .08);
  color: #0f766e;
}

[data-theme="light"] .site-chat-message.user {
  background: linear-gradient(135deg, rgba(20, 184, 166, .16), rgba(96, 165, 250, .1));
  border-color: rgba(13, 147, 115, .28);
  color: #09211f;
}

[data-theme="light"] .site-chat-message.assistant {
  background: rgba(255, 255, 255, .9);
  border-color: rgba(13, 147, 115, .15);
}

[data-theme="light"] .site-chat-message.intro {
  background: linear-gradient(135deg, rgba(20, 184, 166, .14), rgba(255, 255, 255, .92));
  border-color: rgba(13, 147, 115, .2);
}

[data-theme="light"] .site-chat-message a { color: #0f766e; border-bottom-color: rgba(15, 118, 110, .3); }
[data-theme="light"] .site-chat-message a:hover { color: #115e59; }
[data-theme="light"] .site-chat-entity-card {
  border-color: rgba(13, 147, 115, .18);
  background: linear-gradient(135deg, rgba(20, 184, 166, .1), rgba(255, 255, 255, .76));
  color: #09211f;
}
[data-theme="light"] .site-chat-entity-card:hover { border-color: rgba(13, 147, 115, .4); background: rgba(255, 255, 255, .94); }
[data-theme="light"] .site-chat-entity-name { color: #09211f; }
[data-theme="light"] .site-chat-entity-meta { color: #4b6863; }
[data-theme="light"] .site-chat-entity-logo { border-color: rgba(13, 147, 115, .14); }
[data-theme="light"] .site-chat-entity-arrow { color: #0f766e; }

[data-theme="light"] .site-chat-message.error {
  background: rgba(239, 68, 68, .08);
  border-color: rgba(239, 68, 68, .22);
  color: #991b1b;
}

[data-theme="light"] .site-chat-interrupted {
  border-top-color: rgba(180, 83, 9, .2);
  color: #92400e;
}

[data-theme="light"] .site-chat-thinking-text {
  color: #163a36;
}

[data-theme="light"] .site-chat-thinking-bar {
  background: rgba(13, 147, 115, .12);
}

[data-theme="light"] .site-chat-form {
  border-top-color: rgba(13, 147, 115, .16);
  background: linear-gradient(180deg, rgba(255, 255, 255, .45), rgba(20, 184, 166, .08));
}

[data-theme="light"] .site-chat-input {
  border-color: rgba(13, 147, 115, .22);
  background: rgba(255, 255, 255, .78);
  color: #09211f;
}

[data-theme="light"] .site-chat-input:focus {
  border-color: rgba(13, 147, 115, .52);
  box-shadow: 0 0 0 3px rgba(13, 147, 115, .1);
}

[data-theme="light"] .site-chat-send {
  background: linear-gradient(135deg, #14b8a6, #60a5fa);
  color: #041016;
}

@media (max-width: 820px) {
  .site-chat-toggle {
    right: 18px;
    bottom: 24px;
    width: 56px;
    height: 56px;
  }

  .site-chat-toggle-mark {
    width: 48px;
    height: 48px;
  }

  .site-chat-toggle-mark svg {
    width: 44px;
    height: 44px;
  }

  .site-chat {
    right: 14px;
    left: 14px;
    bottom: 88px;
    width: auto;
    max-height: calc(100vh - 100px);
  }

  .site-chat-message.user,
  .site-chat-message.assistant {
    margin-left: 0;
    margin-right: 0;
  }

  .site-chat-entities { margin-right: 0; }

  .site-chat-messages {
    min-height: 250px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-chat-planet-orbit { animation: none; }
  .site-chat-toggle { transition: none; }
}
