:root {
  --tim: #7c5cbf;
  --tim-dam: #5b3f99;
  --tim-nhat: #f3eefc;
  --tim-vien: #d9cdf2;
  --chu: #2d2640;
  --chu-phu: #6b6380;
  --dung: #1f8a4c;
  --dung-nen: #e6f6ec;
  --sai: #c0392b;
  --sai-nen: #fdecea;
  --vang-nen: #fff8e6;
  --vang-vien: #ecd59a;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--chu); background: #faf8fe; font-size: 16px; line-height: 1.55;
}
.zh { font-size: 1.12em; }
.topbar {
  background: var(--tim); color: #fff; padding: 10px 16px; display: flex; flex-wrap: wrap;
  align-items: center; gap: 4px 14px; position: sticky; top: 0; z-index: 10;
}
.brand { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; }
.logo { background: #fff; color: var(--tim); border-radius: 8px; width: 30px; height: 30px; display: grid; place-items: center; font-weight: 800; }
.sub { opacity: .9; font-size: .9rem; }
main { max-width: 820px; margin: 0 auto; padding: 16px 14px 40px; }
.loading { text-align: center; color: var(--chu-phu); padding: 40px 0; }
.foot { text-align: center; color: var(--chu-phu); font-size: .8rem; padding: 18px 10px 28px; }

h1 { font-size: 1.35rem; margin: 6px 0 4px; color: var(--tim-dam); }
.intro { color: var(--chu-phu); margin: 0 0 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.card {
  display: block; background: #fff; border: 1px solid var(--tim-vien); border-radius: 14px; padding: 14px;
  text-decoration: none; color: inherit; transition: transform .1s, box-shadow .1s;
}
.card:hover, .card:focus-visible { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(124,92,191,.15); outline: none; }
.card .so { font-size: .8rem; color: var(--tim); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.card .ten { font-size: 1.15rem; font-weight: 600; margin: 2px 0; }
.card .nghia { color: var(--chu-phu); font-size: .9rem; }
.card .socau { display: inline-block; margin-top: 8px; font-size: .78rem; background: var(--tim-nhat); color: var(--tim-dam); padding: 2px 8px; border-radius: 99px; }

.back { display: inline-block; margin-bottom: 8px; color: var(--tim-dam); text-decoration: none; font-weight: 600; }
.lesson-head { background: #fff; border: 1px solid var(--tim-vien); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.lesson-head p { margin: 4px 0 0; color: var(--chu-phu); font-size: .92rem; }

.section { background: #fff; border: 1px solid var(--tim-vien); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.section h2 { font-size: 1.02rem; margin: 0 0 10px; color: var(--tim-dam); border-bottom: 2px solid var(--tim-nhat); padding-bottom: 6px; }
.section h2 small { font-weight: 400; color: var(--chu-phu); }
.q { padding: 10px 0; border-top: 1px dashed var(--tim-vien); }
.q:first-of-type { border-top: 0; }
.q-title { margin: 0 0 8px; }
.q-num { display: inline-block; min-width: 28px; font-weight: 700; color: var(--tim); }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.opts.wide { grid-template-columns: 1fr; }
.opt {
  display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--tim-vien); border-radius: 10px;
  padding: 9px 10px; cursor: pointer; background: #fff; min-height: 44px; font: inherit; color: inherit; text-align: left;
}
.opt input { accent-color: var(--tim); width: 18px; height: 18px; flex: none; margin: 0; }
.opt.chon { border-color: var(--tim); background: var(--tim-nhat); }
.opt.dung { border-color: var(--dung); background: var(--dung-nen); }
.opt.sai { border-color: var(--sai); background: var(--sai-nen); }
.opt .chu-cai { font-weight: 700; color: var(--tim); }

.bank { background: var(--tim-nhat); border-radius: 10px; padding: 10px; margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; }
.bank span { font-size: 1.08rem; }
select.blank {
  font: inherit; font-size: 1.02rem; border: 1.5px solid var(--tim); border-radius: 8px; padding: 4px 6px;
  background: #fff; color: var(--chu); min-height: 38px; max-width: 100%; margin: 2px 4px; vertical-align: middle;
}
select.blank.dung { border-color: var(--dung); background: var(--dung-nen); }
select.blank.sai { border-color: var(--sai); background: var(--sai-nen); }

.hint { color: var(--chu-phu); font-style: italic; font-size: .92rem; }
.key-word { color: var(--sai); font-weight: 700; font-size: 1.08rem; }
textarea {
  width: 100%; font: inherit; font-size: 1.05rem; border: 1.5px solid var(--tim-vien); border-radius: 10px;
  padding: 8px 10px; min-height: 48px; resize: vertical; margin-top: 6px;
}
textarea:focus, select:focus { outline: 2px solid var(--tim); outline-offset: 1px; }
.pic-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: start; }
.pic-row img { width: 150px; height: auto; border-radius: 10px; display: block; }
@media (max-width: 420px) { .pic-row { grid-template-columns: 1fr; } .pic-row img { width: 170px; } }

.passage { background: var(--vang-nen); border: 1px solid var(--vang-vien); border-radius: 10px; padding: 10px 12px; margin: 4px 0 10px; }
.passage p { margin: 2px 0; font-size: 1.08rem; }
.tf { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.tf .opt { min-width: 110px; justify-content: center; }

.mau { margin-top: 6px; background: var(--dung-nen); border-left: 4px solid var(--dung); padding: 6px 10px; border-radius: 6px; font-size: .97rem; }
.ket-qua-cau { margin-top: 6px; font-size: .92rem; font-weight: 600; }
.ket-qua-cau.dung { color: var(--dung); }
.ket-qua-cau.sai { color: var(--sai); }

.actions { position: sticky; bottom: 0; background: linear-gradient(transparent, #faf8fe 30%); padding: 16px 0 10px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn {
  font: inherit; font-weight: 700; border: 0; border-radius: 12px; padding: 12px 22px; cursor: pointer; min-height: 46px;
  background: var(--tim); color: #fff; box-shadow: 0 3px 10px rgba(124,92,191,.3);
}
.btn:hover { background: var(--tim-dam); }
.btn.phu { background: #fff; color: var(--tim-dam); border: 1.5px solid var(--tim); box-shadow: none; }

.score {
  background: #fff; border: 2px solid var(--tim); border-radius: 14px; padding: 14px; margin-bottom: 14px; text-align: center;
}
.score .diem { font-size: 2rem; font-weight: 800; color: var(--tim-dam); }
.score p { margin: 4px 0; color: var(--chu-phu); }

.modal-nen { position: fixed; inset: 0; background: rgba(45,38,64,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; padding: 18px; max-width: 380px; width: 100%; text-align: center; }
.modal p { margin: 0 0 14px; }
.modal .nut { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.notfound { text-align: center; padding: 30px 0; }
