:root {
  --bg: #0f0e12;
  --panel: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.09);
  --text: #f3efe8;
  --muted: #9a96a0;
  --lemon: #f2d06b;
  --lemon-soft: rgba(242, 208, 107, 0.18);
  --pink: #e9a4b0;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1100px 780px at 16% 0%, rgba(242, 208, 107, 0.11), transparent 62%),
    radial-gradient(900px 700px at 92% 100%, rgba(150, 126, 198, 0.14), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

.app {
  height: 100dvh;
  max-width: 1220px;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(0, 0.96fr);
  gap: 20px;
}

/* ---------- 舞台 ---------- */

.stage {
  position: relative;
  min-height: 0;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.07);
  background: #fdaec4;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 18px 50px rgba(120, 30, 60, 0.16);
}

#avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.stage-top {
  position: absolute;
  top: 18px;
  left: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.live {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: #6b3f4d;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  backdrop-filter: blur(10px);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6f6a78;
  transition: background 0.25s, box-shadow 0.25s;
}

.live-dot.online {
  background: #8fd6a4;
  box-shadow: 0 0 10px rgba(143, 214, 164, 0.7);
}

.live-dot.listening {
  background: var(--lemon);
  box-shadow: 0 0 12px rgba(242, 208, 107, 0.9);
  animation: pulse 1.4s ease-in-out infinite;
}

.live-dot.thinking {
  background: #a89bd8;
  box-shadow: 0 0 10px rgba(168, 155, 216, 0.8);
  animation: pulse 0.9s ease-in-out infinite;
}

.live-dot.speaking {
  background: #d9738d;
  box-shadow: 0 0 12px rgba(217, 115, 141, 0.85);
}

.live-dot.offline {
  background: #d77;
}

.name {
  font-size: 15px;
  letter-spacing: 0.14em;
  color: rgba(107, 63, 77, 0.82);
  text-shadow: 0 1px 14px rgba(255, 255, 255, 0.75);
}

