/* =====================================================================
   styles.css - Giao diện khóa học "AI Foundation — Tư duy dùng AI cho người đi làm"
   Tuân theo Edube Brand Kit v1.0 (màu, font, voice & tone).

   >> CHỖ ANH CÓ THỂ CHỈNH:
      - Đổi màu thương hiệu: sửa các biến trong :root ngay bên dưới.
      - Đổi màu từng chữ D (khung 4D): sửa nhóm biến --d-*.
   ===================================================================== */

:root {
  /* ---- Màu chủ đạo Edube ---- */
  --red:      #FE4536;   /* CTA chính, tiêu đề nhấn */
  --orange:   #FE7D47;   /* gradient, accent */
  --yellow:   #FEC756;   /* highlight, ấm áp */
  --charcoal: #272727;   /* text chính */
  --grey:     #AFAEAE;   /* text phụ, divider */
  --cream:    #EFE6DA;   /* nền ấm */

  /* ---- Dẫn xuất ---- */
  --ink:        #272727;
  --ink-soft:   #5b554f;
  --line:       #e9e1d6;
  --bg:         #fdfbf7;
  --bg-card:    #ffffff;
  --bg-warm:    #faf4ec;
  --gradient:   linear-gradient(100deg, var(--red) 0%, var(--orange) 52%, var(--yellow) 100%);

  /* ---- Hệ màu 4D (dùng nhất quán cho thẻ module + sơ đồ) ---- */
  --d-intro:       #9c9a97;  /* Module 0 - khởi đầu */
  --d-description: #FE7D47;  /* Module 1 - Mô tả (cam) */
  --d-discernment: #FE4536;  /* Module 2 - Đánh giá (đỏ) */
  --d-delegation:  #E79A1F;  /* Module 3 - Giao việc (vàng đậm) */
  --d-diligence:   #5a4a40;  /* Module 4 - Trách nhiệm (nâu ấm) */
  --d-agency:      #C2603A;  /* Module 5 - Ủy quyền (terracotta) */

  /* ---- Khoảng cách, bo góc, đổ bóng ---- */
  --r-sm: 10px;
  --r:    16px;
  --r-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(39,39,39,.06), 0 2px 8px rgba(39,39,39,.05);
  --shadow:    0 4px 14px rgba(39,39,39,.08), 0 12px 32px rgba(39,39,39,.06);
  --shadow-lg: 0 10px 30px rgba(254,69,54,.10), 0 24px 60px rgba(39,39,39,.10);

  --maxw: 1120px;
  --readw: 720px;
  --header-h: 64px;

  --font-head: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ===================== RESET / NỀN ===================== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* tôn trọng thuộc tính hidden kể cả khi có display khác */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--ink); line-height: 1.2; margin: 0 0 .5em; }
p { margin: 0 0 1.1em; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ===================== NÚT ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font-family: var(--font-head); font-weight: 700; font-size: 1rem;
  padding: .8em 1.5em; border-radius: 999px; border: 1.5px solid transparent;
  cursor: pointer; transition: transform .12s ease, box-shadow .2s ease, background .2s ease;
  text-decoration: none; line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--orange); color: var(--red); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink-soft); padding: .6em 1em; }
.btn-ghost:hover { color: var(--red); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ===================== HEADER ===================== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(253,251,247,.88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 40px; height: 32px; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-family: var(--font-head); font-weight: 800; letter-spacing: .04em; color: var(--ink); font-size: 1.15rem; }
.brand-tag { font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--grey); margin-top: 3px; }
.header-nav { display: flex; align-items: center; gap: 18px; }
.nav-link { font-family: var(--font-head); font-weight: 600; color: var(--ink-soft); font-size: .95rem; }
.nav-link:hover { color: var(--red); text-decoration: none; }
.auth-slot { display: flex; align-items: center; gap: 10px; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--ink-soft); background: var(--bg-warm); border: 1px solid var(--line); padding: .35em .8em; border-radius: 999px; }
.user-chip strong { color: var(--ink); font-weight: 600; }

