/* ===== 错题收集与智能出题复习系统 · 基础样式 ===== */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e9f0;
  --text: #1f2937;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --primary: #3b6ef5;
  --primary-dark: #2f57cc;
  --primary-soft: #eaf0ff;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --success: #17a673;
  --success-soft: #e6f7f0;
  --warn: #f5a524;
  --warn-soft: #fff5e6;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 650; line-height: 1.35; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0 0 .8em; }
img { max-width: 100%; }
hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ===== 布局 ===== */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar .inner {
  max-width: 1200px; margin: 0 auto; padding: 0 20px; height: 58px;
  display: flex; align-items: center; gap: 24px;
}
.brand { font-weight: 700; font-size: 16px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 700;
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--text-2); padding: 7px 12px; border-radius: 8px; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.user-menu { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft);
  color: var(--primary); display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.container { max-width: 1200px; margin: 0 auto; padding: 22px 20px 60px; }
.container.narrow { max-width: 820px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); font-size: 13px; margin: 0; }
.footer { text-align: center; color: var(--text-3); font-size: 12px; padding: 24px 0 40px; }

/* ===== 卡片 / 网格 ===== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 650; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 620px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--text-2); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.stat .hint { font-size: 12px; color: var(--text-3); }

/* ===== 按钮 / 表单 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14px; cursor: pointer;
  font-weight: 500; transition: .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

input[type=text], input[type=password], input[type=number], input[type=tel],
input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,110,245,.12); }
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; font-weight: 500; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
@media (max-width: 700px) { .field-row { grid-template-columns: 1fr; } }
.help { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ===== 标签 / 徽章 ===== */
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.tag-primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.tag-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.tag-warn { background: var(--warn-soft); color: #b26b00; border-color: transparent; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.badge { padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; }
.badge-new { background: var(--warn-soft); color: #b26b00; }
.badge-reviewing { background: var(--primary-soft); color: var(--primary); }
.badge-mastered { background: var(--success-soft); color: var(--success); }

/* ===== 列表 / 表格 ===== */
.q-list { display: grid; gap: 12px; }
.q-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; gap: 14px; transition: .15s;
}
.q-card:hover { border-color: #cdd6e6; box-shadow: var(--shadow-sm); }
.q-card .check { padding-top: 3px; }
.q-card .body { flex: 1; min-width: 0; }
.q-stem { font-size: 14px; color: var(--text); margin-bottom: 8px; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.q-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12.5px; color: var(--text-3); }
.q-thumb { width: 62px; height: 62px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { color: var(--text-2); font-weight: 600; background: var(--surface-2); }
tbody tr:hover { background: var(--surface-2); }

/* ===== 筛选栏 ===== */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters .f { min-width: 130px; }
.filters .f.wide { min-width: 240px; flex: 1; }
.filters label { margin-bottom: 3px; }

/* ===== 折叠解析 ===== */
.fold { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 14px; }
.fold > summary {
  cursor: pointer; padding: 11px 14px; background: var(--surface-2); font-weight: 600;
  font-size: 13.5px; list-style: none; display: flex; align-items: center; justify-content: space-between;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "展开"; font-size: 12px; color: var(--text-3); font-weight: 400; }
.fold[open] > summary::after { content: "收起"; }
.fold .fold-body { padding: 14px; }
.answer-box { background: var(--success-soft); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 12px; }
.analysis-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; white-space: pre-wrap; }

/* ===== 题目展示 ===== */
.stem-block { font-size: 15.5px; line-height: 1.85; white-space: pre-wrap; word-break: break-word; }
.options { margin: 12px 0; display: grid; gap: 8px; }
.option-item { padding: 9px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.option-item.selected { border-color: var(--primary); background: var(--primary-soft); }
.quiz-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; background: var(--surface); }
.quiz-item.correct { border-color: #a8e0c6; }
.quiz-item.wrong { border-color: #f3c2c4; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.quiz-no { font-weight: 700; font-size: 15px; }
.quiz-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ===== 进度 ===== */
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); transition: width .3s; }

/* ===== 提示条 ===== */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px; }
.alert-info { background: var(--primary-soft); color: #24479c; }
.alert-warn { background: var(--warn-soft); color: #8a5a00; }
.alert-danger { background: var(--danger-soft); color: #a3272b; }
.alert-success { background: var(--success-soft); color: #0f7a52; }

.empty { text-align: center; padding: 46px 20px; color: var(--text-3); }
.empty .icon { font-size: 40px; margin-bottom: 10px; }

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
.pagination a, .pagination span { padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13px; color: var(--text-2); }
.pagination a:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== 移动端采集端 ===== */
.mobile { max-width: 480px; margin: 0 auto; background: var(--bg); min-height: 100vh; padding-bottom: 30px; }
.mobile-head {
  background: linear-gradient(135deg, var(--primary), #6b8ffb); color: #fff; padding: 22px 18px 26px;
  border-radius: 0 0 22px 22px;
}
.mobile-head h1 { font-size: 19px; margin-bottom: 2px; }
.mobile-head .sub { opacity: .9; font-size: 13px; }
.mobile-body { padding: 16px; }
.m-stat { display: flex; gap: 10px; margin-top: 14px; }
.m-stat div { flex: 1; background: rgba(255,255,255,.16); border-radius: 10px; padding: 8px 10px; text-align: center; }
.m-stat b { display: block; font-size: 19px; }
.camera-btn {
  width: 100%; border: none; border-radius: 16px; padding: 26px 0; font-size: 17px; font-weight: 700;
  background: var(--primary); color: #fff; box-shadow: 0 8px 20px rgba(59,110,245,.28); cursor: pointer;
}
.camera-btn:active { transform: scale(.985); }
.preview-box { width: 100%; border-radius: 12px; border: 1px dashed var(--border); padding: 8px; background: var(--surface); }

/* ===== 原生摄像头取景器 ===== */
.cam-card { padding: 16px; }
.cam-stage {
  position: relative; width: 100%; aspect-ratio: 3 / 4;
  background: #10141c; border-radius: 14px; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.cam-stage video {
  display: block; width: 100%; height: 100%; object-fit: cover; background: #10141c;
}
.cam-stage video.mirror { transform: scaleX(-1); }

/* 三分构图参考线 */
.cam-grid {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, transparent calc(33.33% - .5px), rgba(255,255,255,.22) calc(33.33% - .5px), rgba(255,255,255,.22) calc(33.33% + .5px), transparent calc(33.33% + .5px)),
    linear-gradient(to right, transparent calc(66.66% - .5px), rgba(255,255,255,.22) calc(66.66% - .5px), rgba(255,255,255,.22) calc(66.66% + .5px), transparent calc(66.66% + .5px)),
    linear-gradient(to bottom, transparent calc(33.33% - .5px), rgba(255,255,255,.22) calc(33.33% - .5px), rgba(255,255,255,.22) calc(33.33% + .5px), transparent calc(33.33% + .5px)),
    linear-gradient(to bottom, transparent calc(66.66% - .5px), rgba(255,255,255,.22) calc(66.66% - .5px), rgba(255,255,255,.22) calc(66.66% + .5px), transparent calc(66.66% + .5px));
}

/* 四角取景框 */
.cam-frame { position: absolute; inset: 7% 6%; pointer-events: none; }
.cam-frame i { position: absolute; width: 24px; height: 24px; border: 3px solid rgba(255,255,255,.92); }
.cam-frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 6px 0 0 0; }
.cam-frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 6px 0 0; }
.cam-frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 6px; }
.cam-frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 6px 0; }

.cam-hint {
  position: absolute; left: 12px; right: 12px; bottom: 12px; text-align: center;
  color: #fff; font-size: 12.5px; line-height: 1.5; padding: 6px 12px;
  background: rgba(16, 20, 28, .55); border-radius: 999px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.cam-busy {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center; color: #fff; font-size: 13px;
  background: rgba(16, 20, 28, .72);
}
.cam-spin {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.28); border-top-color: #fff;
  animation: cam-spin .8s linear infinite;
}
@keyframes cam-spin { to { transform: rotate(360deg); } }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: cam-flash .32s ease-out; }
@keyframes cam-flash { 0% { opacity: .92; } 100% { opacity: 0; } }

