/* ============================================================
   错知了智能错题本 · 应用样式
   响应式 Web 布局：手机 <768 / 平板 ≥768 / 宽屏 ≥900
   设计语言：Indigo 主色 + 语义化掌握度色
   ============================================================ */
:root {
  --primary: #4F46E5;
  --primary-2: #6366F1;
  --primary-soft: #EEF0FF;
  --bg: #F4F6FB;
  --card: #FFFFFF;
  --text: #1F2437;
  --text-2: #6B7280;
  --text-3: #9CA3AF;
  --border: #E8EBF4;
  --green: #10B981;
  --orange: #F59E0B;
  --red: #EF4444;
  --blue: #3B82F6;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(31, 36, 55, .06);
  --shadow-lg: 0 10px 30px rgba(31, 36, 55, .14);
  --font: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  --topnav-h: 60px;
  --tabbar-h: 62px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  display: flex; flex-direction: column;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); outline: none; }

/* ============================================================
   顶部导航（平板 / 桌面）
   ============================================================ */
.topnav { display: none; flex: none; background: #fff; border-bottom: 1px solid var(--border); position: relative; z-index: 60; }
.topnav-inner {
  max-width: 1200px; margin: 0 auto; height: var(--topnav-h);
  padding: 0 20px; display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; min-width: 0; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--primary), #7C3AED); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px;
  box-shadow: 0 4px 10px rgba(79, 70, 229, .3);
}
.brand-tx { min-width: 0; }
.brand-tx .bt { font-size: 15px; font-weight: 800; letter-spacing: .3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-tx .bs { font-size: 11px; color: var(--text-3); display: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tn-links { display: flex; gap: 4px; margin-left: auto; min-width: 0; overflow: hidden; }
.tn-link {
  display: flex; align-items: center; gap: 6px; flex: none;
  padding: 8px 14px; border-radius: 12px; font-size: 14px; color: var(--text-2);
  transition: all .15s;
}
.tn-link svg { width: 17px; height: 17px; }
.tn-link:hover { background: #F2F4FA; color: var(--text); }
.tn-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.tn-count {
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--red); color: #fff;
  font-size: 10px; display: inline-flex; align-items: center; justify-content: center;
}
.tn-right { display: flex; align-items: center; gap: 14px; flex: none; min-width: 0; }
.tn-capture {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #7C3AED); color: #fff; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 5px 12px rgba(79, 70, 229, .3); transition: transform .12s;
}
.tn-capture:active { transform: scale(.96); }
.tn-capture svg { width: 17px; height: 17px; }
.tn-user { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.tn-login {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--primary); color: var(--primary);
  background: #fff; font-size: 13px; font-weight: 600; transition: all .12s; cursor: pointer;
}
.tn-login:hover { background: var(--primary-soft); }
.tn-login:active { transform: scale(.96); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
  flex: none;
}
.tn-name { font-size: 13px; color: var(--text-2); }

/* ============================================================
   内容区与底部导航（手机）
   ============================================================ */
.screen {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  background: var(--bg); position: relative;
  scroll-behavior: smooth;
}
.screen::-webkit-scrollbar { width: 0; }

.tabbar {
  display: none; flex: none; height: var(--tabbar-h); background: #fff;
  border-top: 1px solid var(--border);
  align-items: center; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  position: relative; z-index: 60;
}
/* 手机端：仅在顶层 Tab 视图显示底部导航（JS 切换 body.show-tab） */
body.show-tab .tabbar { display: flex; }
.tb-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--text-3); min-width: 56px; position: relative;
  transition: color .2s;
}
.tb-item.active { color: var(--primary); font-weight: 600; }
.tb-ic { display: block; width: 22px; height: 22px; }
.tb-ic svg { width: 100%; height: 100%; }
.tb-badge {
  position: absolute; top: -4px; right: 6px; min-width: 16px; height: 16px;
  background: var(--red); color: #fff; font-size: 10px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.tb-fab {
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  color: #fff; display: flex; align-items: center; justify-content: center;
  margin-top: -26px; box-shadow: 0 8px 18px rgba(79, 70, 229, .35);
  border: 4px solid #fff; transition: transform .15s;
}
.tb-fab:active { transform: scale(.94); }
.tb-fab svg { width: 24px; height: 24px; }

