/* Layout: school portal – logo blue header, gold accents; content in a 1180px column, cards only for objects people act on. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --ink: #131a33;
  --muted: #59627c;
  --line: #dde2ee;
  --primary: #1b3a9a;      /* xanh logo */
  --primary-ink: #ffffff;
  --primary-soft: #e4eafa;
  --gold: #f2b705;         /* vàng logo */
  --gold-soft: #fdf2cc;
  --gold-ink: #6b4d00;
  --header: #12296f;
  --header-ink: #ffffff;
  --good: #1f7a4a;  --good-soft: #def3e6;
  --warn: #9a6200;  --warn-soft: #fbedcc;
  --info: #1b5fb0;  --info-soft: #e0ecfa;
  --bad: #b42318;   --bad-soft: #fde4e1;
  --none: #9aa2b6;  --none-soft: #eceef3;
  --shadow: 0 1px 2px rgba(19, 26, 51, .05), 0 6px 20px rgba(19, 26, 51, .06);
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  --display: "Lexend", "Be Vietnam Pro", "Segoe UI", sans-serif;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1222; --surface: #161b2e; --surface-2: #1e2439; --ink: #e8ebf5; --muted: #a0a8c0; --line: #2a3150;
    --primary: #8fa8ff; --primary-ink: #0e1430; --primary-soft: #1f2a52; --gold: #f5c63a; --gold-soft: #3a3010; --gold-ink: #f5d77a;
    --header: #0b1a4a; --header-ink: #ffffff;
    --good: #6fcf97; --good-soft: #17352a; --warn: #f0b95a; --warn-soft: #3a2c10; --info: #7fb2f5; --info-soft: #182c48;
    --bad: #f28b82; --bad-soft: #3f1d1b; --none: #6b738c; --none-soft: #252b40; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1222; --surface: #161b2e; --surface-2: #1e2439; --ink: #e8ebf5; --muted: #a0a8c0; --line: #2a3150;
  --primary: #8fa8ff; --primary-ink: #0e1430; --primary-soft: #1f2a52; --gold: #f5c63a; --gold-soft: #3a3010; --gold-ink: #f5d77a;
  --header: #0b1a4a; --header-ink: #ffffff;
  --good: #6fcf97; --good-soft: #17352a; --warn: #f0b95a; --warn-soft: #3a2c10; --info: #7fb2f5; --info-soft: #182c48;
  --bad: #f28b82; --bad-soft: #3f1d1b; --none: #6b738c; --none-soft: #252b40; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--font); }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); line-height: 1.25; text-wrap: balance; margin: 0; font-weight: 600; }
h1 { font-size: clamp(24px, 3.4vw, 32px); }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
svg:not([width]) { width: 18px; height: 18px; flex: none; }
.thumb .play svg { width: 28px; height: 28px; }
.player .play svg { width: 44px; height: 44px; }
aside .list .item { padding: 10px 0; }
aside .list .item .grow { min-width: 140px; }

