:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --ink: #1F2328;
  --ink-2: #5B6470;
  --ink-3: #8B949E;
  --line: #E6E8EB;
  --accent: #2F6FE0;
  --accent-weak: #EAF1FD;
  --ok: #17936B;
  --ok-weak: #E4F5EE;
  --warn: #D9822B;
  --warn-weak: #FDF1E3;
  --danger: #D0473F;
  --danger-weak: #FBECEB;
  --radius: 14px;
  --tabbar-h: 58px;
  font-synthesis-weight: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body { overscroll-behavior-y: none; }

.hidden { display: none !important; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 32px);
}

.view { padding-top: 14px; animation: fade .18s ease-out; }

@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h1 { font-size: 22px; font-weight: 600; margin: 4px 0 2px; letter-spacing: -.2px; }
h2 { font-size: 17px; font-weight: 600; margin: 22px 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
p  { margin: 0 0 10px; }
.sub { color: var(--ink-2); font-size: 14px; }
.tiny { color: var(--ink-3); font-size: 13px; }

.topbar {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar .who { font-size: 15px; color: var(--ink-2); }
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 10px;
}
.icon-btn:active { background: var(--line); }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--line);
}

.hero {
  background: linear-gradient(180deg, #EEF4FE 0%, #FFFFFF 100%);
  border: 1px solid #D9E5FA;
}
.hero .count { font-size: 40px; font-weight: 600; line-height: 1.1; color: var(--accent); letter-spacing: -1px; }
.hero .label { font-size: 15px; color: var(--ink-2); }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  font-family: inherit;
  padding: 12px 16px;
  cursor: pointer;
  transition: opacity .12s;
}
.btn:active { opacity: .82; }
.btn[disabled] { opacity: .45; }
.btn.ghost { background: var(--surface); color: var(--accent); border: 1px solid #C9DCF8; }
.btn.plain { background: transparent; color: var(--ink-2); border: 1px solid var(--line); font-size: 16px; font-weight: 500; }
.btn.ok { background: var(--ok); }
.btn.danger { background: var(--danger); }
.btn.sm { min-height: 42px; font-size: 15px; border-radius: 11px; }

.btn-xl {
  min-height: 108px;
  font-size: 22px;
  flex-direction: column;
  gap: 4px;
  border-radius: 18px;
}
.btn-xl .hint { font-size: 13px; font-weight: 400; opacity: .85; }

.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search], input[type=datetime-local], textarea, select {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid #C9DCF8; outline-offset: -1px; }
textarea { min-height: 88px; resize: vertical; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}
.chip.on { background: var(--accent-weak); border-color: #B9D2F7; color: var(--accent); font-weight: 600; }

.tabs { display: flex; gap: 4px; background: #EDEFF2; border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 10px 6px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink-2);
  cursor: pointer;
}
.tabs button.on { background: var(--surface); color: var(--ink); font-weight: 600; }

#tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 30;
}
#tabbar button {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  padding: 0;
}
#tabbar button.on { color: var(--accent); font-weight: 600; }
#tabbar .badge {
  display: inline-block;
  min-width: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--danger);
  margin-left: 3px;
}

.shot {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #FAFAFB;
  display: block;
}
.shot.thumb { width: 72px; height: 72px; object-fit: cover; flex: 0 0 auto; }

.mistake-item { display: flex; gap: 12px; align-items: flex-start; }
.mistake-item .meta { flex: 1; min-width: 0; }
.mistake-item .kp { font-size: 16px; font-weight: 600; margin-bottom: 3px; }
.mistake-item .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #F1F3F5;
  color: var(--ink-2);
}
.tag.blue { background: var(--accent-weak); color: var(--accent); }
.tag.green { background: var(--ok-weak); color: var(--ok); }
.tag.amber { background: var(--warn-weak); color: var(--warn); }
.tag.red { background: var(--danger-weak); color: var(--danger); }

.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #DDE1E6; }
.dot.on { background: var(--ok); }

.empty { text-align: center; color: var(--ink-3); padding: 40px 16px; font-size: 15px; }

.banner {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 12px;
}
.banner.info { background: var(--accent-weak); color: #1B4C9E; }
.banner.warn { background: var(--warn-weak); color: #8A5210; }
.banner.err  { background: var(--danger-weak); color: #9A2F29; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner.dark { border-color: #C9DCF8; border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 20px);
  transform: translateX(-50%);
  background: rgba(31, 35, 40, .94);
  color: #fff;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: 999px;
  max-width: 88vw;
  text-align: center;
  z-index: 60;
  transition: opacity .2s;
}

.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 26, .7);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.sheet-mask img { max-width: 100%; max-height: 88vh; border-radius: 10px; }

.review-stage { min-height: 52vh; }

.explain {
  white-space: pre-wrap;
  background: #F7F9FC;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  margin-top: 10px;
}

.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-weight: 600; }

