: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; }

.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header { position: sticky; top: 0; z-index: 20; }
.header-top { display: flex; align-items: center; gap: 12px 20px; padding-top: 10px; padding-bottom: 10px; }
.brand { font-weight: 700; font-size: 20px; color: var(--text); text-decoration: none; flex: none; }
.header-tools { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.account-nav { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.account-nav span { display: flex; align-items: center; gap: 12px; }
.account-nav a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.account-nav a.button { color: var(--text); }
.account-nav a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* 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; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); white-space: nowrap; }
.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 { font-size: 13px; }

/* 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 22px; font-size: 14px; 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: 10px 0 8px; border-bottom: 2px solid transparent; }
.subjects-nav a:hover { color: var(--text); }
.subjects-nav a[aria-current] { color: var(--text); border-bottom-color: var(--subject, var(--accent)); font-weight: 600; }
.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 { padding: 6px 8px; }
  .account-nav [data-when="in"] a:not(.button) { display: none; }
}

.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(170px, 1fr)); gap: 10px; }
.subject-grid a { display: flex; flex-direction: column; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--subject, var(--accent)); text-decoration: none; color: var(--text); }
.subject-grid span { color: var(--muted); font-size: 13px; }

.cards { list-style: none; padding: 0; margin: 0 0 32px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card a { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--subject, var(--accent)); text-decoration: none; color: var(--text); }
.card a:hover { border-color: var(--subject, var(--accent)); }
.card-subject { font-size: 12px; font-weight: 600; color: var(--subject, var(--accent)); text-transform: uppercase; letter-spacing: .04em; }
.card-name { font-weight: 600; }
.card-summary { color: var(--muted); font-size: 14px; flex: 1; }
.card-ages { font-size: 12px; color: var(--muted); }
.search-empty { color: var(--muted); }
.topic-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; }
.topic-nav a { font-size: 14px; padding: 4px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.topic-nav a:hover { border-color: var(--accent); }
.topic-nav span { color: var(--muted); margin-left: 4px; }
.topic-group h2 { font-size: 20px; margin: 8px 0 12px; }
.topic-group h2 a { color: var(--text); text-decoration: none; }
.topic-group h2 a:hover { text-decoration: underline; }
.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 { font-size: 14px; color: var(--muted); padding-top: 16px; }
.crumbs a { color: var(--muted); }
.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; }

/* 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 { 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; } }

/* 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; }

