/* ===== 广东电网安规题库刷题 · 样式 ===== */
:root {
  --primary: #1a6dff;         /* 电网蓝 */
  --primary-dark: #0a52d0;
  --primary-light: #e8f0ff;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #17203a;
  --muted: #8a92a8;
  --border: #e6e9f2;
  --success: #16a34a;
  --success-bg: #e7f6ec;
  --danger: #e11d48;
  --danger-bg: #fdecef;
  --warning: #f59e0b;
  --key: #ff6b00;
  --key-bg: #fff1e6;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(23, 32, 58, .06);
  --nav-h: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 28px + var(--safe-bottom)); min-height: 100vh; }
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ===== 底部导航 ===== */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  display: flex; height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: #fff; border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(23,32,58,.08);
}
.bottom-nav .nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: 11px; cursor: pointer;
}
.bottom-nav .nav-item.active { color: var(--primary); }
.bottom-nav .nav-icon { font-size: 22px; line-height: 1; }

/* ===== 通用卡片/按钮 ===== */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; line-height: 1.5; }
.tag-diff-易 { background: #e7f6ec; color: #16a34a; }
.tag-diff-适中 { background: #fff7e0; color: #b8860b; }
.tag-diff-难 { background: #fdecef; color: #e11d48; }
.tag-key { background: var(--key-bg); color: var(--key); }
.tag-type { background: var(--primary-light); color: var(--primary); }
.tag-case { background: #f0e9ff; color: #7c3aed; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 12px; padding: 13px 18px; font-size: 16px; font-weight: 600;
  cursor: pointer; transition: transform .05s, opacity .2s; width: 100%;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-sm { padding: 9px 14px; font-size: 14px; width: auto; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ===== 首页 ===== */
.page-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 14px; }
.page-head h1 { font-size: 20px; margin: 0; }
.page-title { font-size: 18px; font-weight: 700; margin: 4px 0 14px; }

.hero { background: linear-gradient(135deg, var(--primary), #3b8bff); color: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.hero .big { font-size: 30px; font-weight: 800; }
.hero .row { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 12px; }
.hero .pct { font-size: 40px; font-weight: 800; line-height: 1; }

.progress { height: 8px; background: rgba(255,255,255,.28); border-radius: 6px; overflow: hidden; margin: 10px 0 6px; }
.progress > i { display: block; height: 100%; background: #fff; border-radius: 6px; transition: width .3s; }
.progress.blue > i { background: var(--primary); }
.progress.thin { height: 6px; }
.bar-track { height: 8px; background: #eef1f8; border-radius: 6px; overflow: hidden; }
.bar-track > i { display: block; height: 100%; background: var(--primary); border-radius: 6px; transition: width .3s; }
.bar-track > i.green { background: var(--success); }
.bar-track > i.orange { background: var(--warning); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-cell { text-align: center; padding: 14px 10px; }
.stat-cell .num { font-size: 24px; font-weight: 800; color: var(--primary); }
.stat-cell .lbl { font-size: 13px; color: var(--muted); margin-top: 2px; }

.type-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.type-row:last-child { border-bottom: none; }
.type-row .tname { width: 46px; font-weight: 700; flex-shrink: 0; }
.type-row .bar-wrap { flex: 1; }
.type-row .tmeta { width: 74px; text-align: right; font-size: 12px; color: var(--muted); flex-shrink: 0; }

.menu-list { display: grid; gap: 12px; }
.menu-list .btn { text-align: left; justify-content: flex-start; }
.menu-card { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); cursor: pointer; }
.menu-card .ico { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.menu-card .info { flex: 1; }
.menu-card .info b { font-size: 16px; display: block; }
.menu-card .info span { font-size: 12px; color: var(--muted); }
.menu-card .arrow { color: var(--muted); }

/* ===== 刷题页 ===== */
.quiz-top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.quiz-top .back { font-size: 22px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 10px; box-shadow: var(--shadow); cursor: pointer; color: var(--text); }
.quiz-top .count { flex: 1; text-align: center; font-weight: 700; font-size: 15px; }
.quiz-top .count .small { color: var(--muted); font-weight: 400; font-size: 13px; }
.quiz-top .icon-btn { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 10px; box-shadow: var(--shadow); cursor: pointer; font-size: 18px; color: var(--muted); }
.quiz-top .icon-btn.faved { color: var(--danger); }

.meta-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.case-box { background: #fbf7ff; border: 1px solid #eadcff; border-radius: 12px; margin-bottom: 14px; overflow: hidden; }
.case-box .case-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; font-weight: 700; font-size: 14px; color: #6d28d9; cursor: pointer; user-select: none; }
.case-box .case-body { padding: 0 14px 13px; font-size: 14px; color: #4c3a66; white-space: pre-wrap; border-top: 1px dashed #eadcff; padding-top: 11px; display: none; }
.case-box.open .case-body { display: block; }
.case-box .case-toggle { font-size: 12px; color: #7c3aed; font-weight: 600; }

.q-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.q-stem { font-size: 17px; font-weight: 600; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.q-type-badge { display: inline-block; background: var(--primary-light); color: var(--primary); font-size: 12px; padding: 2px 8px; border-radius: 6px; margin-bottom: 8px; }

.opt {
  display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px; margin-top: 10px;
  border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; transition: all .12s;
  background: #fff; font-size: 15px; line-height: 1.55;
}
.opt:active { transform: scale(.99); }
.opt .key { width: 26px; height: 26px; border-radius: 50%; background: #eef1f8; color: var(--text); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; margin-top: 2px; }
.opt .otxt { flex: 1; word-break: break-word; }
.opt.selected { border-color: var(--primary); background: var(--primary-light); }
.opt.selected .key { background: var(--primary); color: #fff; }
.opt.correct { border-color: var(--success); background: var(--success-bg); }
.opt.correct .key { background: var(--success); color: #fff; }
.opt.wrong { border-color: var(--danger); background: var(--danger-bg); }
.opt.wrong .key { background: var(--danger); color: #fff; }
.opt.disabled { pointer-events: none; }
.opt .mark { margin-left: 6px; font-weight: 700; }

.explain { background: #f0f6ff; border-left: 4px solid var(--primary); border-radius: 10px; padding: 13px 14px; margin-top: 14px; font-size: 14px; line-height: 1.7; }
.explain b { color: var(--primary); }
.explain .basis { color: #3a4560; white-space: pre-wrap; }
.result-banner { text-align: center; padding: 10px; border-radius: 10px; font-size: 16px; font-weight: 700; margin-top: 14px; }
.result-banner.ok { background: var(--success-bg); color: var(--success); }
.result-banner.no { background: var(--danger-bg); color: var(--danger); }

.quiz-nav { display: flex; gap: 10px; margin-top: 14px; }
.quiz-nav .btn { flex: 1; }

/* 答题卡 */
.sheet-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: none; align-items: flex-end; justify-content: center; }
.sheet-mask.show { display: flex; }
.sheet { background: #fff; width: 100%; max-width: 720px; max-height: 78vh; border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + var(--safe-bottom)); overflow-y: auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head b { font-size: 17px; }
.sheet-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.sheet-grid .cell { aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; cursor: pointer; background: #fff; }
.sheet-grid .cell.done-ok { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.sheet-grid .cell.done-no { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.sheet-grid .cell.current { box-shadow: 0 0 0 2px var(--primary); }
.sheet-legend { display: flex; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.sheet-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.lg-undone { background: #fff; border: 1px solid var(--border); }
.lg-ok { background: var(--success-bg); }
.lg-no { background: var(--danger-bg); }

/* ===== 考试 ===== */
.exam-timer { position: sticky; top: 0; z-index: 50; background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.exam-timer .clock { font-size: 20px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.exam-timer.warn .clock { color: var(--danger); }

.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.setting-row .lbl { font-size: 15px; }
.setting-row .lbl small { display: block; color: var(--muted); font-size: 12px; }

/* switch */
.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #d6dbe6; border-radius: 28px; transition: .2s; cursor: pointer; }
.switch .slider:before { content: ""; position: absolute; height: 22px; width: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* 筛选 */
.filter-panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.filter-panel .fgroup { margin-bottom: 12px; }
.filter-panel .flabel { font-size: 13px; color: var(--muted); margin-bottom: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 14px; border-radius: 20px; border: 1px solid var(--border); font-size: 14px; cursor: pointer; background: #fff; color: var(--text); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 列表 */
.item-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.item-row:last-child { border-bottom: none; }
.item-row .info { flex: 1; min-width: 0; }
.item-row .info .stem { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-row .badge { flex-shrink: 0; }
.wrong-count { display: inline-block; min-width: 22px; text-align: center; background: var(--danger-bg); color: var(--danger); border-radius: 8px; font-size: 12px; padding: 2px 6px; font-weight: 700; }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; font-size: 15px; }
.empty .big { font-size: 44px; margin-bottom: 8px; }

/* 桌面端微调 */
@media (min-width: 720px) {
  body { font-size: 16px; }
  .sheet-grid { grid-template-columns: repeat(10, 1fr); }
}
