:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-2: #1e2230;
  --border: #2a2f3e;
  --text: #e6e8ee;
  --muted: #9aa2b1;
  --socrates: #6aa9ff;      /* 苏格拉底：冷蓝，质询 */
  --aristotle: #e0a96d;     /* 亚里士多德：暖橙，补给 */
  --human: #7ee0a8;         /* 人：绿，转译 */
  --danger: #ff6b6b;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

/* 确保 hidden 属性始终生效（.overlay/.dialogue 等设了 display，会盖过浏览器默认的 [hidden]{display:none}） */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #1a1f2e 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 17, 23, 0.8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 30px;
  color: var(--socrates);
  animation: spin 14s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.topbar h1 { font-size: 18px; margin: 0; }
.subtitle { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.step {
  font-size: 12px;
  color: var(--muted);
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
  transition: all 0.25s;
}
.step.active {
  color: #0f1117;
  background: var(--socrates);
  border-color: var(--socrates);
  font-weight: 600;
}
.step.done { color: var(--human); border-color: var(--human); }

/* ---------- 布局 ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 520px;
  gap: 20px;
  padding: 20px 28px 24px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

/* 口号条 */
.slogan-bar {
  text-align: center;
  font-size: 15px;
  letter-spacing: 0.5px;
  padding: 10px 16px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: rgba(23, 26, 35, 0.5);
}
.slogan-bar b { font-weight: 700; padding: 0 2px; }
.slogan-bar .s-soc { color: var(--socrates); }
.slogan-bar .s-ari { color: var(--aristotle); }
.slogan-bar .s-pla { color: var(--human); }
.main-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.side-col {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: sticky;
  top: 78px;
  height: calc(100vh - 96px); /* 撑满屏幕高度，不随内容长短缩水 */
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 8px; font-size: 16px; }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 12px; line-height: 1.6; }

textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.7;
  resize: vertical;
  font-family: inherit;
}
textarea:focus { outline: none; border-color: var(--socrates); }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
}
.btn:hover { border-color: var(--socrates); transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--socrates); color: #0f1117; border-color: var(--socrates); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { border-color: var(--aristotle); color: var(--aristotle); }
#startBtn { margin-top: 14px; }

/* ---------- 对话流 ---------- */
.dialogue { display: flex; flex-direction: column; gap: 14px; }
.bubble {
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  line-height: 1.75;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  animation: rise 0.3s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.bubble .who { font-size: 12px; font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.bubble.socrates { border-left: 3px solid var(--socrates); }
.bubble.socrates .who { color: var(--socrates); }
.bubble.human { border-left: 3px solid var(--human); background: var(--panel-2); }
.bubble.human .who { color: var(--human); }
.bubble.bg { border-left: 3px solid var(--muted); }
.bubble.bg .who { color: var(--muted); }

/* 打字机光标 */
.bubble-body.typing::after {
  content: '▋';
  color: var(--socrates);
  animation: blink 1s step-start infinite;
  margin-left: 1px;
}
.live-ref.typing::after {
  content: '▋';
  color: var(--aristotle);
  animation: blink 1s step-start infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- 回答区 ---------- */
.answer-card.translate-mode { border-color: var(--human); box-shadow: 0 0 0 1px var(--human) inset; }
.answer-head { display: flex; align-items: center; justify-content: space-between; }
.badge {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: rgba(126, 224, 168, 0.15); color: var(--human); border: 1px solid var(--human);
}
.meta-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; min-height: 18px; }
.counter { font-size: 12px; color: var(--muted); }
.similarity { font-size: 12px; }
.similarity.warn { color: var(--danger); }
.similarity.ok { color: var(--human); }
.answer-actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 14px; flex-wrap: wrap; }

/* ---------- 参考面板（防复制）---------- */
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-head h2 { color: var(--aristotle); font-size: 15px; }
.readonly-tag {
  font-size: 11px; color: var(--aristotle); border: 1px solid var(--aristotle);
  border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.reference {
  margin-top: 12px;
  background: var(--panel-2);
  border: 1px dashed var(--aristotle);
  border-radius: 10px;
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.8;
  flex: 1 1 auto;        /* 填满侧栏剩余高度 */
  min-height: 0;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.reference .placeholder { color: var(--muted); font-style: italic; }
.reference h2, .reference h3 { color: var(--aristotle); font-size: 14px; margin: 12px 0 4px; }
.reference strong { color: var(--text); }

/* 禁止选中 / 复制 */
.noselect {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* ---------- 回顾 ---------- */
.recap-card { border-color: var(--human); }
#recapBody { font-size: 14px; line-height: 1.8; }
.recap-round { border-left: 3px solid var(--border); padding: 8px 0 8px 14px; margin: 10px 0; }
.recap-round .q { color: var(--socrates); }
.recap-round .a { color: var(--human); }
.recap-actions { display: flex; gap: 10px; margin-top: 16px; }

/* ---------- toast / overlay ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--danger);
  color: var(--text); padding: 12px 18px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow); z-index: 50; max-width: 90vw; animation: rise 0.25s ease;
}
.overlay {
  position: fixed; inset: 0; background: rgba(8, 10, 15, 0.65);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  z-index: 40; backdrop-filter: blur(2px); color: var(--text);
}
.spinner {
  width: 38px; height: 38px; border: 3px solid var(--border);
  border-top-color: var(--socrates); border-radius: 50%; animation: spin 0.8s linear infinite;
}

/* ---------- 页脚 ---------- */
.footer {
  text-align: center; padding: 14px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .side-col { position: static; height: auto; }
  .reference { flex: none; max-height: 60vh; min-height: 240px; }
  .steps { display: none; }
}

/* ---------- 柏拉图理论升华 ---------- */
.plato-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--human);
}
.plato-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plato-head h2 { color: var(--human); margin: 0; }
.plato-tabs { display: flex; gap: 6px; }
.plato-tab {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.18s;
}
.plato-tab:hover { border-color: var(--human); color: var(--human); }
.plato-tab.active {
  color: #0f1117;
  background: var(--human);
  border-color: var(--human);
  font-weight: 700;
}
.plato-tab.empty:not(.active)::after { content: ' ·未生成'; opacity: 0.6; font-size: 10px; }
.plato-tab:disabled { opacity: 0.5; cursor: not-allowed; }
.plato-output {
  margin-top: 10px;
  background: var(--panel-2);
  border: 1px solid var(--human);
  border-radius: 10px;
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
}
.plato-output .placeholder { color: var(--muted); font-style: italic; }
.plato-output h2, .plato-output h3 { color: var(--human); font-size: 15px; margin: 14px 0 4px; }
.plato-output.typing::after { content: '▋'; color: var(--human); animation: blink 1s step-start infinite; }
.plato-actions { margin-top: 12px; }
