:root {
  color-scheme: dark;
  --text: #f6f7f8;
  --muted: rgba(246, 247, 248, 0.68);
  --user-bg: rgba(13, 20, 27, 0.34);
  --assistant-bg: rgba(255, 255, 255, 0.12);
  --bubble-line: rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  overflow: hidden;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: #000;
}

.experience-shell,
.stage-frame {
  min-height: 100vh;
}

.stage-frame {
  position: relative;
  overflow: hidden;
  background: #020304;
}

.avatar-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  opacity: 0;
  background: #000;
  transition: opacity 180ms linear;
}

.avatar-video.is-active {
  opacity: 1;
  z-index: 1;
}

.avatar-video.is-idle {
  opacity: 0;
  z-index: 0;
}

.stage-scrim {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(1, 2, 3, 0.02) 0%, rgba(1, 2, 3, 0.08) 72%, rgba(1, 2, 3, 0.22) 100%),
    linear-gradient(270deg, rgba(1, 2, 3, 0) 46%, rgba(1, 2, 3, 0.22) 100%);
}

.db-panel {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  width: 118px;
  padding: 14px 12px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  background: rgba(8, 13, 18, 0.22);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.16);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.db-panel.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.db-panel__shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.db-panel__label {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: rgba(246, 247, 248, 0.64);
  text-align: center;
}

.db-panel__thermo {
  position: relative;
  width: 42px;
  height: 196px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.db-panel__tube {
  position: relative;
  width: 18px;
  height: 154px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.1) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 18px rgba(120, 236, 199, 0.08);
}

.db-panel__meter-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 0;
  border-radius: 999px;
  background:
    linear-gradient(
      180deg,
      rgba(255, 109, 109, 0.7) 0%,
      rgba(252, 212, 80, 0.7) 40%,
      rgba(103, 241, 184, 0.7) 100%
    );
  box-shadow:
    0 0 18px rgba(103, 241, 184, 0.14),
    inset 0 0 12px rgba(255, 255, 255, 0.12);
  transition: height 80ms linear;
}

.db-panel__bulb {
  width: 34px;
  height: 34px;
  margin-top: -6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.18) 0%, rgba(111, 243, 191, 0.24) 38%, rgba(15, 24, 30, 0.24) 100%);
  box-shadow:
    inset 0 0 12px rgba(255, 255, 255, 0.08),
    0 0 22px rgba(103, 241, 184, 0.12);
}

.db-panel__value {
  width: 100%;
  margin: -2px 0 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  color: rgba(246, 247, 248, 0.86);
}

.db-panel__status,
.db-panel__transcript {
  width: 100%;
  margin: 0;
  line-height: 1.5;
  text-align: center;
}

.db-panel__status {
  font-size: 12px;
  color: rgba(246, 247, 248, 0.72);
}

.db-panel__transcript {
  font-size: 12px;
  min-height: 36px;
  color: rgba(246, 247, 248, 0.48);
}

.stage-loading {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  padding: 12px 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(6, 10, 14, 0.58);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(246, 247, 248, 0.82);
  font-size: 14px;
  letter-spacing: 0.08em;
  transform: translate(-50%, -50%);
  opacity: 1;
  transition: opacity 220ms ease, visibility 0s linear 0s;
}

.stage-loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease, visibility 0s linear 220ms;
}

.dialog-panel {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 3;
  width: clamp(280px, 28vw, 360px);
  height: min(64vh, 760px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 220ms ease,
    transform 220ms ease,
    visibility 0s linear 220ms;
}

.dialog-panel.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
  transition:
    opacity 220ms ease,
    transform 220ms ease,
    visibility 0s linear 0s;
}

.status-indicator {
  align-self: flex-end;
  flex: 0 0 auto;
  padding: 0 2px;
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.status-indicator[data-error="true"] {
  color: rgba(255, 198, 190, 0.92);
}

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 4px 8px 8px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  touch-action: pan-y;
}

.messages:focus {
  outline: none;
}

.messages > :first-child {
  margin-top: auto;
}

.messages::-webkit-scrollbar {
  width: 4px;
}

.messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.message {
  max-width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--bubble-line);
  border-radius: 18px;
  background: var(--assistant-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.18);
}

.message-user {
  align-self: flex-end;
  background: var(--user-bg);
}

.message-role,
.message-meta {
  display: none;
}

.message-content {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.65;
  color: var(--text);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.36);
}

@media (orientation: portrait) {
  .dialog-panel {
    right: 12px;
    bottom: 12px;
    width: clamp(240px, 42vw, 320px);
    height: min(58vh, 720px);
  }
}

@media (max-width: 960px) {
  .db-panel {
    top: 12px;
    right: 12px;
    width: 108px;
    padding: 12px 10px 10px;
  }

  .dialog-panel {
    right: 12px;
    bottom: 12px;
    width: clamp(240px, 44vw, 300px);
    height: min(56vh, 520px);
  }
}

@media (max-width: 640px) {
  .db-panel {
    top: 12px;
    right: 12px;
    left: auto;
    width: 102px;
  }

  .dialog-panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    height: min(42vh, 360px);
  }

  .message {
    padding: 11px 13px;
    border-radius: 16px;
  }

  .message-content {
    font-size: 14px;
    line-height: 1.58;
  }
}
