@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap");

/* Học code. Bảng màu: kem #F5F2EA, navy #1C2027, teal #2F5FB3, vàng #F08A4B, nền code #14181F, đỏ nâu #B8521F.
   Phong cách sáng nhưng có khối màu đậm để giao diện nổi bật. Một cột trên điện thoại, mục lục bên phải trên máy tính. */

:root {
  --cream: #F5F2EA;
  --paper: #ffffff;
  --navy: #1C2027;
  --navy-2: #2A2F3A;
  --teal: #2F5FB3;
  --amber: #F08A4B;
  --brick: #B8521F;
  --ink: #14181F;
  --muted: #5b6475;
  --line: #e2e6ee;
  --code-bg: #14181F;
  --code-ink: #e8edf7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(28,32,39,.06), 0 6px 20px rgba(28,32,39,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px; line-height: 1.7; font-feature-settings: "kern" 1; color: var(--ink); background: var(--cream);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--teal); }

/* Thanh đầu: navy đậm với vạch vàng */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 22px; box-shadow: 0 3px 0 var(--amber), 0 6px 18px rgba(20,30,50,.18);
}
header.top .brand { font-weight: 800; font-size: 18px; color: #fff; text-decoration: none; letter-spacing: .2px; }
header.top .brand::before { content: "</>"; font-family: Consolas, monospace; font-size: 13px; color: var(--amber); margin-right: 8px; }
header.top nav { display: flex; gap: 6px; flex-wrap: wrap; }
header.top nav a { color: #d6e6ff; text-decoration: none; font-size: 14px; padding: 6px 12px; border-radius: 999px; }
header.top nav a:hover { background: rgba(255,255,255,.14); color: #fff; }

main { max-width: 1120px; margin: 0 auto; padding: 28px 20px 80px; }

h1 { font-size: 34px; line-height: 1.2; margin: 6px 0 10px; color: var(--navy); letter-spacing: -.2px; }
h2 { font-size: 22px; line-height: 1.3; margin: 34px 0 10px; color: var(--navy); }
h3 { font-size: 18px; margin: 22px 0 8px; color: var(--navy); }
p { margin: 10px 0; }
ul, ol { padding-left: 1.3em; }
li { margin: 6px 0; }
strong { color: #14263f; }

blockquote {
  margin: 16px 0; padding: 14px 18px;
  background: #fff7df; border: 1px solid #f1dc9a; border-left: 6px solid var(--amber);
  border-radius: 12px; color: #3a4456;
}
blockquote p { margin: 6px 0; }

code {
  font-family: Consolas, "Courier New", monospace; font-size: .9em;
  background: #ebe6da; color: #26324a; padding: 1px 6px; border-radius: 5px;
}
pre {
  background: var(--code-bg); color: var(--code-ink);
  padding: 16px 18px; border-radius: 12px; overflow-x: auto;
  border-left: 5px solid var(--amber); font-size: 14px; line-height: 1.6; margin: 14px 0;
  box-shadow: 0 6px 18px rgba(20,30,50,.12);
}
pre code { background: none; padding: 0; color: inherit; font-size: inherit; }

.table-wrap { overflow-x: auto; margin: 14px 0; border-radius: 12px; border: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; background: var(--paper); font-size: 15px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
th { background: #e6eef8; color: var(--navy); font-weight: 700; }
tr:last-child td { border-bottom: 0; }

.muted { color: var(--muted); font-size: 15px; }
.card { background: var(--paper); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--navy); color: #fff; border: 1px solid var(--navy);
  border-radius: 12px; padding: 11px 18px; font: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer; text-decoration: none; transition: background .15s, transform .05s, box-shadow .15s;
  box-shadow: 0 4px 12px rgba(28,32,39,.18);
}
.btn:hover { background: var(--navy-2); }
.btn:active { transform: translateY(1px); }
.btn.amber { background: var(--amber); border-color: var(--amber); color: var(--navy); box-shadow: 0 4px 12px rgba(240,138,75,.3); }
.btn.amber:hover { background: #cf9200; }
.btn.ghost { background: var(--paper); color: var(--navy); border-color: #c5cfdd; box-shadow: none; }
.btn.ghost:hover { background: #f1f5fa; }
.btn.ok { background: #685d51; border-color: #685d51; }
.btn.ok:hover { background: #574e44; }
.btn.run { background: var(--teal); border-color: var(--teal); box-shadow: 0 4px 12px rgba(47,95,179,.3); }
.btn.run:hover { background: #22696a; }
.btn:focus-visible, .ex-tab:focus-visible, .tab-btn:focus-visible, header.top a:focus-visible { outline: 3px solid rgba(240,138,75,.6); outline-offset: 2px; }

/* ---------- Trang chủ ---------- */
.hero {
  background: var(--navy); color: #fff; border-radius: 22px; padding: 34px 32px 30px;
  box-shadow: 0 14px 34px rgba(28,32,39,.25); display: grid; gap: 16px; position: relative; overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; right: -60px; top: -70px; width: 260px; height: 260px;
  border-radius: 50%; background: rgba(47,95,179,.45);
}
.hero::after {
  content: ""; position: absolute; right: 90px; bottom: -90px; width: 170px; height: 170px;
  border-radius: 50%; background: rgba(240,138,75,.35);
}
.hero > * { position: relative; z-index: 1; }
.hero .eyebrow {
  display: inline-block; justify-self: start; font-size: 12.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  background: var(--amber); color: var(--navy); padding: 5px 11px; border-radius: 999px;
}
.hero h1 { margin: 0; color: #fff; max-width: 18ch; }
.hero .lead { font-size: 17px; color: #d8e4f3; margin: 0; max-width: 60ch; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.progress-line { display: grid; gap: 8px; max-width: 460px; }
.progress-line .label { font-size: 14px; color: #d8e4f3; font-weight: 600; }
.bar { height: 12px; background: rgba(255,255,255,.18); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--amber), #F08A4B); border-radius: 999px; }

.level { margin-top: 40px; }
.level-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.level-head .num {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  color: #fff; font-weight: 800; font-size: 16px; flex: none; box-shadow: 0 4px 12px rgba(20,30,50,.15);
}
.level:nth-of-type(1) .num { background: var(--teal); }
.level:nth-of-type(2) .num { background: var(--amber); color: var(--navy); }
.level:nth-of-type(3) .num { background: var(--brick); }
.level-head h2 { margin: 0; }
.level p.muted { margin: 4px 0 0; }
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }

.lesson-card {
  display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit;
  background: var(--paper); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  border-top: 6px solid #c5cfdd; transition: transform .14s, box-shadow .14s;
}
.level:nth-of-type(1) .lesson-card { border-top-color: var(--teal); }
.level:nth-of-type(2) .lesson-card { border-top-color: var(--amber); }
.level:nth-of-type(3) .lesson-card { border-top-color: var(--brick); }
.lesson-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(28,32,39,.16); }
.lesson-card.done { background: #f3faf6; }
.lesson-card h3 { margin: 0; color: var(--navy); font-size: 19px; }
.lesson-card p { margin: 0; color: #4a5263; font-size: 15px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.tag {
  display: inline-block; font-size: 12.5px; font-weight: 700; padding: 4px 11px; border-radius: 999px;
  background: #e8eef7; color: var(--navy);
}
.tag.ok { background: #685d51; color: #fff; }

.error-card { border-left: 6px solid var(--brick); }

/* ---------- Trang bài học ---------- */
.lesson-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 2px 0 4px; }
.lesson-meta .pill {
  font-size: 13px; font-weight: 700; color: var(--navy); background: var(--amber);
  padding: 5px 12px; border-radius: 999px;
}
.lesson-title { margin: 6px 0 12px; }
.slides-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

/* Thanh chuyển tab: máy tính là thanh phía trên, điện thoại là thanh cố định phía dưới */
.tabs {
  display: inline-flex; gap: 4px; background: #e8eaf0; padding: 5px; border-radius: 14px; margin: 4px 0 18px;
}
.tab-btn {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 15px; font-weight: 700;
  padding: 10px 18px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
a.tab-btn { text-decoration: none; }
.tab-btn[aria-selected="true"] { background: var(--paper); color: var(--navy); box-shadow: 0 2px 8px rgba(28,32,39,.12); }
.tab-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.tab-btn[aria-selected="true"] .dot { background: var(--amber); }

.panel[hidden] { display: none; }

.lesson-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.lesson-body { background: var(--paper); border-radius: 20px; padding: 28px 30px; box-shadow: var(--shadow); }
.lesson-body > h1 { display: none; }
.lesson-body > h2:first-child { margin-top: 0; }
.toc { display: none; }

.practice > h2 { margin: 0 0 4px; }
.practice > .muted { margin: 0 0 14px; }
.ex-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ex-tab {
  background: var(--paper); border: 1px solid #c5cfdd; color: var(--navy);
  border-radius: 999px; padding: 7px 15px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.ex-tab:hover { border-color: var(--navy); }
.ex-tab.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.ex-prompt {
  background: var(--paper); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow);
  border-left: 6px solid var(--amber);
}
.ex-prompt h3 { margin-top: 0; }
.ex-prompt p { margin: 8px 0; }

.ide {
  margin-top: 16px; background: var(--code-bg); border-radius: 16px; overflow: hidden;
  box-shadow: 0 14px 34px rgba(20,30,50,.28); border: 1px solid #2c3446;
}
.ide-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #171c27; padding: 10px 14px; border-bottom: 1px solid #2c3446;
}
.dots { display: inline-flex; gap: 6px; }
.dots span { width: 11px; height: 11px; border-radius: 50%; background: #3a4357; }
.dots span:nth-child(1) { background: #e0695a; }
.dots span:nth-child(2) { background: var(--amber); }
.dots span:nth-child(3) { background: #857768; }
.file-tab {
  font-family: Consolas, "Courier New", monospace; font-size: 13px; color: #cfd8e8;
  background: #232b3c; padding: 5px 12px; border-radius: 6px 6px 0 0; margin-left: 6px;
}
.envbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-left: auto; font-size: 13px; color: #b9c4d6; }
.envbar label { display: inline-flex; gap: 6px; align-items: center; }
.envbar select {
  font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid #3a4357; border-radius: 6px;
  background: #232b3c; color: #e8edf7;
}
.envbar input[type="checkbox"] { accent-color: var(--teal); }

.editor { display: grid; grid-template-columns: auto minmax(0, 1fr); height: 340px; }
.gutter {
  margin: 0; padding: 14px 12px 14px 14px; color: #5f6c86; background: #161b26;
  font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 1.6;
  text-align: right; overflow: hidden; user-select: none; white-space: pre; border: 0; border-radius: 0; box-shadow: none;
}
.code-input {
  margin: 0; border: 0; outline: none; resize: none; padding: 14px 16px;
  background: var(--code-bg); color: var(--code-ink);
  font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 1.6;
  white-space: pre; overflow: auto; tab-size: 4; width: 100%;
}
.code-input:focus { box-shadow: inset 0 0 0 2px var(--teal); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 14px; background: #171c27; border-top: 1px solid #2c3446; }
.actions .saved { margin-left: auto; color: #bab1a8; font-size: 13px; min-height: 18px; }
.actions .btn.ghost { background: #232b3c; color: #e8edf7; border-color: #3a4357; box-shadow: none; }
.actions .btn.ghost:hover { background: #2b3446; }

.term-head {
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #8b97ad;
  padding: 10px 14px 0; background: #0f1319;
}
.term {
  background: #0f1319; color: #d7e0ee; margin: 0; padding: 8px 16px 16px; min-height: 120px;
  font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 1.6;
  white-space: pre-wrap; border: 0; border-radius: 0; box-shadow: none;
}
.term .prompt { color: #b2a89e; }
.term .warn { color: #f0c36b; }
.term .err { color: #f38b7b; }
.term .info { color: #8fb3c9; }
.term .ok { color: #b2a89e; }

.saved:empty { display: none; }

/* Máy tính rộng: tab trên cùng, mục lục bên phải trong phần bài đọc */
@media (min-width: 980px) {
  .lesson-wrap { grid-template-columns: minmax(0, 1fr) 230px; }
  .lesson-wrap.no-toc { grid-template-columns: minmax(0, 1fr); }
  .toc { display: block; position: sticky; top: 92px; font-size: 14px; }
  .toc h4 { margin: 0 0 10px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--teal); }
  .toc ol { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--line); }
  .toc a {
    display: block; padding: 6px 0 6px 14px; margin-left: -3px; border-left: 3px solid transparent;
    color: var(--muted); text-decoration: none; line-height: 1.4;
  }
  .toc a:hover, .toc a.on { color: var(--navy); border-left-color: var(--amber); font-weight: 700; }
}

/* Điện thoại: thanh tab cố định phía dưới, một cột */
@media (max-width: 640px) {
  header.top { padding: 10px 14px; }
  header.top nav a { font-size: 13px; padding: 5px 9px; }
  main { padding: 18px 12px 96px; }
  h1 { font-size: 26px; }
  h2 { font-size: 20px; }
  .hero { padding: 24px 20px; border-radius: 18px; }
  .hero h1 { font-size: 26px; }
  .lesson-body { padding: 18px 16px; border-radius: 16px; }
  .editor { height: 280px; }
  .gutter, .code-input, .term { font-size: 13px; }
  pre { font-size: 12.5px; padding: 12px; }
  .actions .saved { margin-left: 0; width: 100%; }
  .envbar { margin-left: 0; }
  .tabs {
    position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 30;
    display: grid; grid-template-columns: 1fr 1fr 1fr; margin: 0;
    background: var(--navy); padding: 6px; border-radius: 16px; box-shadow: 0 10px 28px rgba(20,30,50,.35);
  }
  .tab-btn { justify-content: center; color: #cfdbec; font-size: 14px; padding: 11px 6px; }
  .tab-btn[aria-selected="true"] { background: var(--amber); color: var(--navy); box-shadow: none; }
  .tab-btn .dot { display: none; }
}

/* ---------- Hiệu ứng ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.96); } 60% { transform: scale(1.02); } 100% { transform: scale(1); } }
@keyframes shine { from { transform: translateX(-120%) skewX(-18deg); } to { transform: translateX(260%) skewX(-18deg); } }
@keyframes fill { from { width: 0; } }

/* Nội dung hiện dần khi tải trang */
main > *, .level, .lesson-body, .practice { animation: rise .5s ease both; }
.level:nth-of-type(2) { animation-delay: .08s; }
.level:nth-of-type(3) { animation-delay: .16s; }
.lessons .lesson-card { animation: rise .45s ease both; }
.lessons .lesson-card:nth-child(2) { animation-delay: .06s; }
.lessons .lesson-card:nth-child(3) { animation-delay: .12s; }

/* Nút: nổi lên khi rê chuột, ấn xuống khi bấm, có vệt sáng chạy qua */
.btn { position: relative; overflow: hidden; }
.btn::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  transform: translateX(-120%) skewX(-18deg); pointer-events: none;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(28,32,39,.22); }
.btn:hover::after { animation: shine .7s ease; }
.btn:active { transform: translateY(1px) scale(.98); transition-duration: .05s; }
.btn.run:hover { box-shadow: 0 8px 18px rgba(47,95,179,.35); }
.btn.amber:hover { box-shadow: 0 8px 18px rgba(240,138,75,.4); }

/* Thẻ bài: nổi lên và bóng đậm hơn khi rê chuột */
.lesson-card { transition: transform .18s ease, box-shadow .18s ease, border-color .2s; }
.lesson-card:hover { transform: translateY(-4px); box-shadow: 0 16px 34px rgba(28,32,39,.18); }
.lesson-card:active { transform: translateY(-1px) scale(.99); }

/* Nút chọn bài tập và tab */
.ex-tab, .tab-btn { transition: background .18s ease, color .18s ease, transform .12s ease, box-shadow .18s ease; }
.ex-tab:hover { transform: translateY(-1px); }
.ex-tab:active, .tab-btn:active { transform: scale(.97); }
.tab-btn[aria-selected="true"] { animation: pop .3s ease; }
.tab-btn .dot { transition: transform .25s ease, background .25s ease; }
.tab-btn[aria-selected="true"] .dot { transform: scale(1.4); }

/* Thanh tiến độ chạy từ 0 */
.bar > span { transition: width .9s cubic-bezier(.2,.8,.2,1); }

/* Mục lục: vạch chỉ mục trượt mượt */
.toc a { transition: color .2s, border-color .2s, padding-left .2s; }
.toc a:hover { padding-left: 18px; }

/* Số cấp: nhún nhẹ khi rê chuột vào cả khối cấp */
.level-head .num { transition: transform .25s cubic-bezier(.34,1.56,.64,1); }
.level:hover .level-head .num { transform: rotate(-6deg) scale(1.08); }

/* Tôn trọng người dùng bật "giảm chuyển động" */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Ví dụ & trắc nghiệm ---------- */
[hidden] { display: none !important; }
.demo-card { margin: 14px 0; }
.demo-card h4 { margin: 0 0 8px; color: var(--navy); }
.demo-card pre { margin: 6px 0 10px; }
.demo-card .term { min-height: 0; border-top: 0; border-radius: 10px; background: #0f1319; }
.quiz { margin: 14px 0; }
.quiz h4 { margin: 0 0 10px; color: var(--navy); font-size: 17px; }
.quiz-options { display: grid; gap: 8px; }
.quiz-opt { width: 100%; justify-content: flex-start; text-align: left; white-space: normal; box-shadow: none; }
.quiz-opt:disabled { cursor: default; transform: none; }
.quiz-opt.ok { background: #685d51; border-color: #685d51; color: #fff; }
.quiz-opt.wrong { background: var(--brick); border-color: var(--brick); color: #fff; }
.quiz-feedback { min-height: 22px; margin: 10px 0 0; font-weight: 600; }
.quiz-feedback.good { color: #685d51; }
.quiz-feedback.bad { color: var(--brick); }

/* ---------- Chạy code trực tiếp ---------- */
.stdin-row { background: #171c27; border-top: 1px solid #2c3446; padding: 10px 14px 4px; }
.stdin-row label { display: block; font-size: 12.5px; color: #b9c4d6; margin-bottom: 6px; }
.stdin-row textarea {
  width: 100%; resize: vertical; font-family: Consolas, "Courier New", monospace; font-size: 13px;
  background: #0f1319; color: #e8edf7; border: 1px solid #3a4357; border-radius: 8px; padding: 8px 10px;
}
.term .out { color: #f2f5fa; }
.term .warn { color: #f0c36b; }

/* ---------- Trợ lý học tập ---------- */
#chat-open { position: fixed; right: 18px; bottom: 18px; z-index: 40; background: #F08A4B; color: #14181F; border: 0;
  border-radius: 999px; padding: 12px 18px; font: 700 15px 'Nunito', sans-serif; cursor: pointer; box-shadow: 0 8px 22px rgba(0,0,0,.25); }
#chat-open:hover { background: #f29a62; }
#chat-box { position: fixed; right: 18px; bottom: 18px; z-index: 41; width: min(380px, calc(100vw - 24px)); height: min(520px, calc(100vh - 40px));
  background: #fff; border-radius: 16px; box-shadow: 0 16px 40px rgba(20,24,31,.35); display: flex; flex-direction: column; overflow: hidden; }
#chat-box[hidden] { display: none; }
#chat-box header { background: #1C2027; color: #F1EDE4; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; }
#chat-box header button { background: none; border: 0; color: #F1EDE4; font-size: 22px; cursor: pointer; line-height: 1; }
#chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: #F5F2EA; }
#chat-log .msg { padding: 10px 12px; border-radius: 12px; font-size: 15px; line-height: 1.5; white-space: pre-wrap; max-width: 92%; }
#chat-log .user { background: #2F5FB3; color: #fff; align-self: flex-end; }
#chat-log .bot { background: #fff; color: #1C2027; align-self: flex-start; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
#chat-log .bot.error { color: #B8521F; }
#chat-log .bot.pending { color: #5b6475; font-style: italic; }
#chat-log .passage { background: #fff; border-left: 4px solid #F08A4B; align-self: stretch; max-width: 100%; }
#chat-log .passage .src { font-size: 12.5px; font-weight: 700; color: #B8521F; margin-bottom: 4px; }
#chat-log .passage pre { margin: 0; white-space: pre-wrap; font: 13.5px/1.5 'Nunito', sans-serif; color: #1C2027; background: none; padding: 0; border: 0; box-shadow: none; }
#chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e2e6ee; background: #fff; }
#chat-form input { flex: 1; font: 15px 'Nunito', sans-serif; padding: 9px 11px; border: 1px solid #c5cfdd; border-radius: 10px; }
#chat-form button { background: #1C2027; color: #F1EDE4; border: 0; border-radius: 10px; padding: 0 16px; font: 700 15px 'Nunito', sans-serif; cursor: pointer; }

/* ---------- Bài tập lựa chọn: giải thích từng phương án ---------- */
.quiz-score { font-weight: 700; color: var(--navy); margin: 4px 0 14px; }
.quiz-opt.ok { background: #685d51; border-color: #685d51; color: #fff; }
.quiz-why { margin-top: 10px; padding: 10px 12px; border-radius: 10px; font-size: 15px; line-height: 1.6; }
.quiz-why.good { background: #e6f4ec; color: #4d453d; }
.quiz-why.bad { background: #fbeae7; color: #8a2f22; }
.quiz-again { margin-top: 10px; font-size: 13px; padding: 6px 12px; }
.demo-examples { margin-top: 26px; }
.demo-examples summary { cursor: pointer; font-weight: 700; color: var(--navy); padding: 8px 0; }

/* Chuyển bài và ghi hoàn thành */
.next-link { margin-left: auto; }
.done-note { margin: 10px 0 0; color: #685d51; font-weight: 600; }
.next-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 32px 0 16px; }
.next-bar a[hidden] { display: none; }
.next-link[hidden] { display: none; }

/* Trình chạy từng bước (assets/steps.js) */
.hop-wrap { max-width: 820px; margin: 0 auto; padding: 16px; }
    .hop-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
    .hop-dots { display: flex; gap: 8px; }
    .hop-dots span { width: 12px; height: 12px; border-radius: 50%; background: #c5cfdd; }
    .hop-dots span.on { background: #F08A4B; }
    .hop-stage { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: center; margin-top: 18px; }
    .hop-mascot img { width: 100%; max-width: 180px; height: auto; }
    .hop-bubble { background: #fff; border: 2px solid #1C2027; border-radius: 16px; padding: 16px 18px; font-size: 1.35rem; line-height: 1.5; position: relative; }
    .hop-bubble::before { content: ""; position: absolute; left: -12px; top: 26px; border: 10px solid transparent; border-right: 12px solid #1C2027; border-left: 0; }
    .hop-boxes { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; margin: 26px 0 8px; min-height: 150px; align-items: flex-end; }
    .hop-box { min-width: 150px; max-width: 260px; text-align: center; }
    .hop-box .lid { font-weight: 700; font-size: 1.25rem; background: #2F5FB3; color: #fff; border-radius: 10px 10px 0 0; padding: 6px; font-family: "JetBrains Mono", monospace; }
    .hop-box .body { padding: 0 10px; white-space: nowrap; font-weight: 700; letter-spacing: 0; background: #F5F2EA; border: 3px solid #2F5FB3; border-top: 0; border-radius: 0 0 12px 12px; height: 96px; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; font-weight: 700; color: #1C2027; transition: transform .25s, background .25s; }
    .hop-box .body.fresh { background: #FFE7CF; transform: scale(1.08); }
    .hop-box .body.empty { color: #9aa4b2; font-size: 1rem; font-weight: 600; }
    .hop-code { background: #14181F; color: #E8EDF5; border-radius: 12px; padding: 14px 16px; font-family: "JetBrains Mono", monospace; font-size: 1.25rem; margin-top: 10px; min-height: 52px; }
    .hop-code.none { color: #7d8797; }
    .hop-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
    .hop-actions .btn { font-size: 1.2rem; padding: 14px 22px; }
    .hop-choices { display: grid; gap: 12px; margin-top: 16px; }
    .hop-choices button { font-size: 1.35rem; padding: 14px; border-radius: 14px; border: 2px solid #c5cfdd; background: #fff; cursor: pointer; font-family: inherit; }
    .hop-choices button:hover { border-color: #2F5FB3; }
    .hop-choices button.right { background: #d9f3e4; border-color: #685d51; }
    .hop-choices button.wrong { background: #fde2dc; border-color: #B8521F; }
    .hop-feedback { font-size: 1.2rem; margin-top: 12px; min-height: 1.6em; font-weight: 600; }
    .hop-feedback.good { color: #685d51; }
    .hop-feedback.bad { color: #B8521F; }
    @media (max-width: 600px) {
      .hop-stage { grid-template-columns: 1fr; }
      .hop-mascot img { max-width: 120px; margin: 0 auto; }
      .hop-bubble::before { display: none; }
      .hop-box { width: 120px; }
    }
    @media (prefers-reduced-motion: reduce) { .hop-box .body { padding: 0 10px; white-space: nowrap; font-weight: 700; letter-spacing: 0; transition: none; } }

/* Giá trị dài trong hộp: chữ nhỏ lại để không tràn */
.hop-box .body.long { font-size: 1.35rem; white-space: normal; line-height: 1.25; }

/* Tiến độ theo từng cấp trên trang chủ */
.lvl-progress { margin: 8px 0 14px; }
.lvl-text { font-size: 13px; color: var(--mute, #5b6472); margin-bottom: 6px; }
.lvl-bar { height: 8px; border-radius: 999px; background: #e3e8f0; overflow: hidden; }
.lvl-bar i { display: block; height: 100%; background: var(--amber, #F08A4B); border-radius: 999px; transition: width .4s; }
