/* =============== Phòng Thí Nghiệm Ảo KHTN — giao diện chung =============== */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #16203a;
  --muted: #5a6478;
  --line: #e2e7f0;
  --primary: #1f4fd1;
  --primary-dark: #163a9c;
  --primary-soft: #e9efff;
  --accent: #f59e0b;
  --ok: #15803d;
  --ok-soft: #e6f6ec;
  --bad: #c62828;
  --bad-soft: #fdecec;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 6px 20px rgba(20, 30, 60, .06);
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 17px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.55; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.an { display: none !important; }

/* ---------- Thanh đầu trang ---------- */
.site-head { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.site-head .wrap { display: flex; align-items: center; gap: 16px; min-height: 68px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); margin-right: auto; }
.logo-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; background: linear-gradient(135deg, #2b5ce6, #6f3fe0); color: #fff; box-shadow: 0 4px 12px rgba(43, 92, 230, .3); }
.logo b { display: block; font-size: 1.1rem; line-height: 1.2; }
.logo small { display: block; color: var(--muted); font-size: .8rem; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 600; padding: 9px 14px; border-radius: 10px; font-size: .95rem; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.dang-chon { background: var(--primary-soft); color: var(--primary); }

.site-foot { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .88rem; margin-top: 40px; }
.site-foot .wrap { padding: 18px 20px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Nút ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; padding: 11px 18px; font-weight: 700; cursor: pointer; text-decoration: none; font-size: .95rem; transition: background .15s, transform .05s, box-shadow .15s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-chinh { background: var(--primary); color: #fff; }
.btn-chinh:hover { background: var(--primary-dark); }
.btn-phu { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-phu:hover { border-color: #c5cede; background: #fafbfe; }
.btn-xanh { background: var(--ok); color: #fff; }
.btn-xanh:hover { background: #106532; }
.btn-do { background: var(--bad); color: #fff; }
.btn-lon { padding: 14px 24px; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Thẻ / khung ---------- */
.the { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.nhan { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.tieu-de-muc { font-size: 1.5rem; margin: 0 0 4px; }
.mo-ta { color: var(--muted); margin: 0; }

/* ---------- Trang chủ ---------- */
.hero { padding: 34px 0 10px; }
.hero h1 { font-size: clamp(1.6rem, 3vw, 2.3rem); margin: 0 0 6px; letter-spacing: -.02em; }
.hero p { color: var(--muted); margin: 0; font-size: 1.05rem; }
.thong-ke { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.thong-ke .nhan { background: var(--surface); border: 1px solid var(--line); font-size: .85rem; padding: 6px 12px; }

.bo-loc { position: sticky; top: 69px; z-index: 40; background: var(--bg); padding: 14px 0; }
.bo-loc-trong { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.nhom-chip { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px; flex-wrap: wrap; }
.chip { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; color: var(--muted); font-size: .92rem; }
.chip:hover { color: var(--ink); background: var(--bg); }
.chip.dang-chon { background: var(--primary); color: #fff; }
.chip .so { opacity: .75; font-weight: 500; margin-left: 2px; }
.o-tim { flex: 1; min-width: 220px; position: relative; }
.o-tim input { width: 100%; padding: 11px 14px 11px 40px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.o-tim input:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
.o-tim::before { content: "🔍"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: .9rem; opacity: .6; }

.luoi-bai { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; padding: 6px 0 20px; }
.the-bai { display: flex; flex-direction: column; padding: 20px; text-decoration: none; color: inherit; border-top: 5px solid var(--mau, var(--primary)); transition: transform .15s, box-shadow .15s; }
.the-bai:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(20, 30, 60, .12); }
.the-bai .dong-tren { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.the-bai h3 { margin: 0 0 4px; font-size: 1.2rem; line-height: 1.35; }
.the-bai .chuong { color: var(--mau); font-weight: 600; font-size: .88rem; margin: 0 0 8px; }
.the-bai p.tt { color: var(--muted); font-size: .93rem; margin: 0 0 14px; flex: 1; }
.the-bai .dong-duoi { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px dashed var(--line); padding-top: 12px; font-size: .88rem; color: var(--muted); }
.the-bai .mo { color: var(--mau); font-weight: 700; }
.nhan-mon { background: var(--nen); color: var(--mau); }

.trong { text-align: center; padding: 50px 20px; color: var(--muted); }
.trong .icon { font-size: 44px; }
.loi-du-lieu { background: var(--bad-soft); color: var(--bad); border: 1px solid #f3c1c1; padding: 16px 20px; border-radius: 14px; margin: 20px 0; }

/* ---------- Trang bài học ---------- */
.dau-bai { padding: 18px 0 12px; display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.dau-bai .trai { flex: 1; min-width: 260px; }
.duong-dan { font-size: .88rem; color: var(--muted); margin-bottom: 6px; }
.duong-dan a { color: var(--muted); }
.dau-bai h1 { margin: 0; font-size: clamp(1.4rem, 2.6vw, 2rem); line-height: 1.25; }
.dau-bai .cong-cu { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.tab { border: 0; background: transparent; padding: 12px 16px; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; font-size: .98rem; display: flex; gap: 8px; align-items: center; }
.tab small { font-weight: 500; font-size: .78rem; background: var(--bg); padding: 2px 8px; border-radius: 99px; }
.tab:hover { color: var(--ink); }
.tab.dang-chon { color: var(--primary); border-bottom-color: var(--primary); }

.san-khau { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.san-khau iframe { display: block; width: 100%; height: calc(100vh - 150px); min-height: 620px; border: 0; background: #fff; }
.san-khau .thoat-tc { position: absolute; top: 10px; right: 10px; z-index: 5; display: none; }
.san-khau:fullscreen, .san-khau.gia-toan-man-hinh { border-radius: 0; border: 0; }
.san-khau:fullscreen iframe, .san-khau.gia-toan-man-hinh iframe { height: 100vh; min-height: 0; }
.san-khau:fullscreen .thoat-tc, .san-khau.gia-toan-man-hinh .thoat-tc { display: inline-flex; }
.san-khau.gia-toan-man-hinh { position: fixed; inset: 0; z-index: 1000; }

.ghi-nho { padding: 26px 30px; }
.ghi-nho ol { margin: 0; padding-left: 1.4em; font-size: 1.15rem; }
.ghi-nho li { margin: 10px 0; }

/* ---------- Trắc nghiệm ---------- */
.tn { max-width: 860px; margin: 0 auto; }
.tn-dau { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.thanh-tien-do { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; flex: 1; min-width: 160px; }
.thanh-tien-do div { height: 100%; background: var(--primary); transition: width .3s; }
.cau-hoi { padding: 26px 28px; }
.cau-hoi .so-cau { display: inline-block; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 4px 12px; border-radius: 99px; font-size: .85rem; margin-bottom: 12px; }
.cau-hoi h2 { font-size: 1.35rem; margin: 0 0 18px; line-height: 1.45; font-weight: 700; }
.phuong-an { display: grid; gap: 10px; }
.pa { display: flex; gap: 14px; align-items: center; text-align: left; width: 100%; padding: 14px 16px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; font-size: 1.08rem; transition: border-color .15s, background .15s; }
.pa:hover:not(:disabled) { border-color: #9db3ee; background: #f8faff; }
.pa .chu { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: var(--bg); color: var(--muted); }
.pa.chon { border-color: var(--primary); background: var(--primary-soft); }
.pa.chon .chu { background: var(--primary); color: #fff; }
.pa.dung { border-color: var(--ok); background: var(--ok-soft); }
.pa.dung .chu { background: var(--ok); color: #fff; }
.pa.sai { border-color: var(--bad); background: var(--bad-soft); }
.pa.sai .chu { background: var(--bad); color: #fff; }
.pa:disabled { cursor: default; }
.giai-thich { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: #fff8e6; border: 1px solid #f6dd9c; }
.tn-nut { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- Kiểm tra ---------- */
.form-luoi { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.truong label, .truong .nhan-truong { display: block; font-weight: 700; margin-bottom: 6px; font-size: .95rem; }
.truong input[type=text], .truong select { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.truong input:focus, .truong select:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
.lua-chon-nhanh { display: flex; gap: 6px; flex-wrap: wrap; }
.lua-chon-nhanh button { border: 1px solid var(--line); background: #fff; padding: 9px 14px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.lua-chon-nhanh button.dang-chon { background: var(--primary); border-color: var(--primary); color: #fff; }
.ds-bai { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 6px; background: #fff; }
.ds-bai label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.ds-bai label:hover { background: var(--bg); }
.ds-bai input { margin-top: 5px; }
.hop-link { display: flex; gap: 8px; flex-wrap: wrap; }
.hop-link input { flex: 1; min-width: 240px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-size: .9rem; }
.ghi-chu { font-size: .88rem; color: var(--muted); }
.canh-bao { background: #fff8e6; border: 1px solid #f6dd9c; padding: 12px 16px; border-radius: 12px; font-size: .92rem; }

.thanh-thi { position: sticky; top: 69px; z-index: 30; background: var(--ink); color: #fff; border-radius: 14px; padding: 12px 18px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 16px 0; }
.thanh-thi .ten { font-weight: 700; margin-right: auto; }
.dong-ho { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.2rem; background: rgba(255, 255, 255, .12); padding: 4px 12px; border-radius: 10px; }
.dong-ho.gap { background: var(--bad); }
.bo-cuc-thi { display: grid; grid-template-columns: 1fr 260px; gap: 18px; align-items: start; }
.bang-so { padding: 16px; position: sticky; top: 140px; }
.bang-so h4 { margin: 0 0 10px; font-size: .95rem; }
.luoi-so { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.luoi-so button { aspect-ratio: 1; border: 2px solid var(--line); background: #fff; border-radius: 10px; font-weight: 700; cursor: pointer; }
.luoi-so button.da-lam { background: var(--primary-soft); border-color: #a9bdf2; color: var(--primary); }
.luoi-so button.hien-tai { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.luoi-so button.dung { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.luoi-so button.sai { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

.ket-qua { padding: 28px; text-align: center; background: linear-gradient(180deg, #fffdf5, #fff); }
.ket-qua h2 { margin: 4px 0 18px; font-size: 1.5rem; color: var(--primary-dark); }
.o-diem { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.o-diem > div { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 12px 22px; min-width: 140px; }
.o-diem small { display: block; color: var(--muted); font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.o-diem b { font-size: 2.2rem; line-height: 1.2; }
.xep-loai { font-size: 1.3rem !important; display: inline-block; margin-top: 6px; }
.nut-ket-qua { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.xem-lai { display: grid; gap: 14px; margin-top: 18px; }
.xem-lai .cau-hoi { padding: 20px 22px; }
.xem-lai .cau-hoi h2 { font-size: 1.1rem; }
.xem-lai .pa { font-size: .98rem; padding: 10px 12px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 2000; }
.toast.hien { opacity: 1; transform: translateX(-50%); }

/* ---------- Hướng dẫn ---------- */
.hd { max-width: 920px; margin: 0 auto; }
.hd section { padding: 24px 28px; margin-bottom: 18px; }
.hd h2 { margin-top: 0; font-size: 1.35rem; }
.hd pre { background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: 12px; overflow: auto; font-size: .85rem; line-height: 1.5; }
.hd code { background: var(--bg); padding: 2px 6px; border-radius: 6px; font-size: .9em; }
.hd pre code { background: none; padding: 0; }
.hd ol li, .hd ul li { margin: 6px 0; }

/* ---------- Điện thoại ---------- */
@media (max-width: 820px) {
  html { font-size: 16px; }
  .bo-cuc-thi { grid-template-columns: 1fr; }
  .bang-so { position: static; order: -1; }
  .luoi-so { grid-template-columns: repeat(10, 1fr); }
  .bo-loc, .thanh-thi { position: static; }
  .san-khau iframe { height: 80vh; min-height: 480px; }
  .cau-hoi { padding: 20px; }
}

/* ---------- In / PDF ---------- */
@media print {
  .site-head, .site-foot, .khong-in, .thanh-thi, .bang-so { display: none !important; }
  body { background: #fff; }
  .the { box-shadow: none; }
  .bo-cuc-thi { grid-template-columns: 1fr; }
  .cau-hoi { break-inside: avoid; }
}
