:root {
  color-scheme: dark;
  --ink: #f7f2e8;
  --muted: #b7c0bd;
  --screen: rgba(11, 19, 22, 0.88);
  --screen-soft: rgba(20, 33, 37, 0.88);
  --line: rgba(255, 255, 255, 0.16);
  --blue: #76c7ff;
  --gold: #e7b04a;
  --green: #65d08f;
  --red: #ff826f;
  --donkey: #c88b50;
  --egg: #f1c865;
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background: #0c1011;
}

button,
select,
textarea {
  font: inherit;
}

button,
select {
  border: 1px solid var(--line);
  border-radius: 6px;
}

button {
  color: var(--ink);
  background: rgba(15, 27, 31, 0.9);
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.room-shell {
  min-height: 100vh;
  padding: 18px;
  background:
    radial-gradient(circle at 15% 42%, rgba(200, 139, 80, 0.28), transparent 24%),
    radial-gradient(circle at 84% 48%, rgba(241, 200, 101, 0.24), transparent 22%),
    linear-gradient(180deg, rgba(5, 8, 9, 0.32), rgba(5, 8, 9, 0.7)),
    linear-gradient(135deg, #10191b 0%, #0a1012 48%, #231a10 100%);
}

.stage {
  display: grid;
  grid-template-columns: minmax(160px, 260px) minmax(0, 1fr) minmax(160px, 260px);
  gap: 18px;
  max-width: 1500px;
  min-height: calc(100vh - 36px);
  margin: 0 auto;
  align-items: stretch;
}

.character,
.screen {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(12px);
}

.character {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 18px;
  padding: 18px;
  background: rgba(20, 18, 14, 0.62);
  overflow: hidden;
}

.character-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
  font-size: 13px;
}

.state-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.character.active .state-dot {
  background: var(--blue);
}

.character[data-status="listening"] .state-dot {
  background: var(--green);
  animation: pulse 1.1s ease-in-out infinite;
}

.character[data-status="thinking"] .state-dot {
  background: var(--gold);
  animation: pulse 0.9s ease-in-out infinite;
}

.character[data-status="speaking"] .state-dot {
  background: var(--blue);
  animation: pulse 0.7s ease-in-out infinite;
}

.character[data-status="failed"] .state-dot {
  background: var(--red);
}

.character-donkey {
  align-content: end;
}

.character-egg {
  background: rgba(26, 20, 12, 0.58);
}

.avatar {
  position: relative;
  align-self: end;
  display: grid;
  place-items: center;
  min-height: 300px;
  border-radius: 8px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  overflow: hidden;
}

.donkey-avatar .muzzle {
  z-index: 2;
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  border: 9px solid #80532d;
  border-radius: 50%;
  background: var(--donkey);
  color: #241306;
  font-size: 46px;
  font-weight: 900;
  animation: breathe 3.4s ease-in-out infinite;
}

.ear {
  position: absolute;
  top: 36px;
  width: 46px;
  height: 108px;
  border: 7px solid #74451f;
  border-radius: 50% 50% 42% 42%;
  background: #bd7d3f;
}

.ear-left {
  left: 54px;
  transform: rotate(-18deg);
}

.ear-right {
  right: 54px;
  transform: rotate(18deg);
}

.egg-avatar .egg-face {
  display: grid;
  place-items: center;
  width: 148px;
  height: 190px;
  border: 9px solid #b88427;
  border-radius: 52% 52% 45% 45%;
  background: var(--egg);
  color: #2a1602;
  font-size: 48px;
  font-weight: 900;
  animation: lounge 4s ease-in-out infinite;
}

.character-copy h1 {
  margin: 0 0 8px;
  font-size: 32px;
  letter-spacing: 0;
}

.character-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.call-button {
  min-height: 48px;
  font-weight: 800;
}

.call-button.active {
  background: var(--blue);
  color: #071013;
  border-color: transparent;
}

.character.speaking .avatar {
  box-shadow: inset 0 0 0 2px rgba(118, 199, 255, 0.65);
}

.character[data-status="thinking"] .avatar {
  animation: scan 1.6s ease-in-out infinite;
}

.character[data-status="speaking"] .avatar {
  animation: speak-bob 0.72s ease-in-out infinite;
}

.screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: calc(100vh - 36px);
  background: var(--screen);
  overflow: hidden;
}

.screen-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 17, 20, 0.92);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 12px;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.screen-status {
  display: flex;
  align-items: center;
  justify-content: end;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.screen-status span,
.screen-status select,
.toggle-label {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
}

.screen-status select {
  border-radius: 6px;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
}

.toggle-label input {
  margin: 0;
  accent-color: var(--blue);
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
}

.message {
  width: min(82%, 860px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.075);
  line-height: 1.68;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: rgba(118, 199, 255, 0.15);
}

.message.donkey {
  align-self: flex-start;
  border-left: 4px solid var(--donkey);
}

.message.egg {
  align-self: flex-start;
  border-left: 4px solid var(--egg);
}

.message.system {
  align-self: center;
  width: min(92%, 980px);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
}

.message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.message-name {
  color: var(--ink);
  font-weight: 800;
}

.evidence {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.evidence summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 800;
}

.evidence-grid {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.evidence-item {
  border-left: 3px solid var(--green);
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
}

.composer {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 88px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: rgba(9, 17, 20, 0.95);
}

.voice-button,
.send-button {
  min-height: 54px;
  font-weight: 900;
}

.voice-button.listening {
  background: var(--red);
  border-color: transparent;
  color: #fff;
}

.send-button {
  background: linear-gradient(180deg, rgba(118, 199, 255, 0.95), rgba(78, 150, 205, 0.95));
  color: #071013;
  border-color: transparent;
}

textarea {
  width: 100%;
  min-height: 54px;
  max-height: 140px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  line-height: 1.55;
}

textarea::placeholder {
  color: rgba(247, 242, 232, 0.52);
}

@keyframes breathe {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-6px) scale(1.035);
  }
}

@keyframes lounge {
  0%,
  100% {
    transform: rotate(-3deg) translateY(0);
  }
  50% {
    transform: rotate(3deg) translateY(-5px);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.65;
  }
  50% {
    transform: scale(1.55);
    opacity: 1;
  }
}

@keyframes scan {
  0%,
  100% {
    filter: saturate(1);
  }
  50% {
    filter: saturate(1.28) brightness(1.08);
  }
}

@keyframes speak-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@media (max-width: 1040px) {
  .stage {
    grid-template-columns: 1fr;
  }

  .character {
    grid-template-columns: 150px 1fr auto;
    grid-template-rows: auto;
    align-items: center;
    min-height: 190px;
  }

  .avatar {
    min-height: 150px;
  }

  .screen {
    min-height: 620px;
  }

  .screen-top {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .room-shell {
    padding: 10px;
  }

  .stage {
    min-height: calc(100vh - 20px);
  }

  .character {
    grid-template-columns: 1fr;
  }

  .screen {
    min-height: 680px;
  }

  .message {
    width: 100%;
  }

  .composer {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .send-button {
    grid-column: 1 / 3;
  }
}
