:root {
  --bg: #f2f3f7;
  --surface: #ffffff;
  --border: #e6e8ee;
  --border-strong: #d5d8e0;
  --text: #1f2328;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;

  --primary: #185fa5;
  --primary-strong: #0c447c;
  --primary-soft: #e6f1fb;
  --primary-mid: #378add;

  --green: #3b6d11;
  --green-soft: #eaf3de;
  --amber: #ba7517;
  --amber-soft: #faeeda;
  --red: #a32d2d;
  --red-soft: #fcebeb;

  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #dfe2e8;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

/* ===== 手机容器 ===== */
.phone {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
}
@media (min-width: 440px) {
  .phone { min-height: 100vh; }
}

/* ===== 顶栏 ===== */
.topbar {
  height: 56px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-sub { font-size: 11.5px; opacity: 0.85; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 9px;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ===== 内容区 ===== */
.content { flex: 1; padding: 14px 14px 84px; }

.section-title { font-size: 13px; color: var(--text-secondary); margin: 18px 2px 8px; font-weight: 500; }
.section-title:first-child { margin-top: 4px; }

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}
.card-title { font-size: 14.5px; font-weight: 600; margin-bottom: 10px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-title-row .card-title { margin-bottom: 0; }

/* ===== 指标 ===== */
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric-grid.col2 { grid-template-columns: repeat(2, 1fr); }
.metric {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}
.metric-label { font-size: 12px; color: var(--text-secondary); }
.metric-value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.metric-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }

/* ===== 徽标 ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 500;
  padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-gray { background: var(--bg); color: var(--text-secondary); }

.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--bg); color: var(--text-secondary); margin-right: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-green { background: #639922; }
.dot-amber { background: #ef9f27; }
.dot-red { background: #e24b4a; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-block { width: 100%; }
.btn:disabled { background: var(--border-strong); border-color: var(--border-strong); color: var(--text-tertiary); cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ===== 列表 ===== */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item:active { opacity: 0.6; }
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.li-body { flex: 1; min-width: 0; }
.li-title { font-size: 14px; font-weight: 500; }
.li-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 1px; }
.li-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chev { color: var(--text-tertiary); }
.chev svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ===== 题目行 ===== */
.q-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.q-row:last-child { border-bottom: none; }
.q-icon { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.q-icon.ok { background: var(--green-soft); color: var(--green); }
.q-icon.no { background: var(--red-soft); color: var(--red); }
.q-icon svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.q-body { flex: 1; min-width: 0; }
.q-stem { font-size: 13.5px; }
.q-meta { font-size: 11.5px; color: var(--text-tertiary); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ===== 表单 ===== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field-label { font-size: 13px; color: var(--text-secondary); }
.field select {
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.field select:focus, .field input:focus { border-color: var(--primary-mid); }
.field input {
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

.code-row { display: flex; gap: 8px; align-items: flex-end; }
.code-row .field { flex: 1; margin-bottom: 0; }

.class-filter { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; }
.class-filter::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 6px 15px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 500; }

/* ===== 上传 ===== */
.upload-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-zone:active { border-color: var(--primary-mid); background: var(--primary-soft); }
.upload-zone svg { width: 34px; height: 34px; stroke: var(--primary); stroke-width: 1.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.upload-zone .up-main { font-size: 14px; font-weight: 500; margin-top: 8px; }
.upload-zone .up-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

.thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.thumb { position: relative; aspect-ratio: 3/4; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .thumb-tag { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.55); color: #fff; font-size: 10px; padding: 2px 5px; }
.thumb .thumb-del { position: absolute; top: 5px; right: 5px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,0.5); color: #fff; border: none; cursor: pointer; font-size: 13px; line-height: 1; }

/* ===== 进度条 ===== */
.progress-bar { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; }

/* ===== 分布条 ===== */
.dist-bar { display: flex; height: 26px; border-radius: 7px; overflow: hidden; }
.dist-bar > div { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 500; }

/* ===== 底部 Tab ===== */
.tabbar {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  height: 62px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 11px;
  position: relative;
}
.tab-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab-item.active { color: var(--primary); font-weight: 500; }
.tab-badge {
  position: absolute; top: 6px; right: 50%;
  transform: translateX(22px);
  min-width: 16px; height: 16px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ===== 登录页 ===== */
.login {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px;
}
.login-logo {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}
.login-logo svg { width: 34px; height: 34px; fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.login-title { font-size: 20px; font-weight: 600; text-align: center; }
.login-sub { font-size: 13px; color: var(--text-secondary); text-align: center; margin-top: 4px; margin-bottom: 32px; }

.role-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 12px;
  cursor: pointer;
  display: flex; align-items: center; gap: 14px;
  transition: border-color 0.15s;
}
.role-card:active { border-color: var(--primary-mid); }
.role-icon {
  width: 46px; height: 46px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.role-icon.teacher { background: var(--primary-soft); color: var(--primary); }
.role-icon.student { background: var(--green-soft); color: var(--green); }
.role-icon.admin { background: var(--amber-soft); color: var(--amber); }
.role-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.role-title { font-size: 15px; font-weight: 600; }
.role-desc { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

.login-hint { font-size: 12px; color: var(--text-tertiary); text-align: center; margin-top: 20px; }

/* ===== 空态 ===== */
.empty { text-align: center; color: var(--text-tertiary); padding: 36px 12px; font-size: 13px; }
.empty svg { width: 40px; height: 40px; stroke: var(--border-strong); stroke-width: 1.3; fill: none; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 8px; }

.hint { font-size: 12px; color: var(--text-tertiary); margin-top: 8px; line-height: 1.5; }

/* ===== Toast ===== */
#toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(31, 35, 40, 0.92); color: #fff;
  padding: 10px 18px; border-radius: 20px; font-size: 13px; z-index: 99;
  transition: opacity 0.3s; max-width: 80vw; text-align: center;
}

/* ===== 分段器 ===== */
.segment { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.segment-item { flex: 1; text-align: center; padding: 7px 0; border-radius: 8px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.segment-item.active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
