/* 刷题助手 — 移动端优先样式 */
/* 调色板来自 dataviz 参考调色板（浅色模式，已通过校验） */

:root {
  --bg: #f9f9f7;             /* 页面底色 */
  --surface: #fcfcfb;        /* 卡片面 */
  --ink: #0b0b0b;            /* 主文字 */
  --ink2: #52514e;           /* 次级文字 */
  --ink3: #898781;           /* 弱化文字 */
  --accent: #2a78d6;         /* 主色（单系列图表色） */
  --accent-strong: #1c5cab;  /* 主色深阶（选中态） */
  --accent-wash: #cde2fb;    /* 主色浅阶（选中底色） */
  --good: #0ca30c;           /* 状态色：正确 */
  --good-text: #006300;      /* 正确文字（深阶，保证对比度） */
  --bad: #d03b3b;            /* 状态色：错误 */
  --line: rgba(11, 11, 11, .10);
  --grid: #e1e0d9;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(11, 11, 11, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}
button { font-family: inherit; }
button:disabled { opacity: 1; cursor: default; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
.page { padding: 16px 16px 24px; }
.hidden { display: none !important; }

.page-header h1 { margin: 4px 0 0; font-size: 22px; }
.page-sub { margin: 2px 0 12px; font-size: 13px; color: var(--ink3); }

/* ============ 底部导航 ============ */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 560px; z-index: 50;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: none; cursor: pointer;
  padding: 8px 0 7px; font-size: 12px; color: var(--ink3);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab.active { color: var(--accent); font-weight: 600; }
.tab-icon { font-size: 20px; line-height: 1.2; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-tight { padding: 0 8px; font-size: 13px; gap: 4px; }
.btn-row { display: flex; gap: 10px; margin-bottom: 12px; }
.btn-row .btn { flex: 1; }
.link-btn {
  background: none; border: none; color: var(--accent);
  font-size: 13px; cursor: pointer; padding: 4px 6px;
}

/* ============ 表单 ============ */
.input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-size: 15px; color: var(--ink);
  font-family: inherit;
}
textarea.input { resize: vertical; line-height: 1.6; }
.input:focus { outline: 2px solid var(--accent-wash); border-color: var(--accent); }
.field-label { display: block; font-size: 13px; color: var(--ink2); margin: 12px 0 4px; font-weight: 600; }
.input-sm { min-height: 40px; font-size: 14px; }

/* ============ 卡片 ============ */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}

/* ============ 徽标 / 筛选chips ============ */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--ink2); font-size: 12px; line-height: 1.5;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 34px; padding: 0 14px; border-radius: 17px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink2); font-size: 13px; cursor: pointer;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ============ 刷题卡片 ============ */
.qcard-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.qnum { font-size: 13px; color: var(--ink3); }
.qstem { font-size: 17px; font-weight: 600; line-height: 1.65; margin-bottom: 14px; word-break: break-word; white-space: pre-wrap; }

