.site-assistant {
  --assistant-surface: rgba(16, 20, 25, .78);
  --assistant-paper: #f4f0e7;
  --assistant-muted: #9da4a0;
  --assistant-line: rgba(244, 240, 231, .18);
  --assistant-accent: #d8ff5a;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  transition: opacity .18s ease, visibility .18s ease;
}

/* Do not leave a fixed assistant over clickable literature cards. */
.site-assistant.is-content-avoiding {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.site-assistant * { box-sizing: border-box; }

.site-assistant button, .site-assistant textarea { font: inherit; }

.site-assistant-panel {
  width: min(340px, calc(100vw - 28px));
  height: min(500px, calc(100vh - 210px));
  max-height: min(500px, calc(100vh - 210px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(244, 240, 231, .26);
  border-radius: 20px;
  background: var(--assistant-surface);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .38), inset 0 1px 0 rgba(255, 255, 255, .08);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  backdrop-filter: blur(22px) saturate(1.15);
  opacity: 0;
  transform: translateY(16px) scale(.97);
  transform-origin: right bottom;
  pointer-events: none;
  transition: opacity .2s ease, transform .24s cubic-bezier(.16, 1, .3, 1), visibility .24s;
  visibility: hidden;
}

.site-assistant.is-open .site-assistant-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

.site-assistant-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 32px;
  gap: 12px;
  align-items: center;
  padding: 14px 14px 13px;
  border-bottom: 1px solid rgba(244, 240, 231, .16);
  background: rgba(7, 9, 12, .14);
}

.site-assistant-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border: 1px solid rgba(216, 255, 90, .6);
  border-radius: 50%;
  background: #5ab8d1;
  box-shadow: 0 0 0 3px rgba(216, 255, 90, .08);
}

.site-assistant-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(2.38);
  transform-origin: 50% 39%;
}

.site-assistant-name { min-width: 0; }
.site-assistant-name strong { display: block; color: var(--assistant-paper); font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; font-weight: 600; letter-spacing: .06em; }
.site-assistant-name span { display: block; margin-top: 3px; color: var(--assistant-muted); font-size: 11px; }

.site-assistant-close {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--assistant-line);
  border-radius: 50%;
  background: transparent;
  color: var(--assistant-muted);
  cursor: pointer;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.site-assistant-close:hover { border-color: var(--assistant-accent); background: var(--assistant-accent); color: #07090c; }
.site-assistant-close svg { width: 15px; height: 15px; }

.site-assistant-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px;
  scrollbar-color: var(--assistant-line) transparent;
}

.site-assistant-message {
  width: fit-content;
  max-width: 88%;
  margin: 0;
  padding: 10px 12px;
  color: var(--assistant-paper);
  border: 1px solid var(--assistant-line);
  border-radius: 12px;
  background: rgba(244, 240, 231, .07);
  font-family: "Songti SC", "STSong", SimSun, serif;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.site-assistant-message--visitor { align-self: flex-end; border-color: rgba(216, 255, 90, .42); background: rgba(216, 255, 90, .1); }
.site-assistant-message--typing { color: var(--assistant-muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; letter-spacing: .08em; }

.site-assistant-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 94px;
  overflow-y: auto;
  padding: 0 14px 13px;
}

.site-assistant-suggestion {
  padding: 6px 8px;
  border: 1px solid var(--assistant-line);
  border-radius: 7px;
  background: rgba(7, 9, 12, .12);
  color: var(--assistant-muted);
  cursor: pointer;
  font-family: "SFMono-Regular", Consolas, "Songti SC", "STSong", "Noto Serif CJK SC", SimSun, serif;
  font-size: 11px;
  line-height: 1.35;
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}
.site-assistant-suggestion:hover { border-color: var(--assistant-accent); background: rgba(216, 255, 90, .08); color: var(--assistant-paper); }

.site-assistant-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(244, 240, 231, .16);
}

.site-assistant-input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  max-height: 94px;
  resize: none;
  padding: 9px 10px;
  border: 1px solid var(--assistant-line);
  border-radius: 8px;
  outline: none;
  background: rgba(7, 9, 12, .28);
  color: var(--assistant-paper);
  font-family: "SFMono-Regular", Consolas, "Songti SC", "STSong", "Noto Serif CJK SC", SimSun, serif;
  font-size: 13px;
  line-height: 1.45;
}
.site-assistant-input::placeholder { color: var(--assistant-muted); }
.site-assistant-input:focus { border-color: var(--assistant-accent); }