/* ============================================================
   通用组件
   ============================================================ */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(244, 246, 251, .92); backdrop-filter: blur(10px);
  padding: 10px 16px; display: flex; align-items: center; gap: 10px;
}
.appbar .ab-title { font-size: 17px; font-weight: 700; flex: 1; }
.appbar .ab-sub { font-size: 11px; color: var(--text-3); font-weight: 400; }
.ab-back {
  width: 34px; height: 34px; border-radius: 12px; background: #fff; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--text); box-shadow: var(--shadow);
}
.ab-back svg { width: 16px; height: 16px; }
.ab-action { width: 34px; height: 34px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.ab-action svg { width: 18px; height: 18px; }

.view { padding: 0 16px 18px; animation: viewIn .28s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.site-footer {
  text-align: center; font-size: 11px; color: var(--text-3);
  padding: 10px 16px 14px; letter-spacing: .3px;
}

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px;
}
.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.card-title svg { width: 18px; height: 18px; flex: none; }
.card-title .ct-more { margin-left: auto; flex: none; white-space: nowrap; font-size: 11px; color: var(--text-3); font-weight: 400; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 3px 9px; border-radius: 999px; line-height: 1.6;
  background: var(--primary-soft); color: var(--primary);
}
.chip.green { background: #E7F8F1; color: #0B8A62; }
.chip.orange { background: #FEF3E2; color: #C77E06; }
.chip.red { background: #FEEBEB; color: #D63A3A; }
.chip.gray { background: #F0F2F8; color: var(--text-2); }
.chip.blue { background: #E8F1FE; color: #2563EB; }

.mastery-badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.mb-red { background: #FEEBEB; color: #D63A3A; }
.mb-orange { background: #FEF3E2; color: #C77E06; }
.mb-green { background: #E7F8F1; color: #0B8A62; }
.mb-blue { background: #E6F4FE; color: #0B74C4; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
  transition: transform .12s, opacity .15s; width: 100%;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), #7C3AED); color: #fff; box-shadow: 0 6px 14px rgba(79, 70, 229, .3); }
.btn-primary:disabled { opacity: .5; }
.btn-ghost { background: #fff; color: var(--primary); border: 1px solid #D8DDFA; }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-danger { background: #FEEBEB; color: #D63A3A; }
.btn-sm { padding: 6px 10px; font-size: 11.5px; border-radius: 8px; width: auto; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
/* 练习作答：提交答案按钮居中收窄 */
.answer-submit {
  width: auto; min-width: 176px;
  padding: 9px 24px; font-size: 13px; border-radius: 12px;
}
/* 熟练度评估 */
.assess-tip { display: flex; gap: 8px; align-items: flex-start; border: 1px solid #D8DDFA; background: #F7F8FF; }
.assess-tip svg { width: 16px; height: 16px; flex: none; color: var(--primary); }
.assess-q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.assess-q-num { font-size: 12px; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 3px 9px; border-radius: 999px; }
.assess-q-card { border: 1px solid var(--border); }
.assess-ans-opts { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.assess-ans-line { display: flex; gap: 10px; font-size: 13px; margin-top: 8px; line-height: 1.7; }
.assess-ans-line .alk { flex: none; color: var(--text-3); font-size: 12px; min-width: 58px; }
.assess-ans-line .alv { white-space: pre-line; }
.res-mastery .mastery-badge { font-size: 14px; padding: 6px 14px; }

.seg {
  display: flex; background: #E9EDF6; border-radius: 12px; padding: 3px; gap: 3px;
  overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 1; min-width: 52px; padding: 7px 8px; font-size: 12px; border-radius: 10px;
  color: var(--text-2); white-space: nowrap; transition: all .2s;
}
.seg button.on { background: #fff; color: var(--primary); font-weight: 700; box-shadow: var(--shadow); }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.field select, .field input, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
  background: #FBFCFE; font-size: 14px;
}
.field select:focus, .field input:focus, .field textarea:focus { border-color: var(--primary); }

/* 下拉框：自定义箭头 + 圆角边框 + 聚焦光晕 */
select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--border); border-radius: 10px;
  background-color: #FBFCFE;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
  padding: 7px 30px 7px 10px;
  font-size: 13px; color: var(--text); cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
select:hover { border-color: #C9D1E8; }
select:focus {
  border-color: var(--primary); background-color: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.diag-item select { width: 100%; }
.diag-item .dv select { font-weight: 500; }
.diag-item .dv input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  background: #FBFCFE; padding: 6px 10px; font-size: 13px; font-weight: 500;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.diag-item .dv input:hover { border-color: #C9D1E8; }
.diag-item .dv input:focus {
  border-color: var(--primary); background-color: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); outline: none;
}

/* 多行文本框：圆角边框 + 柔和底 + 聚焦光晕 */
textarea {
  width: 100%;
  border: 1px solid var(--border); border-radius: 12px;
  background: #FBFCFE; padding: 10px 12px;
  font-size: 13px; line-height: 1.7; color: var(--text);
  resize: vertical;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
textarea:hover { border-color: #C9D1E8; }
textarea:focus {
  border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
::placeholder { color: #A8AFC0; }

.searchbar {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 9px 12px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.searchbar svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.searchbar input { border: none; background: none; flex: 1; font-size: 14px; }
.searchbar .fbtn {
  flex: none; width: 32px; height: 32px; border-radius: 10px; background: var(--primary-soft);
  color: var(--primary); display: flex; align-items: center; justify-content: center; position: relative;
}
.searchbar .fbtn svg { width: 16px; height: 16px; }
.fbtn .fdot { position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }

/* ============================================================
   首页
   ============================================================ */
.hero {
  background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 60%, #9333EA 100%);
  border-radius: 20px; padding: 16px; color: #fff; margin-bottom: 12px;
  box-shadow: 0 10px 24px rgba(79, 70, 229, .32); position: relative; overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px;
  border-radius: 50%; background: rgba(255, 255, 255, .08);
}
.hero .h-greet { font-size: 13px; opacity: .85; }
.hero .h-name { font-size: 19px; font-weight: 800; margin: 2px 0 12px; }
.hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.hero-stats .h-stat.tot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 10px; }
.hero-stats .h-stat.tot .v { font-size: 24px; }
.h-stat { background: rgba(255, 255, 255, .14); border-radius: 12px; padding: 8px; text-align: center; }
.h-stat .v { font-size: 18px; font-weight: 800; }
.h-stat .k { font-size: 11px; opacity: .8; margin-top: 2px; }

.home-cta { display: flex; gap: 10px; margin-bottom: 12px; }
.cta-main {
  flex: 1.4; background: linear-gradient(135deg, var(--primary), #7C3AED); color: #fff;
  border-radius: 18px; padding: 14px; box-shadow: 0 8px 18px rgba(79, 70, 229, .3);
  text-align: left; position: relative; overflow: hidden;
}
.cta-main .t1 { font-size: 15px; font-weight: 700; }
.cta-main .t2 { font-size: 11px; opacity: .85; margin-top: 3px; }
.cta-main svg { position: absolute; right: 10px; bottom: 8px; width: 30px; height: 30px; opacity: .5; }
.cta-sub {
  flex: 1; background: #fff; border-radius: 18px; padding: 14px; box-shadow: var(--shadow);
  border: 1px solid var(--border); text-align: left;
}
.cta-sub .t1 { font-size: 13px; font-weight: 700; }
.cta-sub .t2 { font-size: 10px; color: var(--text-3); margin-top: 3px; }
.cta-sub svg { width: 24px; height: 24px; color: var(--primary); display: block; margin-bottom: 6px; }

.task-strip { display: flex; gap: 10px; margin-bottom: 12px; }
.task-item { flex: 1; background: #fff; border-radius: 14px; padding: 10px 12px; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow); }
.task-item .tk { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.task-item .tk svg { width: 18px; height: 18px; }
.task-item .tt { font-size: 13px; font-weight: 700; }
.task-item .ts { font-size: 10px; color: var(--text-3); }

.recent-row { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.recent-row::-webkit-scrollbar { display: none; }
.recent-card {
  flex: none; width: 168px; background: #fff; border-radius: 14px; padding: 10px;
  box-shadow: var(--shadow); cursor: pointer; border: 1px solid transparent;
}
.recent-card:active { border-color: var(--primary); }
.recent-card .rc-tag { display: flex; gap: 4px; margin-bottom: 6px; }
.recent-card .rc-text { font-size: 12.5px; color: var(--text); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recent-card .rc-meta { margin-top: 8px; font-size: 10px; color: var(--text-3); display: flex; justify-content: space-between; }

.weak-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.weak-item .wk-name { flex: none; width: 130px; font-size: 12.5px; }
.weak-item .wk-bar { flex: 1; height: 8px; background: #EDF0F8; border-radius: 999px; overflow: hidden; }
.weak-item .wk-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--red), var(--orange)); }
.weak-item .wk-val { flex: none; width: 34px; text-align: right; font-size: 12px; font-weight: 700; color: var(--red); }

/* ============================================================
   错题本（存档列表）
   ============================================================ */
.q-card { display: flex; gap: 12px; cursor: pointer; }
.q-card:active { transform: scale(.995); }
.q-photo {
  flex: none; width: 74px; height: 74px; border-radius: 12px; overflow: hidden;
  background: linear-gradient(160deg, #EEF1FB, #E4E9F7);
  display: flex; align-items: center; justify-content: center; position: relative;
}
.q-photo img { width: 100%; height: 100%; object-fit: cover; }
.q-photo .ph-fallback { position: absolute; inset: 0; padding: 8px; font-size: 10px; color: var(--text-3); display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.6; flex-direction: column; }
.q-photo .ph-fallback svg { width: 20px; height: 20px; }
.q-body { flex: 1; min-width: 0; }
.q-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.q-text { font-size: 13px; font-weight: 600; margin: 6px 0 4px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.q-meta { font-size: 11px; color: var(--text-3); display: flex; gap: 8px; align-items: center; }
.q-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: #C9CFE0; }

/* 树形分组 */
.tree-node { margin-bottom: 6px; }
.tree-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: #fff;
  border-radius: 12px; box-shadow: var(--shadow); cursor: pointer; font-size: 13.5px; font-weight: 700;
}
.tree-head .count { margin-left: auto; font-size: 11px; color: var(--text-3); font-weight: 400; }
.tree-head .chev { transition: transform .2s; width: 14px; height: 14px; color: var(--text-3); }
.tree-head.open .chev { transform: rotate(90deg); }
.tree-children { display: none; padding: 6px 0 0 14px; }
.tree-node.open > .tree-children { display: block; }

/* ============================================================
   详情页
   ============================================================ */
.detail-photo {
  border-radius: 16px; overflow: hidden; position: relative; margin-bottom: 12px;
  background: linear-gradient(160deg, #EEF1FB, #E4E9F7); cursor: zoom-in;
}
.detail-photo img { width: 100%; display: block; max-height: 260px; object-fit: cover; }
.detail-photo .zoom-hint {
  position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, .45); color: #fff;
  font-size: 10px; padding: 4px 8px; border-radius: 999px; display: flex; align-items: center; gap: 4px;
}
.detail-photo .zoom-hint svg { width: 11px; height: 11px; }
.detail-photo .ph-fallback { padding: 40px 20px; text-align: center; color: var(--text-3); font-size: 12px; }
.detail-photo .ph-fallback svg { width: 26px; height: 26px; }

.diag-item { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed #EDF0F7; font-size: 13px; }
.diag-item:last-child { border-bottom: none; }
.diag-item .dk { flex: none; width: 64px; color: var(--text-2); font-size: 12px; }
.diag-item .dv { flex: 1; font-weight: 600; }
.diag-item .dv.input-like {
  font-weight: 400; color: var(--text); border: 1px solid var(--border); background: #FBFCFE;
  border-radius: 10px; padding: 6px 10px; font-size: 13px;
}

.section { margin-bottom: 14px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 4px 0 8px; display: flex; align-items: center; gap: 6px; }
.qa-block {
  background: #FBFCFE; border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  font-size: 13.5px; line-height: 1.75;
}
.answer-reveal { border: 1px dashed var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 700; }

.gen-item { border: 1px solid var(--border); border-radius: 14px; padding: 12px; margin-bottom: 10px; background: #fff; }
.gen-item .gi-q { font-size: 13.5px; font-weight: 600; line-height: 1.6; }
.gen-item .gi-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.bottom-bar {
  position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--border);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  display: flex; gap: 10px; z-index: 30;
}
.bottom-bar .btn { flex: 1; padding: 9px 14px; font-size: 13px; border-radius: 12px; }
.bottom-bar .btn svg { width: 15px; height: 15px; }

/* ============================================================
   拍照上传流程
   ============================================================ */
.capture-src {
  background: #fff; border: 2px dashed #D3D9EE; border-radius: 18px; padding: 22px 16px;
  text-align: center; cursor: pointer; margin-bottom: 12px; transition: all .2s;
}
.capture-src:hover, .capture-src:active { border-color: var(--primary); background: var(--primary-soft); }
.capture-src .cs-ic {
  width: 52px; height: 52px; margin: 0 auto 10px; border-radius: 16px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.capture-src .cs-ic svg { width: 26px; height: 26px; }
.capture-src .cs-t { font-size: 15px; font-weight: 700; }
.capture-src .cs-s { font-size: 11px; color: var(--text-3); margin-top: 4px; }

.viewfinder {
  position: relative; border-radius: 18px; overflow: hidden; background: #10131C;
  aspect-ratio: 3/4; max-width: 430px; margin: 0 auto;
}
.viewfinder .vf-img { width: 100%; height: 100%; object-fit: cover; opacity: .92; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder .cam-error {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: #fff; padding: 20px; box-sizing: border-box;
}
.viewfinder .cam-error svg { width: 30px; height: 30px; opacity: .9; }
.viewfinder .crop-frame {
  position: absolute; inset: 12% 8%; border: 2px solid #fff; border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .35);
}
.viewfinder .cf-corner { content: ''; position: absolute; width: 18px; height: 18px; border: 3px solid var(--primary); }
.cf-tl { top: -3px; left: -3px; border-right: none; border-bottom: none; border-top-left-radius: 8px; }
.cf-tr { top: -3px; right: -3px; border-left: none; border-bottom: none; border-top-right-radius: 8px; }
.cf-bl { bottom: -3px; left: -3px; border-right: none; border-top: none; border-bottom-left-radius: 8px; }
.cf-br { bottom: -3px; right: -3px; border-left: none; border-top: none; border-bottom-right-radius: 8px; }
.viewfinder .vf-correcting {
  position: absolute; inset: 0; background: rgba(16, 19, 28, .72); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 5;
}
/* 手动裁剪：图片 contain 完整显示 + 可拖动/缩放的裁剪框 */
.viewfinder.crop-view .vf-img { object-fit: contain; opacity: 1; }
.crop-view .crop-box {
  position: absolute; border: 2px solid #fff; border-radius: 4px; cursor: move;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45);
  touch-action: none; user-select: none; -webkit-user-select: none; box-sizing: border-box;
}
.crop-view .crop-handle { position: absolute; width: 24px; height: 24px; touch-action: none; }
.crop-view .crop-handle::before {
  content: ''; position: absolute; width: 14px; height: 14px; border: 3px solid #fff; box-sizing: border-box;
}
.crop-view .crop-handle[data-dir="nw"] { top: -12px; left: -12px; cursor: nwse-resize; }
.crop-view .crop-handle[data-dir="nw"]::before { top: 0; left: 0; border-right: none; border-bottom: none; }
.crop-view .crop-handle[data-dir="ne"] { top: -12px; right: -12px; cursor: nesw-resize; }
.crop-view .crop-handle[data-dir="ne"]::before { top: 0; right: 0; border-left: none; border-bottom: none; }
.crop-view .crop-handle[data-dir="sw"] { bottom: -12px; left: -12px; cursor: nesw-resize; }
.crop-view .crop-handle[data-dir="sw"]::before { bottom: 0; left: 0; border-right: none; border-top: none; }
.crop-view .crop-handle[data-dir="se"] { bottom: -12px; right: -12px; cursor: nwse-resize; }
.crop-view .crop-handle[data-dir="se"]::before { bottom: 0; right: 0; border-left: none; border-top: none; }
.crop-tips { text-align: center; font-size: 12px; color: var(--text-2); margin-top: 10px; line-height: 1.8; }
.vf-shutter {
  width: 64px; height: 64px; border-radius: 50%; background: #fff; border: 5px solid rgba(255, 255, 255, .35);
  display: flex; align-items: center; justify-content: center; margin: 14px auto 0;
}
.vf-shutter .inner { width: 46px; height: 46px; border-radius: 50%; background: #fff; }
.vf-shutter:active .inner { background: #E5E7EF; }
.vf-tips { color: rgba(255, 255, 255, .75); font-size: 12px; text-align: center; margin-top: 8px; }

.progress-track { height: 8px; background: #EDF0F8; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #7C3AED); width: 0; transition: width .3s ease; }

.ai-steps { display: flex; flex-direction: column; gap: 10px; }
.ai-step { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }
.ai-step .st-ic {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: #EDF0F8; color: var(--text-3); display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.ai-step .st-ic svg { width: 14px; height: 14px; }
.ai-step.done .st-ic { background: var(--green); color: #fff; }
.ai-step.active .st-ic { background: var(--primary); color: #fff; animation: pulse 1s infinite; }
.ai-step.active { color: var(--text); font-weight: 700; }
.ai-step.done { color: var(--text); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, .4); } 50% { box-shadow: 0 0 0 6px rgba(79, 70, 229, 0); } }

/* ============================================================
   练习
   ============================================================ */
.answer-opt {
  width: 100%; text-align: left; background: #fff; border: 1.5px solid var(--border);
  border-radius: 14px; padding: 13px 14px; margin-bottom: 10px; font-size: 14px;
  display: flex; align-items: center; gap: 10px; transition: all .15s;
}
.answer-opt .opt-key {
  width: 26px; height: 26px; border-radius: 50%; background: #F0F2F8; color: var(--text-2);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none;
}
.answer-opt.right { border-color: var(--green); background: #F0FBF6; }
.answer-opt.right .opt-key { background: var(--green); color: #fff; }
.answer-opt.wrong { border-color: var(--red); background: #FEF1F1; }
.answer-opt.wrong .opt-key { background: var(--red); color: #fff; }
.answer-opt.dim { opacity: .45; }

.result-banner { border-radius: 14px; padding: 12px; font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.result-banner.correct { background: #F0FBF6; color: #0B8A62; border: 1px solid #CDEFDF; }
.result-banner.wrong { background: #FEF1F1; color: #D63A3A; border: 1px solid #FAD1D1; }
.result-banner svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }

/* ============================================================
   我的
   ============================================================ */
.profile-head {
  background: linear-gradient(135deg, #4F46E5, #7C3AED); border-radius: 20px; color: #fff;
  padding: 18px 16px; display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
  box-shadow: 0 10px 24px rgba(79, 70, 229, .3);
}
.profile-head .avatar {
  width: 52px; height: 52px; border-radius: 50%; background: rgba(255, 255, 255, .2);
  display: flex; align-items: center; justify-content: center; font-size: 20px; border: 2px solid rgba(255, 255, 255, .4);
  flex: none;
}
.profile-head .p-name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-head .p-sub { font-size: 11.5px; opacity: .85; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-head > div:last-child { flex: 1; min-width: 0; }

.setting-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #F0F2F8; font-size: 14px; }
.setting-row:last-child { border-bottom: none; }
.setting-row .sk { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; }
.setting-row .sk svg { width: 16px; height: 16px; }
.setting-row .st { flex: 1; }
.setting-row .st-s { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.setting-row .go { color: var(--text-3); }
.setting-row .go svg { width: 16px; height: 16px; }

.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { display: none; }
.switch .knob { position: absolute; inset: 0; background: #D5DAE6; border-radius: 999px; transition: background .2s; }
.switch .knob::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.switch input:checked + .knob { background: var(--primary); }
.switch input:checked + .knob::after { transform: translateX(18px); }

.stat-bar-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 12.5px; }
.stat-bar-row .lb { flex: none; width: 62px; color: var(--text-2); }
.stat-bar-row .bar { flex: 1; height: 9px; background: #EDF0F8; border-radius: 999px; overflow: hidden; }
.stat-bar-row .bar i { display: block; height: 100%; border-radius: 999px; }
.stat-bar-row .val { flex: none; width: 40px; text-align: right; font-weight: 700; }

/* ============================================================
   筛选底部弹层 / 灯箱 / Toast / 空态
   ============================================================ */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(15, 18, 30, .45); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s ease;
}
.sheet {
  width: 100%; max-width: 480px; background: #fff; border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(16px + env(safe-area-inset-bottom));
  max-height: 78vh; overflow-y: auto;
  animation: sheetUp .28s ease;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet .sheet-bar { width: 40px; height: 4px; border-radius: 999px; background: #D5DAE6; margin: 0 auto 14px; }
.sheet-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.sheet-title svg { width: 18px; height: 18px; flex: none; }
.filter-group { margin-bottom: 16px; }
.filter-group .fg-t { font-size: 12px; color: var(--text-2); font-weight: 700; margin-bottom: 8px; }
.chip-options { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt {
  font-size: 12px; padding: 7px 13px; border-radius: 999px; background: #F2F4FA; color: var(--text-2);
  border: 1px solid transparent; transition: all .15s;
}
.chip-opt.on { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); font-weight: 600; }
.chip-opt:active { transform: scale(.96); }

/* 生成类似题：数量快捷选择 */
.gen-count-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  font-size: 12.5px; padding: 8px 16px; border-radius: 999px; background: #F2F4FA; color: var(--text-2);
  border: 1px solid #E3E7F2; transition: all .15s; cursor: pointer; font-weight: 600;
}
.chip-btn:active { transform: scale(.95); background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.sheet-close {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
  border: none; border-radius: 50%; background: #F2F4FA; color: var(--text-2); cursor: pointer; flex: none;
}
.sheet-close svg { width: 14px; height: 14px; }
.sheet-close:active { transform: scale(.92); }

/* 类似题 AI 例图 */
.gen-img { width: 100%; border-radius: 12px; margin-top: 10px; display: block; border: 1px solid var(--border); }
/* KaTeX 公式渲染保护：块级公式超出容器时横向滚动，避免撑破卡片 */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; max-width: 100%; }
.katex-error { color: #cc0000; font-style: italic; }
.qa-block .katex, .q-text .katex, .gi-q .katex, .rc-text .katex { font-size: 1.02em; }
.gen-img-wrap { position: relative; margin-top: 10px; }
.gen-img-wrap .gen-img { margin-top: 0; }
.img-beta {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: .5px; line-height: 1.6;
  color: #fff; background: linear-gradient(135deg, #6D5DF6, #3B82F6);
  box-shadow: 0 2px 6px rgba(0,0,0,.22); cursor: help; user-select: none;
}
.img-beta::after {
  content: attr(data-tip);
  position: absolute; top: 130%; right: 0; z-index: 99;
  width: max-content; max-width: 220px; padding: 8px 10px; border-radius: 8px;
  background: rgba(17,24,39,.93); color: #fff;
  font-size: 11px; font-weight: 400; line-height: 1.6; letter-spacing: 0;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); white-space: normal; word-break: break-all;
  opacity: 0; pointer-events: none; transform: translateY(4px);
  transition: opacity .15s, transform .15s;
}
.img-beta:hover::after { opacity: 1; transform: translateY(0); }

.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 200;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px;
  animation: fadeIn .2s ease;
}
.lightbox img { max-width: 94%; max-height: 84%; border-radius: 12px; }
.lightbox .lb-note { color: rgba(255, 255, 255, .7); font-size: 12px; }

#toast-root { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(24, 28, 40, .92); color: #fff; font-size: 13px;
  padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px; max-width: 86vw;
  animation: toastIn .25s ease;
}
.toast svg { width: 16px; height: 16px; flex: none; }
.toast.success svg { color: var(--green); }
.toast.error svg { color: var(--red); }
.toast.info svg { color: var(--blue); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid #DEE3F4; border-top-color: var(--primary);
  animation: spin .8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 46px 20px; color: var(--text-3); }
.empty-state svg { width: 46px; height: 46px; opacity: .5; margin-bottom: 10px; }
.empty-state .es-t { font-size: 14px; font-weight: 600; color: var(--text-2); }
.empty-state .es-s { font-size: 12px; margin-top: 4px; }

/* ============================================================
   响应式断点
   ============================================================ */
/* 手机（默认，即上方基础样式） */
/* 平板 ≥768px：显示顶部导航，隐藏底部导航，内容限宽，存档双列 */
@media (min-width: 768px) {
  body { background: radial-gradient(1200px 600px at 20% -10%, #E9ECFF 0%, transparent 55%), #EFF2F9; }
  .topnav { display: block; }
  .topnav-inner { padding: 0 16px; gap: 14px; }
  .tn-links { flex: 1; justify-content: flex-end; }
  .tabbar, body.show-tab .tabbar { display: none; }
  .brand-tx .bs { display: block; }
  .view { max-width: 1060px; margin: 0 auto; padding: 18px 20px 30px; }
  .view-narrow { max-width: 800px; }
  .appbar { padding: 10px 20px; }
  .archive-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; align-items: start; }
  .archive-grid .card { margin-bottom: 10px; }
  .capture-src { max-width: 560px; margin-left: auto; margin-right: auto; }
  .home-cta { max-width: 620px; margin-left: auto; margin-right: auto; }
  .recent-row { flex-wrap: wrap; }
  .recent-card { width: calc(33.333% - 14px); min-width: 200px; }
  /* Toast 下移，避开顶部导航 */
  #toast-root { top: calc(var(--topnav-h) + 14px); }
  /* 筛选改为居中弹窗 */
  .sheet-mask { align-items: center; padding: 20px; }
  .sheet { border-radius: 22px; padding-bottom: 16px; }
  .sheet .sheet-bar { display: none; }
}

/* 宽屏 ≥900px：详情页图文分栏 */
@media (min-width: 900px) {
  .detail-cols { display: grid; grid-template-columns: 360px 1fr; gap: 14px; align-items: start; }
  .detail-cols > .card, .detail-cols > .detail-photo { margin-bottom: 0; }
  .dc-left { position: sticky; top: 66px; align-self: start; }
}

/* AI 判题加载动画 */
.ai-judging {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 15px; font-weight: 700; color: var(--primary);
}
.ai-spinner {
  width: 20px; height: 20px; flex: none;
  border: 3px solid var(--primary-soft); border-top-color: var(--primary);
  border-radius: 50%; display: inline-block;
  animation: ai-spin .8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* 上传前自动处理提示图标 */
.pre-tips svg { width: 14px; height: 14px; flex: none; color: var(--primary); margin-top: 1px; }

/* 解析队列 */
.queue-card { margin-bottom: 12px; }
.queue-item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.queue-item:last-child { border-bottom: none; }
.queue-item > img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; background: #fff; border: 1px solid var(--border); }
.qi-ic { width: 52px; height: 52px; border-radius: 10px; flex: none; display: flex; align-items: center; justify-content: center; background: #fff; color: var(--text-3); border: 1px solid var(--border); }
.qi-ic svg { width: 20px; height: 20px; }
.qi-body { flex: 1; min-width: 0; }
.qi-t { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.queue-item .qi-t svg { width: 14px; height: 14px; flex: none; }
.qi-s { font-size: 11.5px; color: var(--text-2); line-height: 1.6; margin-top: 3px; }
.qi-ops { flex: none; display: flex; gap: 6px; align-items: center; }

/* 错题卡删除按钮 */
.q-card { position: relative; }
.q-del {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 26px; height: 26px; border: none; border-radius: 8px;
  background: rgba(0, 0, 0, .06); color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; transition: opacity .15s, background-color .15s, color .15s;
}
.q-card:hover .q-del { opacity: 1; }
.q-del:hover { background: var(--red); color: #fff; }
.q-del svg { width: 13px; height: 13px; }

/* 多选模式：复选框与顶栏文字按钮 */
.multi-chk {
  width: 22px; height: 22px; flex: none; margin-top: 2px; border-radius: 7px;
  border: 1.6px solid #C9CFE3; background: #fff; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s;
}
.multi-chk.on { background: var(--primary); border-color: var(--primary); box-shadow: 0 2px 6px rgba(79, 70, 229, .25); }
.multi-chk svg { width: 13px; height: 13px; }
.ab-txt { font-size: 13px; font-weight: 600; color: var(--primary); padding: 7px 10px; border-radius: 10px; flex: none; }
.ab-txt:hover { background: var(--primary-soft); }