/* ---------- Demo bar ---------- */
.demo-bar { background: var(--gold); color: #2b2000; font-size: 13px; }
.demo-bar .wrap { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; padding-block: 6px; }
.demo-bar b { font-weight: 600; }
.demo-bar select { border: 1px solid rgba(0,0,0,.25); background: #fff8dc; color: #2b2000; border-radius: 6px; padding: 3px 8px; max-width: 100%; }
.demo-bar .reset { margin-left: auto; background: none; border: 0; text-decoration: underline; cursor: pointer; color: #2b2000; padding: 0; }

/* ---------- Header ---------- */
header.top { background: var(--header); color: var(--header-ink); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
header.top .wrap { display: flex; align-items: center; gap: 16px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.brand img { width: 44px; height: 44px; border-radius: 50%; background: #fff; flex: none; }
.brand b { display: block; font-family: var(--display); font-weight: 600; font-size: 16px; line-height: 1.2; }
.brand span { display: block; font-size: 12px; opacity: .8; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: #2b2000; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.role-pill { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: rgba(255,255,255,.15); }
nav.sections { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: calc(env(safe-area-inset-top, 0px) + 64px); z-index: 19; }
nav.sections .wrap { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
nav.sections a { text-decoration: none; color: var(--muted); padding: 12px 12px; font-size: 14px; white-space: nowrap; border-bottom: 2px solid transparent; }
nav.sections a:hover { color: var(--ink); }
nav.sections a.on { color: var(--primary); border-bottom-color: var(--gold); font-weight: 600; }
.urlbar { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding-block: 10px 0; }
.urlbar code { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; color: var(--ink); overflow-x: auto; white-space: nowrap; max-width: 100%; }
.urlbar code b { color: var(--primary); }

main { padding-block: 20px 56px; }
.page-head { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin-top: 4px; color: var(--muted); max-width: 640px; }

/* ---------- Buttons, inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 8px 14px; cursor: pointer; text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #2b2000; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.btn.danger.armed { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
textarea.input { resize: vertical; min-height: 90px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.hint { font-size: 13px; color: var(--muted); }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card.raised { box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.tight { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.section { margin-top: 32px; }
.section > .spread { margin-bottom: 12px; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* tags & badges */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.gold { background: var(--gold-soft); color: var(--gold-ink); }
.tag.blue { background: var(--primary-soft); color: var(--primary); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.none { background: var(--none-soft); color: var(--muted); }
.subj { display: inline-grid; place-items: center; min-width: 44px; height: 28px; padding: 0 8px; border-radius: 6px; color: #fff; font: 700 11px/1 var(--display); letter-spacing: .04em; }

/* ---------- Home ---------- */
.hero { background: linear-gradient(160deg, var(--header) 0%, #1b3a9a 100%); color: #fff; }
.hero .wrap { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; padding-block: 36px; }
.hero h1 { font-size: clamp(26px, 4vw, 38px); }
.hero p { opacity: .85; margin-top: 8px; max-width: 560px; }
.hero img { width: 150px; height: 150px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 6px rgba(242,183,5,.35); }
.doors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: -28px; position: relative; }
.door { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.door h2 { font-size: 18px; }
.door ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.door .btn { align-self: flex-start; margin-top: auto; }
.door .kicker { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--gold-ink); }
.subject-tile { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); min-width: 0; }
.subject-tile:hover { border-color: var(--primary); }
.subject-tile b { display: block; font-weight: 600; }
.subject-tile span.small { display: block; color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-tile span.small b { display: inline; color: var(--primary); font-weight: 700; }
.grid.subjects { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.feature { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius); text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); }
.feature:hover { border-color: var(--primary); }
.feature .ico { flex: none; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.feature .ico svg { width: 20px; height: 20px; }
.feature p { color: var(--muted); font-size: 13.5px; }

/* ---------- Subject site ---------- */
.subject-hero { border-radius: var(--radius); padding: 22px; color: #fff; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.subject-hero .code { font: 700 22px var(--display); background: rgba(255,255,255,.18); border-radius: 10px; padding: 10px 14px; }
.subject-hero p { opacity: .85; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0; overflow-x: auto; }
.tabs a, .tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; color: var(--muted); text-decoration: none; white-space: nowrap; font-size: 14px; }
.tabs .on { color: var(--primary); border-bottom-color: var(--gold); font-weight: 600; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px; }
.chip.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* video card */
.video { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.video:hover { border-color: var(--primary); }
.thumb { aspect-ratio: 16 / 9; max-width: 100%; display: grid; place-items: center; position: relative; color: #fff; }
.thumb .play { width: 46px; height: 46px; border-radius: 50%; background: rgba(0,0,0,.35); display: grid; place-items: center; }
.thumb .dur { position: absolute; right: 8px; bottom: 8px; font-size: 12px; background: rgba(0,0,0,.55); padding: 1px 6px; border-radius: 4px; }
.thumb .tcode { position: absolute; left: 10px; top: 10px; font: 700 12px var(--display); letter-spacing: .05em; opacity: .9; }
.video .body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.player { aspect-ratio: 16 / 9; max-width: 100%; border-radius: var(--radius); display: grid; place-items: center; color: #fff; text-align: center; padding: 16px; }
.player .play { width: 70px; height: 70px; border-radius: 50%; background: rgba(0,0,0,.35); display: grid; place-items: center; margin: 0 auto 10px; }

/* list rows */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list .item { display: flex; gap: 14px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.list .item:first-child { border-top: 0; }
.list .item .grow { flex: 1; min-width: 200px; }
.fileico { width: 40px; height: 44px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font: 700 10px var(--display); flex: none; }

/* lesson layout */
.lesson { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }

/* quiz */
.q { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--surface); }
.q .qt { font-weight: 600; margin-bottom: 10px; }
.opt { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; cursor: pointer; }
.opt:hover { border-color: var(--primary); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.result { padding: 14px; border-radius: 10px; background: var(--primary-soft); color: var(--ink); }

/* FAQ */
details.faq { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 16px; }
details.faq + details.faq { margin-top: 8px; }
details.faq summary { cursor: pointer; padding: 14px 0; font-weight: 600; list-style: none; display: flex; gap: 10px; align-items: center; }
details.faq summary::after { content: "+"; margin-left: auto; font-size: 18px; color: var(--muted); }
details.faq[open] summary::after { content: "−"; }
details.faq .a { padding: 0 0 14px; color: var(--ink); }

/* threads */
.thread { display: flex; flex-direction: column; gap: 8px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.thread:hover { border-color: var(--primary); }
.thread h3 { font-family: var(--font); font-weight: 600; font-size: 15.5px; }
.reply { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.reply .avatar { background: var(--surface-2); color: var(--ink); }
.reply.teacher .avatar { background: var(--primary); color: var(--primary-ink); }
.visibility { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }

/* consult */
.stepper { display: flex; gap: 0; margin: 6px 0 2px; overflow-x: auto; }
.stepper .st { flex: 1; min-width: 92px; text-align: center; position: relative; font-size: 12px; color: var(--muted); padding-top: 22px; }
.stepper .st::before { content: ""; position: absolute; top: 6px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); z-index: 1; }
.stepper .st::after { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: var(--line); }
.stepper .st:first-child::after { display: none; }
.stepper .st.done { color: var(--ink); }
.stepper .st.done::before { background: var(--primary); border-color: var(--primary); }
.stepper .st.done::after { background: var(--primary); }
.stepper .st.cur { font-weight: 600; color: var(--primary); }
.stepper .st.cur::before { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.route { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 10px; background: var(--gold-soft); color: var(--ink); font-size: 14px; }
.route b { color: var(--gold-ink); }
.msg { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); max-width: 85%; }
.msg.mine { background: var(--primary-soft); align-self: flex-end; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.flow .stage { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--surface); font-size: 13px; }
.flow .stage b { display: block; font-size: 14px; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { padding: 10px 12px; text-align: left; border-top: 1px solid var(--line); white-space: nowrap; }
table.t thead th { border-top: 0; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600; }
table.t td.wrap-cell { white-space: normal; min-width: 180px; }
table.t tr.err td { background: var(--bad-soft); }

/* progress / charts */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font: 600 26px var(--display); font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.stackbar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; background: var(--none-soft); }
.stackbar span { display: block; height: 100%; }
.seg-done { background: var(--good); } .seg-late { background: var(--warn); } .seg-doing { background: var(--info); } .seg-none { background: var(--none); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart-row { display: grid; grid-template-columns: minmax(140px, 260px) minmax(0, 1fr) 70px; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.chart-row:first-of-type { border-top: 0; }
.bar { height: 10px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 0 4px 4px 0; }
.cell-st { display: inline-flex; align-items: center; gap: 6px; }
.cell-st i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12.5px; padding: 6px 10px; border-radius: 6px; max-width: 260px; display: none; }

/* layout helpers */
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.side-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(10, 14, 30, .5); z-index: 40; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h2 { margin-bottom: 4px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 60; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; }

footer.foot { border-top: 1px solid var(--line); padding-block: 22px; color: var(--muted); font-size: 13px; }

/* guide */
.guide-step { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.guide-step:first-child { border-top: 0; }
.guide-step .n { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-weight: 700; font-size: 14px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media (max-width: 900px) {
  .lesson, .side-layout { grid-template-columns: 1fr; }
  .flow { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .doors { grid-template-columns: 1fr; margin-top: 16px; }
  .hero .wrap { grid-template-columns: 1fr; }
  .hero img { width: 88px; height: 88px; order: -1; }
  .two { grid-template-columns: 1fr; }
  .who .name { display: none; }
  .brand span { display: none; }
  nav.sections { top: calc(env(safe-area-inset-top, 0px) + 60px); }
  .chart-row { grid-template-columns: 1fr 60px; }
  .chart-row .bar, .chart-row .stackbar { grid-column: 1 / -1; grid-row: 2; }
}
