:root {
  --blue: #1a6cf0; --blue-d: #0f4fc0; --green: #19b24b; --orange: #ff7a00; --pink: #ff3d81; --purple: #7c3aed; --yellow: #ffc400; --teal: #00b8a9;
  --ink: #1b2340; --muted: #5d6786; --line: #e3e7f5; --bg: #f3f5ff; --card: #fff;
  --ok: #12923a; --bad: #e0213f; --radius: 18px;
  --shadow: 0 8px 28px rgba(60, 70, 160, .14);
  --grad: linear-gradient(135deg, #1a6cf0, #7c3aed);
  --grad2: linear-gradient(135deg, #ff7a00, #ff3d81);
  --grad3: linear-gradient(135deg, #19b24b, #00b8a9);
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.55 Nunito, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
  background: radial-gradient(1200px 500px at 90% -10%, #ffe8f1 0, transparent 60%), radial-gradient(900px 500px at -10% 10%, #dff1ff 0, transparent 60%), var(--bg); min-height: 100vh; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; font-weight: 800; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1.02rem; }
a { color: var(--blue); } .muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.hidden { display: none !important; }

/* khung: đoàn tàu Trạm Tri Thức */
.train { position: sticky; top: 0; z-index: 30; background: linear-gradient(180deg, #cfe8ff 0%, #eaf5ff 70%, #f3f5ff 100%); padding: 10px 14px 0; box-shadow: 0 6px 18px rgba(40, 60, 140, .12); }
.train-row { display: flex; align-items: flex-end; overflow-x: auto; padding: 14px 4px 0; scrollbar-width: none; gap: 0; }
.train-row::-webkit-scrollbar { display: none; }
.loco, .wagon, .dest { position: relative; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; text-decoration: none; color: #fff; }
.loco { background: linear-gradient(180deg, #4b2bb5, #2a1a80); border-radius: 18px 34px 8px 8px; padding: 10px 18px 14px 14px; min-width: 150px; margin-left: 14px; flex-direction: row; gap: 8px; align-items: center; height: 74px; }
.loco::before { content: ""; position: absolute; top: -14px; right: 22px; width: 18px; height: 16px; background: #2a1a80; border-radius: 4px 4px 0 0; }
.loco img { width: 38px; background: #fff; border-radius: 12px; padding: 3px; } .loco b { font-size: .85rem; letter-spacing: .03em; line-height: 1.1; }
.smoke { position: absolute; top: -34px; right: 16px; display: flex; gap: 4px; }
.smoke s { width: 10px; height: 10px; border-radius: 50%; background: #fff; opacity: .8; animation: puff 2.4s infinite ease-out; } .smoke s:nth-child(2) { animation-delay: .8s; } .smoke s:nth-child(3) { animation-delay: 1.6s; }
@keyframes puff { 0% { transform: translate(0, 10px) scale(.4); opacity: .9; } 100% { transform: translate(-16px, -16px) scale(1.5); opacity: 0; } }
.wagon { background: var(--c, #1a6cf0); border-radius: 12px 12px 6px 6px; padding: 8px 14px 14px; min-width: 96px; height: 74px; margin-right: 12px; font-weight: 800; font-size: .84rem; transition: transform .15s, filter .15s; text-align: center; }
.wagon .win { display: grid; place-items: center; width: 34px; height: 28px; background: #fffbe0; border-radius: 8px; font-size: 1.1rem; margin-bottom: 4px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .1); }
.wagon:hover { transform: translateY(-3px); filter: brightness(1.08); }
.wagon.on { transform: translateY(-6px); box-shadow: 0 8px 0 -2px rgba(255, 255, 255, .6), 0 10px 18px rgba(0, 0, 0, .25); outline: 3px solid #fff; }
.wagon .coupler, .loco .coupler { position: absolute; right: -13px; bottom: 18px; width: 14px; height: 5px; background: #556; border-radius: 3px; }
.wheels { position: absolute; bottom: -9px; left: 0; right: 0; display: flex; justify-content: space-around; padding: 0 12px; }
.wheels u { width: 16px; height: 16px; border-radius: 50%; background: #222; border: 3px solid #999; display: block; animation: spin 2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loco .coupler.back { right: auto; left: -13px; }
.dest { margin-left: auto; padding: 0 6px 8px 40px; color: var(--ink); min-width: 150px; }
.dest .flagpole { font-size: 2.2rem; line-height: 1; } .dest b { font-size: .8rem; }
.dest .banner { background: linear-gradient(135deg, #e0213f, #ff7a00); color: #ffe066; font-weight: 800; font-size: .72rem; letter-spacing: .04em; padding: 5px 16px 5px 12px; margin-bottom: 4px; white-space: nowrap; clip-path: polygon(0 0, 100% 0, 92% 50%, 100% 100%, 0 100%); box-shadow: 0 3px 8px rgba(0, 0, 0, .25); animation: wave 2.4s ease-in-out infinite; transform-origin: left center; }
@keyframes wave { 50% { transform: skewY(-3deg) scaleX(.97); } }
.rail { height: 12px; margin: 0 -14px; background: repeating-linear-gradient(90deg, #8b5a2b 0 10px, transparent 10px 24px) bottom/100% 6px no-repeat, linear-gradient(180deg, #888 0 3px, transparent 3px); border-top: 3px solid #7a7a8a; margin-top: 4px; }
.userbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 4px; font-size: .9rem; position: relative; }
.userbar .bar { position: relative; }
.userbar button { box-shadow: none; }
main { padding: 22px 24px 60px; max-width: 1180px; width: 100%; margin: 0 auto; min-width: 0; }
.journey .track { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; background: rgba(255, 255, 255, .22); padding: 8px 12px; border-radius: 99px; }
.journey .stn { width: 28px; height: 28px; border-radius: 50%; background: rgba(255, 255, 255, .3); display: grid; place-items: center; font-size: .9rem; } .journey .stn.got { background: #ffe066; }
.journey .flag { font-size: 1.6rem; margin-left: auto; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; } .avatar.adm { background: var(--grad2); }
.post { padding: 14px 16px; } .composer { padding: 12px 16px; }
.like { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); padding: 4px 12px; } .like.on { box-shadow: inset 0 0 0 2px #ffb3c7; background: #fff0f4; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.head h1 { margin: 0; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* thẻ */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); border: 1px solid #fff; }
.card.accent { border-top: 6px solid var(--c, var(--blue)); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 16px; }
.tile { border-radius: var(--radius); padding: 16px 18px; color: #fff; box-shadow: var(--shadow); background: var(--grad); }
.tile:nth-child(4n+2) { background: var(--grad2); } .tile:nth-child(4n+3) { background: var(--grad3); } .tile:nth-child(4n+4) { background: linear-gradient(135deg, #7c3aed, #ff3d81); }
.tile b { display: block; font-size: 2rem; line-height: 1.1; } .tile span { opacity: .92; font-weight: 700; }
a.tile { text-decoration: none; display: block; transition: transform .12s; } a.tile:hover { transform: translateY(-3px); }
.hero { background: var(--grad); color: #fff; border-radius: 22px; padding: 22px 24px; margin-bottom: 16px; box-shadow: var(--shadow); display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: space-between; }
.hero h1 { color: #fff; -webkit-text-fill-color: #fff; margin: 0 0 4px; }
.starbar { background: rgba(255,255,255,.28); border-radius: 99px; height: 16px; overflow: hidden; min-width: 240px; margin: 8px 0 4px; }
.starbar i { display: block; height: 100%; background: linear-gradient(90deg, #ffe066, #ffc400); border-radius: 99px; transition: width .6s; }
.big-star { font-size: 3rem; filter: drop-shadow(0 4px 6px rgba(0,0,0,.25)); }

/* nút */
button, .btn { font: inherit; font-weight: 800; border: 0; border-radius: 99px; padding: 9px 18px; cursor: pointer; color: #fff; background: var(--grad); text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 4px 12px rgba(26,108,240,.3); transition: transform .1s, box-shadow .1s, filter .1s; }
button:hover, .btn:hover { transform: translateY(-1px); filter: brightness(1.06); } button:active { transform: translateY(1px); }
button.ghost { background: #fff; color: var(--blue-d); box-shadow: inset 0 0 0 2px var(--line); }
button.warm { background: var(--grad2); box-shadow: 0 4px 12px rgba(255,61,129,.3); }
button.green { background: var(--grad3); box-shadow: 0 4px 12px rgba(25,178,75,.3); }
button.danger { background: #fff; color: var(--bad); box-shadow: inset 0 0 0 2px #ffc9d1; }
button.sm { padding: 5px 12px; font-size: .85rem; } button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* form */
label { display: block; font-weight: 800; font-size: .86rem; margin: 10px 0 4px; color: var(--muted); }
input, select, textarea { font: inherit; width: 100%; padding: 9px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(26,108,240,.15); }
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--blue); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink); margin: 4px 12px 4px 0; cursor: pointer; }
.chk input { margin: 0; }

/* bảng */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; }
table.plan td, table.plan th { text-align: center; padding: 6px; } table.plan input { width: 64px; text-align: center; padding: 6px; }
table.plan td:first-child, table.plan th:first-child { text-align: left; white-space: nowrap; font-weight: 800; }

/* nhãn */
.tag { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .76rem; font-weight: 800; background: #e9eeff; color: var(--blue-d); margin: 0 4px 2px 0; }
.tag.l1 { background: #dff7e6; color: #0b7a30; } .tag.l2 { background: #dff0ff; color: #0b5cb8; } .tag.l3 { background: #fff0d1; color: #a35a00; } .tag.l4 { background: #ffe0e8; color: #b8133e; }
.tag.warn { background: #fff0d1; color: #a35a00; } .tag.ok { background: #dff7e6; color: #0b7a30; } .tag.bad { background: #ffe0e8; color: #b8133e; } .tag.ai { background: #efe3ff; color: #6a21d6; }
.alert { padding: 11px 14px; border-radius: 14px; margin: 10px 0; font-weight: 700; background: #fff0d1; color: #7a4300; }
.alert.bad { background: #ffe0e8; color: #a30f36; } .alert.ok { background: #dff7e6; color: #0b6a2a; }

/* học liệu */
.subj { --c: var(--blue); } .s-Toán { --c: #1a6cf0; } .s-Ngữ { --c: #e0213f; } .s-Tiếng { --c: #ff7a00; } .s-KHTN, .s-Vật, .s-Hoá, .s-Sinh { --c: #19b24b; } .s-Lịch { --c: #7c3aed; } .s-Tin { --c: #00b8a9; }
.mat { display: block; text-decoration: none; color: inherit; transition: transform .12s; } .mat:hover { transform: translateY(-3px); }
.mat .kind { font-size: 1.8rem; }

/* bài thi */
.q { padding: 16px; border-radius: 16px; background: #fff; border: 2px solid var(--line); margin-bottom: 14px; }
.q.right { border-color: #7fdca0; background: #f4fff7; } .q.wrong { border-color: #ffa9b8; background: #fff6f8; } .q.half { border-color: #ffd37a; background: #fffaf0; }
.q .num { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 99px; background: var(--grad); color: #fff; font-weight: 800; margin-right: 8px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border: 2px solid var(--line); border-radius: 12px; margin: 7px 0; cursor: pointer; background: #fff; }
.opt:hover { border-color: var(--blue); } .opt.sel { border-color: var(--blue); background: #eaf1ff; }
.opt.good { border-color: #19b24b; background: #e7fbed; } .opt.miss { border-color: #e0213f; background: #ffecef; }
.opt b { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: .85rem; }
.opt.sel b { background: var(--blue); color: #fff; }
.tfrow { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.tfbtn { padding: 5px 14px; border-radius: 99px; border: 2px solid var(--line); background: #fff; color: var(--ink); box-shadow: none; }
.tfbtn.sel { background: var(--blue); border-color: var(--blue); color: #fff; } .tfbtn.good { background: #19b24b; border-color: #19b24b; color: #fff; }
.timer { position: sticky; top: 0; z-index: 5; background: rgba(255,255,255,.95); backdrop-filter: blur(8px); padding: 10px 14px; border-radius: 0 0 18px 18px; box-shadow: var(--shadow); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; margin: -8px 0 16px; }
.timer .clock { font-weight: 800; font-size: 1.3rem; color: var(--orange); font-variant-numeric: tabular-nums; }
.nav-dots { display: flex; flex-wrap: wrap; gap: 5px; } .nav-dots a { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; text-decoration: none; font-weight: 800; font-size: .8rem; background: #e9eeff; color: var(--blue-d); }
.nav-dots a.done { background: var(--blue); color: #fff; }
.score { font-size: 3.4rem; font-weight: 800; line-height: 1; }
.expl { background: #f1f5ff; border-radius: 12px; padding: 10px 12px; margin-top: 8px; }
.ai-box { background: #f6efff; border-left: 5px solid var(--purple); border-radius: 12px; padding: 10px 14px; margin-top: 8px; white-space: pre-wrap; }

/* diễn đàn */
.thread { display: block; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); padding: 12px 4px; } .thread:hover { background: #f6f8ff; }
.reply { border-left: 4px solid var(--line); padding: 8px 14px; margin: 12px 0; background: #fafbff; border-radius: 0 14px 14px 0; } .reply.best { border-color: var(--green); background: #f1fff5; }
.rank { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--yellow); font-weight: 800; margin-right: 8px; }
.pre { white-space: pre-wrap; word-break: break-word; }

/* hộp thoại, thông báo */
.modal-bg { position: fixed; inset: 0; background: rgba(20,20,60,.55); display: grid; place-items: start center; padding: 28px 12px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 22px; padding: 22px; width: min(760px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(80px); background: #1b2340; color: #fff; padding: 11px 20px; border-radius: 99px; font-weight: 800; z-index: 100; opacity: 0; transition: .25s; max-width: 92vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); } #toast.bad { background: var(--bad); }
.bell { position: relative; } .bell .n { position: absolute; top: -6px; right: -6px; background: var(--pink); color: #fff; border-radius: 99px; font-size: .7rem; padding: 0 6px; font-weight: 800; }
.notes { position: absolute; right: 0; top: 46px; width: min(340px, 90vw); background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 8px; z-index: 20; color: var(--ink); max-height: 60vh; overflow: auto; }
.notes a { display: block; padding: 8px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; font-size: .9rem; } .notes a:hover { background: #f1f4ff; } .notes a.un { font-weight: 800; }

/* đăng nhập */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #1a2a8a, #7c3aed 55%, #ff3d81); }
.login .box { background: #fff; border-radius: 28px; padding: 30px 26px; width: min(400px, 100%); box-shadow: 0 24px 60px rgba(0,0,0,.35); text-align: center; }
.login img { width: 84px; } .login h1 { background: none; color: var(--ink); -webkit-text-fill-color: var(--ink); margin: 8px 0 2px; } .login form { text-align: left; }

/* điện thoại */
@media (max-width: 700px) { main { padding: 16px 12px 60px; } .wagon { min-width: 86px; } .loco { min-width: 120px; } .loco b { font-size: .72rem; } }
@media print { .train, .no-print, #toast { display: none !important; } main { padding: 0; } .card { box-shadow: none; border: 1px solid #ccc; } body { background: #fff; } }

/* ma trận, cây chương/bài, ảnh */
.tree { max-height: 420px; overflow-y: auto; border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; margin-top: 10px; }
.tch { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); } .tch button { margin-left: auto; padding: 2px 10px; }
.tls { padding: 4px 0 8px 26px; }
table.mx input { width: 46px; padding: 5px 2px; font-weight: 700; } table.mx th.l1 { color: #0b7a30; } table.mx th.l2 { color: #0b5cb8; } table.mx th.l3 { color: #a35a00; } table.mx th.l4 { color: #b8133e; }
table.mx td:first-child { text-align: left; white-space: normal; font-weight: 400; max-width: 300px; }
.imgs { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; } .imgs img { max-width: 220px; max-height: 180px; border-radius: 12px; border: 2px solid var(--line); object-fit: cover; }
img.thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; border: 2px solid var(--line); }

input.oc { padding: 5px 8px; font-size: .88rem; }

/* ---- hình trong câu hỏi ---- */
.qimg { display: block; max-width: min(100%, 460px); max-height: 300px; margin: 8px 0; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; }
.qimg[data-act] { cursor: zoom-in; }
.opt .qimg { max-width: 220px; max-height: 150px; margin: 6px 0 2px; }
#lightbox { position: fixed; inset: 0; z-index: 20000; background: rgba(15, 23, 42, .86); display: flex; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out; }
#lightbox img { max-width: 100%; max-height: 100%; background: #fff; border-radius: 10px; }
