﻿:root {
  --bg-top: #faf8f5;
  --bg-bottom: #f1ebe4;
  --line: rgba(139, 0, 18, 0.2);
  --text-main: #1a0f0f;
  --text-subtle: #5a4040;
  --brand: #8b0012;
  --brand-strong: #b5001a;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: 'Microsoft YaHei UI', 'PingFang SC', 'Segoe UI', sans-serif;
  color: var(--text-main);
  background: linear-gradient(160deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

body {
  padding: 28px;
}

.sparring-page {
  max-width: 1480px;
  margin: 0 auto;
}

.sparring-header {
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(248, 239, 233, 0.96));
  box-shadow: 0 16px 34px rgba(139, 0, 18, 0.16);
}

.back-link {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--brand);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.sparring-header h1 {
  margin: 0;
  font-size: clamp(25px, 2.3vw, 34px);
}

.sparring-header p {
  margin: 10px 0 0;
  font-size: 15px;
  color: var(--text-subtle);
}

.sparring-main {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  min-height: calc(100vh - 240px);
}

.agent-sidebar,
.chat-panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 14px 30px rgba(139, 0, 18, 0.13);
}

.agent-sidebar {
  padding: 16px;
}

.agent-sidebar__title {
  font-size: 15px;
  font-weight: 800;
  color: #8b0012;
  margin-bottom: 12px;
}

.agent-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-item {
  width: 100%;
  border: 1px solid rgba(139, 0, 18, 0.28);
  border-radius: 14px;
  background: var(--surface-strong);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.agent-item:hover {
  border-color: rgba(139, 0, 18, 0.55);
  transform: translateY(-1px);
}

.agent-item.is-active {
  border-color: rgba(139, 0, 18, 0.78);
  box-shadow: 0 10px 18px rgba(139, 0, 18, 0.16);
  background: linear-gradient(180deg, #fffcfb, #f7efe9);
}

.agent-item__name {
  font-size: 15px;
  font-weight: 800;
}

.agent-item__key {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-subtle);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 580px;
}

.chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.chat-panel__agent {
  font-size: 20px;
  font-weight: 800;
}

.chat-panel__hint {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-subtle);
}

.ghost-button {
  border: 1px solid rgba(139, 0, 18, 0.36);
  border-radius: 12px;
  background: #f8eeea;
  color: #8b0012;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 12px;
  cursor: pointer;
}

.chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: min(78ch, 92%);
  border-radius: 14px;
  padding: 11px 12px;
  line-height: 1.58;
  word-break: break-word;
}

.message--user {
  align-self: flex-end;
  background: linear-gradient(180deg, #b5001a, #8b0012);
  color: #fff;
  white-space: pre-wrap;
}

.message--assistant {
  align-self: flex-start;
  background: #fff7f4;
  color: #3b2020;
  border: 1px solid rgba(139, 0, 18, 0.24);
}

.message--assistant p,
.message--assistant ul,
.message--assistant ol,
.message--assistant pre,
.message--assistant blockquote {
  margin: 0;
}

.message--assistant p + p,
.message--assistant p + ul,
.message--assistant p + ol,
.message--assistant ul + p,
.message--assistant ol + p,
.message--assistant ul + ul,
.message--assistant ol + ol,
.message--assistant ul + ol,
.message--assistant ol + ul,
.message--assistant pre + p,
.message--assistant p + pre,
.message--assistant blockquote + p,
.message--assistant p + blockquote {
  margin-top: 8px;
}

.message--assistant ul,
.message--assistant ol {
  padding-left: 1.25rem;
}

.message--assistant pre {
  overflow-x: auto;
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(139, 0, 18, 0.08);
  white-space: pre;
}

.message--assistant code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 0.92em;
  background: rgba(139, 0, 18, 0.12);
  border-radius: 6px;
  padding: 0 4px;
}

.message--assistant pre code {
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.message--assistant blockquote {
  border-left: 3px solid rgba(139, 0, 18, 0.4);
  padding-left: 10px;
  color: #6e3b3b;
}

.message--assistant a {
  color: #8b0012;
}

.message--system {
  align-self: center;
  background: rgba(248, 236, 228, 0.66);
  color: #7f3d3d;
  border: 1px dashed rgba(139, 0, 18, 0.42);
  font-size: 13px;
  white-space: pre-wrap;
}

.chat-panel__composer {
  border-top: 1px solid var(--line);
  padding: 14px;
}

#chat-input {
  width: 100%;
  border: 1px solid rgba(139, 0, 18, 0.32);
  border-radius: 12px;
  background: #fff;
  resize: vertical;
  min-height: 68px;
  max-height: 220px;
  font: inherit;
  color: var(--text-main);
  padding: 10px;
}

.chat-panel__composer-meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#chat-status {
  color: var(--text-subtle);
  font-size: 13px;
}

.send-button {
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #b5001a, var(--brand));
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 9px 16px;
  cursor: pointer;
}

.send-button:disabled,
.ghost-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 1100px) {
  body {
    padding: 16px;
  }

  .sparring-main {
    grid-template-columns: 1fr;
  }

  .agent-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-panel {
    min-height: 540px;
  }
}

@media (max-width: 640px) {
  .sparring-header {
    padding: 18px;
  }

  .chat-panel__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .agent-list {
    grid-template-columns: 1fr;
  }
}

