/* Quy tắc nền tảng: đồng nhất cách tính kích thước và đặt các biến màu của website. */
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

* {
  box-sizing: border-box;
}

:root {
  --site-navy: #0f172a;
  --site-blue: #2563eb;
  --site-cyan: #06b6d4;
  --site-gold: #f59e0b;
  --site-cream: #f0f4ff;
  --site-paper: rgba(255, 255, 255, 0.86);
  --site-ink: #0f172a;
  --site-muted: #475569;
  --site-border: rgba(255, 255, 255, 0.75);
  --site-border-subtle: rgba(148, 163, 184, 0.25);

  /* Màu quầng sáng nền (Mesh Gradient) mặc định */
  --bg-glow-1: rgba(59, 130, 246, 0.22);
  --bg-glow-2: rgba(168, 85, 247, 0.20);
  --bg-glow-3: rgba(6, 182, 212, 0.18);
  --bg-glow-4: rgba(244, 63, 94, 0.12);

  /* Hệ thống đổ bóng đa tầng pha sắc xanh */
  --site-shadow-sm: 0 4px 12px -2px rgba(30, 58, 138, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --site-shadow: 0 14px 34px -6px rgba(30, 58, 138, 0.10), 0 4px 14px -2px rgba(15, 23, 42, 0.05);
  --site-shadow-lg: 0 24px 48px -10px rgba(30, 58, 138, 0.18), 0 10px 20px -5px rgba(15, 23, 42, 0.08);

  --site-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html {
  scroll-behavior: smooth;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  background-color: #eef2ff;
  background-image:
    radial-gradient(at 8% 12%, var(--bg-glow-1) 0px, transparent 48%),
    radial-gradient(at 92% 10%, var(--bg-glow-2) 0px, transparent 45%),
    radial-gradient(at 85% 88%, var(--bg-glow-3) 0px, transparent 50%),
    radial-gradient(at 15% 85%, var(--bg-glow-4) 0px, transparent 45%),
    linear-gradient(135deg, #f0f7ff 0%, #f5f3ff 50%, #ecfeff 100%);
  background-attachment: fixed;
  color: var(--site-ink);
  font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Lớp lưới chấm kỹ thuật (Dot Pattern) + Quầng sáng nổi hiện đại */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(37, 99, 235, 0.11) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.25) 100%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.25) 100%);
  pointer-events: none;
}

a,
button,
input,
textarea {
  font: inherit;
}

/* Khung trang, phần nội dung chính và header điều hướng. */
.site-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
}

.site-main {
  padding: 32px 0 64px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 1400;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.88) 0%, rgba(30, 41, 59, 0.88) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
}

.site-brand {
  color: #ffffff;
  text-decoration: none;
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.site-brand span {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Thanh điều hướng, nút menu và trạng thái liên kết đang chọn. */
.site-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.site-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
}

.site-menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 3px 0;
  background: #ffffff;
  border-radius: 999px;
}

.site-header .site-nav-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.86);
  text-decoration: none;
  font-size: 0.94rem;
  font-weight: 600;
  transition: all 0.22s var(--site-ease);
}

.site-nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  transform: translateY(-1px);
}

.site-nav-link.is-active {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.22), rgba(245, 158, 11, 0.12));
  color: #fde68a;
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.4);
}

/* Tiêu đề trang, mô tả và kiểu dáng các nút thao tác. */
.site-hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 88% 18%, rgba(56, 189, 248, 0.42) 0%, transparent 45%),
    radial-gradient(circle at 15% 90%, rgba(168, 85, 247, 0.35) 0%, transparent 50%),
    linear-gradient(130deg, #0f172a 0%, #1e3a8a 48%, #3b82f6 100%);
  border-radius: 28px;
  padding: 42px 38px;
  color: #ffffff;
  box-shadow: 0 24px 50px -12px rgba(30, 58, 138, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.site-hero::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -8%;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.16) 0%, transparent 68%);
  pointer-events: none;
}

.site-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.44rem 0.95rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.26);
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.site-title {
  margin: 18px 0 12px;
  font-size: clamp(2rem, 4.3vw, 3.35rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 16px rgba(15, 23, 42, 0.2);
}

.site-subtitle {
  max-width: 720px;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.05rem;
  line-height: 1.75;
}

.site-action-row,
.site-page-actions,
.grade-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.site-primary-link,
.site-secondary-link,
.site-ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0.78rem 1.35rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  border: 0;
  cursor: pointer;
  transition: transform 0.22s var(--site-ease), box-shadow 0.22s var(--site-ease), background 0.22s ease, filter 0.22s ease;
}

