/* ============ 语文作业批改 · 移动端优先样式 ============ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --red: #c92f3a;
  --red-soft: #fdecec;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #26282c;
  --muted: #8a8f98;
  --line: #e6e8eb;
  --blue: #2f6fd6;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  max-width: 780px; margin: 0 auto;
  overscroll-behavior-y: none;
}
button { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- 顶部 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: linear-gradient(135deg, #c92f3a, #a02030);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 34px; height: 34px; border-radius: 9px; background: #fff; color: var(--red);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px;
}
.app-title { font-weight: 700; font-size: 16px; }
.app-sub { font-size: 11px; opacity: .85; }
.grade-badge {
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.4);
  padding: 4px 8px; border-radius: 999px; font-size: 11px; white-space: nowrap;
}

/* ---------- 屏幕容器 / 底部导航 ---------- */
.screens { padding: 12px 12px calc(84px + var(--safe-bottom)); }
.screen.hidden { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-bottom));
  background: #fff; border-top: 1px solid var(--line);
}
.tab {
  border: none; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; padding: 4px 10px; border-radius: 8px; cursor: pointer;
}
.t-ico { font-size: 20px; line-height: 1.2; }
.tab.active { color: var(--red); font-weight: 700; }

/* ---------- 卡片 / 通用控件 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; font-weight: 700; font-size: 14px; margin-bottom: 10px; flex-wrap: wrap;
}
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 0; }
.tip { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 4px 6px; }
.row-btns { display: flex; gap: 8px; align-items: center; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 10px; padding: 10px 14px; font-size: 14px; cursor: pointer;
  min-height: 42px; flex: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.btn.danger { color: var(--red); }
.btn.big { padding: 13px 20px; font-size: 16px; }
.btn.small { padding: 6px 10px; font-size: 12px; min-height: 32px; border-radius: 8px; }

.filter-input, .title-input, .text-input {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  font-size: 14px; background: #fafbfc; flex: 1; min-width: 0;
}
textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; background: #fafbfc;
  resize: vertical;
}
select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; background: #fff; }

/* ---------- 拍照页 ---------- */
.hero { display: flex; flex-direction: column; gap: 12px; }
.hero-text p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.hero-btns { display: flex; gap: 12px; }
.hero-btns .btn { flex: 1; font-size: 17px; padding: 16px; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.shot {
  position: relative; border-radius: 10px; overflow: hidden;
  border: 2px solid var(--line); background: #000;
}
.shot img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.shot .ops { position: absolute; right: 4px; bottom: 4px; display: flex; gap: 4px; }
.shot .ops button {
  border: none; background: rgba(0,0,0,.55); color: #fff; border-radius: 6px;
  width: 30px; height: 30px; font-size: 14px; cursor: pointer;
}
.shot .idx {
  position: absolute; left: 4px; top: 4px; background: rgba(0,0,0,.55); color: #fff;
  font-size: 11px; padding: 1px 6px; border-radius: 6px;
}
.shot .flag {
  position: absolute; right: 4px; top: 4px; background: var(--blue); color: #fff;
  font-size: 10px; padding: 1px 5px; border-radius: 6px;
}
.sticky-actions { display: flex; gap: 10px; margin: 4px 2px 10px; }
.sticky-actions .btn { flex: 1; }
.sticky-actions .btn.primary { flex: 1.6; }

/* ---------- 批改页 ---------- */
.corr-top { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.corr-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.corr-strip img {
  height: 64px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; flex: none;
}
.corr-strip img.on { border-color: var(--red); }
.canvas-wrap {
  position: relative; background: #1c1e22; border-radius: 12px; overflow: hidden;
  user-select: none; touch-action: none; min-height: 220px;
  display: flex; align-items: center; justify-content: center;
}
.canvas-wrap canvas { position: absolute; left: 0; top: 0; max-width: 100%; }
#cvImg { position: relative !important; max-width: 100%; height: auto; display: block; }
#cvDraw, #cvFlash { pointer-events: none; }
.canvas-wrap.drawing { cursor: crosshair; }
.canvas-empty { color: #9aa0a8; font-size: 13px; padding: 60px 0; position: relative; }

.tool-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: #fff; border-radius: 12px; padding: 8px; margin: 10px 0;
  border: 1px solid var(--line);
  overflow-x: auto;
}
.tool {
  width: 42px; height: 42px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; font-size: 18px; cursor: pointer; flex: none;
}
.tool.active { background: var(--red-soft); border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.tool-sep { width: 1px; height: 26px; background: var(--line); flex: none; }
.swatches { display: inline-flex; gap: 6px; flex: none; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; flex: none;
}
.swatch.on { border-color: #26282c; box-shadow: 0 0 0 2px #fff inset; }
.mini-select { padding: 6px 6px; font-size: 12px; }

.corr-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.corr-actions .btn { padding: 10px 4px; font-size: 12.5px; min-height: 40px; }

.panel { background: #fff; border-radius: 12px; border: 1px solid var(--line); overflow: hidden; margin-bottom: 10px; }
.ptabs { display: flex; border-bottom: 1px solid var(--line); }
.ptab {
  flex: 1; padding: 11px 0; border: none; background: none; font-size: 14px;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
}
.ptab.active { color: var(--red); font-weight: 700; border-bottom-color: var(--red); }
.panel-body { padding: 12px; }

.ai-status { font-size: 13px; color: var(--muted); }
.ai-marks-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.mark-legend { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; flex-wrap: wrap; }
.mark-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin: 0 4px 0 8px; }
#btnMarksToggle.on { background: #e9f7ee; border-color: #0a8a3d; color: #0a8a3d; }
.ai-summary {
  background: #fff8e6; border: 1px solid #f2dc9e; color: #7a5b00;
  border-radius: 10px; padding: 8px 10px; font-size: 13px; margin: 8px 0;
}
.ai-list { display: flex; flex-direction: column; gap: 8px; }
.ai-item {
  border: 1px solid var(--line); border-left: 4px solid var(--muted);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; cursor: pointer;
  background: #fff;
}
.ai-item:active { background: #f7f8fa; }
.ai-item .cat {
  display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px;
  color: #fff; margin-right: 6px; vertical-align: middle;
}
.ai-item .txt { font-weight: 700; margin: 3px 0; word-break: break-all; }
.ai-item .fix { color: #0a8a3d; font-size: 12.5px; }
.ai-item .note { color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.5; }
.cat-错字,.cat-多笔少画,.cat-形近字,.cat-漏字 { background: #d5303f; }
.cat-拼音 { background: #e8890c; }
.cat-标点 { background: #d6336c; }
.cat-语序,.cat-病句,.cat-重复 { background: #7048e8; }
.cat-建议 { background: #2f6fd6; }
.cat-好句 { background: #0a8a3d; }
.cat-人工复核 { background: #7a828c; }
/* AI 结果卡片左边线与图上圈画同色 */
.ai-item.c-错字,.ai-item.c-多笔少画,.ai-item.c-形近字,.ai-item.c-漏字 { border-left-color: #d5303f; }
.ai-item.c-拼音 { border-left-color: #e8890c; }
.ai-item.c-标点 { border-left-color: #d6336c; }
.ai-item.c-语序,.ai-item.c-病句,.ai-item.c-重复 { border-left-color: #7048e8; }
.ai-item.c-建议 { border-left-color: #2f6fd6; }
.ai-item.c-好句 { border-left-color: #0a8a3d; }
.ai-item.c-人工复核 { border-left-color: #7a828c; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: #f1f2f4; border: 1px solid var(--line); color: #444;
  padding: 7px 12px; border-radius: 999px; font-size: 13px; cursor: pointer;
}
.chip:active { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.chips-manage .chip { display: inline-flex; align-items: center; gap: 6px; }
.chips-manage .chip b { color: var(--red); font-weight: 700; cursor: pointer; }
.remark-edit { margin-top: 10px; }
.remark-btns { display: flex; gap: 8px; margin-top: 8px; }
.remark-btns .btn { flex: 1; }
#btnMic.on { background: var(--red); color: #fff; border-color: var(--red); }

.meta-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.meta-label { font-size: 13px; color: var(--muted); }
.stars { font-size: 30px; letter-spacing: 4px; cursor: pointer; user-select: none; }
.stars .st { cursor: pointer; }
.grade-text { font-weight: 800; color: #e8890c; font-size: 16px; }
.meta-save { margin-top: 12px; }
.meta-save .btn { width: 100%; }
#metaNote { margin-top: 4px; }

/* ---------- 记录页 ---------- */
.rec-list { display: flex; flex-direction: column; gap: 10px; }
.rec-item {
  display: flex; gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 8px;
}
.rec-item img { width: 64px; height: 84px; object-fit: cover; border-radius: 8px; background: #000; }
.rec-main { flex: 1; min-width: 0; }
.rec-title { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.rec-stars { color: #e8890c; font-size: 13px; }
.rec-ops { display: flex; flex-direction: column; gap: 6px; }
.rec-check { width: 22px; height: 22px; flex: none; accent-color: var(--red); }

/* ---------- 错题页 ---------- */
.err-list { display: flex; flex-direction: column; gap: 6px; }
.err-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 14px;
}
.err-item .w { font-weight: 800; color: var(--red); font-size: 17px; }
.err-item .to { color: #0a8a3d; font-weight: 700; }
.err-item .meta { margin-left: auto; color: var(--muted); font-size: 11px; text-align: right; }
.err-head { font-size: 12px; color: var(--muted); padding: 2px 4px; }

/* ---------- 设置页 ---------- */
.set-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.set-row label { font-size: 14px; flex: none; max-width: 45%; }
.set-row.col { flex-direction: column; align-items: stretch; gap: 6px; }
.set-row.col label { max-width: none; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 0; font-size: 14px; border-bottom: 1px dashed var(--line); cursor: pointer;
}
.switch-row:last-of-type { border-bottom: none; }
.switch { width: 44px; height: 26px; accent-color: var(--red); flex: none; }
input[type=range] { accent-color: var(--red); flex: 1; }
input[type=radio] { accent-color: var(--red); width: 20px; height: 20px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 12px;
}
.modal-box {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  max-height: 92vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.modal-foot { display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.modal-foot .btn { flex: 1; }
.edit-canvas-wrap {
  flex: 1; min-height: 200px; background: #1c1e22; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  touch-action: none; user-select: none;
}
#editCanvas { max-width: 100%; max-height: 46vh; display: block; cursor: crosshair; }
.edit-tools { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 0; }
.edit-boost { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.viewer-body { flex: 1; overflow-y: auto; padding: 12px 14px; }
.viewer-body img { width: 100%; border-radius: 10px; margin: 8px 0; background: #000; }
.view-note { font-size: 13px; background: #fafbfc; border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; line-height: 1.6; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%); z-index: 99;
  background: rgba(20,22,26,.92); color: #fff; font-size: 13.5px;
  padding: 10px 16px; border-radius: 10px; max-width: 86vw;
  pointer-events: none; text-align: center;
}

/* ---------- 桌面端微调 ---------- */
@media (min-width: 640px) {
  .canvas-wrap { min-height: 300px; }
  .corr-actions { grid-template-columns: repeat(4, 1fr); }
}
