/* ===========================================================
   执业药师 AI 陪练 · 样式
   Light theme，参照后台管理系统的克制风格
   =========================================================== */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e4e7ec;
  --text: #1a1d23;
  --text-2: #5a6270;
  --text-3: #8b93a1;
  --brand: #1a6b4f;
  --brand-light: #e8f4ef;
  --warn: #b7791f;
  --warn-bg: #fdf8eb;
  --danger: #c53030;
  --danger-bg: #fdf0f0;
  --ok: #1a6b4f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 40px; height: 40px;
  background: var(--brand);
  color: #fff;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 20px;
}
.topbar h1 { font-size: 17px; font-weight: 600; letter-spacing: -.2px; }
.sub { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }

.status {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-2);
  background: #f2f4f7;
  padding: 6px 12px;
  border-radius: 20px;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #c8ccd4;
}
.status.mock .dot { background: var(--warn); }
.status.live .dot { background: var(--ok); }

/* ---------- 容器 ---------- */
.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}
.stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.hidden { display: none !important; }

/* ---------- 阶段头 ---------- */
.stage-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 22px;
}
.stage-head > div { flex: 1; }
.stage-head h2 { font-size: 17px; font-weight: 600; }
.stage-head p { font-size: 13.5px; color: var(--text-2); margin-top: 3px; }

.step {
  width: 26px; height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  display: grid; place-items: center;
}
.topic-name { color: var(--brand) !important; font-weight: 500; }
.round-badge {
  font-size: 12px;
  background: var(--brand-light);
  color: var(--brand);
  padding: 4px 11px;
  border-radius: 20px;
  white-space: nowrap;
  font-weight: 500;
}

/* ---------- 知识点卡片 ---------- */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.topic-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all .16s;
  background: #fff;
}
.topic-card:hover {
  border-color: var(--brand);
  background: var(--brand-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26, 107, 79, .1);
}
.topic-card h4 {
  font-size: 14.5px;
  font-weight: 550;
  margin-bottom: 5px;
  line-height: 1.45;
}
.topic-card .meta {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  gap: 8px;
  align-items: center;
}
.badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  background: #f0f2f5;
  color: var(--text-2);
}
.badge.ok { background: var(--brand-light); color: var(--brand); }

.loading, .empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 0;
  color: var(--text-3);
  font-size: 14px;
}

/* ---------- 输入区 ---------- */
.tip-box {
  background: #f7f9fb;
  border-left: 3px solid var(--brand);
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  color: var(--text-2);
  white-space: pre-line;
  margin-bottom: 16px;
}
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.7;
  resize: vertical;
  transition: border-color .15s;
  color: var(--text);
}
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26, 107, 79, .08);
}
.input-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}
#charCount { font-size: 12.5px; color: var(--text-3); }

/* ---------- 按钮 ---------- */
button {
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  border: none;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
  padding: 10px 24px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
}
.btn-primary:hover:not(:disabled) { background: #14543e; }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary.wide { width: 100%; margin-top: 22px; padding: 13px; font-size: 15px; }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  white-space: nowrap;
}
.btn-ghost:hover { background: #f2f4f7; color: var(--text); }

/* ---------- 评分 ---------- */
.score-total {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 8px 0 24px;
}
.score-num {
  font-size: 46px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1;
  letter-spacing: -1.5px;
}
.score-denom { font-size: 16px; color: var(--text-3); }

.dims { display: grid; gap: 10px; margin-bottom: 22px; }
.dim-row {
  display: grid;
  grid-template-columns: 88px 1fr 46px;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
}
.dim-label { color: var(--text-2); }
.dim-bar {
  height: 7px;
  background: #eef0f3;
  border-radius: 4px;
  overflow: hidden;
}
.dim-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 4px;
  transition: width .5s cubic-bezier(.4, 0, .2, 1);
}
.dim-fill.low { background: #d97706; }
.dim-fill.zero { background: #dc2626; }
.dim-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; }

/* ---------- 面板 ---------- */
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.panel h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.panel ul { list-style: none; }
.panel li {
  font-size: 13.5px;
  color: var(--text-2);
  padding-left: 16px;
  position: relative;
  margin-bottom: 6px;
}
.panel li::before {
  content: "·";
  position: absolute;
  left: 5px;
  font-weight: 700;
}
.panel.warn { background: var(--warn-bg); border-color: #f0e0bd; }
.panel.warn h3 { color: var(--warn); }
.panel.danger { background: var(--danger-bg); border-color: #f5d0d0; }
.panel.danger h3 { color: var(--danger); }
.panel p { font-size: 13.5px; color: var(--text-2); }

/* ---------- 对话 ---------- */
.chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}
.msg {
  display: flex;
  gap: 10px;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg .avatar {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 13px;
  font-weight: 600;
}
.msg.teacher .avatar { background: var(--brand-light); color: var(--brand); }
.msg.user .avatar { background: #eef1f5; color: var(--text-2); }
.msg .bubble {
  background: #f7f9fb;
  padding: 11px 15px;
  border-radius: 2px 10px 10px 10px;
  font-size: 14px;
  max-width: 88%;
}
.msg.user { flex-direction: row-reverse; }
.msg.user .bubble {
  background: var(--brand);
  color: #fff;
  border-radius: 10px 2px 10px 10px;
}
.msg .hint {
  font-size: 12.5px;
  color: var(--warn);
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px dashed #f0e0bd;
}

.chat-input { display: flex; gap: 10px; align-items: flex-end; }
.chat-input textarea { flex: 1; }
.chat-input button { padding: 10px 22px; height: fit-content; }

.conclusion { background: var(--brand-light); border-color: #c5e3d5; }
.conclusion h3 { color: var(--brand); }
.conclusion #conclusionText {
  font-size: 14px;
  white-space: pre-line;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 14px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .wrap { padding: 18px 12px 60px; }
  .stage { padding: 20px 16px; }
  .topbar { padding: 12px 16px; }
  .topic-grid { grid-template-columns: 1fr; }
  .score-num { font-size: 38px; }
  .dim-row { grid-template-columns: 74px 1fr 42px; gap: 9px; }
}
