/* ==========================================================
   VibeCoding 质性编码工作台 · 样式
   护眼浅色主题：米白暖底 + 深灰文字，避免纯白刺眼
   全局字号 >= 15px，学生原文区 >= 17px
   ========================================================== */

:root {
  --bg: #f3f0e8;          /* 页面底色：暖米白 */
  --panel: #fffdf6;       /* 卡片底色：柔白 */
  --panel-2: #faf7ee;     /* 次级面板 */
  --ink: #2e2c26;         /* 主文字 */
  --muted: #6f6a5d;       /* 次要文字 */
  --line: #e2dcc9;        /* 分隔线 */
  --accent: #3f6f54;      /* 主操作绿 */
  --accent-ink: #ffffff;
  --warn: #b45309;        /* 存疑橙 */
  --danger: #b91c1c;
  --c-S: #2563eb;         /* 学生行为 */
  --c-A: #7c3aed;         /* AI行为 */
  --c-M: #059669;         /* 元认知 */
  --c-SEP: #dc2626;       /* 分离现象 */
  --radius: 10px;
  --shadow: 0 1px 3px rgba(60, 55, 40, 0.12);
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  font-size: 1rem;         /* 16px */
  line-height: 1.65;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); }

/* ---------- 访问密码门 ---------- */
body.locked { overflow: hidden; }
body.locked .topbar, body.locked .view { visibility: hidden; }
#gateOverlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
#gateForm { width: min(360px, 88vw); }
.gate-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 30px 28px; text-align: center;
}
.gate-title { font-weight: 700; font-size: 1.1rem; }
.gate-sub { color: var(--muted); font-size: 0.92rem; margin: 8px 0 18px; }
#gateInput {
  width: 100%; padding: 10px 12px; font-size: 1rem; text-align: center;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
#gateInput:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.gate-btn { width: 100%; margin-top: 12px; padding: 10px; font-size: 1rem; }
.gate-err { color: var(--danger); font-size: 0.9rem; margin-top: 10px; min-height: 1.2em; }

/* ---------- 截图缺失兜底（部署版不含图片文件时） ---------- */
.shot-item.no-img {
  border: 1px dashed var(--line); border-radius: 8px;
  background: var(--panel-2); padding: 10px 12px;
}
.shot-item.no-img::before {
  content: "🖼 本部署版本未包含图片文件，以下为该截图的文字描述";
  display: block; color: var(--muted); font-size: 0.88rem; margin-bottom: 6px;
}

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.brand { font-weight: 700; font-size: 1.06rem; white-space: nowrap; }
.topnav { display: flex; gap: 6px; flex: 1; }
.topnav a {
  padding: 7px 14px; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-size: 0.97rem;
}
.topnav a:hover { background: var(--panel-2); }
.topnav a.active { background: var(--accent); color: var(--accent-ink); }
.coder-switch {
  border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 8px; padding: 7px 14px; font-size: 0.97rem; color: var(--ink);
}
.coder-switch:hover { border-color: var(--accent); }

/* ---------- 主容器 ---------- */
.view { max-width: 1440px; margin: 0 auto; padding: 20px; }

/* ---------- 看板 ---------- */
.board-stats {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  margin-bottom: 16px;
}
.stat-chip {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 18px; font-size: 0.97rem; box-shadow: var(--shadow);
}
.stat-chip b { font-size: 1.15rem; color: var(--accent); }
.sort-toggle {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  font-size: 0.97rem; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px;
}
.sort-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