.site-primary-link {
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 50%, #7c3aed 100%);
  box-shadow: 0 10px 24px -4px rgba(79, 70, 229, 0.45);
}

.site-secondary-link {
  color: var(--site-ink);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: var(--site-shadow-sm);
  backdrop-filter: blur(8px);
}

.site-ghost-link {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
}

.site-primary-link:hover,
.site-secondary-link:hover,
.site-ghost-link:hover {
  transform: translateY(-2px);
}

.site-primary-link:hover {
  box-shadow: 0 14px 28px -4px rgba(79, 70, 229, 0.58);
  filter: brightness(1.06);
}

.site-secondary-link:hover {
  background: #ffffff;
  border-color: #93c5fd;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.12);
}

.site-ghost-link:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* Liên kết video, lưới nội dung, thẻ bài học (Hiệu ứng Kính mờ) và danh sách chủ đề. */
.video-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 11px 18px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 14px;
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(225, 29, 72, 0.28);
  transition: transform 0.2s var(--site-ease), box-shadow 0.2s var(--site-ease), filter 0.2s ease;
}

.video-link:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 12px 24px rgba(225, 29, 72, 0.38);
}

.video-link:focus-visible {
  outline: 3px solid #fda4af;
  outline-offset: 3px;
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 22px;
  margin-top: 28px;
}

.site-card {
  grid-column: span 4;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0.78) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--site-border);
  border-radius: 24px;
  padding: 26px;
  box-shadow: var(--site-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: transform 0.28s var(--site-ease), box-shadow 0.28s var(--site-ease), border-color 0.28s ease;
}

.site-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--site-shadow-lg), inset 0 1px 0 #ffffff;
  border-color: rgba(96, 165, 250, 0.55);
}

.site-card.wide {
  grid-column: span 8;
}

.site-card.full {
  grid-column: 1 / -1;
}

.site-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.4rem 0.88rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.14), rgba(79, 70, 229, 0.14));
  border: 1px solid rgba(37, 99, 235, 0.18);
  color: var(--site-blue);
  font-size: 0.84rem;
  font-weight: 700;
}

.site-card h2,
.site-card h3 {
  margin: 16px 0 10px;
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.site-card p,
.site-copy {
  margin: 0;
  color: var(--site-muted);
  line-height: 1.72;
}

.topic-list,
.site-link-list {
  margin: 16px 0 0;
  padding-left: 1.2rem;
  color: var(--site-muted);
  line-height: 1.8;
}

.topic-list li + li,
.site-link-list li + li {
  margin-top: 6px;
}

.site-link-list a {
  color: var(--site-blue);
  font-weight: 600;
  text-decoration: none;
}

.site-link-list a:hover {
  color: #4f46e5;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.topic-link-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 22px;
  margin-top: 28px;
}

.topic-link-grid[hidden] {
  display: none;
}

.topic-link-card {
  grid-column: span 6;
  padding: 26px;
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.92) 0%, rgba(248, 250, 252, 0.82) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--site-border);
  box-shadow: var(--site-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: transform 0.28s var(--site-ease), box-shadow 0.28s var(--site-ease), border-color 0.28s ease;
}

.topic-link-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--site-shadow-lg);
  border-color: rgba(96, 165, 250, 0.55);
}