/* ---- Thanh tiến độ tổng ---- */
.course-progress { border-top: 1px solid var(--line); background: var(--bg-warm); }
.course-progress-inner { display: flex; align-items: center; gap: 12px; height: 38px; }
.course-progress-label { font-size: .78rem; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.course-progress-track { flex: 1; height: 8px; background: #ece3d6; border-radius: 999px; overflow: hidden; }
.course-progress-fill { height: 100%; background: var(--gradient); border-radius: 999px; transition: width .5s ease; }
.course-progress-pct { font-size: .78rem; font-weight: 700; font-family: var(--font-head); color: var(--red); min-width: 34px; text-align: right; }

/* ===================== HERO (TRANG CHỦ) ===================== */
.hero { position: relative; overflow: hidden; padding: 64px 0 56px; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(1100px 420px at 78% -8%, rgba(254,199,86,.30), transparent 60%),
    radial-gradient(820px 380px at 12% 8%, rgba(254,125,71,.18), transparent 60%);
}
.hero-inner { max-width: 760px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 700; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--red); background: #fff; border: 1px solid var(--line); padding: .45em 1em; border-radius: 999px; box-shadow: var(--shadow-sm); }
.hero h1 { font-size: clamp(2.1rem, 6vw, 3.4rem); font-weight: 800; letter-spacing: -.02em; margin-top: 22px; }
.hero .lead { font-size: clamp(1.05rem, 2.4vw, 1.3rem); color: var(--ink-soft); max-width: 640px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; align-items: center; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 34px; }
.hero-meta div { display: flex; flex-direction: column; }
.hero-meta b { font-family: var(--font-head); font-size: 1.5rem; color: var(--ink); }
.hero-meta span { font-size: .85rem; color: var(--ink-soft); }
.tagline-pill { font-family: var(--font-head); font-style: italic; color: var(--ink-soft); }

/* ===================== SECTION CHUNG ===================== */
.section { padding: 56px 0; }
.section-tight { padding: 40px 0; }
.section-head { max-width: var(--readw); margin-bottom: 32px; }
.section-head h2 { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 800; }
.section-head p { color: var(--ink-soft); margin-bottom: 0; }
.section.alt { background: var(--bg-warm); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

/* ---- Khung 4D trên trang chủ ---- */
.fourd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.fourd-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow-sm); border-top: 4px solid var(--c, var(--orange)); }
.fourd-card .d-letter { font-family: var(--font-head); font-weight: 800; font-size: 1.8rem; color: var(--c, var(--orange)); line-height: 1; }
.fourd-card .fourd-en { font-family: var(--font-head); font-weight: 700; font-size: .8rem; letter-spacing: .01em; color: var(--c, var(--orange)); margin-top: 4px; }
.fourd-card h3 { font-size: 1.05rem; margin: 2px 0 4px; }
.fourd-card p { font-size: .9rem; color: var(--ink-soft); margin: 0; }

/* Sơ đồ luồng 4D: bốn nhịp nối nhau bằng mũi tên */
.fourd-flow { display: flex; align-items: center; gap: 6px; }
.fourd-flow .fourd-card { flex: 1; min-width: 0; }
.flow-arrow { flex: 0 0 auto; color: var(--grey); font-size: 1.5rem; font-weight: 700; }
.fourd-loop { margin-top: 18px; text-align: center; color: var(--ink-soft); font-size: .95rem; }
@media (max-width: 760px) {
  .fourd-flow { flex-direction: column; align-items: stretch; }
  .flow-arrow { transform: rotate(90deg); align-self: center; margin: 2px 0; }
}

/* ===================== THẺ MODULE ===================== */
.modules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; }
.module-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 24px; box-shadow: var(--shadow-sm); overflow: hidden;
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
  text-decoration: none; color: inherit;
}
.module-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c, var(--orange)); }
.module-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); text-decoration: none; border-color: color-mix(in srgb, var(--c, var(--orange)) 40%, var(--line)); }
.module-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.module-badge { font-family: var(--font-head); font-weight: 800; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--c, var(--orange)); }
.module-dchip { font-family: var(--font-head); font-weight: 700; font-size: .72rem; color: #fff; background: var(--c, var(--orange)); padding: .35em .7em; border-radius: 999px; white-space: nowrap; }
.module-card h3 { font-size: 1.22rem; font-weight: 700; margin-bottom: 8px; }
.module-card .desc { color: var(--ink-soft); font-size: .95rem; flex: 1; }
.module-card .meta { font-size: .82rem; color: var(--grey); margin-top: 14px; }
.module-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; font-weight: 600; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--grey); }
.status.todo { color: var(--grey); }
.status.doing { color: var(--orange); }
.status.doing::before { background: var(--orange); }
.status.done { color: #2f9e54; }
.status.done::before { background: #2f9e54; }
.module-go { font-family: var(--font-head); font-weight: 700; font-size: .9rem; color: var(--c, var(--red)); }

/* ===================== TRANG HỌC MODULE ===================== */
.lesson-wrap { max-width: var(--readw); margin: 0 auto; padding: 36px 20px 80px; }
.lesson-head { padding-bottom: 22px; margin-bottom: 26px; border-bottom: 2px solid var(--line); }
.lesson-head .module-badge { font-size: .8rem; }
.lesson-head h1 { font-size: clamp(1.7rem, 4.5vw, 2.4rem); font-weight: 800; margin: 8px 0; }
.lesson-head .sub { color: var(--ink-soft); font-size: 1.05rem; margin: 0; }
.lesson-head .head-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; font-size: .85rem; color: var(--grey); }
.lesson-head .dpill { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: #fff; background: var(--c, var(--orange)); padding: .3em .8em; border-radius: 999px; font-size: .78rem; }

.lesson-body > h2 { font-size: 1.5rem; font-weight: 700; margin: 2em 0 .5em; padding-top: .4em; scroll-margin-top: 110px; }
.lesson-body > h2:first-child { margin-top: 0; }
.lesson-body > h3 { font-size: 1.15rem; font-weight: 600; color: var(--ink); margin: 1.6em 0 .4em; }
.lesson-body p { font-size: 1.06rem; }

/* ---- Các ô đặc biệt ---- */
.box { border-radius: var(--r); padding: 20px 22px 20px 56px; margin: 28px 0; position: relative; box-shadow: var(--shadow-sm); }
.box .box-label { font-family: var(--font-head); font-weight: 700; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; display: block; margin-bottom: 8px; }
.box p:last-child { margin-bottom: 0; }
.box .box-icon { position: absolute; left: 18px; top: 20px; width: 24px; height: 24px; }

/* Ý cốt lõi - nổi bật nhất, dùng gradient nhẹ */
.box-core { background: linear-gradient(180deg, #fff7ee, #fff); border: 1px solid #f6d9b8; border-left: 5px solid var(--red); }
.box-core .box-label { color: var(--red); }
/* Ghi nhớ */
.box-remember { background: #fffaf0; border: 1px solid #f3e2bf; border-left: 5px solid var(--yellow); }
.box-remember .box-label { color: #b8860b; }
/* Chiêm nghiệm - nhẹ, mời suy ngẫm */
.box-reflection { background: var(--bg-warm); border: 1px dashed var(--grey); box-shadow: none; font-style: italic; color: var(--ink-soft); }
.box-reflection .box-label { color: var(--ink-soft); font-style: normal; }
/* Tài nguyên tham khảo */
.box-resource { background: #f5f7f8; border: 1px solid #e2e7ea; border-left: 5px solid #5a6b73; }
.box-resource .box-label { color: #4a5b63; }
.box-resource a { color: var(--red); word-break: break-word; }

/* ---- Hình minh họa ---- */
.figure { margin: 30px 0; }
.figure-frame { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow-sm); }
.figure-frame svg, .figure-frame img { width: 100%; height: auto; border-radius: 8px; }
.figure figcaption { font-size: .85rem; color: var(--grey); margin-top: 10px; text-align: center; line-height: 1.5; }

/* ---- Bài tập (có checkbox tự đánh dấu) ---- */
.exercise { background: #fff; border: 2px solid var(--orange); border-radius: var(--r-lg); padding: 24px; margin: 32px 0; box-shadow: var(--shadow); }
.exercise-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.exercise-tag { font-family: var(--font-head); font-weight: 800; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: #fff; background: var(--gradient); padding: .4em .8em; border-radius: 999px; }
.exercise h3 { font-size: 1.2rem; margin: 0; }
.exercise ol { margin: 14px 0 18px; padding-left: 1.3em; }
.exercise ol li { margin-bottom: 8px; }
.exercise-check { display: flex; align-items: flex-start; gap: 12px; background: var(--bg-warm); border-radius: var(--r); padding: 14px 16px; cursor: pointer; user-select: none; border: 1px solid var(--line); }
.exercise-check input { width: 22px; height: 22px; margin-top: 1px; accent-color: var(--red); cursor: pointer; flex-shrink: 0; }
.exercise-check span { font-weight: 600; font-size: .98rem; }
.exercise-check.done { background: #effaf1; border-color: #b9e6c6; }

/* ===================== TRẮC NGHIỆM ===================== */
.quiz { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 26px; margin: 40px 0 0; box-shadow: var(--shadow); }
.quiz-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.quiz-tag { font-family: var(--font-head); font-weight: 800; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--red); }
.quiz h3 { font-size: 1.3rem; margin: 0 0 4px; }
.quiz .quiz-intro { color: var(--ink-soft); font-size: .92rem; margin-bottom: 8px; }
.quiz-q { padding: 18px 0; border-top: 1px solid var(--line); }
.quiz-q .q-text { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; margin-bottom: 12px; }
.quiz-q .q-text .qnum { color: var(--red); }
.quiz-opts { display: flex; flex-direction: column; gap: 10px; }
.quiz-opt { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-sm); cursor: pointer; transition: border-color .15s, background .15s; background: #fff; }
.quiz-opt:hover { border-color: var(--orange); }
.quiz-opt input { margin-top: 3px; accent-color: var(--red); width: 18px; height: 18px; flex-shrink: 0; }
.quiz-opt.sel { border-color: var(--orange); background: #fff7f0; }
.quiz-opt.correct { border-color: #2f9e54; background: #effaf1; }
.quiz-opt.wrong { border-color: var(--red); background: #fff0ef; }
.quiz-opt .mark { margin-left: auto; font-weight: 700; font-family: var(--font-head); }
.quiz-opt.correct .mark { color: #2f9e54; }
.quiz-opt.wrong .mark { color: var(--red); }
.quiz-foot { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.quiz-result { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; }
.quiz-result.pass { color: #2f9e54; }
.quiz-result.again { color: var(--orange); }
.quiz.graded .quiz-opt { cursor: default; }

/* ===================== ĐIỀU HƯỚNG BÀI ===================== */
.lesson-nav { display: flex; gap: 12px; justify-content: space-between; margin-top: 44px; padding-top: 24px; border-top: 1px solid var(--line); }
.lesson-nav a { flex: 1; max-width: 48%; }
.lesson-nav .navbtn { display: flex; flex-direction: column; gap: 4px; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; transition: border-color .15s, transform .12s; }
.lesson-nav .navbtn:hover { border-color: var(--orange); transform: translateY(-2px); text-decoration: none; }
.lesson-nav .navbtn small { font-size: .75rem; color: var(--grey); }
.lesson-nav .navbtn span { font-family: var(--font-head); font-weight: 700; color: var(--ink); font-size: .95rem; }
.lesson-nav .next { text-align: right; margin-left: auto; }

/* ===================== BỐ CỤC HỌC: SIDEBAR + NỘI DUNG ===================== */
.learn { display: grid; grid-template-columns: 300px 1fr; align-items: start; max-width: 1240px; margin: 0 auto; }
.learn-main { min-width: 0; }                 /* cho phép co lại, tránh tràn ngang */
.learn .lesson-wrap { max-width: 760px; margin: 0 auto; padding-top: 30px; }

/* ---- Mục lục (sidebar) ---- */
.toc {
  position: sticky; top: calc(var(--header-h) + 39px);
  align-self: start; max-height: calc(100vh - var(--header-h) - 50px);
  overflow-y: auto; border-right: 1px solid var(--line);
  background: var(--bg-warm); padding: 8px 0 30px;
}
.toc-head { display: flex; align-items: center; justify-content: space-between; font-family: var(--font-head); font-weight: 700; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); padding: 16px 18px 10px; }
.toc-x { display: none; background: none; border: none; font-size: 1.6rem; line-height: 1; color: var(--grey); cursor: pointer; }
.toc-nav { padding: 0 10px; }
.toc-mod { margin-bottom: 4px; border-radius: var(--r-sm); }
.toc-mod-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; background: none; border: none; cursor: pointer; padding: 10px 10px; border-radius: var(--r-sm); border-left: 3px solid var(--c, var(--orange)); }
.toc-mod-btn:hover { background: #fff; }
.toc-mod-title { font-family: var(--font-head); font-weight: 700; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; color: var(--c, var(--orange)); line-height: 1.3; }
.toc-mod-name { display: block; font-size: .82rem; letter-spacing: 0; text-transform: none; color: var(--ink); font-weight: 600; margin-top: 2px; }
.toc-mod.mod-done .toc-mod-title::after { content: " ✓"; color: #2f9e54; }
.toc-caret { color: var(--grey); transition: transform .2s; font-size: 1.1rem; flex-shrink: 0; }
.toc-mod.open .toc-caret { transform: rotate(90deg); }
.toc-pages { list-style: none; margin: 2px 0 8px; padding: 0; display: none; }
.toc-mod.open .toc-pages { display: block; }
.toc-page { display: flex; align-items: flex-start; gap: 9px; padding: 7px 12px 7px 22px; font-size: .86rem; color: var(--ink-soft); border-radius: 8px; line-height: 1.35; }
.toc-page:hover { background: #fff; text-decoration: none; color: var(--ink); }
.toc-page .toc-dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--grey); margin-top: 5px; flex-shrink: 0; background: #fff; }
.toc-page.done .toc-dot { background: #2f9e54; border-color: #2f9e54; }
.toc-page.active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.toc-page.active .toc-dot { border-color: var(--c, var(--orange)); background: var(--c, var(--orange)); }

/* ---- Nút mở mục lục trên mobile ---- */
.toc-toggle { display: none; align-items: center; gap: 8px; margin: 14px 16px 0; font-family: var(--font-head); font-weight: 700; font-size: .9rem; color: var(--ink); background: #fff; border: 1px solid var(--line); padding: .6em 1em; border-radius: 999px; cursor: pointer; box-shadow: var(--shadow-sm); }
.toc-backdrop { display: none; }

/* Thẻ tổng quan trang chủ: không phải link nên không nhấc lên khi rê chuột */
.module-card.overview { cursor: default; }
.module-card.overview:hover { transform: none; box-shadow: var(--shadow-sm); border-color: var(--line); }

/* ===================== HIỂN THỊ TIẾN ĐỘ ===================== */
/* Thanh tiến độ nhỏ trên mỗi thẻ module */
.card-progress { height: 6px; background: #ece3d6; border-radius: 999px; overflow: hidden; margin-top: 14px; }
.card-progress-fill { height: 100%; background: var(--c, var(--orange)); border-radius: 999px; transition: width .4s ease; }

/* Ô tổng quan tiến độ ở đầu trang Các phần học */
.overview-card { display: flex; align-items: center; gap: 22px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px 24px; box-shadow: var(--shadow-sm); margin-bottom: 26px; }
.overview-ring { position: relative; width: 84px; height: 84px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; background: conic-gradient(var(--red) calc(var(--p) * 1%), #ece3d6 0); }
.overview-ring::before { content: ""; position: absolute; width: 64px; height: 64px; border-radius: 50%; background: #fff; }
.overview-ring span { position: relative; font-family: var(--font-head); font-weight: 800; font-size: 1.05rem; color: var(--ink); }
.overview-info { flex: 1; min-width: 0; }
.overview-info h3 { font-size: 1.1rem; margin: 0 0 4px; }
.overview-info p { margin: 0 0 10px; color: var(--ink-soft); font-size: .95rem; }
.overview-bar { height: 8px; background: #ece3d6; border-radius: 999px; overflow: hidden; }
.overview-bar-fill { height: 100%; background: var(--gradient); border-radius: 999px; transition: width .4s ease; }

/* Tiến độ trong đầu sidebar */
.toc-progress { padding: 4px 18px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.toc-progress-row { display: flex; justify-content: space-between; font-family: var(--font-head); font-weight: 700; font-size: .8rem; color: var(--ink); margin-bottom: 6px; }
.toc-progress-track { height: 7px; background: #ece3d6; border-radius: 999px; overflow: hidden; }
.toc-progress-fill { height: 100%; background: var(--gradient); border-radius: 999px; transition: width .4s ease; }
.toc-progress-sub { font-size: .72rem; color: var(--ink-soft); margin-top: 5px; }

@media (max-width: 540px) {
  .overview-card { flex-direction: column; text-align: center; }
}

/* ===================== KHỐI BỔ SUNG (case, tip, prompt, tabs, tự kiểm) ===================== */
.box .box-title { font-family: var(--font-head); font-weight: 700; font-size: 1.02rem; margin: 0 0 6px; color: var(--ink); }

/* Ví dụ thực tế - tông xanh lá nhẹ, gợi tính thực chiến */
.box-case { background: #f1faf3; border: 1px solid #c6e9d1; border-left: 5px solid #2f9e54; padding-left: 22px; }
.box-case .box-label { color: #228049; }
/* Mẹo từ Anthropic - tông xanh dương trầm, như ghi chú chuyên môn */
.box-tip { background: #f3f6fc; border: 1px solid #d4e0f2; border-left: 5px solid #3f63b0; padding-left: 22px; }
.box-tip .box-label { color: #33518f; }

/* Prompt mẫu có nút sao chép */
.prompt-box { margin: 28px 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-sm); background: #fff; }
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--bg-warm); border-bottom: 1px solid var(--line); }
.prompt-label { font-family: var(--font-head); font-weight: 700; font-size: .82rem; color: var(--ink); }
.prompt-copy { font-family: var(--font-head); font-weight: 700; font-size: .8rem; color: #fff; background: var(--gradient); border: none; padding: .45em 1em; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.prompt-copy:hover { filter: brightness(1.05); }
.prompt-text { margin: 0; padding: 16px; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .9rem; line-height: 1.55; color: var(--ink); white-space: pre-wrap; word-break: break-word; background: #fffdf9; }

/* So sánh Trước / Sau bằng tab */
.cmp-tabs { margin: 28px 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-sm); }
.cmp-title { font-family: var(--font-head); font-weight: 700; font-size: .95rem; padding: 14px 16px 0; }
.cmp-tabbar { display: flex; gap: 8px; padding: 12px 16px; }
.cmp-tab { flex: 1; font-family: var(--font-head); font-weight: 700; font-size: .88rem; padding: .6em 1em; border: 1.5px solid var(--line); background: #fff; color: var(--ink-soft); border-radius: 999px; cursor: pointer; transition: all .15s; }
.cmp-tab.active { background: var(--c, var(--orange)); border-color: var(--c, var(--orange)); color: #fff; }
.cmp-panel { display: none; padding: 4px 18px 18px; }
.cmp-panel.active { display: block; }
.cmp-panel p:last-child { margin-bottom: 0; }

/* Câu hỏi tự kiểm nhanh */
.selfcheck { margin: 28px 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; box-shadow: var(--shadow-sm); }
.sc-label { font-family: var(--font-head); font-weight: 700; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--orange); }
.sc-q { font-family: var(--font-head); font-weight: 600; font-size: 1.02rem; margin: 8px 0 14px; }
.sc-opts { display: flex; flex-direction: column; gap: 10px; }
.sc-opt { text-align: left; font-family: var(--font-body); font-size: .98rem; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: #fff; cursor: pointer; transition: border-color .15s, background .15s; }
.sc-opt:hover { border-color: var(--orange); }
.selfcheck.answered .sc-opt { cursor: default; }
.sc-opt.correct { border-color: #2f9e54; background: #effaf1; }
.sc-opt.wrong { border-color: var(--red); background: #fff0ef; }
.sc-explain { margin: 14px 0 0; padding: 12px 14px; background: var(--bg-warm); border-radius: var(--r-sm); font-size: .92rem; color: var(--ink-soft); }

/* ===================== MỤC TIÊU + TÓM TẮT BÀI ===================== */
.lesson-objective { background: var(--bg-warm); border-left: 4px solid var(--c, var(--orange)); border-radius: var(--r-sm); padding: 12px 16px; margin: 0 0 6px; }
.lo-label { display: block; font-family: var(--font-head); font-weight: 700; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--c, var(--orange)); margin-bottom: 4px; }
.lesson-objective p { margin: 0; font-size: 1rem; color: var(--ink); }
.lesson-summary { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--c, var(--orange)); border-radius: var(--r); padding: 16px 18px; margin: 30px 0 0; box-shadow: var(--shadow-sm); }
.ls-label { display: block; font-family: var(--font-head); font-weight: 700; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--c, var(--orange)); margin-bottom: 6px; }
.lesson-summary ul { margin: 0; padding-left: 1.2em; }
.lesson-summary li { margin-bottom: 5px; }

/* ===================== RUBRIC TỰ CHẤM + ĐẦU RA MẪU ===================== */
.rubric { background: #fffaf0; border: 1px solid #f3e2bf; border-radius: var(--r); padding: 18px 20px; margin: 28px 0; }
.rubric-label { font-family: var(--font-head); font-weight: 700; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: #b8860b; }
.rubric-title { font-family: var(--font-head); font-weight: 700; font-size: 1rem; margin: 6px 0 4px; }
.rubric-list { list-style: none; margin: 10px 0 0; padding: 0; }
.rubric-list li { margin-bottom: 9px; }
.rubric-list label { display: flex; gap: 11px; align-items: flex-start; cursor: pointer; font-size: .97rem; }
.rubric-list input { margin-top: 2px; width: 19px; height: 19px; accent-color: var(--red); flex-shrink: 0; cursor: pointer; }

.sample { margin: 24px 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff; }
.sample summary { cursor: pointer; padding: 12px 16px; font-family: var(--font-head); font-weight: 700; font-size: .9rem; color: var(--ink); background: var(--bg-warm); list-style: none; }
.sample summary::-webkit-details-marker { display: none; }
.sample summary::before { content: "\25B8\00a0"; color: var(--grey); }
.sample[open] summary::before { content: "\25BE\00a0"; }
.sample-body { padding: 14px 16px; }
.sample-body p { font-size: .95rem; margin-bottom: .6em; }
.sample-body p:last-child { margin-bottom: 0; }

/* ===================== KHỐI HƯỚNG DẪN CÁC BƯỚC ===================== */
.steps-box { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--orange); border-radius: var(--r); padding: 18px 20px; margin: 28px 0; box-shadow: var(--shadow-sm); }
.steps-label { font-family: var(--font-head); font-weight: 700; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--orange); }
.steps-title { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; margin: 6px 0 2px; }
.steps-intro { margin: 4px 0 8px; color: var(--ink-soft); font-size: .95rem; }
.steps-list { margin: 8px 0 0; padding-left: 1.3em; }
.steps-list li { margin-bottom: 8px; }
.steps-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.steps-links .btn { font-size: .88rem; padding: .6em 1.1em; }
.steps-note { margin: 14px 0 0; font-size: .85rem; color: var(--ink-soft); background: var(--bg-warm); border-radius: var(--r-sm); padding: 10px 12px; }

/* ===================== CẨM NANG BỎ TÚI ===================== */
.cs-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.cs-top h2 { margin-bottom: 4px; }
.cs-top p { margin: 0; color: var(--ink-soft); }
.cs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.cs-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow-sm); border-top: 4px solid var(--c, var(--orange)); }
.cs-card h3 { font-size: 1.05rem; margin: 0 0 10px; color: var(--c, var(--orange)); }
.cs-list { margin: 0; padding-left: 1.2em; font-size: .92rem; color: var(--ink-soft); }
.cs-list li { margin-bottom: 6px; }
.cs-list b { color: var(--ink); }
.cs-back { margin-top: 24px; }
.overview-link { display: inline-block; margin-top: 10px; font-family: var(--font-head); font-weight: 700; font-size: .85rem; color: var(--red); }
.toc-cheatsheet { display: block; margin: 12px 10px 4px; padding: 10px 12px; border-radius: var(--r-sm); font-family: var(--font-head); font-weight: 700; font-size: .85rem; color: var(--red); border: 1px dashed #f0c9a0; text-align: center; }
.toc-cheatsheet:hover { background: #fff; text-decoration: none; }

/* ===================== IN ẤN (chỉ in phần cẩm nang) ===================== */
@media print {
  .site-header, .site-footer, .toc, .toc-toggle, .toc-backdrop, #toast, .modal-overlay, .cs-top .btn, .cs-back { display: none !important; }
  .section { padding: 0; }
  body { background: #fff; }
  .cs-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .cs-card { box-shadow: none; break-inside: avoid; }
}

/* ===================== AUTH MODAL ===================== */
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(39,39,39,.5); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { position: relative; background: #fff; border-radius: var(--r-lg); padding: 32px; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); max-height: 92vh; overflow-y: auto; }
.modal-close { position: absolute; top: 14px; right: 16px; background: none; border: none; font-size: 1.7rem; line-height: 1; color: var(--grey); cursor: pointer; }
.modal-close:hover { color: var(--ink); }
.modal h2 { font-size: 1.5rem; }
.modal .sub { color: var(--ink-soft); font-size: .95rem; margin-bottom: 18px; }
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-family: var(--font-head); font-weight: 600; font-size: .88rem; margin-bottom: 5px; }
.form-field input { width: 100%; font-family: var(--font-body); font-size: 1rem; padding: .7em .9em; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: #fff; transition: border-color .15s; }
.form-field input:focus { outline: none; border-color: var(--orange); }
.form-field input.invalid { border-color: var(--red); background: #fff6f5; }
.field-error { color: var(--red); font-size: .8rem; margin-top: 4px; min-height: 1em; }
.notice { background: var(--bg-warm); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; font-size: .82rem; color: var(--ink-soft); margin: 4px 0 18px; }
.auth-switch { text-align: center; font-size: .9rem; color: var(--ink-soft); margin-top: 16px; }
.auth-switch button { background: none; border: none; color: var(--red); font-weight: 600; cursor: pointer; font-size: .9rem; font-family: var(--font-body); }
.form-status { font-size: .9rem; margin-top: 10px; min-height: 1.2em; }
.form-status.err { color: var(--red); }
.form-status.ok { color: #2f9e54; }

/* ===================== TOAST ===================== */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--charcoal); color: #fff; padding: .8em 1.3em; border-radius: 999px; font-size: .9rem; box-shadow: var(--shadow); z-index: 200; opacity: 0; transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===================== FOOTER ===================== */
.site-footer { background: var(--charcoal); color: #cfcac4; margin-top: 60px; }
.footer-inner { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1.2fr; gap: 36px 40px; padding-top: 48px; padding-bottom: 32px; }
.footer-brand { max-width: 460px; }
.footer-name { color: #fff; font-size: 1.3rem; }
.footer-line { font-family: var(--font-head); font-style: italic; color: var(--yellow); margin: 6px 0 12px; }
.footer-note { font-size: .85rem; margin: 0; color: #9a948d; }

.footer-col { display: flex; flex-direction: column; gap: 10px; }
.footer-heading { color: #fff; font-family: var(--font-head); font-size: .82rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin: 0 0 4px; }
.footer-link { color: #cfcac4; font-size: .9rem; text-decoration: none; transition: color .15s ease; }
.footer-link:hover { color: var(--yellow); }
.footer-link-note { color: #807a73; font-size: .8rem; }
.footer-contact-name { color: #fff; font-size: .9rem; margin: 0 0 2px; line-height: 1.45; }
.footer-contact-name span { display: block; color: #9a948d; font-size: .82rem; }

.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 20px; padding-bottom: 28px; border-top: 1px solid rgba(255,255,255,.08); font-size: .8rem; color: #807a73; }
.footer-bottom span:last-child { font-family: var(--font-head); font-style: italic; color: var(--yellow); }

@media (max-width: 860px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .footer-inner { grid-template-columns: 1fr; gap: 28px; }
}

/* ===================== EMPTY / LOADING ===================== */
.center-state { max-width: 520px; margin: 80px auto; text-align: center; padding: 0 20px; }
.center-state h2 { font-size: 1.4rem; }
.center-state p { color: var(--ink-soft); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; margin: 0 auto 16px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 720px) {
  body { font-size: 16px; }
  .header-nav { gap: 10px; }
  .nav-link { display: none; }            /* gọn trên mobile, vẫn vào được qua trang chủ */
  .course-progress-label { display: none; }
  .hero { padding: 40px 0 36px; }
  .box { padding: 18px 18px 18px 18px; }
  .box .box-icon { display: none; }
  .lesson-nav { flex-direction: column; }
  .lesson-nav a { max-width: 100%; }
  .modal { padding: 24px 20px; }

  /* Học trên mobile: sidebar thành ngăn kéo trượt từ trái */
  .learn { grid-template-columns: 1fr; }
  .toc-toggle { display: inline-flex; }
  .toc {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 90;
    width: 82%; max-width: 320px; max-height: 100vh;
    border-right: 1px solid var(--line); box-shadow: var(--shadow-lg);
    transform: translateX(-105%); transition: transform .25s ease;
  }
  .toc.show { transform: translateX(0); }
  .toc-x { display: block; }
  .toc-backdrop.show { display: block; position: fixed; inset: 0; z-index: 80; background: rgba(39,39,39,.45); }
  .learn .lesson-wrap { padding-top: 8px; }
}
@media (min-width: 721px) {
  .lesson-body p, .lesson-body li { letter-spacing: .002em; }
}

/* Tôn trọng người dùng tắt hiệu ứng chuyển động */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
