/* Sân tập số – giao diện chung cho trang chủ, chi tiết khóa học, khóa học của tôi, hướng dẫn học */
:root {
  --bg: #f4f7f5; --surface: #ffffff; --ink: #15241e; --muted: #5a6b63; --line: #dbe4de;
  --field: #1d6a51; --field-deep: #14513d; --field-soft: #e3efe8; --accent: #d9621f; --accent-soft: #fdeee3;
  --head: #fbf6ee; --head-line: #d9621f;
  --f-display: "Lexend", "Be Vietnam Pro", system-ui, sans-serif;
  --f-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 14px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0e1613; --surface: #16211c; --ink: #e5eee8; --muted: #9db0a6; --line: #2a3b33;
  --field: #5cc398; --field-deep: #123828; --field-soft: #1b3128; --accent: #f08a4b; --accent-soft: #3a2518;
  --head: #131d19; --head-line: #f08a4b; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0e1613; --surface: #16211c; --ink: #e5eee8; --muted: #9db0a6; --line: #2a3b33;
  --field: #5cc398; --field-deep: #123828; --field-soft: #1b3128; --accent: #f08a4b; --accent-soft: #3a2518;
  --head: #131d19; --head-line: #f08a4b; color-scheme: dark; }

* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--ink); }
body { margin: 0; font: 16px/1.6 var(--f-body); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.25; text-wrap: balance; margin: 0; }
p { margin: 0; }
.in { max-width: 1200px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.muted { color: var(--muted); }

/* Đầu trang */
.site-head { background: var(--head); border-bottom: 3px solid var(--head-line); position: sticky; top: 0; z-index: 20; }
.site-head .in { display: flex; align-items: center; gap: 12px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; min-width: 0; }
.brand .mk { flex: none; width: 42px; height: 42px; }
.brand b { display: block; font-family: var(--f-display); font-weight: 800; font-size: 19px; color: var(--accent); letter-spacing: .01em; text-transform: uppercase; line-height: 1.1; }
.brand small { display: block; font-size: 11.5px; font-weight: 700; color: var(--field); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hnav { display: flex; gap: 8px; align-items: center; }
.hbtn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 7px 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; font-size: 14px; text-decoration: none; color: var(--ink); cursor: pointer; font-family: inherit; white-space: nowrap; }
.hbtn:hover { border-color: var(--field); }
.hbtn[aria-current="page"] { border-color: var(--field); color: var(--field); font-weight: 600; }
.hbtn.solid { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; padding-inline: 16px; }
.hbtn.solid:hover { filter: brightness(1.07); }
.user { display: flex; align-items: center; gap: 8px; }
.user img, .user .av { width: 34px; height: 34px; border-radius: 50%; flex: none; }
.user .av { display: grid; place-items: center; background: var(--field); color: #fff; font-weight: 700; font-family: var(--f-display); }
.user .nm { font-size: 14px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; }
.exam-quick { display: none; }
/* Mục Bài kiểm tra trên trang chủ */
.exam-band { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; padding: 22px 24px; border-radius: 16px; border: 2px solid var(--accent); background: var(--accent-soft); }
.exam-band .ico { width: 56px; height: 56px; border-radius: 14px; background: var(--accent); color: #fff; display: grid; place-items: center; font: 800 26px var(--f-display); }
.exam-band h2 { margin: 0 0 4px; font-family: var(--f-display); font-size: 22px; }
.exam-band ul { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 15px; color: var(--ink); }
.exam-band li::before { content: "•"; color: var(--accent); margin-right: 6px; font-weight: 800; }
.exam-band .btn { white-space: nowrap; }
@media (max-width: 640px) { .exam-band { grid-template-columns: 1fr; text-align: left; } .exam-band .ico { display: none; } .exam-band .btn { justify-self: stretch; text-align: center; justify-content: center; } }

/* Nút chung */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 22px; border-radius: 8px; font-weight: 700; font-size: 16px; text-decoration: none; border: 1.5px solid transparent; cursor: pointer; font-family: inherit; }
.btn.accent { background: var(--accent); color: #fff; }
.btn.accent:hover { filter: brightness(1.07); }
.btn.field { background: var(--field); color: var(--surface); }
.btn.outline { border-color: var(--line); background: var(--surface); color: var(--ink); }
.btn.outline:hover { border-color: var(--field); }
.btn.sm { min-height: 38px; padding: 7px 14px; font-size: 14px; }

/* Ảnh bìa khóa học */
.cover { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; max-width: 100%; }

/* Lưới khóa học */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.ccard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease; }
a.ccard:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(20, 50, 38, .12); }
.ccard .body { padding: 14px 16px 16px; display: grid; gap: 4px; align-content: start; flex: 1; }
.ccard h3 { font-size: 18px; font-weight: 500; line-height: 1.35; margin-bottom: 4px; }
.ccard .code { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ccard .org { font-size: 14px; color: var(--muted); }
.ccard .date { font-size: 14px; color: var(--muted); margin-top: 4px; }
.ccard .bar { height: 6px; background: var(--field-soft); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.ccard .bar i { display: block; height: 100%; background: var(--field); }
.ccard.empty { border-style: dashed; justify-content: center; align-items: center; text-align: center; padding: 24px; color: var(--muted); min-height: 260px; gap: 8px; }
.ccard.empty b { font-family: var(--f-display); color: var(--ink); font-weight: 600; }

/* Tiêu đề trang */
.page-title { text-align: center; padding-block: 44px 28px; display: grid; gap: 8px; justify-items: center; }
.page-title h1 { font-size: clamp(28px, 5vw, 40px); font-weight: 700; }
.page-title p { color: var(--muted); max-width: 60ch; }
.sec { padding-block: 8px 48px; }
.sec-h { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.sec-h h2 { font-size: 24px; font-weight: 700; }
.sec-h a { margin-left: auto; font-size: 14px; font-weight: 600; color: var(--field); text-decoration: none; }

/* Dải giới thiệu trang chủ */
.intro { background: var(--field-deep); color: #fff; }
.intro .in { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; align-items: center; padding-block: 40px; }
.intro h1 { font-size: clamp(30px, 5vw, 46px); font-weight: 800; }
.intro h1 em { font-style: normal; color: #ffb27d; }
.intro p { color: #cfe6da; font-size: 17px; margin-top: 12px; max-width: 52ch; }
.intro .row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.intro .btn.ghost { border-color: rgba(255,255,255,.45); color: #fff; }
.intro .btn.ghost:hover { background: rgba(255,255,255,.08); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats div { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: 12px; padding: 14px; }
.stats b { display: block; font-family: var(--f-display); font-size: 30px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.stats span { font-size: 13px; color: #cfe6da; }

/* Chi tiết khóa học */
.banner { background: var(--accent-soft); }
.banner .in { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 0; max-width: 1200px; }
.banner .txt { padding: 40px max(16px, env(safe-area-inset-left, 0px)) 36px; display: grid; gap: 12px; align-content: center; justify-items: start; }
.banner h1 { font-size: clamp(26px, 4vw, 36px); font-weight: 600; color: var(--accent); }
.banner .sub { font-weight: 700; color: var(--ink); }
.banner .cover { align-self: center; }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--field); text-decoration: none; }
.detail { display: grid; grid-template-columns: 1.6fr 1fr; gap: 40px; padding-block: 28px 56px; align-items: start; }
.detail h2 { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.detail .blk { display: grid; gap: 10px; margin-bottom: 30px; }
.goals { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.lessons { display: grid; gap: 10px; }
.lrow { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; text-decoration: none; }
a.lrow:hover { border-color: var(--field); }
.lrow .num { width: 40px; height: 40px; border-radius: 10px; background: var(--field-soft); color: var(--field); display: grid; place-items: center; font-family: var(--f-display); font-weight: 700; }
.lrow.done .num { background: var(--field); color: var(--surface); }
.lrow.lock { opacity: .7; }
.lrow.lock .num { background: var(--line); color: var(--muted); }
.lrow.exam .num { background: var(--accent); color: #fff; }
.lrow b { font-family: var(--f-display); font-weight: 600; display: block; }
.lrow small { color: var(--muted); font-size: 14px; display: block; }
.lrow .st { font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--field); text-align: right; }
.lrow.lock .st { color: var(--muted); }
.lrow .mini { width: 90px; height: 6px; background: var(--field-soft); border-radius: 99px; overflow: hidden; margin-top: 6px; margin-left: auto; }
.lrow .mini i { display: block; height: 100%; background: var(--field); }
.info { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 18px; position: sticky; top: 90px; }
.info dl { margin: 0; }
.info div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px dotted var(--line); font-size: 15px; }
.info div:last-child { border-bottom: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; font-weight: 700; text-align: right; }
.progress-box { margin-top: 14px; display: grid; gap: 8px; }
.progress-box .bar { height: 10px; background: var(--field-soft); border-radius: 99px; overflow: hidden; }
.progress-box .bar i { display: block; height: 100%; background: var(--field); }

/* Khóa học của tôi */
.mine { display: grid; gap: 16px; }
.mcard { display: grid; grid-template-columns: 300px 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.mcard .cover { height: 100%; aspect-ratio: auto; min-height: 170px; object-fit: cover; }
.mcard .body { padding: 18px 20px; display: grid; gap: 8px; align-content: start; position: relative; }
.mcard h3 { font-size: 22px; font-weight: 600; padding-right: 44px; }
.mcard .meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--muted); }
.mcard .row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.mcard .bar { flex: 1; min-width: 140px; max-width: 320px; height: 8px; background: var(--field-soft); border-radius: 99px; overflow: hidden; }
.mcard .bar i { display: block; height: 100%; background: var(--field); }
.gear { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.gear:hover { background: var(--field-soft); color: var(--ink); }
.pop { position: absolute; top: 52px; right: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.14); padding: 6px; display: grid; min-width: 190px; z-index: 5; }
.pop button { text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 8px; font: inherit; color: var(--ink); cursor: pointer; }
.pop button:hover { background: var(--field-soft); }
.confirm { background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; display: grid; gap: 10px; font-size: 15px; }
.empty-state { text-align: center; padding: 48px 16px; display: grid; gap: 12px; justify-items: center; background: var(--surface); border: 1px dashed var(--line); border-radius: 14px; }
.empty-state b { font-family: var(--f-display); font-size: 20px; }

/* Hướng dẫn học */
.guide { max-width: 820px; margin: 0 auto; padding-bottom: 56px; }
.toc { display: grid; gap: 4px; margin-bottom: 36px; }
.toc .lbl { color: var(--muted); font-size: 18px; margin-bottom: 12px; }
.toc a { color: var(--accent); text-decoration: none; padding: 4px 0; }
.toc a:hover { text-decoration: underline; }
.toc a.l1 { font-weight: 700; margin-top: 8px; }
.toc a.l2 { padding-left: 20px; }
.gsec { display: grid; gap: 12px; padding-block: 22px; border-top: 1px solid var(--line); scroll-margin-top: 90px; }
.gsec h2 { font-size: 22px; font-weight: 700; color: var(--field); }
.gsec h3 { font-size: 17px; font-weight: 600; scroll-margin-top: 90px; margin-top: 8px; }
.gsec ol, .gsec ul { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.tip { background: var(--field-soft); border-radius: 10px; padding: 12px 14px; font-size: 15px; }

/* Chân trang */
.site-foot { background: var(--field-deep); color: #cfe6da; margin-top: auto; }
.site-foot .in { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 24px; padding-block: 32px calc(28px + env(safe-area-inset-bottom, 0px)); font-size: 14px; }
.site-foot b { color: #fff; font-family: var(--f-display); }
.site-foot .big { font-size: 18px; display: block; margin-bottom: 4px; }
.site-foot a { color: #cfe6da; }
.site-foot .col { display: grid; gap: 6px; align-content: start; }
.site-foot .fine { grid-column: 1 / -1; border-top: 1px solid rgba(255,255,255,.14); padding-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; }

@media (max-width: 1000px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 820px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .intro .in, .banner .in, .detail { grid-template-columns: 1fr; }
  .banner .cover { order: -1; }
  .info { position: static; }
  .mcard { grid-template-columns: 1fr; }
  .mcard .cover { aspect-ratio: 16 / 9; min-height: 0; }
  .site-foot .in { grid-template-columns: 1fr; }
  .menu-btn { display: inline-flex; }
  .exam-quick { display: inline-flex; margin-left: auto; margin-right: 8px; padding-inline: 12px; }
  .hnav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--head); border-bottom: 3px solid var(--head-line); padding: 10px max(16px, env(safe-area-inset-left, 0px)) 14px; flex-direction: column; align-items: stretch; }
  .hnav.open { display: flex; }
  .hnav .hbtn { justify-content: center; }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; }
  .stats b { font-size: 24px; }
  .brand small { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Đầu trang trên điện thoại: chừa chỗ cho nút Làm bài thi */
@media (max-width: 820px) {
  .site-head .brand { min-width: 0; flex-shrink: 1; }
  .site-head .brand span { min-width: 0; overflow: hidden; }
  .site-head .brand b, .site-head .brand small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 440px) {
  .site-head .brand small { display: none; }
  .site-head .brand b { font-size: 16px; }
  .exam-quick, .menu-btn { padding-inline: 10px; font-size: 13px; }
}

/* Phần tử có thuộc tính hidden luôn bị ẩn, kể cả khi lớp CSS khác đặt display */
[hidden] { display: none !important; }