.topic-link-card h2 {
  margin: 14px 0 10px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topic-link-card p {
  margin: 0;
  color: var(--site-muted);
  line-height: 1.72;
}

.overall-test-card {
  background:
    radial-gradient(circle at 90% 15%, rgba(56, 189, 248, 0.35), transparent 45%),
    linear-gradient(130deg, #0f172a 0%, #1e3a8a 55%, #3b82f6 100%);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.overall-test-card h2,
.overall-test-card p {
  color: #fff;
}

.overall-test-card .site-badge {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.overall-test-card .site-primary-link {
  margin-top: 18px;
  background: #ffffff;
  color: #1d4ed8;
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.25);
}

.topic-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.topic-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #eff6ff, #eef2ff);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: var(--site-blue);
  font-size: 0.9rem;
  font-weight: 600;
}

/* Bố cục câu hỏi, lựa chọn trắc nghiệm, phản hồi và thông báo kết quả. */
.question-stack {
  display: grid;
  gap: 20px;
  margin-top: 28px;
}

.question-card {
  padding: 26px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--site-border);
  box-shadow: var(--site-shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.question-card:hover {
  box-shadow: var(--site-shadow);
}

.question-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.38rem 0.85rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #ecfeff, #e0f2fe);
  border: 1px solid rgba(6, 182, 212, 0.25);
  color: #0f766e;
  font-size: 0.84rem;
  font-weight: 700;
}

.question-card h2 {
  margin: 14px 0 10px;
  font-size: 1.15rem;
  line-height: 1.45;
}

.question-card p {
  margin: 0 0 14px;
  color: var(--site-muted);
  line-height: 1.65;
}

.question-card fieldset {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  border: 0;
}

.question-card legend {
  margin-bottom: 10px;
  color: var(--site-muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.question-card fieldset label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  line-height: 1.55;
  transition: all 0.18s ease;
}

.question-card fieldset label:hover {
  border-color: #93c5fd;
  background: #f8fafc;
  transform: translateX(2px);
}

.question-card fieldset label:has(input[type="radio"]:checked) {
  border-color: var(--site-blue);
  background: linear-gradient(90deg, #eff6ff 0%, #eef2ff 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
  font-weight: 600;
}

.question-card input[type="radio"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--site-blue);
  cursor: pointer;
}

.question-card.is-correct {
  border-color: #16a34a;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.95) 0%, #dcfce7 100%);
}

.question-card.is-incorrect {
  border-color: #dc2626;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.95) 0%, #fee2e2 100%);
}

.answer-feedback {
  margin: 16px 0 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.05);
  font-weight: 600;
  line-height: 1.6;
}

.question-card.is-correct .answer-feedback {
  background: rgba(22, 163, 74, 0.14);
  color: #14532d;
}

.question-card.is-incorrect .answer-feedback {
  background: rgba(220, 38, 38, 0.12);
  color: #7f1d1d;
}

.answer-feedback:empty {
  display: none;
}

/* Nút ôn tập xuất hiện bên dưới phản hồi của câu trả lời sai. */
.lesson-review-link {
  align-self: flex-start;
  margin-top: 12px;
}

.lesson-review-link[hidden] {
  display: none;
}

.result-banner {
  margin-top: 24px;
  padding: 20px 24px;
  border-radius: 20px;
  background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 50%, #fae8ff 100%);
  border: 1px solid #93c5fd;
  color: #0f172a;
  font-size: 1.05rem;
  font-weight: 700;
  box-shadow: var(--site-shadow);
}

/* Bố cục chân trang và các liên kết cuối trang. */
.site-footer {
  margin-top: 64px;
  padding: 40px 0 28px;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  color: #e2e8f0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.site-footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 32px;
}

.site-footer-title {
  margin: 0 0 14px;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
}

.site-footer-text {
  margin: 10px 0 0;
  color: #94a3b8;
  line-height: 1.65;
}

.site-footer-links {
  display: grid;
  gap: 10px;
  align-content: start;
}

.site-footer-link {
  color: #cbd5e1;
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
  display: inline-block;
}

.site-footer-link:hover {
  color: #fbbf24;
  transform: translateX(3px);
}

.site-footer-note {
  margin: 28px 0 0;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #64748b;
  font-size: 0.9rem;
}

/* Màu nhận diện riêng theo chương (Đổi cả màu nền trang lẫn thẻ nội dung). */
body[data-chapter="I"],
[data-chapter="I"].site-card,
[data-chapter="I"].topic-link-card {
  --chapter-accent: #1d4ed8;
  --chapter-accent-2: #0d9488;
  --chapter-soft: #dbeafe;
  --chapter-soft-2: #ccfbf1;
  --bg-glow-1: rgba(29, 78, 216, 0.24);
  --bg-glow-2: rgba(13, 148, 136, 0.20);
}

body[data-chapter="II"],
[data-chapter="II"].site-card,
[data-chapter="II"].topic-link-card {
  --chapter-accent: #ea580c;
  --chapter-accent-2: #d97706;
  --chapter-soft: #ffedd5;
  --chapter-soft-2: #fef3c7;
  --bg-glow-1: rgba(234, 88, 12, 0.22);
  --bg-glow-2: rgba(245, 158, 11, 0.20);
}

body[data-chapter="III"],
[data-chapter="III"].site-card,
[data-chapter="III"].topic-link-card {
  --chapter-accent: #059669;
  --chapter-accent-2: #0284c7;
  --chapter-soft: #d1fae5;
  --chapter-soft-2: #e0f2fe;
  --bg-glow-1: rgba(5, 150, 105, 0.22);
  --bg-glow-2: rgba(2, 132, 199, 0.20);
}

body[data-chapter="IV"],
[data-chapter="IV"].site-card,
[data-chapter="IV"].topic-link-card {
  --chapter-accent: #4f46e5;
  --chapter-accent-2: #d97706;
  --chapter-soft: #e0e7ff;
  --chapter-soft-2: #fef3c7;
  --bg-glow-1: rgba(79, 70, 229, 0.24);
  --bg-glow-2: rgba(217, 119, 6, 0.18);
}

body[data-chapter="V"],
[data-chapter="V"].site-card,
[data-chapter="V"].topic-link-card {
  --chapter-accent: #7c3aed;
  --chapter-accent-2: #db2777;
  --chapter-soft: #ede9fe;
  --chapter-soft-2: #fce7f3;
  --bg-glow-1: rgba(124, 58, 237, 0.24);
  --bg-glow-2: rgba(219, 39, 119, 0.20);
}

body[data-chapter] .site-hero {
  background:
    radial-gradient(circle at 85% 20%, rgba(255, 255, 255, 0.22), transparent 45%),
    linear-gradient(125deg, var(--chapter-accent), var(--chapter-accent-2));
}

body[data-chapter] .site-primary-link,
.topic-link-card[data-chapter] .site-primary-link {
  background: linear-gradient(135deg, var(--chapter-accent), var(--chapter-accent-2));
  box-shadow: 0 10px 22px color-mix(in srgb, var(--chapter-accent) 32%, transparent);
}

.topic-link-card[data-chapter] .site-primary-link:hover {
  filter: brightness(1.06);
}

body[data-chapter] .site-card,
body[data-chapter] .chapter-feature-card,
.site-card[data-chapter],
.topic-link-card[data-chapter] {
  border-top: 4px solid var(--chapter-accent);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.92) 25%, color-mix(in srgb, var(--chapter-soft) 75%, white) 100%);
}

