:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --text: #243036;
  --muted: #6d7780;
  --line: #ddd8ce;
  --primary: #2f7f7b;
  --primary-dark: #23635f;
  --coral: #d96b5f;
  --soft: #e9f2ef;
  --shadow: 0 12px 30px rgba(44, 50, 56, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: 340px minmax(420px, 1fr) 390px;
  gap: 16px;
  height: 100vh;
  padding: 16px;
}

.sidebar,
.debug {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 17px;
}

.hint,
.chat-header p {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}

input:focus {
  border-color: var(--primary);
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  padding: 11px 14px;
}

button:hover {
  background: var(--primary-dark);
}

.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

.ghost:hover {
  background: var(--soft);
}

#loginBtn {
  width: 100%;
  margin-top: 14px;
}

.token {
  margin-top: 12px;
  overflow-wrap: anywhere;
  border-radius: 8px;
  background: #f4f7f7;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.bots {
  display: grid;
  gap: 10px;
}

.bot-card {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  padding: 12px;
}

.bot-card.active {
  border-color: var(--primary);
  background: var(--soft);
}

.avatar {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  background: var(--coral);
  color: #fff;
  font-weight: 700;
}

.bot-name {
  margin: 0 0 4px;
  font-weight: 700;
}

.bot-meta,
.bot-style {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.chat {
  display: grid;
  min-height: 0;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.bubble-row {
  align-items: flex-end;
  gap: 8px;
  display: flex;
  margin: 10px 0;
}

.bubble-row.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 74%;
  border-radius: 8px;
  padding: 11px 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.bubble.assistant {
  background: #f1efe8;
}

.bubble.user {
  background: var(--primary);
  color: #fff;
}

.voice-btn {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--primary-dark);
  padding: 7px 9px;
  font-size: 12px;
}

.voice-btn:hover {
  background: var(--soft);
}

.voice-btn:disabled {
  cursor: wait;
  opacity: 0.7;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px;
}

pre {
  max-height: 260px;
  overflow: auto;
  margin: 12px 0 0;
  border-radius: 8px;
  background: #222a2e;
  color: #edf4f2;
  padding: 12px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 320px 1fr;
    height: auto;
    min-height: 100vh;
  }

  .debug {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .chat {
    min-height: 620px;
  }
}
