:root {
  --bg: #eef1f6;
  --card: #fff;
  --text: #24292f;
  --muted: #6b7280;
  --primary: #3b6ef5;
  --ok: #16a34a;
  --ok-bg: #e8f8ee;
  --bad: #dc2626;
  --bad-bg: #fdecec;
  --border: #dde2ea;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 16px;
}
.screen { display: none; max-width: 860px; margin: 0 auto; }
.screen.active { display: block; }
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
  margin-bottom: 16px;
}
.center { text-align: center; }
h1 { font-size: 1.6rem; margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.hidden { display: none !important; }

button {
  font: inherit;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform .05s, background .15s;
}
button:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--primary); color: #fff; }
.primary:hover { background: #2c5be0; }
.secondary { background: #e5e9f2; color: var(--text); }
.secondary:hover { background: #d8deea; }
.danger { background: var(--bad); color: #fff; }
.big { width: 100%; padding: 14px; font-size: 1.1rem; margin-top: 8px; }

.field { margin: 18px 0; }
.field > label { display: block; font-weight: bold; margin-bottom: 8px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chips button {
  background: #f3f5f9;
  border: 2px solid var(--border);
  flex: 1;
  min-width: 120px;
}
.chips button small { display: block; color: var(--muted); font-size: .8rem; }
.chips button.sel { border-color: var(--primary); background: #eaf0ff; }
#btn-start-wrong { width: 100%; margin-top: 6px; }

.topbar {
  display: flex; justify-content: space-between;
  font-weight: bold; padding: 4px 4px 8px;
}
.progress { height: 6px; background: #d9dee8; border-radius: 3px; margin-bottom: 14px; overflow: hidden; }
#progress-bar { height: 100%; background: var(--primary); width: 0; transition: width .2s; }

.qno { color: var(--primary); font-weight: bold; margin-bottom: 6px; }
.qtext { font-size: 1.12rem; margin-bottom: 14px; }
.qimg {
  display: block; max-width: 100%; max-height: 460px;
  margin: 0 auto 16px; border-radius: 8px; border: 1px solid var(--border);
  cursor: zoom-in;
}
.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px;
  text-align: left; background: #f6f7fa;
  border: 2px solid transparent; padding: 12px 14px;
}
.opt:hover:not(:disabled) { background: #ecf0f8; }
.opt .letter {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: #fff; border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: bold;
}
.opt.chosen { border-color: var(--primary); background: #eaf0ff; }
.opt.correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt:disabled { opacity: 1; cursor: default; color: var(--text); }

.feedback { margin-top: 14px; padding: 10px 14px; border-radius: 10px; font-weight: bold; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }

.nav { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.nav button { min-width: 130px; }

.palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.palette button {
  width: 38px; height: 34px; padding: 0; font-size: .85rem;
  background: #f0f2f6; border: 2px solid transparent;
}
.palette button.answered { background: #cfdcff; }
.palette button.p-ok { background: #bfe9cf; }
.palette button.p-bad { background: #f6c4c4; }
.palette button.current { border-color: var(--text); }

.big-score { font-size: 3rem; font-weight: bold; color: var(--primary); }
.filter { margin: 0 4px 12px; }
.review-item { border-left: 5px solid var(--ok); }
.review-item.bad { border-left-color: var(--bad); }
.review-item .opt { cursor: default; }

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 10; cursor: zoom-out;
}
.lightbox img { max-width: 96vw; max-height: 94vh; background: #fff; border-radius: 6px; }

@media (max-width: 600px) {
  body { padding: 8px; }
  .card { padding: 16px; }
  .nav button { flex: 1; min-width: 0; }
}


/* ---------- 題庫背誦 ---------- */
.bank-entry { width: 100%; margin-top: 10px; }
.bank-toolbar { position: sticky; top: 0; z-index: 5; }
.bank-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.bank-head h2 { margin: 0; }
#bank-search {
  width: 100%; margin: 12px 0 8px; padding: 10px 14px; font: inherit;
  border: 2px solid var(--border); border-radius: 10px; outline: none;
}
#bank-search:focus { border-color: var(--primary); }
.bank-opts { display: flex; flex-direction: column; gap: 4px; }
.bank-opts label { cursor: pointer; }
.bank-item .qtext { margin-bottom: 10px; }
.bank-item .options { gap: 6px; }
.bank-item .opt { padding: 8px 12px; cursor: default; }
.bank-item .opt.correct { font-weight: bold; }
.bank-answer {
  padding: 10px 14px; border-radius: 10px; background: var(--ok-bg);
  color: var(--ok); font-weight: bold; border: 2px solid var(--ok);
}
.bank-item.masked { cursor: pointer; }
.bank-item.masked .opt.correct { border-color: transparent; background: #f6f7fa; font-weight: normal; }
.bank-item.masked .bank-answer { color: transparent; background: #e5e9f2; border-color: #e5e9f2; user-select: none; }
.bank-item.masked .bank-answer::after { content: "（點一下顯示答案）"; color: var(--muted); font-weight: normal; }
.bank-item.masked .bank-answer span { display: none; }
mark { background: #fff1a8; padding: 0 2px; border-radius: 3px; }
.to-top {
  position: fixed; right: 18px; bottom: 18px; width: 46px; height: 46px;
  border-radius: 50%; padding: 0; font-size: 1.3rem; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

/* ---------- 題庫切換 / 課程考題 ---------- */
.bank-tabs { display: flex; gap: 10px; margin: 6px 0 4px; flex-wrap: wrap; }
.bank-tabs button {
  flex: 1; min-width: 180px; padding: 14px; font-size: 1.05rem; font-weight: bold;
  background: #f3f5f9; border: 2px solid var(--border);
}
.bank-tabs button small { display: block; font-weight: normal; color: var(--muted); font-size: .82rem; }
.bank-tabs button.sel { border-color: var(--primary); background: #eaf0ff; color: var(--primary); }
.bank-scope { margin-top: 12px; }
.bank-scope button { min-width: 100px; padding: 6px 10px; font-size: .9rem; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.badge {
  font-size: .78rem; padding: 2px 8px; border-radius: 999px;
  background: #eef1f6; color: var(--muted);
}
.badge.new { background: #fff1d6; color: #b45309; }
.badge.warn { background: #fdecec; color: var(--bad); font-weight: bold; }
.tip { margin-top: 10px; font-size: .92rem; color: #8a6d1d; background: #fff9e6; padding: 8px 12px; border-radius: 8px; }
.conflict { margin-top: 10px; font-size: .93rem; color: #9a3412; background: #fff7ed; border: 1.5px solid #fdba74; padding: 10px 14px; border-radius: 8px; white-space: pre-line; font-weight: normal; line-height: 1.65; }
.opt.alt-ans { border-color: #f59e0b; background: #fffbeb; }
.tag-ans { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 6px; font-size: .78rem; font-weight: bold; }
.tag-ans.ok-tag { background: var(--ok); color: #fff; }
.tag-ans.alt-tag { background: #f59e0b; color: #fff; }
.bank-item.masked .opt.alt-ans { border-color: transparent; background: #f6f7fa; }
.bank-item.masked .tag-ans { display: none; }
details.expl { margin-top: 12px; background: #f6f8fc; border-radius: 10px; padding: 8px 12px; }
details.expl summary { cursor: pointer; font-weight: bold; color: var(--primary); }
details.expl .expl-body { white-space: pre-line; font-size: .93rem; margin-top: 8px; line-height: 1.7; }
.feedback .ans-note { font-weight: normal; margin-left: 6px; }
.bank-item.masked details.expl,
.bank-item.masked .conflict { display: none; }
.bank-item.masked .opt.correct .letter { font-size: 0; }
.bank-item.masked .opt.correct .letter::after { content: attr(data-l); font-size: 1rem; }