body[data-chapter] .chapter-study-card {
  border-top: 4px solid var(--chapter-accent-2);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.92) 25%, color-mix(in srgb, var(--chapter-soft-2) 75%, white) 100%);
}

body[data-chapter] .site-badge,
.site-card[data-chapter] .site-badge,
.topic-link-card[data-chapter] .site-badge {
  background: color-mix(in srgb, var(--chapter-accent) 14%, white);
  border-color: color-mix(in srgb, var(--chapter-accent) 24%, transparent);
  color: var(--chapter-accent);
}

/* Trang giới thiệu (About) */
body[data-nav-active="about"] .site-hero {
  background: linear-gradient(125deg, #0f172a 0%, #312e81 52%, #4f46e5 100%);
}

body[data-nav-active="about"] .site-hero .site-primary-link {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 12px 24px rgba(79, 70, 229, 0.32);
}

body[data-nav-active="about"] .site-card {
  border-top: 4px solid #7c3aed;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.94) 30%, #f5f3ff 100%);
}

body[data-nav-active="about"] .site-card .site-badge {
  background: #f3e8ff;
  color: #6d28d9;
}

body[data-chapter] .chapter-feature-card,
body[data-chapter] .chapter-study-card,
body[data-chapter] .chapter-video-card {
  grid-column: span 6;
}

/* Kích thước, khung nhúng và liên kết mở video YouTube. */
.chapter-video-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-top: 4px solid var(--site-cyan);
}

.chapter-video-card h2 {
  margin: 2px 0 0;
  font-size: 1.15rem;
  line-height: 1.45;
}

.chapter-video-card iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 16px;
  background: #0f172a;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.chapter-video-source {
  align-self: flex-start;
  color: var(--site-blue);
  font-weight: 700;
  text-decoration: none;
}

.chapter-video-source:hover {
  text-decoration: underline;
}

/* Hỗ trợ truy cập: ẩn nội dung trực quan nhưng giữ cho trình đọc màn hình. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Giao diện cửa sổ chat, tin nhắn, ô nhập và nút gửi. */
.chatbot-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1500;
}

.chatbot-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0 22px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 50%, #7c3aed 100%);
  box-shadow: 0 14px 30px rgba(79, 70, 229, 0.42);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.22s var(--site-ease), box-shadow 0.22s var(--site-ease);
}

.chatbot-toggle:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 18px 36px rgba(79, 70, 229, 0.52);
}

.chatbot-toggle span {
  margin-right: 6px;
}

.chatbot-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 120px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  animation: chatbotSlideUp 0.25s var(--site-ease);
}

@keyframes chatbotSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chatbot-panel[hidden] {
  display: none;
}

