/* wrong-book · 全局样式
   风格：学习类清新（米白底 + 墨蓝主色 + 柔和绿强调），Mobile-first，底部固定 Tab
   约定：零外部依赖，无 CDN，图表用纯 CSS 条形 + 内联 SVG */

:root {
  --bg: #faf7f0;
  --card: #ffffff;
  --ink: #2c4a6e;
  --ink-2: #5c7290;
  --ink-3: #8b9bb0;
  --line: #e8e2d6;
  --line-2: #f1ece2;
  --accent: #7ba87b;
  --accent-ink: #476b47;
  --accent-soft: #e9f1e9;
  --warn: #c9744a;
  --warn-soft: #fbeee7;
  --danger: #b4524e;
  --danger-soft: #fbecec;
  --radius: 12px;
  --radius-sm: 8px;
  --tab-h: 58px;
  --shadow: 0 1px 3px rgba(44, 74, 110, .06), 0 6px 18px rgba(44, 74, 110, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

a { color: var(--ink); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
img { display: block; max-width: 100%; }

/* ---------- 布局骨架 ---------- */
.wrap {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px calc(var(--tab-h) + 28px);
}
.wrap--nobar { padding-bottom: 32px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  background: linear-gradient(180deg, var(--bg) 72%, rgba(250, 247, 240, .86));
  backdrop-filter: blur(6px);
}
.topbar .back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: -6px;
  border-radius: 50%;
  color: var(--ink);
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 16px;
  flex: 0 0 auto;
}
.topbar h1 { font-size: 17px; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .act { font-size: 13px; color: var(--ink-2); flex: 0 0 auto; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card--flat { box-shadow: none; }
.card__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 10px;
}
.card__title .more { font-size: 12px; font-weight: 400; color: var(--ink-3); }

/* ---------- 数字卡 ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat__num { font-size: 22px; font-weight: 600; line-height: 1.2; color: var(--ink); }
.stat__num.is-due { color: var(--warn); }
.stat__label { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--ghost { background: transparent; }
.btn--danger { background: var(--danger-soft); border-color: #f0d6d5; color: var(--danger); }
.btn--block { width: 100%; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 0; min-width: 0; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 72px; resize: vertical; }
select.input { appearance: none; background-image: none; }

/* 片状选择器（学科 / 复习预设 / 状态筛选） */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.chip.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---------- 列表 ---------- */
.qitem {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.qitem__thumb {
  width: 62px;
  height: 62px;
  flex: 0 0 62px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--line-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  font-size: 11px;
}
/* 缩略图按顶部裁切：题目照片的有效信息（题号、题干开头）在顶部，
   居中裁切会把最上面那段切掉 */
.qitem__thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.qitem__body { flex: 1 1 auto; min-width: 0; }
.qitem__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.qitem__meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--ink-3); }
.qitem__due { font-variant-numeric: tabular-nums; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.7;
  background: var(--line-2);
  color: var(--ink-2);
}
.badge--subject { background: #eaf0f7; color: #4a6a92; }
.badge--tag { background: var(--accent-soft); color: var(--accent-ink); }
.badge--mastered { background: var(--accent-soft); color: var(--accent-ink); }
.badge--due { background: var(--warn-soft); color: var(--warn); }
.badge--muted { background: var(--line-2); color: var(--ink-3); }

/* ---------- 空状态 / 提示 ---------- */
.empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty__icon { font-size: 26px; margin-bottom: 8px; }

.note {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
  margin-bottom: 12px;
}
.note--warn { background: var(--warn-soft); color: var(--warn); }
.note--danger { background: var(--danger-soft); color: var(--danger); }
.note:empty { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + 20px);
  transform: translateX(-50%);
  z-index: 60;
  max-width: 86vw;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(44, 74, 110, .94);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
}
.toast.is-on { opacity: 1; }

/* ---------- 图片预览 ---------- */
.photo {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--line-2);
  min-height: 160px;
  object-fit: contain;
}

/* ---------- 上传选择区 ---------- */
.picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 150px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 14px;
  cursor: pointer;
  overflow: hidden;
}
.picker img { width: 100%; max-height: 260px; object-fit: contain; }
.picker__hint { font-size: 12px; color: var(--accent-ink); opacity: .8; }

/* ---------- 图表（纯 CSS + SVG） ---------- */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar { display: grid; grid-template-columns: 52px 1fr 34px; gap: 8px; align-items: center; font-size: 12px; }
.bar__name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar__track { height: 12px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 999px; background: var(--accent); min-width: 3px; transition: width .3s ease; }
.bar__val { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring { flex: 0 0 108px; width: 108px; height: 108px; }
.ring__legend { flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--ink-2); }
.ring__legend div { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }

.spark { width: 100%; height: auto; display: block; }
.spark__axis { font-size: 10px; fill: var(--ink-3); }

/* ---------- 底部 Tab ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: var(--tab-h);
  display: flex;
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar__item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--ink-3);
}
.tabbar__item svg { width: 22px; height: 22px; }
.tabbar__item.is-on { color: var(--ink); font-weight: 600; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 14px 0 4px; }
.pager__info { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- 家长分享页 ---------- */
.share-hero {
  background: linear-gradient(135deg, #eef3f9, #e9f1e9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.share-hero h2 { font-size: 17px; margin-bottom: 4px; }
.share-hero p { margin: 0; font-size: 13px; color: var(--ink-2); }

@media (min-width: 600px) {
  .wrap { padding-left: 20px; padding-right: 20px; }
}
