:root{
  --bg:#f4f6fa; --card:#fff; --text:#1f2937; --muted:#6b7280;
  --primary:#2563eb; --primary-d:#1d4ed8; --primary-l:#eff6ff;
  --danger:#e11d48; --warn:#f59e0b; --ok:#16a34a; --border:#e5e7eb;
  --radius:14px; --shadow:0 2px 10px rgba(15,23,42,.07);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
body{
  background:var(--bg); color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei","Helvetica Neue",sans-serif;
  font-size:16px; line-height:1.6; padding-bottom:calc(70px + env(safe-area-inset-bottom));
}
a{color:inherit;text-decoration:none}
svg{width:1em;height:1em;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.page{max-width:900px;margin:0 auto;padding:14px 14px 20px}
h1{font-size:22px;margin:6px 0 14px}
h2{font-size:17px;margin:18px 0 10px}
.muted{color:var(--muted);font-size:13px}

/* 卡片 */
.card{background:var(--card);border-radius:var(--radius);box-shadow:var(--shadow);padding:14px;margin-bottom:14px}
.grid2{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}
.stat{background:var(--card);border-radius:var(--radius);box-shadow:var(--shadow);padding:14px;text-align:center}
.stat b{display:block;font-size:26px;line-height:1.2;color:var(--primary)}
.stat span{font-size:12px;color:var(--muted)}

/* 按钮 */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;
  border:none;border-radius:12px;padding:12px 18px;font-size:16px;font-weight:600;
  background:var(--primary);color:#fff;cursor:pointer;min-height:48px;transition:.15s}
.btn:active{transform:scale(.97)}
.btn.block{display:flex;width:100%}
.btn.ghost{background:#fff;color:var(--text);border:1.5px solid var(--border)}
.btn.gray{background:#eef1f5;color:var(--text)}
.btn.danger{background:var(--danger)}
.btn.warn{background:var(--warn)}
.btn.ok{background:var(--ok)}
.btn.sm{padding:8px 12px;font-size:14px;min-height:38px;border-radius:10px}
.btn svg{width:18px;height:18px}
.btnrow{display:flex;gap:10px;flex-wrap:wrap}

/* 表单 */
.field{margin-bottom:14px}
.field label{display:block;font-size:14px;font-weight:600;margin-bottom:6px}
input[type=text],input[type=number],textarea,select{
  width:100%;border:1.5px solid var(--border);border-radius:12px;padding:12px;
  font-size:16px;font-family:inherit;background:#fff;color:var(--text);outline:none}
input:focus,textarea:focus,select:focus{border-color:var(--primary)}
textarea{min-height:110px;resize:vertical;line-height:1.7}
select{height:48px;appearance:none;background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat:no-repeat;background-position:right 12px center;background-size:18px}

/* 标签/徽章 */
.tag{display:inline-block;padding:2px 10px;border-radius:999px;font-size:12px;font-weight:600;line-height:22px}
.tag.subj-数学{background:#dbeafe;color:#1d4ed8}
.tag.subj-语文{background:#fee2e2;color:#b91c1c}
.tag.subj-英语{background:#dcfce7;color:#15803d}
.tag.subj-科学{background:#ede9fe;color:#6d28d9}
.tag.subj-道德与法治{background:#ffedd5;color:#c2410c}
.tag.subj-其他{background:#f1f5f9;color:#475569}
.tag.gray{background:#f1f5f9;color:#64748b}
.m-0{background:#f1f5f9;color:#64748b}
.m-1{background:#fee2e2;color:#b91c1c}
.m-2{background:#fef3c7;color:#b45309}
.m-3{background:#dcfce7;color:#15803d}

/* 筛选条 */
.filters{display:flex;gap:8px;overflow-x:auto;padding:2px 0 10px;-webkit-overflow-scrolling:touch}
.chip{flex:0 0 auto;padding:8px 14px;border-radius:999px;background:#fff;border:1.5px solid var(--border);
  font-size:14px;font-weight:600;cursor:pointer;white-space:nowrap}
.chip.on{background:var(--primary);color:#fff;border-color:var(--primary)}

/* 题目卡 */
.qcard{background:var(--card);border-radius:var(--radius);box-shadow:var(--shadow);
  margin-bottom:12px;overflow:hidden}
.qcard .thumb{width:100%;display:block;background:#f8fafc;border-bottom:1px solid var(--border)}
.qcard .body{padding:12px}
.qcard .txt{font-size:15px;line-height:1.7;max-height:4.9em;overflow:hidden;color:#334155}
.qcard .meta{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:8px}
.qcard .date{font-size:12px;color:var(--muted);margin-left:auto}

/* 答案区 */
.answer{display:none;margin-top:12px;padding:14px;border-radius:12px;background:#f0fdf4;
  border:1.5px dashed #86efac;font-size:15px;line-height:1.8;white-space:pre-wrap}
.answer.show{display:block;animation:fade .25s}
@keyframes fade{from{opacity:0;transform:translateY(-4px)}to{opacity:1}}

/* 图片查看 */
.bigimg{width:100%;border-radius:12px;display:block;background:#f8fafc}

/* 涂抹画布 */
.canvas-wrap{position:relative;background:#e2e8f0;border-radius:12px;overflow:hidden;touch-action:none}
.canvas-wrap canvas{display:block;width:100%;height:auto}
.toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:10px 0}
.toolbar .btn{flex:0 0 auto}

/* 相机直拍 */
.cam-wrap{position:relative;background:#000;border-radius:12px;overflow:hidden}
.cam-wrap video{display:block;width:100%;height:auto;max-height:60vh;object-fit:contain}
.cam-tip{margin-top:12px;padding:12px 14px;border-radius:12px;background:#fff7ed;
  border:1.5px solid #fdba74;color:#9a3412;font-size:14px;line-height:1.7}
.cam-tip b{color:#c2410c}
.brush-preview{width:28px;height:28px;border-radius:50%;border:2px solid var(--border)}

/* 底部导航 */
.tabbar{position:fixed;left:0;right:0;bottom:0;display:flex;background:#fff;
  border-top:1px solid var(--border);padding-bottom:env(safe-area-inset-bottom);z-index:50}
.tab{flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;padding:9px 0 7px;
  font-size:11px;color:var(--muted)}
.tab svg{width:23px;height:23px}
.tab.on{color:var(--primary);font-weight:700}

/* 常驻底部保存条 */
.savebar{position:fixed;left:0;right:0;bottom:calc(62px + env(safe-area-inset-bottom));
  z-index:60;padding:6px 10px;pointer-events:none}
.savebar-inner{max-width:900px;margin:0 auto;display:flex;align-items:center;gap:10px;
  background:#fff;border:2px solid #86efac;border-radius:14px;padding:10px 12px;
  box-shadow:0 4px 18px rgba(15,23,42,.18);pointer-events:auto}
.savebar-inner .btn{padding:12px 14px}
body.has-savebar .page{padding-bottom:150px}

/* toast */
.toast{position:fixed;left:50%;bottom:90px;transform:translateX(-50%) translateY(12px);
  background:rgba(17,24,39,.92);color:#fff;padding:11px 20px;border-radius:999px;font-size:14px;
  opacity:0;pointer-events:none;transition:.25s;z-index:99;white-space:nowrap}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}

.empty{text-align:center;padding:50px 20px;color:var(--muted)}
.empty b{display:block;font-size:17px;color:#475569;margin-bottom:6px}

/* 重做模式 */
.review-stage{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow);padding:16px;margin-bottom:14px}
.review-stage img{width:100%;border-radius:12px;background:#f8fafc}
.progress{height:8px;background:#e5e7eb;border-radius:999px;overflow:hidden;margin:10px 0 4px}
.progress i{display:block;height:100%;background:var(--primary);transition:.3s}

/* 图表容器 */
.chartbox{height:240px;position:relative}
.bar{display:flex;align-items:center;gap:10px;margin-bottom:9px;font-size:14px}
.bar .lb{width:76px;flex:0 0 auto;color:var(--muted)}
.bar .track{flex:1;height:22px;background:#f1f5f9;border-radius:6px;overflow:hidden}
.bar .track i{display:block;height:100%;background:var(--primary);border-radius:6px}
.bar .vl{width:34px;text-align:right;font-weight:700}

@media(min-width:760px){
  body{font-size:17px}
  .grid3{grid-template-columns:repeat(3,1fr)}
}
