:root {
  --bg: #fbfbf8;
  --surface: #ffffff;
  --text: #1d2327;
  --muted: #5d6870;
  --line: #e2e4df;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --radius: 10px;
  --math: #6d4bd8; --physics: #1f6feb; --chemistry: #d9480f; --biology: #2b8a3e; --science: #0b7285;
  --computer-science: #5c6ac4; --geography: #0c8599; --history: #9c5b2e; --technology: #7a6f00;
  font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171a; --surface: #1c2024; --text: #e8eaec; --muted: #9aa4ad; --line: #2c3238; --accent: #5b9dff; --accent-ink: #0b0d0f; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--accent); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* Header: nền mờ khi cuộn, cao cố định 64px (không nhảy khi nút tài khoản đổi), liên kết dạng nút nhẹ. */
.site-header { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent); -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px); }
.header-top { display: flex; align-items: center; gap: 12px 20px; min-height: 64px; box-sizing: border-box; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; font-weight: 700; font-size: 20px; color: var(--text); text-decoration: none; flex: none; }
.brand img { display: block; height: 40px; width: auto; }
.header-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.account-nav { display: flex; align-items: center; gap: 4px; font-size: 14px; }
.account-nav > span { display: flex; align-items: center; gap: 4px; }
.account-nav a, .account-nav .nav-user { color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 500; }
.account-nav a:not(.button) { padding: 8px 10px; border-radius: 8px; transition: background-color .15s, color .15s; }
.account-nav a:not(.button):hover, .account-nav a:not(.button)[aria-current] { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.account-nav a.button { color: var(--text); margin-left: 6px; padding: 8px 14px; border-radius: 8px; font-weight: 600; line-height: 1.2; }
.account-nav a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.account-nav a.button.primary:hover { filter: brightness(1.06); }
/* Ô tìm trong header (mọi trang) và biểu tượng thay thế trên màn hẹp. */
.header-search input { width: 220px; font: inherit; font-size: 14px; padding: 7px 12px 7px 34px; border: 1px solid var(--line); border-radius: 8px; color: var(--text);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7' fill='none' stroke='%237a848c' stroke-width='2'/%3E%3Cpath d='M20 20l-4-4' stroke='%237a848c' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 10px center / 16px; transition: border-color .15s, width .2s; }
.header-search input:focus { outline: none; border-color: var(--accent); width: 280px; }
.header-search-icon { display: none; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
@media (max-width: 900px) { .header-search { display: none; } .header-search-icon { display: inline-flex; } }
/* Trang tĩnh: auth-hint.js đặt .auth-in trên <html> trước khi vẽ (đăng nhập lần trước), site.js sửa lại theo /app/api/me. */
.auth-in .account-nav [data-when="out"] { display: none; }
.auth-in .account-nav [data-when="in"] { display: flex; }

/* Chọn ngôn ngữ: <details> không cần JS, danh sách thả xuống. */
.lang-menu { position: relative; font-size: 14px; }
.lang-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); font-weight: 500; white-space: nowrap; transition: border-color .15s, color .15s; }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary::after { content: " ▾"; font-size: 11px; }
.lang-menu[open] summary, .lang-menu summary:hover { color: var(--text); border-color: var(--accent); }
.lang-list { position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; display: flex; flex-direction: column; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); z-index: 30; }
.lang-list a { padding: 7px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.lang-list a:hover { background: var(--bg); }
.lang-list a[aria-current] { font-weight: 600; color: var(--accent); }
.lang-globe { flex: none; opacity: .8; }

/* Tài khoản: vòng tròn avatar (chữ cái đầu, màu theo email) mở menu thả xuống; dùng chung cho site tĩnh và ứng dụng.
   Chỗ avatar luôn rộng 34px, kể cả khi còn rỗng chờ /app/api/me, nên header không nhảy. */
.user-menu { position: relative; flex: none; margin-left: 4px; }
.avatar { list-style: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; box-sizing: border-box;
  border-radius: 50%; background: hsl(var(--avatar-hue, 210) 52% 44%); color: #fff; font-size: 13px; font-weight: 700; letter-spacing: .02em; user-select: none;
  transition: box-shadow .15s; }
.avatar::-webkit-details-marker { display: none; }
.avatar:empty { background: var(--line); }
.avatar:hover, .user-menu[open] .avatar, .avatar:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.user-menu-panel { position: absolute; right: 0; top: calc(100% + 8px); width: max-content; min-width: 230px; max-width: min(320px, calc(100vw - 32px));
  display: flex; flex-direction: column; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .14); z-index: 30; }