.opt {
  display: flex; align-items: center; width: 100%; gap: 10px;
  min-height: 52px; padding: 10px 12px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; color: var(--ink);
  text-align: left; cursor: pointer;
}
.opt:active { transform: scale(.99); }
.opt-letter {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--ink2);
}
.opt-text { flex: 1; word-break: break-word; }
.opt-mark { flex: none; font-size: 16px; font-weight: 700; }
.opt.sel { border-color: var(--accent); background: var(--accent-wash); }
.opt.sel .opt-letter { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt.ok { border-color: var(--good); background: rgba(12, 163, 12, .08); }
.opt.ok .opt-letter { background: var(--good); border-color: var(--good); color: #fff; }
.opt.ok .opt-mark { color: var(--good-text); }
.opt.no { border-color: var(--bad); background: rgba(208, 59, 59, .08); }
.opt.no .opt-letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt.no .opt-mark { color: var(--bad); }
.opt:disabled { cursor: default; }
.opt:disabled:active { transform: none; }

.judge-row { display: flex; gap: 12px; }
.judge-btn {
  flex: 1; min-height: 64px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-size: 20px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.judge-btn.ok { border-color: var(--good); background: rgba(12, 163, 12, .08); color: var(--good-text); }
.judge-btn.no { border-color: var(--bad); background: rgba(208, 59, 59, .08); color: var(--bad); }

/* ============ 反馈区 ============ */
.feedback {
  border-left: 3px solid var(--line); background: rgba(11, 11, 11, .03);
  border-radius: 8px; padding: 12px; margin-top: 4px; font-size: 14px;
}
.feedback.ok { border-left-color: var(--good); background: rgba(12, 163, 12, .05); }
.feedback.wrong { border-left-color: var(--bad); background: rgba(208, 59, 59, .05); }
.fb-banner {
  font-size: 20px; font-weight: 700; line-height: 1.4;
  padding: 12px 14px; border-radius: 10px; text-align: center;
  margin-bottom: 10px;
  animation: fb-pop .3s ease-out;
}
.fb-banner.ok { background: rgba(12, 163, 12, .13); color: var(--good-text); }
.fb-banner.no { background: rgba(208, 59, 59, .11); color: var(--bad); }
.fb-banner.neutral { background: var(--bg); border: 1px dashed var(--line); color: var(--ink2); font-size: 15px; }
@keyframes fb-pop { from { transform: scale(.94); opacity: .4; } to { transform: none; opacity: 1; } }
.fb-answer { margin-top: 4px; }
.fb-answer b { font-weight: 700; }
.fb-analysis { margin-top: 6px; color: var(--ink2); white-space: pre-wrap; word-break: break-word; }
.fb-your { margin-top: 6px; color: var(--ink2); word-break: break-word; }
.next-row { margin-top: 14px; }

/* ============ 划重点 & 笔记 ============ */
.kw-remind {
  border-left: 3px solid #eda100; background: rgba(237, 161, 0, .12);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px;
}
.kw-remind-head { font-weight: 700; color: #8a5a00; cursor: pointer; font-size: 13px; }
.kw-remind-body { margin-top: 6px; }
.kw-line { padding: 2px 0; word-break: break-word; }
.kw-line.kw { background: rgba(237, 161, 0, .16); border-radius: 6px; padding: 6px 8px; }
.fb-notes { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.fb-notes-head { font-size: 13px; font-weight: 700; color: var(--ink2); }
.fb-notes-tip { font-weight: 400; color: var(--ink3); font-size: 12px; }
.kbd-hint { display: none; font-size: 12px; color: var(--ink3); text-align: center; margin-top: 12px; }

/* ============ 进度条 ============ */
.qprogress { height: 6px; background: var(--grid); border-radius: 3px; overflow: hidden; margin: 14px 0 4px; }
.qprogress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }
.qprogress-label { font-size: 12px; color: var(--ink3); text-align: center; }

/* ============ 成绩总结 ============ */
.score-hero { font-size: 48px; font-weight: 700; line-height: 1.1; }
.score-card { text-align: center; }
.score-sub { color: var(--ink2); font-size: 14px; }
.sum-wrong {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin-bottom: 8px; font-size: 14px;
}
.sum-wrong .sw-stem { word-break: break-word; }
.sum-wrong .sw-ans { margin-top: 4px; color: var(--good-text); font-weight: 600; word-break: break-word; }

/* ============ 题库列表 ============ */
.bank-summary { font-size: 13px; }
.qitem {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.qitem-top { display: flex; align-items: center; gap: 8px; }
.qitem-answer { font-size: 12px; color: var(--ink3); }
.qitem-stem { margin: 6px 0 4px; font-size: 15px; word-break: break-word; }
.qitem-meta { font-size: 12px; color: var(--ink3); }
.qitem-actions { display: flex; gap: 8px; margin-top: 8px; }
.qlist-note { font-size: 12px; color: var(--ink3); text-align: center; padding: 8px 0; }

/* ============ 空状态 ============ */
.empty { text-align: center; padding: 36px 16px; color: var(--ink2); }
.empty-icon { font-size: 44px; margin-bottom: 8px; }
.empty p { margin: 6px 0; font-size: 14px; }
.empty .btn { margin-top: 12px; }

/* ============ 统计 ============ */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.tile {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
}
.tile-label { font-size: 12px; color: var(--ink3); }
.tile-value { font-size: 24px; font-weight: 600; line-height: 1.3; }
.tile-note { font-size: 11px; color: var(--ink2); }

.day-chart { display: flex; align-items: flex-end; gap: 2px; height: 118px; padding: 8px 0 0; }
.day-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.day-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.day-bar { width: 100%; max-width: 18px; min-height: 4px; background: var(--accent); border-radius: 4px 4px 0 0; }
.day-col.sel .day-bar { background: var(--accent-strong); }
.day-label { font-size: 10px; color: var(--ink3); padding-top: 3px; }
.day-col.sel .day-label { color: var(--ink2); font-weight: 700; }
.chart-detail { margin-top: 8px; font-size: 13px; color: var(--ink2); text-align: center; min-height: 20px; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.detail-table th, .detail-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; font-variant-numeric: tabular-nums; }
.detail-table th { color: var(--ink3); font-weight: 600; }

/* ============ 设置 ============ */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: none; }
.switch-row .sw-label { font-size: 15px; }
.switch-row .sw-desc { font-size: 12px; color: var(--ink3); }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: var(--grid); border-radius: 14px; transition: .2s; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: .2s; }
.switch input:checked ~ .track { background: var(--accent); }
.switch input:checked ~ .thumb { left: 23px; }

.setting-group-title { font-size: 15px; font-weight: 700; margin: 18px 0 4px; }
.danger-zone { margin-top: 8px; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(11, 11, 11, .45); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 88vh;
  overflow-y: auto; border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  animation: slide-up .22s ease-out;
}
@keyframes slide-up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--ink3); cursor: pointer; padding: 4px; }
.modal-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.modal-tabs .chip { flex: 1; text-align: center; }
.format-help {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 13px; color: var(--ink2); white-space: pre-wrap;
  word-break: break-word; margin-bottom: 12px;
}
.preview-box { margin-top: 12px; }
.preview-count { font-size: 14px; font-weight: 700; }
.preview-errors { font-size: 13px; color: var(--bad); margin-top: 6px; }
.preview-sample { font-size: 13px; color: var(--ink2); margin-top: 6px; max-height: 120px; overflow-y: auto; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 12px 0; }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: 84px; z-index: 200;
  transform: translateX(-50%) translateY(10px);
  background: rgba(11, 11, 11, .88); color: #fff;
  padding: 10px 16px; border-radius: 20px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s;
  max-width: 85vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 两步确认按钮 */
.btn-confirming { background: var(--bad); border-color: var(--bad); color: #fff; }

/* ============ 桌面端（MacBook 等大屏）适配 ============ */
@media (min-width: 900px) {
  .app { max-width: 980px; padding-bottom: 110px; }
  .page { padding: 28px 28px 48px; }
  #quiz-root, #wrong-root { max-width: 760px; margin: 0 auto; }
  #bank-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  #bank-list .qitem { margin-bottom: 0; }
  #bank-list .qlist-note { grid-column: 1 / -1; }
  .tabbar {
    bottom: 20px; left: 50%; transform: translateX(-50%);
    width: auto; max-width: none;
    border-radius: 18px; border: 1px solid var(--line);
    box-shadow: 0 6px 24px rgba(11, 11, 11, .14);
    padding-bottom: 0;
  }
  .tab { flex: none; padding: 9px 30px 8px; }
  .modal-mask { align-items: center; }
  .modal-sheet { border-radius: 16px; margin: 24px; }
  .toast { bottom: 104px; }
  .kbd-hint { display: block; }
}
