:root {
  --bg: #faf5ec;
  --panel: #fffaf0;
  --ink: #3a2a1a;
  --muted: #8a7158;
  --line: #e8d9bf;
  --accent: #d97706;
  --accent-2: #b45309;
  --gold: #eab308;
  --good: #16a34a;
  --warn: #dc2626;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  height: 100vh;
  overflow: hidden;
}

/* ================ Chat 布局 ================ */
.chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 860px;
  margin: 0 auto;
  background: var(--bg);
}

.chat-header {
  flex-shrink: 0;
  padding: 18px 24px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.chat-header h1 { margin: 0; font-size: 20px; color: var(--accent-2); }
.chat-header .sub { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }

.feed {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* 消息卡片 */
.msg {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px 16px;
  box-shadow: 0 1px 4px rgba(180, 83, 9, 0.05);
  animation: msg-in 0.3s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-head {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-2);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}
.msg-sub { margin: -4px 0 10px; color: var(--muted); font-size: 12.5px; }
.msg-actions { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }

.msg-welcome { background: #fffdf8; }
.msg-welcome h3 { margin: 0 0 8px; color: var(--accent-2); font-size: 15px; }
.msg-welcome p { margin: 0 0 6px; font-size: 13px; }
.msg-welcome ul { font-size: 13px; }

/* ================ Composer（底部输入栏） ================ */
.composer {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 12px 24px 16px;
  box-shadow: 0 -2px 10px rgba(180, 83, 9, 0.04);
}

.advanced {
  margin-bottom: 10px;
  font-size: 12.5px;
}
.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  padding: 4px 0;
}
.advanced summary:hover { color: var(--accent-2); }
.advanced textarea, .advanced select {
  margin-top: 6px;
}

.composer-input textarea#prompt {
  width: 100%;
  font-family: "SFMono-Regular", Consolas, "PingFang SC", monospace;
  font-size: 13px;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  resize: none;
  min-height: 80px;
  max-height: 240px;
}
.composer-input textarea#prompt:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.15);
}

.composer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ================ 通用元素 ================ */
textarea, select {
  width: 100%;
  font-family: "SFMono-Regular", Consolas, "PingFang SC", monospace;
  font-size: 13px;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  resize: vertical;
}
textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.15);
}

.small { font-size: 12px; color: var(--muted); margin-top: 8px; display: block; }

button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
button:hover { border-color: var(--accent); color: var(--accent-2); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: var(--accent-2); color: #fff; }
button.ghost { background: transparent; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.status { font-size: 12px; color: var(--muted); min-height: 16px; flex: 1; text-align: right; }
.status.err { color: var(--warn); }

/* 评分样式 */
.score-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 15px; margin-bottom: 10px;
}
.score-head #total { font-size: 22px; font-weight: 700; color: var(--accent-2); }
.grade {
  padding: 3px 10px; border-radius: 999px; font-size: 12px;
  background: var(--gold); color: #fff;
}
#bars { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.bar-row {
  display: grid; grid-template-columns: 80px 1fr 36px; align-items: center; gap: 8px;
  font-size: 12px;
}
.bar-label { color: var(--muted); }
.bar-track { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--accent)); }
.bar-val { text-align: right; font-weight: 600; }
.bar-reason { grid-column: 1 / -1; color: var(--muted); font-size: 11px; padding-left: 88px; }

details { margin: 8px 0; }
summary { cursor: pointer; font-size: 13px; color: var(--accent-2); font-weight: 600; }
ul, ol { margin: 6px 0 6px 20px; padding: 0; }
li { font-size: 13px; margin: 3px 0; }

.revised {
  white-space: pre-wrap;
  background: #fdf6e3;
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 10px;
  font-size: 12.5px;
  max-height: 360px;
  overflow: auto;
}

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 640px) {
  .compare { grid-template-columns: 1fr; }
}
.col { display: flex; flex-direction: column; min-width: 0; }
.col-h { font-size: 13px; color: var(--accent-2); font-weight: 600; margin-bottom: 6px; }
.lat { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.out {
  white-space: pre-wrap;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font-size: 12.5px;
  overflow: auto;
  min-height: 220px;
  max-height: 400px;
}

/* 裁判卡片 */
.msg-judge { background: #fdf6e3; border-color: #d4b78a; }
.judge-verdict {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px;
  background: #fffaf0; border-radius: 8px; border: 1px solid var(--line);
}
.judge-winner {
  background: var(--accent); color: #fff;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.judge-winner.tie { background: var(--muted); }
.judge-oneliner { font-size: 13.5px; font-weight: 500; flex: 1; min-width: 0; }
.judge-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
@media (max-width: 640px) { .judge-grid { grid-template-columns: 1fr; } }
.judge-col {
  background: #fffdf8; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px;
}
.judge-col-h {
  font-weight: 600; color: var(--accent-2);
  font-size: 13.5px; margin-bottom: 8px;
  padding-bottom: 6px; border-bottom: 1px dashed var(--line);
}
.judge-sec-title { font-size: 12px; color: var(--muted); margin: 8px 0 4px; font-weight: 600; }
.judge-symptoms, .judge-strengths { margin: 0 0 4px 0; padding: 0; list-style: none; }
.judge-symptoms li, .judge-strengths li {
  font-size: 12.5px; margin: 6px 0;
  padding: 6px 8px; border-radius: 6px;
}
.judge-symptoms li { background: #fef2f2; border-left: 3px solid var(--warn); }
.judge-strengths li { background: #f0fdf4; border-left: 3px solid var(--good); }
.judge-symptom-name { font-weight: 600; color: var(--warn); }
.judge-quote {
  display: block; margin: 3px 0;
  color: var(--muted); font-style: italic;
  border-left: 2px solid var(--line); padding-left: 6px;
  font-size: 11.5px;
}
.judge-why { display: block; color: var(--ink); font-size: 12px; }
.judge-takeaway {
  margin-top: 12px; padding: 10px 12px;
  background: #fffaf0; border: 1px dashed var(--accent);
  border-radius: 8px; font-size: 13px; color: var(--accent-2);
  font-weight: 500;
}
.judge-takeaway::before { content: "💡 "; }

.q-why { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.q-opts { font-size: 12px; color: var(--ink); }
.q-opts span { background: var(--line); padding: 1px 6px; border-radius: 4px; margin-right: 4px; display: inline-block; margin-bottom: 3px; }
.q-opts span.opt:hover { background: var(--gold); color: #fff; cursor: pointer; }
textarea.q-ans { margin-top: 6px; font-size: 12.5px; }

@media (max-width: 640px) {
  .chat-header { padding: 14px 16px 10px; }
  .feed { padding: 16px 16px 10px; }
  .composer { padding: 10px 16px 14px; }
}