.user-menu-head { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.user-menu-head strong { max-width: 100%; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-head span { max-width: 100%; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-head .pro-badge { margin-top: 4px; }
.account-nav .user-menu-panel a, .user-menu-panel button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; box-sizing: border-box;
  padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 14px; font-weight: 500; text-align: left;
  text-decoration: none; cursor: pointer; }
.account-nav .user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--bg); }
.user-menu-panel form { margin: 4px 0 0; padding-top: 4px; border-top: 1px solid var(--line); }
.user-menu-meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.account-nav .user-menu-panel .user-menu-mobile { display: none; }
.pro-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
  font-size: 12px; font-weight: 700; }
/* Ứng dụng: số credit còn lại (bấm để mua thêm) và nút tạo sim. */
.account-nav a.credit-chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.account-nav a.nav-create { margin-left: 2px; padding: 7px 12px; }

/* Hàng danh mục môn: một hàng, cuộn ngang khi hẹp; môn đang xem gạch chân theo màu môn. */
.header-subjects { border-top: 1px solid var(--line); }
.subjects-nav { display: flex; gap: 2px 24px; font-size: 14px; font-weight: 500; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.subjects-nav::-webkit-scrollbar { display: none; }
.subjects-nav a { color: var(--muted); text-decoration: none; padding: 11px 0 9px; border-bottom: 2px solid transparent; transition: color .15s, border-color .15s; }
.subjects-nav a:hover { color: var(--text); border-bottom-color: var(--line); }
.subjects-nav a[aria-current] { color: var(--text); border-bottom-color: var(--subject, var(--accent)); font-weight: 600; }
/* "Guides": chữ trên máy rộng, nút biểu tượng (như nút tìm) trên điện thoại. */
.nav-guides-icon { display: none; }
.lang-nav { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; }
.lang-nav a { color: var(--muted); text-decoration: none; }
.lang-nav a:hover, .lang-nav a[aria-current] { color: var(--text); }
@media (max-width: 560px) {
  .header-tools { gap: 8px; }
  .lang-menu summary { width: 36px; height: 36px; padding: 0; box-sizing: border-box; justify-content: center; } /* cùng cỡ nút tìm, nút sách */
  .lang-menu .lang-name, .lang-menu summary::after { display: none; } /* chỉ còn quả địa cầu */
  .nav-my-sims, .nav-create-label { display: none !important; }      /* vào menu avatar; nút tạo chỉ còn dấu + */
  .account-nav .user-menu-panel .user-menu-mobile { display: flex; }
  .account-nav a.nav-guides { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; box-sizing: border-box;
    border: 1px solid var(--line); border-radius: 8px; }
  .nav-guides-icon { display: block; }
  .nav-guides-label { display: none; }
}
@media (max-width: 400px) { .nav-pricing { display: none; } } /* điện thoại rất hẹp: giá vẫn có ở trang chủ và chân trang */
@media (max-width: 440px) { .account-nav a.nav-create { display: none; } } /* ứng dụng trên điện thoại hẹp: tạo sim từ "Sim của tôi" */

.hero { padding: 32px 0 16px; }
.hero h1 { font-size: clamp(24px, 4vw, 36px); line-height: 1.2; margin: 0 0 8px; }
.hero p { color: var(--muted); margin: 0 0 16px; max-width: 60ch; }
.search { width: 100%; max-width: 480px; padding: 10px 14px; font-size: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); }