.subtitle {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 14px);
  width: min(86%, 520px);
  padding: 12px 20px;
  border-radius: 16px;
  font-size: 16px;
  line-height: 1.65;
  text-align: center;
  color: #5f3a48;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 30px rgba(120, 40, 65, 0.12);
  backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.subtitle.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 右侧面板 ---------- */

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 22px 20px 18px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.018));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 2px 4px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.panel-head h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.panel-head p {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.ghost {
  flex: none;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.ghost:hover {
  color: var(--text);
  border-color: rgba(242, 208, 107, 0.4);
}

.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 4px 10px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.chat::-webkit-scrollbar {
  width: 6px;
}

.chat::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 99px;
}

.empty {
  margin: 18% auto 0;
  max-width: 300px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.9;
}

.empty p {
  margin: 0;
}

.msg {
  display: flex;
  margin: 10px 0;
  animation: rise 0.28s ease both;
}

.msg.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 84%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg.assistant .bubble {
  color: #fbf6ea;
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom-left-radius: 6px;
}

.msg.user .bubble {
  color: #221e26;
  background: linear-gradient(160deg, #f6dc92, #ebc35b);
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 18px rgba(242, 208, 107, 0.16);
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(242, 208, 107, 0.1);
  border: 1px solid rgba(242, 208, 107, 0.35);
  border-radius: 14px;
}

.action-bar[hidden] {
  display: none;
}

.action-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #f6e7bf;
}

.action-buttons {
  flex: none;
  display: flex;
  gap: 8px;
}

.action-btn {
  padding: 6px 14px;
  font: inherit;
  font-size: 12.5px;
  color: #f0e0b0;
  background: transparent;
  border: 1px solid rgba(242, 208, 107, 0.35);
  border-radius: 999px;
  cursor: pointer;
}

.action-btn:hover {
  background: rgba(242, 208, 107, 0.18);
}

.action-btn.primary {
  color: #221a08;
  background: #f2d06b;
  border-color: #f2d06b;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.composer {
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding-top: 14px;
}

.mic {
  position: relative;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  color: #27221b;
  background: linear-gradient(150deg, #f7e3a4, #eac45f);
  box-shadow: 0 10px 26px rgba(242, 208, 107, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.mic:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(242, 208, 107, 0.3);
}

.mic:active {
  transform: scale(0.96);
}

.mic svg {
  width: 25px;
  height: 25px;
}

.mic.listening {
  background: linear-gradient(150deg, #f9d7dd, #e79aa8);
  box-shadow: 0 0 0 0 rgba(233, 164, 176, 0.45);
  animation: micPulse 1.8s ease-out infinite;
}

.mic.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  animation: none;
}

.screen {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  color: #cfc8de;
  background: rgba(168, 155, 216, 0.12);
  border: 1px solid rgba(168, 155, 216, 0.38);
  transition: transform 0.18s ease, background 0.2s ease;
}

.screen:hover {
  transform: translateY(-1px);
  background: rgba(168, 155, 216, 0.24);
}

.screen:active {
  transform: scale(0.95);
}

.screen svg {
  width: 20px;
  height: 20px;
}

.screen.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.screen.watching {
  color: #fff;
  background: linear-gradient(150deg, #a89bd8, #7e6cc4);
  border-color: transparent;
  animation: watchPulse 1.8s ease-out infinite;
}

@keyframes watchPulse {
  0% { box-shadow: 0 0 0 0 rgba(168, 155, 216, 0.55); }
  70% { box-shadow: 0 0 0 15px rgba(168, 155, 216, 0); }
  100% { box-shadow: 0 0 0 0 rgba(168, 155, 216, 0); }
}

.bubble img {
  display: block;
  max-width: 220px;
  max-height: 150px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.bubble img:last-child {
  margin-bottom: 0;
}

.text-form {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.text-form input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 16px;
  font-size: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.text-form input::placeholder {
  color: #7e7985;
}

.text-form input:focus {
  border-color: rgba(242, 208, 107, 0.45);
  background: rgba(255, 255, 255, 0.065);
}

.send {
  flex: none;
  height: 46px;
  padding: 0 20px;
  font-size: 13.5px;
  color: #26221c;
  background: rgba(242, 208, 107, 0.86);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}

.send:hover {
  background: var(--lemon);
}

.music {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  color: #f0e0b0;
  background: rgba(242, 208, 107, 0.1);
  border: 1px solid rgba(242, 208, 107, 0.35);
  transition: transform 0.18s ease, background 0.2s ease;
}

.music:hover {
  transform: translateY(-1px);
  background: rgba(242, 208, 107, 0.22);
}

.music:active {
  transform: scale(0.95);
}

.music svg {
  width: 20px;
  height: 20px;
}

/* ---------- 點歌面板 ---------- */

.panel {
  position: relative;
}

.music-sheet {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100% - 28px);
  padding: 14px;
  overflow-y: auto;
  border-radius: 20px;
  background: rgba(22, 19, 27, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

.music-sheet[hidden] {
  display: none;
}

.music-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
}

.music-form {
  display: flex;
  gap: 8px;
}

.music-form input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  font-size: 13.5px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
}

.music-form input:focus {
  border-color: rgba(242, 208, 107, 0.45);
}

.music-form .send {
  height: 40px;
  padding: 0 16px;
}

.music-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.music-list .channel {
  font-size: 12.5px;
  color: var(--muted);
  padding: 4px 2px;
}

.music-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  text-align: left;
  color: inherit;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
}

.music-item:hover {
  border-color: rgba(242, 208, 107, 0.4);
}

.music-item img {
  flex: none;
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
}

.music-item .meta {
  min-width: 0;
}

.music-item .title {
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.music-item .channel {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.music-player {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.music-player[hidden] {
  display: none;
}

.music-player iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: 12px;
  background: #000;
}

.music-now {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.music-player .ghost {
  align-self: flex-start;
}

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 14px;
  margin-top: 2px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch .slider {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.2s;
}

.switch .slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f4f0e8;
  transition: transform 0.2s;
}

.switch input:checked + .slider {
  background: rgba(242, 208, 107, 0.65);
}

.switch input:checked + .slider::after {
  transform: translateX(16px);
}

.switch .label {
  font-size: 12.5px;
  color: var(--muted);
}

.hint {
  flex: 1;
  font-size: 11.5px;
  line-height: 1.5;
  color: #7e7985;
  text-align: right;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  max-width: min(88vw, 560px);
  padding: 11px 18px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  color: #f5efe4;
  background: rgba(28, 24, 32, 0.92);
  border: 1px solid rgba(242, 208, 107, 0.28);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(233, 164, 176, 0.45); }
  70% { box-shadow: 0 0 0 16px rgba(233, 164, 176, 0); }
  100% { box-shadow: 0 0 0 0 rgba(233, 164, 176, 0); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  body {
    overflow: hidden;
  }

  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 42dvh minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .stage {
    border-radius: 22px;
  }

  .panel {
    border-radius: 22px;
    padding: 16px 14px 12px;
  }

  .panel-head {
    padding-bottom: 10px;
  }

  .panel-head h1 {
    font-size: 18px;
  }

  .panel-head p {
    display: none;
  }

  .chat {
    padding-top: 12px;
  }

  .empty {
    margin-top: 8%;
  }

  .hint {
    display: none;
  }
}
