:root {
  --ink: #1f2a44; --accent: #c8922a; --accent-soft: #f6ead0; --bg: #faf7f2; --card: #fff; --muted: #677086; --line: #e6e0d6;
  --ok: #2f7d5b; --ok-bg: #e6f3ec; --bad: #b8432f; --bad-bg: #fbe9e5;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 "Proxima Nova", "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--ink); }
.muted { color: var(--muted); font-size: .93rem; }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; background: var(--ink); }
.brand { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.brand span { color: #f0c66b; }
.top nav { display: flex; gap: 6px; }
.top nav a { color: #d7dbe6; text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: .95rem; }
.top nav a.on { background: rgba(255, 255, 255, .14); color: #fff; }

main { max-width: 900px; margin: 0 auto; padding: 28px 20px 80px; }
h1 { font-size: 1.8rem; line-height: 1.25; margin: .2em 0 .3em; }
h2 { font-size: 1.25rem; margin: 0 0 .6em; }
h3 { font-size: 1.1rem; margin: 1.8em 0 .5em; color: var(--ink); }
.hero { margin-bottom: 28px; }
.hero p { max-width: 680px; margin: .4em 0; }

.module { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin: 16px 0; }
.module h2 small { font-weight: 400; color: var(--muted); font-size: .95rem; margin-left: 6px; }
.tag { display: inline-block; background: var(--accent-soft); color: #7d5a12; border-radius: 6px; padding: 1px 8px; font-size: .8rem; font-weight: 600; vertical-align: middle; }
.lessons { list-style: none; margin: 0; padding: 0; }
.lessons li + li { border-top: 1px solid var(--line); }
.lessons a, .lessons li > div { display: flex; align-items: center; gap: 12px; padding: 10px 4px; text-decoration: none; }
.lessons a:hover { background: #fbf6ea; }
.lessons .no { width: 42px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.lessons .t { flex: 1; font-weight: 500; }
.lessons .t small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.lessons .off { opacity: .55; }
.badge { flex: none; font-size: .78rem; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.new { background: var(--ink); color: #fff; border-color: var(--ink); }
.badge.done { background: var(--ok-bg); color: var(--ok); border-color: transparent; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.mcard { display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; text-decoration: none; transition: transform .12s, box-shadow .12s, border-color .12s; }
.mcard:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 6px 18px rgba(31, 42, 68, .08); }
.mnum { font-size: 1.6rem; font-weight: 700; color: var(--accent); line-height: 1; }
.mcard strong { font-size: 1.08rem; line-height: 1.3; margin-top: 6px; }
.mvi { color: var(--muted); font-size: .92rem; min-height: 2.9em; }
.mmeta { color: var(--muted); font-size: .8rem; }
.mcard .bar { margin: 6px 0 2px; }
.pager { display: flex; justify-content: space-between; font-size: .92rem; }
.level.mix { background: #e9e4ee; color: #5b3a78; }
.crumb { font-size: .9rem; color: var(--muted); margin: 0; }
.tabs { position: sticky; top: 50px; z-index: 10; display: flex; gap: 8px; padding: 10px 0; background: var(--bg); border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.tabs a { text-decoration: none; padding: 5px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .92rem; }
.tabs a:hover { border-color: var(--accent); }
article { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 24px 24px; margin: 18px 0; scroll-margin-top: 110px; }
article > h2 { margin-top: 18px; }
article > h3:first-child { margin-top: 16px; }
.lesson h3 { color: var(--accent); border-top: 1px solid var(--line); padding-top: 1.1em; }
.lesson h3:first-child { border-top: 0; padding-top: 0; }
blockquote { margin: 1em 0; padding: 12px 18px; background: #fbf6ea; border-left: 4px solid var(--accent); border-radius: 0 10px 10px 0; font-size: 1.03rem; }
figure { margin: 1.2em 0; }
figure img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 12px; }
figcaption { font-size: .86rem; color: var(--muted); text-align: center; margin-top: 6px; }
.table-wrap { overflow-x: auto; margin: 1em 0; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th { text-align: left; font-weight: 500; color: var(--muted); border-bottom: 2px solid var(--ink); padding: 6px 10px; }
td { border-bottom: 1px solid var(--line); padding: 8px 10px; vertical-align: top; }

.role { display: inline-block; padding: 0 7px; border-radius: 6px; font-weight: 600; }
.role-S { background: #e4e8f3; color: #1f2a44; }
.role-be, .role-aux { background: #f6ead0; color: #7d5a12; }
.role-V { background: #f3dcd6; color: #8c3423; }
.role-not { background: #e9e4ee; color: #5b3a78; }
.role-wh, .role-O { background: #e3ece6; color: #2f5d47; }
.lesson em, .exercise em, .why em, .vocab em { color: #9a3d6b; font-weight: 600; }
.vocab td.w { white-space: nowrap; }
.say { border: 0; background: var(--accent-soft); color: #7d5a12; width: 26px; height: 26px; padding: 0; border-radius: 50%; margin-right: 8px; vertical-align: -6px; display: inline-flex; align-items: center; justify-content: center; }
.say:hover { background: var(--accent); color: #fff; }
.ipa { font-family: "Lucida Sans Unicode", "Arial Unicode MS", system-ui, sans-serif; color: var(--muted); white-space: nowrap; }
.pos { color: var(--muted); font-size: .88rem; white-space: nowrap; }
.freewrite { display: block; }
.free { display: block; width: 100%; font: inherit; line-height: 1.6; padding: 10px 12px; border: 1.5px solid #b9c0d0; border-radius: 10px; background: #f7f8fb; resize: vertical; }
.free:focus { outline: none; border-color: var(--accent); background: #fffaf0; }
.sample { display: block; margin-top: 8px; padding: 10px 14px; background: var(--ok-bg); border-radius: 10px; line-height: 1.6; }
.legend { font-size: .88rem; color: var(--muted); }

.gloss { border-bottom: 1.5px dotted var(--accent); cursor: help; position: relative; outline: none; }
.gloss:hover::after, .gloss:focus::after { content: attr(data-vi); position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 30; background: var(--ink); color: #fff; font: 500 .85rem/1.35 inherit; font-style: normal; padding: 5px 10px; border-radius: 8px; white-space: nowrap; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }

.exercise { border-top: 1px solid var(--line); margin-top: 22px; }
.exercise h3 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.level { font-size: .75rem; font-weight: 600; padding: 1px 10px; border-radius: 999px; background: #e4e8f3; color: var(--ink); }
.level.hi { background: var(--accent-soft); color: #7d5a12; }
.exscore { margin-left: auto; font-size: .9rem; font-weight: 600; color: var(--muted); }
.intro { color: var(--muted); margin: .2em 0 .6em; }
.wordbox { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; border: 1.5px dashed var(--accent); border-radius: 10px; }
.wordbox span { background: var(--accent-soft); padding: 1px 10px; border-radius: 6px; font-weight: 500; }
.example { background: #f4f2ee; border-radius: 8px; padding: 6px 12px; font-size: .95rem; }
.shown { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.shown.prefilled { display:inline-block; padding:1px 8px; border-radius:6px; background:#eef6ee; color:#2f6b3a; text-decoration:none; }
.exercise ol { padding-left: 1.5em; }
.exercise li { margin: 12px 0; padding-left: 4px; }
.q { line-height: 2.1; }
.blank { font: inherit; color: var(--ink); border: 0; border-bottom: 2px solid #b9c0d0; background: #f7f8fb; padding: 2px 8px; border-radius: 6px 6px 0 0; max-width: 100%; }
select.blank { padding: 4px 6px; }
.blank:focus { outline: none; border-bottom-color: var(--accent); background: #fffaf0; }
.slot.ok .blank { background: var(--ok-bg); border-bottom-color: var(--ok); color: var(--ok); opacity: 1; font-weight: 600; }
.slot.bad .blank { background: var(--bad-bg); border-bottom-color: var(--bad); color: var(--bad); opacity: 1; text-decoration: line-through; }
.fix { margin-left: 6px; color: var(--ok); font-weight: 600; }
.fix::before { content: "→ "; }
.why { margin-top: 2px; font-size: .92rem; color: var(--muted); padding: 6px 12px; border-left: 3px solid var(--line); }
li.wrong .why { border-left-color: var(--bad); color: var(--ink); background: #fdf5f3; }
li.right::marker { color: var(--ok); font-weight: 700; }
li.wrong::marker { color: var(--bad); font-weight: 700; }

.actions { display: flex; gap: 10px; margin-top: 26px; }
button { font: inherit; cursor: pointer; border: 1px solid var(--ink); background: #fff; color: var(--ink); padding: 8px 18px; border-radius: 999px; }
button.primary, #retry { background: var(--ink); color: #fff; font-weight: 600; padding: 10px 28px; }
button:hover { filter: brightness(1.1); }
.warn { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; margin-top: 18px; }
.warn button { padding: 3px 12px; margin-left: 6px; font-size: .9rem; }
.result { display: flex; gap: 20px; align-items: center; background: var(--ink); color: #fff; border-radius: 14px; padding: 16px 22px; scroll-margin-top: 110px; }
.result p { margin: .2em 0; }
.result .muted, .result a { color: #cfd5e3; }
.result .big { font-size: 2rem; font-weight: 700; line-height: 1.1; white-space: nowrap; text-align: center; }
.result .big small { display: block; font-size: 1rem; color: #f0c66b; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 18px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.card b { display: block; font-size: 1.7rem; }
.card span { color: var(--muted); font-size: .9rem; }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.prog details { font-size: .85rem; color: var(--muted); }
.prog details ul { margin: 4px 0; padding-left: 1.2em; }
.up { color: var(--ok); font-weight: 600; font-size: .85rem; }
.down { color: var(--bad); font-weight: 600; font-size: .85rem; }
.spark { color: var(--accent); vertical-align: middle; }
.note { margin-top: 24px; }

@media (max-width: 600px) {
  .top { padding: 10px 14px; }
  main { padding: 18px 14px 60px; }
  article { padding: 4px 16px 18px; }
  h1 { font-size: 1.45rem; }
  .result { flex-direction: column; align-items: flex-start; }
}

/* Đăng nhập và trang giáo viên */
.top nav { align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.top nav .who { color: #f0c66b; font-size: .9rem; padding: 0 4px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth { max-width: 440px; margin: 0 auto; }
.auth-tabs { position: static; border: 0; }
.auth-tabs a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.authform { display: grid; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.authform label { display: grid; gap: 4px; font-weight: 600; font-size: .92rem; }
.authform input { font: inherit; font-weight: 400; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; }
.authform input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.authform .warn { margin: 0; }
.ok-msg { background: var(--ok-bg); color: var(--ok); border-radius: 10px; padding: 10px 14px; margin: 0; }
.chip { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 999px; background: var(--bad-bg); color: var(--bad); margin: 2px 0; }
.chip.demo { background: #f0c66b; color: var(--ink); }
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .93rem; }
.prog .hist { list-style: none; padding-left: 0; }
.prog .hist > li { padding: 6px 0; border-top: 1px dashed var(--line); color: var(--ink); }
.wrongs { margin: 4px 0 0; padding-left: 1.1em; }
.wrongs li { margin: 3px 0; }
.wrongs .q { display: block; color: var(--ink); }
.wrongs .given { color: var(--bad); text-decoration: line-through; }
.wrongs .correct { color: var(--ok); font-weight: 600; }
.written { background: var(--bg); border-radius: 8px; padding: 6px 10px; margin-top: 6px; color: var(--ink); }
.written p { margin: 2px 0; }
@media (max-width: 640px) { .top { padding: 10px 16px; flex-wrap: wrap; } .top nav a { padding: 5px 9px; font-size: .88rem; } }

/* Trang giáo viên: cảnh báo, bảng tổng lớp, bài viết chờ nhận xét */
.card.attn { border-color: var(--accent); background: var(--accent-soft); }
.alerts { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 14px; padding: 12px 18px; margin: 18px 0; }
.alerts h2 { margin: 4px 0 8px; font-size: 1.15rem; }
.alerts h2 small { font-size: .8rem; background: var(--bad-bg); color: var(--bad); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.alerts ul { margin: 0; padding-left: 1.1em; }
.alerts li { margin: 4px 0; }
.alerts li.lvl3::marker { color: var(--bad); }
.alerts li.lvl2::marker { color: var(--accent); }
table.classgrid { border-collapse: separate; border-spacing: 3px; width: auto; }
table.classgrid th { font-weight: 600; font-size: .82rem; text-align: center; padding: 2px 4px; white-space: nowrap; }
table.classgrid tbody th { text-align: left; padding-right: 10px; }
.cell { display: inline-block; min-width: 38px; text-align: center; border-radius: 6px; font-size: .82rem; font-weight: 600; padding: 4px 2px; }
td.cell { display: table-cell; height: 28px; }
.cell.hi { background: var(--ok-bg); color: var(--ok); }
.cell.mid { background: #fbf0d4; color: #8a6412; }
.cell.lo { background: var(--bad-bg); color: var(--bad); }
.cell.none { background: #f1eee8; }
.legend .cell { min-width: 44px; margin: 0 2px 0 8px; padding: 1px 4px; }
.given-c { color: var(--bad); text-decoration: line-through; }
.correct-c { color: var(--ok); font-weight: 600; }
.wcard { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 10px 0; background: var(--card); }
.wcard > p { margin: 2px 0 4px; }
.fbform { margin-top: 8px; }
.fbform label { display: block; font-size: .88rem; color: var(--muted); }
.fbform textarea { display: block; width: 100%; box-sizing: border-box; margin: 4px 0 6px; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.fb { background: var(--accent-soft); border-radius: 8px; padding: 6px 10px; margin-top: 6px; }
.fb p { margin: 2px 0; }
.chip.good { background: var(--accent-soft); color: #8a6412; }
details.done { margin-top: 12px; }
.focus { list-style: none; padding: 0; margin: 0; }
.focus li { padding: 8px 0; border-bottom: 1px solid var(--line); }