.board-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.board-tab {
  border: 1px solid var(--line); background: var(--panel);
  padding: 9px 20px; border-radius: 999px; font-size: 1rem;
}
.board-tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.card-wall {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.stu-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); text-align: left;
  display: block; width: 100%; font-size: 1rem; color: var(--ink);
  transition: transform 0.08s ease, border-color 0.08s ease;
}
.stu-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.stu-card .name-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.stu-card .sname { font-weight: 700; font-size: 1.08rem; }
.stu-card .sid { color: var(--muted); font-size: 0.94rem; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 0.94rem; color: #fff; background: #8a8577; white-space: nowrap;
}
.badge.deepseek { background: #4d6bfe; }
.badge.kimi { background: #111827; }
.badge.doubao { background: #0ea5e9; }
.badge.qianwen { background: #7c3aed; }
.stu-card .unit-line { color: var(--muted); font-size: 0.94rem; margin: 4px 0; }
.progress {
  height: 10px; border-radius: 999px; background: #e7e1cf; overflow: hidden; margin: 6px 0 4px;
}
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.stu-card .prog-text { font-size: 0.94rem; color: var(--muted); display: flex; justify-content: space-between; }
.stu-card .unsure-n { color: var(--warn); }
.stu-card.done { border-color: var(--accent); }
.stu-card.done .prog-text { color: var(--accent); }

/* ---------- 工作台 ---------- */
.work-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.work-head .who { font-weight: 700; font-size: 1.1rem; }
.work-head .round-no { font-size: 1rem; color: var(--muted); }
.work-head .spacer { flex: 1; }
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  border-radius: 8px; padding: 8px 16px; font-size: 0.97rem;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.warn { border-color: var(--warn); color: var(--warn); background: #fdf3e7; }
.save-hint { color: var(--muted); font-size: 0.94rem; }

.round-dots {
  display: flex; flex-wrap: wrap; gap: 5px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px;
}
.dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid #b9b2a0; background: #efeadb; padding: 0;
}
.dot.coded { background: var(--accent); border-color: var(--accent); }
.dot.unsure { background: var(--warn); border-color: var(--warn); }
.dot.current { outline: 3px solid rgba(63, 111, 84, 0.35); outline-offset: 1px; }

.work-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  gap: 16px; align-items: start;
}
@media (max-width: 1080px) {
  .work-grid { grid-template-columns: 1fr; }
}

/* 左栏：材料 */
.material { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 10px; font-size: 1rem; color: var(--muted); font-weight: 700;
  letter-spacing: 0.03em;
}
.student-text {
  font-size: 1.13rem;            /* >=17px，编码焦点区大字号 */
  line-height: 1.85;
  white-space: pre-wrap; word-break: break-word;
}
.student-text.empty { color: var(--muted); font-style: italic; font-size: 1rem; }

.shot-list { display: flex; flex-direction: column; gap: 12px; }
.shot-item { display: flex; gap: 12px; align-items: flex-start; }
.shot-item img {
  height: 120px; width: auto; max-width: 220px; object-fit: cover;
  border: 1px solid var(--line); border-radius: 8px; cursor: zoom-in; background: #eee;
  flex-shrink: 0;
}
.shot-item .shot-desc { font-size: 0.97rem; color: var(--ink); }
.lost-note {
  margin-top: 10px; padding: 10px 14px; border-radius: 8px;
  background: #fdf3e7; border: 1px solid #eecd9f; color: var(--warn); font-size: 0.97rem;
}
.file-list { margin: 0; padding-left: 20px; font-size: 0.97rem; color: var(--muted); }

.ai-card + .ai-card { margin-top: 12px; }
.ai-summary { white-space: pre-wrap; word-break: break-word; font-size: 0.99rem; }
.ai-full {
  white-space: pre-wrap; word-break: break-word; font-size: 0.99rem;
  border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px;
  background: var(--panel-2); border-radius: 8px; padding: 12px;
}
.ai-full[hidden] { display: none; }
.ai-toggle { margin-top: 10px; }
.ai-none { color: var(--muted); font-style: italic; }

/* 反思 meta chips */
.meta-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.meta-chip {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 13px; font-size: 0.94rem;
}
.meta-chip b { color: var(--accent); font-weight: 700; }
.q-text { font-size: 1.06rem; font-weight: 700; margin: 0 0 10px; }
.a-text { font-size: 1.09rem; line-height: 1.85; white-space: pre-wrap; word-break: break-word; }

/* 右栏：编码面板 */
.panel {
  position: sticky; top: 76px;
  max-height: calc(100vh - 96px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.panel h3 { margin: 0; font-size: 1rem; }
/* flex 列布局下子项默认会被压缩，导致展开的 details 内容被裁掉；
 * 禁止收缩，让面板按内容自然滚动 */
.panel > * { flex-shrink: 0; }
.code-group { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.code-group summary {
  padding: 9px 12px; cursor: pointer; font-weight: 700; font-size: 0.98rem;
  background: var(--panel-2); list-style: none; display: flex; align-items: center; gap: 8px;
  user-select: none;
}
.code-group summary::-webkit-details-marker { display: none; }
.code-group summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.code-group:not([open]) summary::after { content: "▸"; }
.gdot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.gcount { font-weight: 400; color: var(--muted); font-size: 0.94rem; }
.tag-wrap { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px 12px; }
.tag {
  border: 1.5px solid var(--gc, #888); color: var(--gc, #888);
  background: #fff; border-radius: 999px; padding: 5px 12px;
  font-size: 0.95rem; line-height: 1.3;
}
.tag:hover { background: color-mix(in srgb, var(--gc, #888) 8%, #fff); }
.tag.on { background: var(--gc, #888); color: #fff; }
.tag .tc { opacity: 0.72; font-size: 0.94rem; margin-left: 4px; }

.panel-block { border-top: 1px dashed var(--line); padding-top: 10px; }
.panel-block .blk-title { font-weight: 700; font-size: 0.97rem; margin-bottom: 8px; }

.free-input { width: 100%; padding: 8px 10px; font-size: 0.97rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 5px 12px; font-size: 0.95rem;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
}
.chip.sel { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .x { font-weight: 700; opacity: 0.7; padding-left: 2px; }
.chip .x:hover { opacity: 1; }
.theme-chip { border-color: #8a8577; }
.theme-chip.sel { background: #57534e; border-color: #57534e; }

.unsure-btn {
  width: 100%; border: 1.5px solid var(--warn); color: var(--warn);
  background: #fff; border-radius: 8px; padding: 9px; font-size: 1rem;
}
.unsure-btn.on { background: var(--warn); color: #fff; }

.note-area {
  width: 100%; min-height: 76px; resize: vertical;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 0.97rem; font-family: inherit; background: #fff; color: var(--ink);
}

/* 底部操作条 */
.work-foot {
  position: sticky; bottom: 0; z-index: 40;
  display: flex; gap: 12px; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; margin-top: 14px; box-shadow: 0 -1px 4px rgba(60,55,40,0.10);
}
.work-foot .btn { font-size: 1.03rem; padding: 10px 22px; }
.key-hint { color: var(--muted); font-size: 0.94rem; }
kbd {
  background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 7px; font-size: 0.94rem; font-family: inherit;
}

/* ---------- 导出与一致性 ---------- */
.export-grid { display: grid; grid-template-columns: 1fr; gap: 16px; max-width: 1100px; }
.file-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 10px 0; }
.file-row label { font-weight: 700; }
input[type="file"] { font-size: 0.95rem; }
.result-table { border-collapse: collapse; width: 100%; font-size: 0.96rem; margin-top: 10px; }
.result-table th, .result-table td {
  border: 1px solid var(--line); padding: 8px 12px; text-align: left; vertical-align: top;
}
.result-table th { background: var(--panel-2); }
.result-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.kappa-good { color: var(--accent); font-weight: 700; }
.kappa-bad { color: var(--danger); font-weight: 700; }
.scroll-x { overflow-x: auto; }
.codes-cell { font-size: 0.9rem; color: var(--muted); max-width: 420px; word-break: break-word; }
.sub-note { color: var(--muted); font-size: 0.94rem; margin-top: 6px; }

/* ---------- 遮罩（图片放大 / 身份选择） ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(30, 28, 22, 0.78);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.overlay img { max-width: 94vw; max-height: 90vh; border-radius: 8px; background: #fff; }
.overlay .ov-cap { position: fixed; bottom: 18px; left: 0; right: 0; text-align: center; color: #eee; font-size: 0.97rem; }
.id-box {
  background: var(--panel); border-radius: 14px; padding: 34px 40px; text-align: center;
  max-width: 480px; box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}
.id-box h2 { margin-top: 0; }
.id-box .id-btns { display: flex; gap: 16px; justify-content: center; margin-top: 20px; }
.id-box .id-btns .btn { font-size: 1.08rem; padding: 12px 26px; }
.id-box p { color: var(--muted); }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #33302a; color: #f5f2ea; padding: 10px 22px; border-radius: 999px;
  font-size: 0.97rem; opacity: 0; pointer-events: none; transition: all 0.25s ease; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