.subject-grid { list-style: none; padding: 0; margin: 8px 0 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.subject-grid a { display: flex; align-items: center; gap: 14px; height: 100%; box-sizing: border-box; padding: 14px 16px; border-radius: var(--radius); text-decoration: none; color: var(--text);
  background: linear-gradient(135deg, color-mix(in srgb, var(--subject, var(--accent)) 9%, var(--surface)), var(--surface) 70%); border: 1px solid var(--line);
  transition: box-shadow .15s, transform .15s, border-color .15s; }
.subject-grid a:hover { border-color: var(--subject, var(--accent)); box-shadow: 0 8px 20px rgba(16, 24, 40, .08); transform: translateY(-2px); }
.subject-icon { flex: none; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; font-size: 22px;
  background: color-mix(in srgb, var(--subject, var(--accent)) 16%, var(--surface)); }
.subject-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.subject-text strong { line-height: 1.25; }
.subject-text span { color: var(--muted); font-size: 13px; }
.subject-arrow { color: var(--subject, var(--accent)); font-size: 18px; opacity: 0; transform: translateX(-4px); transition: opacity .15s, transform .15s; }
.subject-grid a:hover .subject-arrow { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .subject-grid a, .subject-arrow { transition: none; } .subject-grid a:hover { transform: none; } }

.cards { list-style: none; padding: 0; margin: 0 0 32px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
/* Thẻ sim: ảnh 16:10 trên cùng, tên, dòng phụ "môn · chủ đề", mô tả, tuổi (cùng bố cục thẻ kho mô phỏng ClassQR). */
.card a { display: flex; flex-direction: column; height: 100%; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  overflow: hidden; text-decoration: none; color: var(--text); transition: box-shadow .15s, transform .15s, border-color .15s; }
.card a:hover { box-shadow: 0 10px 24px rgba(16, 24, 40, .10); transform: translateY(-2px); border-color: var(--subject, var(--accent)); }
.card-thumb { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; background: #fff;
  border-bottom: 3px solid var(--subject, var(--accent)); }
.card-thumb--empty { display: flex; align-items: center; justify-content: center; font-size: 44px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--subject, var(--accent)), color-mix(in srgb, var(--subject, var(--accent)) 55%, #fff)); }
.card-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 14px; flex: 1; }
.card-name { font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-topic { font-size: 13px; font-weight: 500; color: var(--subject, var(--accent)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-subject { font-size: 12px; font-weight: 600; color: var(--subject, var(--accent)); text-transform: uppercase; letter-spacing: .04em; }
.card-summary { color: var(--muted); font-size: 14px; flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-ages { font-size: 12px; color: var(--muted); }
/* Nhãn 3D / 2D + 3D góc ảnh thẻ; bộ lọc kiểu hiển thị cạnh ô tìm kiếm. */
.card a { position: relative; }
.card-view { position: absolute; top: 8px; right: 8px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: rgba(17, 24, 39, .78); color: #fff; letter-spacing: .02em; }
.view-filter { display: inline-flex; margin-top: 10px; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.view-filter button { border: 0; border-radius: 0; background: transparent; padding: 6px 14px; font-size: 14px; color: var(--muted); }
.view-filter button + button { border-left: 1px solid var(--line); }
.view-filter button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.view-filter button:hover { color: var(--text); }
.view-filter button[aria-pressed="true"]:hover { color: var(--accent-ink); }
/* Sim cộng đồng (giáo viên tạo bằng AI, đã duyệt): nhãn nhỏ trên thẻ và trên trang sim. */
.card-badge, .sim-chips .chip-community { align-self: flex-start; font-size: 11px; font-weight: 600; letter-spacing: .02em; padding: 1px 8px;
  border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); border: 0; }
.sim-community-note { font-size: 13px; color: var(--muted); }
/* Hướng dẫn dưới sim: sim cho thấy gì, cách dùng + tham số, câu hỏi gợi ý. */
.sim-lesson { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.sim-guide { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin: 20px 0 8px; }
.sim-guide section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.sim-guide h2 { font-size: 17px; margin: 0 0 8px; }
.sim-guide h3 { font-size: 14px; margin: 12px 0 6px; color: var(--muted); }
.sim-guide p { margin: 0; line-height: 1.55; }
.sim-params, .sim-questions { margin: 0; padding-left: 20px; line-height: 1.55; }
.sim-params span { color: var(--muted); }
.sim-questions li + li, .sim-params li + li { margin-top: 4px; }
@media (prefers-reduced-motion: reduce) { .card a { transition: none; } .card a:hover { transform: none; } }
.search-empty { color: var(--muted); }
.topic-nav { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 0 0 28px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.topic-nav a { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; padding: 5px 6px 5px 12px; border-radius: 999px; background: var(--bg); border: 1px solid transparent; color: var(--text); text-decoration: none; transition: border-color .15s, background .15s; }
.topic-nav a:hover { border-color: var(--subject, var(--accent)); background: var(--surface); }
.topic-nav span { min-width: 22px; padding: 0 6px; box-sizing: border-box; border-radius: 999px; text-align: center; font-size: 12px; line-height: 20px; font-weight: 600;
  color: var(--subject, var(--accent)); background: color-mix(in srgb, var(--subject, var(--accent)) 12%, var(--surface)); }
.topic-group { margin: 0 0 12px; scroll-margin-top: 130px; }
.topic-group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 8px 0 14px; padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.topic-group h2 { font-size: 20px; margin: 0; padding-left: 12px; border-left: 4px solid var(--subject, var(--accent)); line-height: 1.25; }
.topic-group h2 a { color: var(--text); text-decoration: none; }
.topic-group h2 a:hover { color: var(--subject, var(--accent)); }
.topic-group-count { flex: none; font-size: 14px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.topic-group-count:hover { color: var(--subject, var(--accent)); }
/* Trong nhóm chủ đề, dòng "môn · chủ đề" trên thẻ lặp lại tiêu đề nhóm: ẩn. */
.topic-group .card-subject, .topic-group .card-topic { display: none; }
.subject-math { --subject: var(--math); } .subject-physics { --subject: var(--physics); } .subject-chemistry { --subject: var(--chemistry); }
.subject-biology { --subject: var(--biology); } .subject-science { --subject: var(--science); } .subject-computer-science { --subject: var(--computer-science); }
.subject-geography { --subject: var(--geography); } .subject-history { --subject: var(--history); } .subject-technology { --subject: var(--technology); }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 14px; color: var(--muted); padding-top: 16px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs .crumb-sep { color: var(--line); font-weight: 600; }
.crumbs [aria-current] { color: var(--text); font-weight: 500; }
.sim-page h1 { font-size: clamp(22px, 3.5vw, 32px); line-height: 1.25; margin: 8px 0; }
.sim-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.sim-chips span { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.sim-description { max-width: 70ch; }
.sim-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
button { font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
button:hover { border-color: var(--accent); color: var(--accent); }

.player { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.player-stage { position: relative; background: #fff; min-height: 320px; }
.player-stage iframe { display: block; width: 100%; height: 600px; border: 0; background: #fff; }
.player-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; color: #5d6870; }
.player-stage:fullscreen iframe { height: 100vh; }
.player-signin { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 600; color: var(--accent-ink); background: var(--accent); }
a.button { display: inline-block; font-size: 14px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; }
a.button:hover { border-color: var(--accent); color: var(--accent); }
.controls { border-top: 1px solid var(--line); padding: 8px 14px; font-size: 14px; }
.controls summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.control { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; align-items: center; gap: 10px; padding: 6px 0; }
.control input[type=range] { width: 100%; }
.control select, .control input[type=text] { font: inherit; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); max-width: 100%; }
.control output { min-width: 5em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.control-reset { margin-top: 6px; }
@media (max-width: 560px) { .control { grid-template-columns: 1fr auto; } .control-name { grid-column: 1 / -1; } }

.related h2 { font-size: 20px; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; padding: 16px 0 32px; }

.site-footer a { color: var(--muted); }
.legal { max-width: 76ch; padding: 8px 0 32px; }
.legal h1 { font-size: clamp(24px, 3.5vw, 34px); margin: 16px 0 4px; }
.legal .legal-date { color: var(--muted); margin: 0 0 20px; }
.legal h2 { font-size: 20px; margin: 28px 0 8px; }
.legal li { margin: 4px 0; }
.legal table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 8px 0 16px; }
.legal th, .legal td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.legal code { font-size: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }

/* Nội dung bài hướng dẫn: dùng chung cho trang tĩnh /{loc}/guides/… và khung xem trước trong trình soạn admin. */
.guide-content { font-size: 17px; line-height: 1.7; color: var(--text); }
.guide-content h2 { font-size: clamp(21px, 2.6vw, 26px); line-height: 1.3; margin: 36px 0 10px; }
.guide-content h3 { font-size: 19px; line-height: 1.35; margin: 26px 0 8px; }
.guide-content p { margin: 0 0 14px; }
.guide-content ul, .guide-content ol { margin: 0 0 16px; padding-left: 24px; }
.guide-content li { margin: 6px 0; }
.guide-content img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; }
.guide-content blockquote { margin: 16px 0; padding: 10px 16px; border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 8px 8px 0; color: var(--muted); }
.guide-content code { font-size: .88em; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.guide-content table { border-collapse: collapse; width: 100%; font-size: 15px; margin: 8px 0 18px; display: block; overflow-x: auto; }
.guide-content th, .guide-content td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.guide-sim { margin: 20px 0 24px; }
.guide-sim-frame { display: block; width: 100%; height: 600px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.guide-sim figcaption { font-size: 14px; color: var(--muted); margin-top: 6px; }
.guide-simcard { display: flex; align-items: center; gap: 14px; margin: 16px 0; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-decoration: none; color: var(--text); font-weight: 600; }
.guide-simcard img { width: 160px; height: 100px; object-fit: cover; border-radius: 8px; border: 0; }
.guide-simcard:hover { border-color: var(--accent); }
/* Trang bài và mục lục bài hướng dẫn; khối "Teaching ideas" ở trang sim. */
.guide-page { max-width: 760px; padding: 8px 0 24px; }
.guide-page h1 { font-size: clamp(26px, 4vw, 38px); line-height: 1.2; margin: 16px 0 6px; }
.guide-updated { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.guides-hero { padding-bottom: 8px; }
.guides-hero .lead { color: var(--muted); font-size: 17px; max-width: 70ch; }
.guides-section { margin: 24px 0 32px; }
.guides-section h2, .guides-related h2, .sim-teaching h2 { font-size: 20px; margin: 0 0 12px; }
.guide-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.guide-cards a { display: flex; flex-direction: column; gap: 6px; height: 100%; box-sizing: border-box; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); text-decoration: none; color: var(--text); transition: border-color .15s; }
.guide-cards a:hover { border-color: var(--accent); }
.guide-cards strong { font-size: 16px; line-height: 1.35; }
.guide-cards span { color: var(--muted); font-size: 14px; line-height: 1.5; }
.sim-teaching { margin-top: 28px; }
/* Ô tìm ở trang chủ (gửi tới trang tìm kiếm) và trang tìm kiếm. */
.home-search { display: flex; gap: 8px; max-width: 560px; }
.home-search .search { flex: 1; min-width: 0; max-width: none; }
.home-search .button { flex: none; font-size: 16px; padding: 10px 20px; }
.search-page { padding: 8px 0 40px; }
.search-page h1 { font-size: clamp(24px, 3.5vw, 32px); margin: 16px 0 12px; }
.search-page-form .search { max-width: 640px; font-size: 17px; padding: 12px 16px; }
.search-subjects { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 4px; }
.search-subjects button { font: inherit; font-size: 14px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); cursor: pointer; }
.search-subjects button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.search-status { margin: 12px 0; font-size: 14px; }
.search-guides { margin: 8px 0 24px; }
.search-guides h2 { font-size: 18px; margin: 0 0 10px; }
.search-more-wrap { text-align: center; margin: 20px 0; }
.search-none { padding: 24px 0; }
.search-none p:first-child { font-size: 17px; }
.guides-related { margin: 8px 0 32px; }
.guide-use-lesson { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin: 28px 0 8px; padding: 18px 20px;
  border: 1px solid var(--accent); border-radius: 12px; background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.guide-use-lesson strong { font-size: 18px; }
.guide-use-lesson p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }

/* Logo: bản trong suốt, chữ xanh đậm; nền tối thì đặt trên thẻ sáng để đọc được. */
.brand img { display: block; height: 46px; width: auto; }
@media (prefers-color-scheme: dark) { .brand img { background: #fff; border-radius: 8px; padding: 3px 6px; box-sizing: content-box; height: 40px; } }

/* Trang chủ */
main.home { padding: 0; }
.home-hero { background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%); border-bottom: 1px solid var(--line); }
.home-hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 32px; align-items: center; padding-top: 44px; padding-bottom: 48px; }
.home-eyebrow { display: inline-block; margin: 0 0 14px; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.home-hero h1 { font-size: clamp(30px, 4.4vw, 48px); line-height: 1.1; margin: 0 0 14px; letter-spacing: -.02em; }
.home-lead { font-size: 18px; color: var(--muted); margin: 0 0 22px; max-width: 52ch; }
.home-hero .search { max-width: 520px; padding: 13px 16px; font-size: 17px; box-shadow: 0 2px 10px rgba(0, 0, 0, .05); }
.home-cta { margin: 16px 0 0; }
.button.primary, a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
a.button.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.home-hero-art { position: relative; height: 360px; }
.home-hero-art .shot { position: absolute; display: block; width: 72%; border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
  background: #fff; box-shadow: 0 18px 40px rgba(16, 24, 40, .16); transition: transform .2s; }
.home-hero-art .shot img { display: block; width: 100%; height: auto; }
.home-hero-art .shot-1 { top: 0; left: 0; z-index: 3; }
.home-hero-art .shot-2 { top: 34px; right: 0; width: 58%; z-index: 2; transform: rotate(2deg); }
.home-hero-art .shot-3 { bottom: 0; left: 18%; width: 56%; z-index: 1; transform: rotate(-2deg); }
.home-hero-art .shot:hover { transform: translateY(-4px); z-index: 4; }

.home-stats { list-style: none; margin: 28px 0 8px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.home-stats li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.home-stats b { display: block; font-size: 28px; line-height: 1.1; }
.home-stats span { color: var(--muted); font-size: 14px; }
.home-section { margin: 36px 0; }
.home-section h2 { font-size: 22px; margin: 0 0 14px; }
.home-results { margin: 28px 0; }
.home-results h2 { font-size: 20px; }

.featured { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.featured a { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 0 0 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--text); transition: box-shadow .15s, transform .15s; }
.featured a:hover { box-shadow: 0 10px 28px rgba(16, 24, 40, .12); transform: translateY(-2px); border-color: var(--subject, var(--accent)); }
.featured img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-bottom: 3px solid var(--subject, var(--accent)); background: #fff; }
.featured .card-subject, .featured .card-name, .featured .card-topic { padding: 0 16px; }

.how-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.how-steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 16px; }
.how-n { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15px; }
.how-steps h3 { font-size: 17px; margin: 12px 0 6px; }
.how-steps p { margin: 0; color: var(--muted); font-size: 15px; }

@media (max-width: 860px) {
  .home-hero-grid { grid-template-columns: 1fr; padding-top: 28px; padding-bottom: 32px; }
  .home-hero-art { height: 260px; max-width: 520px; }
  .home-stats { grid-template-columns: repeat(2, 1fr); }
  .how-steps { grid-template-columns: 1fr; }
}
@media (max-width: 480px) { .home-hero-art { display: none; } }

/* Trang chủ: khối tạo sim bằng AI */
.home-create { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); gap: 32px; align-items: center; margin: 40px 0; padding: 32px;
  border-radius: 16px; border: 1px solid var(--line);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 9%, var(--surface)) 0%, color-mix(in srgb, #22c55e 8%, var(--surface)) 100%); }
.home-create h2 { font-size: clamp(22px, 3vw, 30px); line-height: 1.2; margin: 0 0 12px; }
.home-create-text > p { color: var(--muted); font-size: 16px; margin: 0 0 14px; }
.create-points { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.create-points li { position: relative; padding-left: 26px; }
.create-points li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 18px; height: 18px; border-radius: 50%; font-size: 12px; line-height: 18px;
  text-align: center; background: var(--accent); color: var(--accent-ink); }
.create-note { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.home-create-demo { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.demo-prompt { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: 0 6px 18px rgba(16, 24, 40, .08); }
.demo-prompt p { margin: 4px 0 0; font-size: 15px; }
.demo-label { font-size: 12px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.demo-arrow { text-align: center; color: var(--accent); font-size: 20px; line-height: 1; }
.demo-result { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 10px 28px rgba(16, 24, 40, .12); }
.demo-result img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; }
.demo-result span { display: block; padding: 8px 14px; font-size: 14px; font-weight: 600; color: #15803d; }
@media (max-width: 860px) { .home-create { grid-template-columns: 1fr; padding: 22px; } }
/* Khối gói và giá trên trang chủ: ba thẻ Free / AI credits / Pro. */
.plans-grid { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px; }
.plans-grid li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.plans-grid h3 { margin: 0; font-size: 17px; }
.plans-grid .plans-price { font-size: 26px; font-weight: 700; margin: 6px 0 8px; }
.plans-grid li > p:last-child { color: var(--muted); margin: 0; font-size: 15px; }
.plans-grid .plans-pro { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* Trang 404 */
.not-found { padding: 40px 0 48px; }
.not-found-code { margin: 0; font-size: 64px; font-weight: 800; line-height: 1; color: var(--accent); opacity: .25; }
.not-found h1 { font-size: clamp(26px, 4vw, 36px); margin: 8px 0 10px; }
.not-found .subject-grid { margin-top: 28px; }


/* Trình chiếu ngay trên trang sim (nút "Trình chiếu", player.js thêm body.presenting): chỉ còn sim, bảng tham số và nút
   trình chiếu/đặt lại; sim cao gần hết màn hình, chữ to cho màn hình lớp. */
body.presenting .site-header, body.presenting .site-footer, body.presenting .crumbs, body.presenting .sim-chips,
body.presenting .sim-description, body.presenting .sim-lesson, body.presenting .sim-community-note, body.presenting .sim-guide,
body.presenting .related { display: none; }
body.presenting .sim-actions > :not([data-present-toggle]):not([data-restart]) { display: none; }
body.presenting main { max-width: none; padding: 8px 16px; }
body.presenting .sim-page h1 { margin: 4px 0 8px; font-size: 1.9rem; }
body.presenting .player-stage iframe { height: calc(100vh - 170px); min-height: 480px; }
body.presenting .controls { font-size: 18px; }