html[lang^="zh"] .site-assistant-suggestion,
html[lang^="zh"] .site-assistant-input {
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", SimSun, serif;
}

html[lang="en"] .site-assistant-suggestion,
html[lang="en"] .site-assistant-input,
html[lang="en"] .site-assistant-input::placeholder {
  font-family: "SFMono-Regular", Consolas, monospace !important;
}

.site-assistant-send {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--assistant-accent);
  border-radius: 8px;
  background: var(--assistant-accent);
  color: #07090c;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}
.site-assistant-send:hover { transform: translateY(-1px); background: #efffb2; }
.site-assistant-send:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.site-assistant-send svg { width: 17px; height: 17px; }

.site-assistant-launcher {
  position: relative;
  width: 72px;
  height: 72px;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--assistant-accent);
  border-radius: 50%;
  background: #5ab8d1;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .38), 0 0 0 5px rgba(216, 255, 90, .1);
  cursor: pointer;
  isolation: isolate;
  transition: transform .22s cubic-bezier(.16, 1, .3, 1), box-shadow .22s ease;
}
.site-assistant-launcher:hover { transform: translateY(-4px) scale(1.04); box-shadow: 0 18px 34px rgba(0, 0, 0, .42), 0 0 0 7px rgba(216, 255, 90, .14); }
.site-assistant-launcher:active { transform: translateY(-1px) scale(.98); }

.site-assistant-launcher::before {
  position: absolute;
  z-index: 2;
  right: 4px;
  bottom: 5px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--assistant-surface);
  border-radius: 50%;
  background: var(--assistant-accent);
  content: "";
}

.site-assistant-launcher img { width: 100%; height: 100%; object-fit: cover; transform: scale(2.38); transform-origin: 50% 39%; }

.site-assistant[data-state="idle"] .site-assistant-launcher { animation: assistant-float 3.4s ease-in-out infinite; }
.site-assistant[data-state="thinking"] .site-assistant-launcher img { animation: assistant-think .75s ease-in-out infinite alternate; }
.site-assistant[data-state="reply"] .site-assistant-launcher { animation: assistant-pop .5s cubic-bezier(.16, 1, .3, 1); }

@keyframes assistant-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }
@keyframes assistant-think { from { transform: scale(2.38) rotate(-2deg); } to { transform: scale(2.38) rotate(2deg); } }
@keyframes assistant-pop { 0% { transform: scale(1); } 45% { transform: scale(1.11) rotate(-3deg); } 100% { transform: scale(1); } }

@media (max-width: 570px) {
  .site-assistant { right: 14px; bottom: 14px; }
  .site-assistant-panel { height: min(460px, calc(100vh - 190px)); max-height: min(460px, calc(100vh - 190px)); }
  .site-assistant-launcher { width: 64px; height: 64px; }
}

[data-mode="reading"] .site-assistant {
  --assistant-surface: rgba(255, 255, 255, .32);
  --assistant-paper: #151619;
  --assistant-muted: #515852;
  --assistant-line: rgba(21, 22, 25, .18);
  --assistant-accent: #4b6d11;
}

[data-mode="reading"] .site-assistant-panel {
  border-color: rgba(21, 22, 25, .2);
  background: rgba(255, 255, 255, .3);
  box-shadow: 0 18px 48px rgba(38, 42, 32, .12), inset 0 1px 0 rgba(255, 255, 255, .62);
  -webkit-backdrop-filter: blur(30px) saturate(1.08);
  backdrop-filter: blur(30px) saturate(1.08);
}

[data-mode="reading"] .site-assistant-header { background: rgba(255, 255, 255, .14); }
[data-mode="reading"] .site-assistant-message { background: rgba(255, 255, 255, .22); }
[data-mode="reading"] .site-assistant-message--visitor { border-color: rgba(75, 109, 17, .4); background: rgba(75, 109, 17, .1); }
[data-mode="reading"] .site-assistant-suggestion { background: rgba(255, 255, 255, .12); }
[data-mode="reading"] .site-assistant-input { background: rgba(255, 255, 255, .22); }
[data-mode="reading"] .site-assistant-send { color: #f4f0e7; }

@media (prefers-reduced-motion: reduce) {
  .site-assistant *, .site-assistant { animation: none !important; transition-duration: .01ms !important; }
}
