:root {
  --bg: #e7e8ea;
  --panel: #f5f5f6;
  --line: #8d9199;
  --line-soft: #b5b8be;
  --text: #181a1f;
  --muted: #656972;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
}

body {
  background-image: radial-gradient(circle, #c1c4ca 1.2px, transparent 1.2px);
  background-size: 24px 24px;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}

body.started #stage {
  opacity: 1;
  pointer-events: auto;
}

.scene {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

.title {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  font-size: clamp(42px, 6vw, 92px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.title.hidden {
  opacity: 0;
  transform: translate(-50%, calc(-50% - 24px));
  pointer-events: none;
}

.logo {
  position: absolute;
  top: 28px;
  left: 32px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 14px;
  letter-spacing: 0.32em;
  opacity: 0;
  transform: translateY(-16px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.scene.started .logo {
  opacity: 1;
  transform: translateY(0);
}

.friend-panel {
  position: absolute;
  top: 86px;
  bottom: 48%;
  left: 32px;
  width: min(24vw, 340px);
  border: 1px solid rgba(24, 26, 31, 0.32);
  background: rgba(245, 245, 246, 0.86);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 10px;
  opacity: 0;
  transform: translateY(-14px);
  transition: opacity 0.45s ease, transform 0.45s ease;
  pointer-events: auto;
}

.article-panel {
  position: absolute;
  top: 86px;
  right: 32px;
  width: min(30vw, 460px);
  height: 52vh;
  border: 1px solid rgba(24, 26, 31, 0.32);
  background: rgba(245, 245, 246, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  opacity: 0;
  transform: translateX(14px);
  transition: opacity 0.28s ease, transform 0.28s ease;
  pointer-events: none;
}

.article-panel.show {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.article-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.article-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.article-panel-open {
  height: 32px;
  border: 1px solid rgba(24, 26, 31, 0.34);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 0 10px;
  cursor: pointer;
}

.article-panel-title {
  color: #181a1f;
  font-size: 14px;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.article-panel-close {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(24, 26, 31, 0.4);
  background: #f6f6f8;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.article-panel-frame {
  width: 100%;
  flex: 1;
  border: 1px solid rgba(24, 26, 31, 0.24);
  background: #fff;
}

.scene.started .friend-panel {
  opacity: 1;
  transform: translateY(0);
}

.friend-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.friend-panel-title {
  color: #181a1f;
  padding: 0;
  font-size: 14px;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.friend-panel-add {
  width: 32px;
  height: 32px;
  border: none;
  background: #f6f6f8;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.28s ease;
}

.friend-panel-add:hover {
  transform: rotate(180deg);
}

.friend-links-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 14px;
  padding-right: 2px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.friend-links-scroll::-webkit-scrollbar {
  display: none;
}

.friend-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  border: 1px solid rgba(24, 26, 31, 0.24);
  background: rgba(255, 255, 255, 0.52);
  text-decoration: none;
  color: inherit;
  padding: 8px;
}

.friend-link-item:hover {
  border-color: #181a1f;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset -2px 0 0 #2fbf5e;
}

.friend-link-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 700;
  flex: 0 0 auto;
}

.friend-link-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.friend-link-empty {
  padding: 12px 8px;
  color: var(--muted);
  font-size: 13px;
}

.friend-link-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.friend-link-title {
  font-size: 15px;
  font-weight: 700;
  color: #16181c;
}

.friend-link-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.friend-scroll-indicator {
  position: absolute;
  left: -33px;
  top: 50%;
  align-self: auto;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-family: "Consolas", "Courier New", monospace;
  text-align: center;
  white-space: nowrap;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: center;
  pointer-events: none;
}

.trigger-wrap {
  position: absolute;
  top: 80%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 220px;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.scene.started .trigger-wrap {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.85);
  pointer-events: none;
}

.loading-metaball {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.metaball-filter-defs {
  position: absolute;
  width: 0;
  height: 0;
}

.metaball-layer {
  position: relative;
  width: 196px;
  height: 196px;
  filter: url(#metaball-threshold);
  isolation: isolate;
}

.metaball {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  background: #fff;
  mix-blend-mode: difference;
}

.blob-main {
  width: 84px;
  height: 84px;
  transform: translate(-50%, -50%) scale(0.36);
  animation: blob-main-grow 1.8s cubic-bezier(0.2, 0.7, 0.25, 1) infinite;
}

.blob-small {
  width: 20px;
  height: 20px;
  transform: translate(calc(-50% + var(--sx, 0px)), calc(-50% + var(--sy, 0px))) scale(0.3);
  animation: blob-inward 1.8s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

.blob-n { --sx: 0px; --sy: -82px; --delay: 0s; }
.blob-ne { --sx: 58px; --sy: -58px; --delay: .12s; }
.blob-e { --sx: 82px; --sy: 0px; --delay: .24s; }
.blob-se { --sx: 58px; --sy: 58px; --delay: .36s; }
.blob-s { --sx: 0px; --sy: 82px; --delay: .48s; }
.blob-sw { --sx: -58px; --sy: 58px; --delay: .6s; }
.blob-w { --sx: -82px; --sy: 0px; --delay: .72s; }
.blob-nw { --sx: -58px; --sy: -58px; --delay: .84s; }

.loading-ring {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 74px;
  height: 74px;
  z-index: 3;
  border-radius: 50%;
  border: 1px solid rgba(24, 26, 31, 0.25);
  border-top-color: var(--text);
  animation: spin 0.9s linear infinite;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.trigger {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 74px;
  height: 74px;
  z-index: 4;
  border: 1px solid var(--text);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.scene.live2d-ready .loading-metaball {
  opacity: 0;
  transform: scale(0.9);
}

.scene.live2d-ready .loading-ring {
  opacity: 0;
  transform: scale(0.82);
}

.scene.live2d-ready .trigger {
  opacity: 1;
  pointer-events: auto;
}

.trigger::before,
.trigger::after,
.ring {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--text);
  border-radius: 50%;
  animation: ripple 2.8s linear infinite;
}

.trigger::after {
  animation-delay: 0.9s;
}

.ring {
  animation-delay: 1.8s;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
}

.dialog {
  position: absolute;
  left: 50%;
  bottom: 34px;
  width: min(78vw, 1080px);
  height: 118px;
  transform: translateX(-50%) translateY(130%);
  border: 1px solid var(--line);
  background: rgba(245, 245, 246, 0.94);
  opacity: 0;
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.scene.started .dialog {
  opacity: 0;
  transform: translateX(-50%) translateY(130%);
}

.dialog::before,
.dialog::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  height: 1px;
  background: var(--line-soft);
}

.dialog::before {
  top: 20px;
}

.dialog::after {
  bottom: 20px;
}

.dialog-core {
  position: absolute;
  inset: 18px;
  border: 1px solid #c9ccd2;
  display: flex;
  align-items: center;
  padding: 0 28px;
}

.dialog-bar {
  width: min(30vw, 320px);
  height: 18px;
  border: 1px solid var(--line);
  background-color: #ececef;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='18' viewBox='0 0 28 18'%3E%3Crect width='18' height='18' fill='%23d8dade'/%3E%3C/svg%3E");
  background-size: 28px 18px;
}

.dialog-pulse {
  width: 12px;
  height: 12px;
  margin-left: 18px;
  background: var(--text);
  animation: blink 0.9s steps(1) infinite;
}

.chat-history {
  position: absolute;
  left: max(12px, calc(50% - 580px));
  bottom: 168px;
  width: min(30vw, 410px);
  max-height: 30vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.45s ease, transform 0.45s ease;
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.chat-history::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.chat-history::before {
  content: "";
  position: sticky;
  top: 0;
  display: block;
  height: 22px;
  margin-bottom: -22px;
  background: linear-gradient(to bottom, rgba(236, 238, 241, 0.96), rgba(236, 238, 241, 0));
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.18s ease;
}

.chat-history.fade-top::before {
  opacity: 1;
}

.scene.started .chat-history {
  opacity: 1;
  transform: translateY(0);
}

.chat-bubble {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid rgba(141, 145, 153, 0.55);
  background: rgba(245, 245, 246, 0.76);
  backdrop-filter: blur(6px);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.chat-bubble.user {
  margin-right: 42px;
}

.chat-bubble.assistant {
  margin-left: 42px;
}

.chat-thinking {
  position: absolute;
  left: max(12px, calc(50% - 580px));
  bottom: 146px;
  width: min(30vw, 410px);
  color: rgba(24, 26, 31, 0.68);
  font-size: 12px;
  letter-spacing: 0.06em;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.chat-thinking.show {
  opacity: 1;
  transform: translateY(0);
}

.chat-quick {
  position: absolute;
  left: 50%;
  bottom: 128px;
  width: min(78vw, 1080px);
  transform: translateX(-50%) translateY(14px);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.45s ease, transform 0.45s ease;
  pointer-events: auto;
  flex-wrap: wrap;
}

.scene.started .chat-quick {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.chat-quick.empty {
  pointer-events: none;
}

.chat-quick-item {
  border: 1px solid rgba(24, 26, 31, 0.34);
  background: rgba(245, 245, 246, 0.76);
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  padding: 9px 12px;
  cursor: pointer;
}

.chat-quick-item:hover {
  border-color: rgba(24, 26, 31, 0.62);
  background: rgba(255, 255, 255, 0.9);
}

.chat-form {
  position: absolute;
  left: 50%;
  bottom: 34px;
  width: min(78vw, 1080px);
  height: 86px;
  transform: translateX(-50%) translateY(130%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(141, 145, 153, 0.75);
  background: rgba(245, 245, 246, 0.55);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.55s ease, transform 0.55s ease;
  pointer-events: auto;
}

.scene.started .chat-form {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.chat-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 1px solid rgba(141, 145, 153, 0.7);
  background: rgba(255, 255, 255, 0.3);
  color: var(--text);
  font-size: 16px;
  padding: 0 16px;
  outline: none;
}

.chat-input:focus {
  border-color: var(--text);
  background: rgba(255, 255, 255, 0.45);
}

.chat-send {
  width: 116px;
  height: 100%;
  border: 1px solid var(--text);
  background: rgba(240, 241, 242, 0.8);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

@keyframes ripple {
  0% {
    transform: scale(1);
    opacity: 0.9;
  }
  100% {
    transform: scale(2.75);
    opacity: 0;
  }
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }
  50.01%,
  100% {
    opacity: 0.15;
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes blob-main-grow {
  0% {
    transform: translate(-50%, -50%) scale(0.34);
    opacity: 0.55;
  }
  45% {
    transform: translate(-50%, -50%) scale(1.3);
    opacity: 0.95;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.95);
    opacity: 0.08;
  }
}

@keyframes blob-inward {
  0% {
    transform: translate(calc(-50% + var(--sx, 0px)), calc(-50% + var(--sy, 0px))) scale(0.28);
    opacity: 0;
  }
  20% {
    opacity: 0.95;
  }
  72% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.88;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.24);
    opacity: 0;
  }
}

@media (max-width: 860px) {
  .title {
    top: 50%;
    white-space: normal;
    width: calc(100% - 48px);
    text-align: center;
  }

  .dialog {
    width: calc(100% - 28px);
  }

  .friend-panel {
    left: 14px;
    width: min(38vw, 320px);
    bottom: 48%;
  }

  .article-panel {
    right: 14px;
    width: min(44vw, 420px);
    height: 48vh;
  }

  .chat-history {
    left: 16px;
    width: min(42vw, 340px);
  }

  .chat-thinking {
    left: 16px;
    width: min(42vw, 340px);
  }

  .chat-form {
    width: calc(100% - 28px);
  }

  .chat-quick {
    width: calc(100% - 28px);
  }
}

@media (max-width: 680px) {
  .dialog {
    height: 94px;
  }

  .dialog-bar {
    width: 58vw;
  }

  .friend-panel {
    left: 14px;
    right: 14px;
    width: auto;
    top: 78px;
    bottom: 48%;
  }

  .article-panel {
    left: 14px;
    right: 14px;
    width: auto;
    top: 78px;
    height: 42vh;
  }

  .chat-history {
    left: 14px;
    right: 14px;
    width: auto;
    bottom: 148px;
    max-height: 28vh;
  }

  .chat-thinking {
    left: 14px;
    right: 14px;
    width: auto;
    bottom: 132px;
  }

  .chat-form {
    width: calc(100% - 20px);
    height: 74px;
    gap: 8px;
    padding: 10px;
  }

  .chat-quick {
    width: calc(100% - 20px);
    bottom: 116px;
    gap: 6px;
  }

  .chat-quick-item {
    font-size: 12px;
    padding: 8px 10px;
  }

  .chat-input {
    font-size: 14px;
    padding: 0 12px;
  }

  .chat-send {
    width: 84px;
    font-size: 14px;
  }
}