/* 快门控制条 */
.cam-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 14px; padding: 0 6px;
}
.cam-ctl {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 58px; padding: 4px 0; background: none; border: 0; cursor: pointer;
  color: var(--text-2); font-size: 11px; font-family: inherit;
}
.cam-ctl-ico {
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2);
  border: 1px solid var(--border); display: grid; place-items: center;
  font-size: 16px; color: var(--text); transition: .15s;
}
.cam-ctl:active .cam-ctl-ico { transform: scale(.94); }
.cam-ctl.active .cam-ctl-ico { background: var(--warn-soft); border-color: transparent; color: #b26b00; }
.cam-ctl-placeholder { width: 58px; }
.cam-shutter {
  width: 68px; height: 68px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 4px solid var(--primary); background: #fff; position: relative;
  box-shadow: 0 4px 14px rgba(59, 110, 245, .22);
}
.cam-shutter::after {
  content: ""; position: absolute; inset: 5px; border-radius: 50%;
  background: var(--primary); transition: .12s;
}
.cam-shutter:active::after { inset: 9px; }
.cam-shutter:disabled { opacity: .5; }

/* 已拍下照片的预览台 */
.shot-stage {
  display: grid; place-items: center; overflow: hidden;
  background: var(--surface-2); border: 1px dashed var(--border);
  border-radius: 12px; padding: 8px; min-height: 180px;
}
.shot-stage img {
  max-width: 100%; max-height: 56vh; border-radius: 8px; display: block;
}
.m-nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); display: flex; max-width: 480px; margin: 0 auto; }
.m-nav a { flex: 1; text-align: center; padding: 11px 0; font-size: 12.5px; color: var(--text-2); }
.m-nav a.active { color: var(--primary); font-weight: 600; }
.m-nav a:hover { text-decoration: none; }
.low-conf { border-bottom: 2px dashed var(--warn); background: #fffaf0; }

/* ===== 图表 ===== */
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 46px; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
.bar-row .bar { height: 16px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-row .bar > i { display: block; height: 100%; border-radius: 999px; }
.bar-row .val { text-align: right; color: var(--text-2); }

/* ===== 杂项 ===== */
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(31,41,55,.94); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; z-index: 999; opacity: 0; pointer-events: none; transition: .25s;
}
.toast.show { opacity: 1; }

@media print {
  .topbar, .no-print, .footer { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