.chatbot-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #4f46e5 100%);
  color: #ffffff;
}

.chatbot-header h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
}

.chatbot-header p {
  margin: 4px 0 0;
  color: #dbeafe;
  font-size: 0.82rem;
}

.chatbot-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: rotate(90deg);
}

.chatbot-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 18px;
  background: linear-gradient(180deg, #f8fafc 0%, #eff6ff 100%);
}

.chatbot-message {
  max-width: 86%;
  margin: 0;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 0.94rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.chatbot-message-assistant {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: var(--site-ink);
}

.chatbot-message-user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
}

.chatbot-message-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.chatbot-form {
  padding: 14px;
  background: #ffffff;
  border-top: 1px solid var(--site-border-subtle);
}

.chatbot-form textarea {
  display: block;
  width: 100%;
  min-height: 56px;
  resize: vertical;
  padding: 10px 14px;
  border: 1.5px solid #cbd5e1;
  border-radius: 14px;
  color: var(--site-ink);
  font-size: 0.94rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-form textarea:focus {
  border-color: var(--site-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.chatbot-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--site-muted);
  font-size: 0.78rem;
}

.chatbot-send {
  min-height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.2s ease;
}

.chatbot-send:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.chatbot-send:disabled {
  cursor: wait;
  opacity: 0.6;
}

/* Mô phỏng mạch điện và ghi chú an toàn. */
.circuit-demo {
  width: 100%;
  max-width: 560px;
  margin: 16px auto;
  display: block;
  padding: 18px;
  background: linear-gradient(145deg, #ffffff, #f0f9ff);
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: inset 0 2px 6px rgba(15, 23, 42, 0.03);
}

.circuit-demo .wire,
.circuit-demo .switch-contact {
  fill: none;
  stroke: #334155;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
  transition: stroke 0.25s ease;
}

.circuit-demo.is-closed .wire {
  stroke: #0f172a;
}

.circuit-demo .terminal {
  fill: #334155;
}

.circuit-demo .lamp {
  fill: #f8fafc;
  stroke: #334155;
  stroke-width: 5;
  transition: fill 0.25s ease, filter 0.25s ease, stroke 0.25s ease;
}

.circuit-demo.is-closed .lamp {
  fill: #fde047;
  stroke: #ca8a04;
  filter: drop-shadow(0 0 16px rgba(245, 158, 11, 0.8));
}

.circuit-demo text {
  fill: #334155;
  font: 600 15px "Be Vietnam Pro", "Segoe UI", sans-serif;
  text-anchor: middle;
}

.safety-note {
  border-left: 4px solid #dc2626;
  border-radius: 14px;
  padding: 16px 20px;
  background: linear-gradient(90deg, #fef2f2 0%, #fff1f2 100%);
  color: #7f1d1d;
  line-height: 1.7;
  box-shadow: var(--site-shadow-sm);
}

.circuit-status {
  margin: 16px 0 0;
  color: #334155;
  font-weight: 700;
}

/* Điều chỉnh lưới và chân trang cho màn hình vừa. */
@media (max-width: 980px) {
  .site-card,
  .site-card.wide {
    grid-column: 1 / -1;
  }

  body[data-chapter] .chapter-feature-card,
  body[data-chapter] .chapter-study-card,
  body[data-chapter] .chapter-video-card {
    grid-column: 1 / -1;
  }

  .site-footer-grid {
    grid-template-columns: 1fr;
  }
}

/* Điều chỉnh menu, hero, lưới và chatbot cho điện thoại. */
@media (max-width: 768px) {
  .site-shell {
    width: min(100%, calc(100% - 24px));
  }

  .site-menu-toggle {
    display: inline-flex;
  }

  .site-nav {
    position: relative;
  }

  .site-header .site-nav-links {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    min-width: 230px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(16px);
    box-shadow: 0 20px 38px rgba(15, 23, 42, 0.35);
    display: none;
    flex-direction: column;
    align-items: stretch;
  }

  .site-header .site-nav-links.is-open {
    display: flex;
  }

  .site-nav-link {
    width: 100%;
    justify-content: flex-start;
  }

  .site-hero,
  .site-card,
  .question-card,
  .topic-link-card {
    padding: 22px;
  }

  .site-title {
    font-size: 1.95rem;
  }

  .site-grid,
  .topic-link-grid {
    gap: 16px;
  }

  .topic-link-card {
    grid-column: 1 / -1;
  }

  .chatbot-widget {
    right: 12px;
    bottom: 12px;
  }
}