.bar { height: 8px; border-radius: 4px; background: #EDEFF2; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.login-wrap { max-width: 420px; margin: 6vh auto 0; }
.brand { text-align: center; margin-bottom: 26px; }
.brand .mark {
  width: 62px; height: 62px; border-radius: 18px;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 600; margin-bottom: 12px;
}
.brand h1 { font-size: 24px; }

/* ---- 删除按钮 ---- */
.del-btn {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 13px;
  font-family: inherit;
  padding: 6px 9px;
  border-radius: 8px;
  margin: -2px -4px 0 0;
  cursor: pointer;
  flex: 0 0 auto;
  align-self: flex-start;
}
.del-btn:active { background: #F1F3F5; }
.del-btn.armed { background: var(--danger-weak); color: var(--danger); font-weight: 600; }
.del-btn[disabled] { opacity: .5; }

/* ---- 裁剪全屏层 ---- */
.crop-sheet {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: #1A1C20;
  display: flex;
  flex-direction: column;
}
.crop-sheet.hidden { display: none !important; }
.crop-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 6px;
  padding-top: calc(10px + env(safe-area-inset-top));
  color: #C6CCD4;
}
.crop-top .icon-btn { color: #C6CCD4; font-size: 15px; }
.crop-title { font-size: 15px; font-weight: 600; color: #FFFFFF; }
.crop-stage { flex: 1; overflow: hidden; min-height: 0; }
.crop-stage img { display: block; max-width: 100%; }
.crop-actions {
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
}
.crop-actions > * { flex: 1; }
.crop-actions .btn.plain { background: #2A2D33; color: #C6CCD4; border-color: #3A3E45; }

/* ---- 出题练习 ---- */
.q-card { font-size: 17px; line-height: 1.75; white-space: pre-wrap; }
.res-item { margin-bottom: 12px; }
.res-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.res-ans { font-size: 14px; margin-top: 6px; white-space: pre-wrap; }

/* ---- 录入：一图多题，逐题一张卡 ---- */
.cap-item { margin-bottom: 12px; }
.cap-item h3 { margin-bottom: 8px; }
.cap-item textarea { min-height: 96px; }
.cap-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.cap-item-head b { font-size: 15px; }

/* ---- 选择题点选 ---- */
.opt-btn {
  text-align: left;
  font-size: 16px;
  line-height: 1.6;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  white-space: pre-wrap;
}
.opt-btn:active { background: #F4F7FC; }
.opt-btn.on { border-color: var(--accent); background: var(--accent-weak); font-weight: 600; }

/* ---- 练习记录 ---- */
.hist-item { cursor: pointer; }
.hist-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }

/* 没有照片的错题（练习错题入本）：文字缩略块 */
.txt-thumb {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: #F4F7FC;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
}
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
#practiceTabs { margin: 4px 0 18px; }
.score { font-size: 38px; font-weight: 600; color: var(--accent); line-height: 1.2; letter-spacing: -1px; }

.support-qr { display:block; width:min(100%,280px); height:auto; margin:18px auto; border-radius:12px; }
.support-dialog { max-width:380px; max-height:88vh; overflow:auto; }
.support-dialog h2 { margin-top:0; }
details { margin:12px 0; }
summary { color:var(--accent); cursor:pointer; min-height:40px; padding:8px 0; }
button:focus-visible,a:focus-visible,summary:focus-visible { outline:3px solid #8bb8ff; outline-offset:3px; }
button { touch-action:manipulation; }
.q-card,.explain,.meta { overflow-wrap:anywhere; }
.divider { border:0; border-top:1px solid var(--line); margin:24px 0; }
.admin-header { display:flex; justify-content:space-between; align-items:center; max-width:1100px; margin:auto; padding:22px 20px; }
.admin-brand { color:var(--accent); font-size:19px; font-weight:700; text-decoration:none; }
.admin-main { max-width:1100px; padding-bottom:40px; }
.admin-login { max-width:420px; margin:8vh auto 0; }
.admin-heading { display:flex; justify-content:space-between; align-items:center; gap:16px; margin:16px 0; }
.admin-toolbar { display:grid; grid-template-columns:2fr 1fr auto; gap:14px; align-items:end; }
.admin-toolbar .field { margin:0; }
.admin-user { display:flex; justify-content:space-between; gap:16px; text-align:left; width:100%; cursor:pointer; font:inherit; color:inherit; }
.admin-user strong { margin-right:12px; }
.admin-user p { margin:5px 0; }
.admin-user-stats { min-width:84px; display:flex; flex-direction:column; align-items:flex-end; justify-content:center; gap:4px; }
.admin-user-stats b { color:var(--accent); font-size:24px; }
.admin-pagination { max-width:340px; margin:20px auto; }
.admin-profile-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin-top:16px; overflow-wrap:anywhere; }
.admin-stats { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.admin-stats b { font-size:26px; color:var(--accent); display:block; margin-top:6px; }
.admin-photo { display:block; max-width:100%; max-height:320px; margin:12px 0; border-radius:10px; }
@media (max-width:560px) {
  .admin-toolbar { grid-template-columns:1fr 1fr; }
  .admin-toolbar .field:first-child { grid-column:1/-1; }
  .admin-profile-grid,.admin-stats { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .admin-heading { align-items:flex-start; flex-direction:column; }
  .admin-user { gap:6px; }
  .admin-user .tiny { max-width:220px; }
  #loginTabs button { font-size:13px; padding:10px 3px; }
  .mistake-item { flex-wrap:wrap; }
  .mistake-item .meta { min-width:130px; }
}
@media (prefers-reduced-motion:reduce) { .view { animation:none; } }
