@layer reset, base, layout, components, pages, utils;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 88px; }
  body { margin: 0; }
  img, svg, video, iframe { display: block; max-width: 100%; }
  img { height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; }
  h1, h2, h3, h4, p, figure, blockquote, ul, ol { margin: 0; }
  ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
  a { color: inherit; }
  :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
}

@layer base {
  :root {
    color-scheme: light;
    --ink: #0f1b2d;
    --ink-2: #364254;
    --muted: #5a6575;
    --line: #dce2ea;
    --line-2: #e8ecf2;
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #eef2f7;
    --brand: #1f56b8;
    --brand-ink: #173f87;
    --brand-soft: #e6eefb;
    --accent: #e8701a;
    --accent-ink: #b25206;
    --accent-soft: #fdefe2;
    --mark: #ffd84a;
    --ok: #15803d; --ok-soft: #e7f6ec;
    --warn: #a16207; --warn-soft: #fdf6dd;
    --err: #c62828; --err-soft: #fdecec;
    --focus: #f59e0b;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-1: 0 1px 2px rgba(20,32,51,.06), 0 1px 1px rgba(20,32,51,.04);
    --shadow-2: 0 10px 30px -12px rgba(20,32,51,.18), 0 2px 6px rgba(20,32,51,.05);
    --wrap: 1200px;
    --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    /* Tiêu đề: Bricolage Grotesque (có dấu tiếng Việt, độ đậm thay đổi) — chỉ dùng cho h1/h2, logo, giá lớn */
    --font-display: 'Bricolage Grotesque', 'Be Vietnam Pro', system-ui, sans-serif;
    /* Prompt & code: JetBrains Mono — prompt là "sản phẩm" của GENOS nên được trình bày như văn bản thật */
    --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --ink: #eef2f8; --ink-2: #c5cedb; --muted: #9aa5b5;
      --line: #273145; --line-2: #1f2838;
      --bg: #0d1320; --surface: #141c2b; --surface-2: #1a2335;
      --mark: rgba(255, 216, 74, .32);
      --brand: #6b9cf0; --brand-ink: #a9c5f7; --brand-soft: #1b2a45;
      --accent: #f2913f; --accent-ink: #f7b47a; --accent-soft: #3a2614;
      --ok-soft: #10301d; --warn-soft: #33290b; --err-soft: #3a1515;
      --shadow-2: 0 10px 30px -12px rgba(0,0,0,.6);
    }
  }
  @view-transition { navigation: auto; }

  body {
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
  /* Dấu tiếng Việt chồng tầng (ộ, ữ, Ở) cần line-height ≥ 1.12 để không chạm dòng trên */
  h1, h2 { font-family: var(--font-display); letter-spacing: -.028em; }
  h1 { font-size: clamp(2rem, 1.35rem + 2.6vw, 3.1rem); line-height: 1.12; font-weight: 800; }
  h2 { font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.35rem); line-height: 1.16; }
  h3 { font-size: 1.15rem; }
  code, kbd, pre, samp { font-family: var(--font-mono); }
  p { text-wrap: pretty; }
  a { text-decoration-thickness: 1px; text-underline-offset: 3px; }
  ::selection { background: var(--brand-soft); color: var(--ink); }
  /* Icon mặc định cỡ theo chữ; specificity 0 để mọi rule cụ thể ghi đè được */
  :where(svg[aria-hidden="true"]) { width: 1.15em; height: 1.15em; display: inline-block; vertical-align: -.2em; flex: none; }
}

@layer layout {
  .wrap { width: min(100% - 32px, var(--wrap)); margin-inline: auto; }
  .wrap-narrow { width: min(100% - 32px, 760px); margin-inline: auto; }
  .section { padding-block: clamp(48px, 7vw, 88px); }
  .section-tight { padding-block: 40px; }
  .section-alt { background: var(--surface); border-block: 1px solid var(--line-2); }
  .grid { display: grid; gap: 24px; }
  .grid-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
  .grid-4 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
  .stack > * + * { margin-top: var(--gap, 16px); }
  .row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
  .between { justify-content: space-between; }
  .skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; }
  .skip:focus { left: 8px; }
}

@layer components {
  /* ---------- Header ---------- */
  .site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
  .site-header .wrap { display: flex; align-items: center; gap: 20px; min-height: 68px; }
  .logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 1.32rem; letter-spacing: -.01em; color: var(--ink); }
  .logo-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1.1rem; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
  .main-nav { display: flex; gap: 4px; margin-left: 8px; }
  .main-nav a { white-space: nowrap; text-decoration: none; padding: 8px 14px; border-radius: 999px; font-weight: 500; color: var(--ink-2); }
  .main-nav a:hover { background: var(--surface-2); color: var(--ink); }
  .main-nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
  .header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
  .icon-btn { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--ink-2); text-decoration: none; }
  .icon-btn:hover { background: var(--surface-2); color: var(--ink); }
  .icon-btn svg { width: 22px; height: 22px; }
  .badge-count { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
  .search-form { position: relative; flex: 0 1 280px; }
  .search-form input { width: 100%; height: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); padding: 0 16px 0 42px; }
  .search-form svg { position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); }

  .user-menu { position: relative; }
  .user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
  .user-menu summary::-webkit-details-marker { display: none; }
  .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
  .menu-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 8px; }
  .menu-pop a, .menu-pop button { display: flex; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px; text-decoration: none; border: 0; background: none; font-size: .95rem; }
  .menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); }
  .menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

  /* Thanh điều hướng đáy cho điện thoại */
  .tabbar { display: none; }
  .show-m { display: none !important; }
  @media (max-width: 1120px) { .search-form { display: none; } .search-form + .show-m { display: grid !important; } }
  @media (max-width: 860px) {
    .main-nav, .search-form, .hide-m { display: none !important; }
    .show-m { display: grid !important; }
    .site-header .wrap { min-height: 60px; }
    body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
    .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 60; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
    .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 9px 2px 8px; font-size: .72rem; font-weight: 500; text-decoration: none; color: var(--muted); }
    .tabbar a svg { width: 23px; height: 23px; }
    .tabbar a[aria-current="page"] { color: var(--brand); }
  }

  /* ---------- Buttons ---------- */
  .btn { --b: var(--brand); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 22px; border-radius: 12px; border: 1px solid var(--b); background: var(--b); color: #fff; font-weight: 600; text-decoration: none; line-height: 1.2; transition: background .15s, transform .1s, box-shadow .15s; white-space: nowrap; }
  .btn:hover { background: color-mix(in srgb, var(--b) 88%, #000); }
  .btn:active { transform: translateY(1px); }
  .btn svg { width: 19px; height: 19px; }
  .btn-accent { --b: var(--accent); }
  .btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
  .btn-ghost:hover { background: var(--surface-2); }
  .btn-soft { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
  .btn-soft:hover { background: color-mix(in srgb, var(--brand-soft) 80%, var(--brand)); }
  .btn-danger { --b: var(--err); }
  .btn-lg { min-height: 54px; padding: 0 28px; font-size: 1.05rem; border-radius: 14px; }
  .btn-sm { min-height: 36px; padding: 0 14px; font-size: .9rem; border-radius: 9px; }
  .btn-block { width: 100%; }
  .btn[disabled] { opacity: .55; pointer-events: none; }
  .link { color: var(--brand); font-weight: 600; text-decoration: none; }
  .link:hover { text-decoration: underline; }

  /* ---------- Badges & chips ---------- */
  .tag { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
  .tag-free { background: var(--ok-soft); color: var(--ok); }
  .tag-paid { background: var(--accent-soft); color: var(--accent-ink); }
  .tag-brand { background: var(--brand-soft); color: var(--brand-ink); }
  .chips { display: flex; gap: 8px; flex-wrap: wrap; }
  .chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; font-weight: 500; font-size: .95rem; color: var(--ink-2); }
  .chip:hover { border-color: var(--brand); color: var(--brand); }
  .chip[aria-current="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

  /* ---------- Cards ---------- */
  .card { container-type: inline-size; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .2s, transform .2s, border-color .2s; position: relative; }
  .card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); border-color: color-mix(in srgb, var(--line) 60%, var(--brand)); }
  .card-media { aspect-ratio: 16/9; background: var(--surface-2); overflow: hidden; }
  .card-media img { width: 100%; height: 100%; object-fit: cover; }
  .card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
  .card-title { font-size: 1.1rem; font-weight: 700; line-height: 1.38; text-wrap: pretty; }
  .card-title a { text-decoration: none; }
  .card-title a::after { content: ""; position: absolute; inset: 0; }
  .card-text { color: var(--muted); font-size: .95rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
  .card-foot { margin-top: auto; padding-top: 12px; border-top: 1px dashed var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .price { font-weight: 700; font-size: 1.08rem; color: var(--ink); }
  .price-old { color: var(--muted); text-decoration: line-through; font-size: .88rem; font-weight: 400; margin-left: 6px; }
  .price-free { color: var(--ok); }
  .card-type { position: absolute; top: 12px; left: 12px; z-index: 1; }
  @container (min-width: 520px) {
    .card-row { flex-direction: row; }
  }

  /* Prompt card (dạng chữ, không ảnh) */
  .prompt-card .card-body { gap: 12px; }
  /* Thẻ prompt không có ảnh: khung prompt giãn hết chiều cao thẻ để hàng thẻ đều nhau */
  .prompt-card .prompt-preview { flex: 1 1 auto; min-height: 5.4em; -webkit-line-clamp: 9; }
  .prompt-preview.is-locked { display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center; font-family: var(--font); font-size: .88rem; color: var(--muted); border-left-color: var(--accent); background: repeating-linear-gradient(-45deg, var(--surface-2) 0 10px, color-mix(in srgb, var(--surface-2) 70%, var(--surface)) 10px 20px); }
  .prompt-preview { font-family: var(--font-mono); font-size: .82rem; line-height: 1.6; background: var(--surface-2); border-left: 3px solid var(--brand); border-radius: 4px 10px 10px 4px; padding: 12px 14px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

  /* ---------- Forms ---------- */
  .field { display: grid; gap: 6px; }
  .field label, .label { font-weight: 600; font-size: .95rem; }
  .hint { color: var(--muted); font-size: .85rem; }
  .input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
    width: 100%; min-height: 50px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); padding: 10px 14px; transition: border-color .15s, box-shadow .15s;
  }
  .field textarea { min-height: 120px; resize: vertical; }
  .field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
  .field:has(input:user-invalid) input { border-color: var(--err); }
  .check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
  .check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--brand); }
  .pw-wrap { position: relative; }
  .pw-wrap button { position: absolute; right: 6px; top: 50%; translate: 0 -50%; border: 0; background: none; color: var(--muted); font-size: .85rem; font-weight: 600; padding: 8px; }
  .hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

  .alert { padding: 14px 16px; border-radius: 12px; font-size: .95rem; border: 1px solid transparent; display: flex; gap: 10px; align-items: flex-start; }
  .alert-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
  .alert-err { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
  .alert-info { background: var(--brand-soft); color: var(--brand-ink); }
  .alert-warn { background: var(--warn-soft); color: var(--warn); }

  .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(20px, 3vw, 32px); }
  .panel-title { font-size: 1.15rem; margin-bottom: 16px; }

  /* ---------- Breadcrumb, pagination ---------- */
  .crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: .88rem; color: var(--muted); margin-bottom: 14px; }
  .crumbs a { text-decoration: none; color: var(--muted); }
  .crumbs a:hover { color: var(--brand); }
  .crumbs li + li::before { content: "›"; margin-right: 6px; }
  .pager { display: flex; justify-content: center; gap: 6px; margin-top: 40px; flex-wrap: wrap; }
  .pager a, .pager span { min-width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); text-decoration: none; background: var(--surface); font-weight: 600; }
  .pager [aria-current] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

  /* ---------- Section heads ---------- */
  .sec-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 32px; flex-wrap: wrap; }
  .sec-head h2 { max-width: 24ch; }
  .card-foot .small { white-space: nowrap; }
  .sec-head p { color: var(--muted); margin-top: 6px; max-width: 60ch; }
  .eyebrow { display: inline-block; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 8px; }

  /* ---------- Prose (bài viết, mô tả) ---------- */
  .prose { font-size: 1.06rem; line-height: 1.75; color: var(--ink-2); }
  .prose > * + * { margin-top: 1.1em; }
  .prose h2 { color: var(--ink); margin-top: 1.8em; font-size: 1.55rem; }
  .prose h3 { color: var(--ink); margin-top: 1.5em; font-size: 1.22rem; }
  .prose a { color: var(--brand); }
  .prose ul, .prose ol { padding-left: 1.4em; }
  .prose li + li { margin-top: .4em; }
  .prose img { border-radius: 12px; margin-inline: auto; }
  .prose blockquote { border-left: 4px solid var(--accent); padding: 4px 0 4px 18px; color: var(--ink); font-style: italic; }
  .prose code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: .9em; }
  .prose hr { border: 0; border-top: 1px solid var(--line); }
  .prose .table-wrap { overflow-x: auto; }
  .prose table { border-collapse: collapse; width: 100%; font-size: .95rem; }
  .prose th, .prose td { border: 1px solid var(--line); padding: 10px 12px; text-align: left; }
  .prose th { background: var(--surface-2); color: var(--ink); }
  pre.code { position: relative; background: #0f1724; color: #e6edf6; border-radius: 12px; padding: 18px; overflow-x: auto; font-size: .9rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
  pre.code code { background: none; padding: 0; font-family: var(--font-mono); }
  .copy-btn { position: absolute; top: 10px; right: 10px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #fff; border-radius: 8px; padding: 4px 10px; font-size: .8rem; }

  /* ---------- Tables ---------- */
  .table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  .table { width: 100%; border-collapse: collapse; font-size: .95rem; }
  .table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
  .table th, .table td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
  .table tr:last-child td { border-bottom: 0; }

  /* ---------- Empty, toast ---------- */
  .empty { text-align: center; padding: 56px 20px; color: var(--muted); border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
  .empty h3 { color: var(--ink); margin-bottom: 6px; }
  .toast { position: fixed; left: 50%; bottom: 96px; translate: -50% 0; background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 12px; font-weight: 600; z-index: 200; box-shadow: var(--shadow-2); animation: toast .25s ease-out; }
  @keyframes toast { from { opacity: 0; translate: -50% 10px; } }

  /* ---------- Footer ---------- */
  .site-footer { background: #0e1726; color: #c4ccd8; margin-top: 40px; }
  .site-footer a { color: #c4ccd8; text-decoration: none; }
  .site-footer a:hover { color: #fff; }
  .footer-grid { display: grid; gap: 32px; grid-template-columns: 1.4fr repeat(3, 1fr); padding-block: 56px 32px; }
  .footer-grid h4 { color: #fff; font-size: .95rem; margin-bottom: 14px; }
  .footer-grid li + li { margin-top: 8px; }
  .footer-bottom { border-top: 1px solid rgba(255,255,255,.08); padding-block: 20px; font-size: .88rem; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  .site-footer .logo { color: #fff; }
  @media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }

  dialog.modal { border: 0; border-radius: var(--radius); padding: 0; max-width: min(520px, 100% - 32px); box-shadow: var(--shadow-2); background: var(--surface); color: var(--ink); }
  dialog.modal::backdrop { background: rgba(10,15,25,.5); }
}

@layer pages {
  /* ---------- Home ---------- */
  .hero { padding-block: clamp(36px, 6vw, 84px) clamp(48px, 7vw, 100px); }
  .hero-grid { display: grid; grid-template-columns: 1.12fr .88fr; gap: clamp(28px, 5vw, 72px); align-items: center; }
  .hero h1 { font-size: clamp(2.35rem, 1.3rem + 3.4vw, 3.9rem); line-height: 1.1; letter-spacing: -.035em; text-wrap: pretty; }
  /* Dấu ấn: vệt bút dạ quang như học viên đánh dấu ý chính trong sách */
  .hero h1 mark { color: inherit; background: linear-gradient(176deg, transparent 0 52%, var(--mark) 52% 90%, transparent 90%); padding-inline: .06em; margin-inline: -.06em; border-radius: .12em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
  .hero-lead { font-size: 1.16rem; color: var(--ink-2); margin-top: 20px; max-width: 50ch; }
  .hero-cta { margin-top: 30px; display: flex; gap: 12px; flex-wrap: wrap; }
  .hero-points { display: flex; gap: 10px 22px; margin-top: 26px; flex-wrap: wrap; color: var(--ink-2); font-size: .95rem; font-weight: 500; }
  .hero-points li { display: flex; align-items: center; gap: 7px; }
  .hero-points svg { color: var(--ok); width: 19px; height: 19px; }
  .hero-visual { position: relative; padding-bottom: 36px; }
  .hero-visual img { border-radius: 22px; aspect-ratio: 4/3.6; object-fit: cover; width: 100%; box-shadow: var(--shadow-2); }
  /* Thẻ prompt thật đặt chồng lên ảnh — cho thấy ngay thứ học viên mang về */
  .hero-prompt { position: absolute; left: -36px; right: 18%; bottom: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 40px -16px rgba(15,27,45,.35); padding: 14px 16px 12px; display: grid; gap: 8px; }
  .hero-prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .78rem; font-weight: 600; color: var(--muted); }
  .hero-prompt-head .tag { height: 22px; font-size: .72rem; }
  .hero-prompt p { font-family: var(--font-mono); font-size: .86rem; line-height: 1.6; color: var(--ink); }
  .hero-prompt .btn { justify-self: start; }
  @media (max-width: 900px) {
    .hero-grid { grid-template-columns: 1fr; }
    .hero-visual { padding-bottom: 0; }
    .hero-prompt { position: relative; left: auto; right: auto; margin: -48px 14px 0; }
  }
  @media (max-width: 560px) {
    .hero-cta .btn { flex: 1 1 100%; }
    .hero-points { flex-direction: column; gap: 8px; }
    /* Thẻ dẫn hướng gọn lại: icon bên trái, cả thẻ là link */
    .pillar { grid-template-columns: 44px 1fr; column-gap: 14px; row-gap: 2px; }
    .pillar .pillar-ico { grid-row: span 2; width: 44px; height: 44px; }
    .pillar h3 { font-size: 1.08rem; align-self: end; }
    .pillar p { font-size: .9rem; }
    .pillar .link { display: none; }
    .sec-head { margin-bottom: 20px; }
    .sec-head .btn { min-height: 38px; padding: 0 14px; font-size: .92rem; border-radius: 10px; }
  }

  .pillars { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
  .pillar { padding: 26px 28px; text-decoration: none; display: grid; gap: 10px; align-content: start; transition: background .2s; }
  .pillar + .pillar { border-left: 1px solid var(--line); }
  .pillar:hover { background: var(--surface-2); }
  .pillar h3 { font-size: 1.2rem; }
  .pillar-ico { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
  .pillar:nth-child(2) .pillar-ico { background: var(--accent-soft); color: var(--accent-ink); }
  .pillar:nth-child(3) .pillar-ico { background: var(--ok-soft); color: var(--ok); }
  .pillar-ico svg { width: 26px; height: 26px; }
  .pillar p { color: var(--muted); font-size: .95rem; }
  .pillar .link { margin-top: 4px; }
  @media (max-width: 860px) { .pillars { grid-template-columns: 1fr; } .pillar + .pillar { border-left: 0; border-top: 1px solid var(--line); } .pillar { padding: 20px; } }

  .steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 28px; counter-reset: s; list-style: none; padding: 0; }
  .step { counter-increment: s; padding-top: 18px; border-top: 2px solid var(--line); position: relative; }
  .step::before { content: ""; position: absolute; top: -2px; left: 0; width: 44px; height: 2px; background: var(--brand); }
  .step::after { content: counter(s); display: block; order: -1; font-family: var(--font-display); font-weight: 800; font-size: 2.6rem; line-height: 1; color: var(--brand); margin-bottom: 14px; letter-spacing: -.04em; }
  .step { display: flex; flex-direction: column; }
  .step p { color: var(--muted); font-size: .95rem; margin-top: 6px; }
  @media (max-width: 860px) { .steps { grid-template-columns: 1fr 1fr; gap: 28px 20px; } }

  .cta-band { background: var(--brand) radial-gradient(120% 140% at 100% 0%, rgba(255,255,255,.14), transparent 55%); color: #fff; border-radius: 24px; padding: clamp(28px, 5vw, 56px); display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; align-items: center; }
  .cta-band p { opacity: .9; margin-top: 8px; }
  .cta-band form { display: grid; gap: 10px; }
  .cta-band input { min-height: 52px; border-radius: 12px; border: 0; padding: 0 16px; width: 100%; color: #142033; background: #fff; }
  @media (max-width: 860px) { .cta-band { grid-template-columns: 1fr; } }

  .faq details { border-bottom: 1px solid var(--line); padding: 18px 0; }
  .faq summary { cursor: pointer; font-weight: 600; font-size: 1.05rem; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
  .faq summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--brand); }
  .faq details[open] summary::after { content: "–"; }
  .faq details p { color: var(--ink-2); margin-top: 10px; }

  /* ---------- Listing ---------- */
  .page-head { padding-block: 36px 24px; }
  .page-head p { color: var(--muted); margin-top: 8px; max-width: 65ch; font-size: 1.05rem; }
  .filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 28px; }
  .filters .chips { flex: 1; }
  .filters select { min-height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; }
  .result-count { color: var(--muted); font-size: .92rem; margin-bottom: 16px; }

  /* ---------- Detail ---------- */
  .detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 40px; align-items: start; }
  .buy-box { position: sticky; top: 92px; display: grid; gap: 14px; }
  .buy-box .price { font-size: 1.9rem; font-family: var(--font-display); font-weight: 800; letter-spacing: -.02em; }
  .buy-box ul { display: grid; gap: 8px; font-size: .93rem; color: var(--ink-2); }
  .buy-box li { display: flex; gap: 8px; }
  .buy-box li svg { flex: none; width: 18px; height: 18px; color: var(--ok); margin-top: 3px; }
  .detail-cover { border-radius: var(--radius); overflow: hidden; margin-bottom: 28px; border: 1px solid var(--line); }
  .prompt-box { position: relative; }
  .prompt-box pre { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 20px; white-space: pre-wrap; font-family: var(--font-mono); font-size: .9rem; line-height: 1.7; }
  .locked { position: relative; border-radius: 12px; overflow: hidden; }
  .locked pre { filter: blur(5px); user-select: none; pointer-events: none; }
  .locked-cover { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; background: color-mix(in srgb, var(--surface) 55%, transparent); padding: 20px; }
  .meta-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: .93rem; }
  .meta-list dt { color: var(--muted); }
  .meta-list dd { margin: 0; font-weight: 500; }
  @media (max-width: 960px) {
    .detail-grid { grid-template-columns: 1fr; }
    .buy-box { position: static; }
    /* Trên điện thoại đưa hộp mua/học lên đầu để không phải cuộn tìm nút */
    .detail-grid > aside.buy-box { order: -1; }
    .course-hero .detail-grid > div:empty { display: none; }
    .course-hero { padding-block: 28px; }
  }

  /* Tiêu đề, ảnh bìa và nội dung bài viết chung một cột trái → mắt đọc không bị lệch */
  .article-wrap { width: min(100% - 32px, 1080px); margin-inline: auto; }
  .article-head { padding-block: 36px 28px; }
  .article-head h1, .article-head .hero-lead { max-width: 760px; }
  .article-head h1 { font-size: clamp(2rem, 1.3rem + 2.6vw, 3.2rem); }
  .article-meta { display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: .92rem; margin-top: 16px; flex-wrap: wrap; }
  .article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 48px; align-items: start; }
  .toc { position: sticky; top: 92px; font-size: .92rem; border-left: 2px solid var(--line); padding-left: 16px; }
  .toc h4 { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
  .toc a { display: block; padding: 4px 0; text-decoration: none; color: var(--ink-2); }
  .toc a:hover { color: var(--brand); }
  .toc .l3 { padding-left: 12px; font-size: .88rem; }
  @media (max-width: 960px) { .article-layout { grid-template-columns: 1fr; } .toc { display: none; } }

  /* ---------- Course ---------- */
  .course-hero { background: #101a2b; color: #e8edf5; padding-block: 44px; }
  .course-hero .crumbs a, .course-hero .crumbs { color: #9fb0c8; }
  .course-hero p.lead { color: #c4ccd8; font-size: 1.1rem; margin-top: 12px; max-width: 62ch; }
  .course-hero .card-meta { color: #c4ccd8; margin-top: 18px; }
  .course-hero .detail-grid { align-items: start; }
  .course-hero + .section .buy-box { margin-top: -240px; }
  .curriculum details { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
  .curriculum details + details { margin-top: 10px; }
  .curriculum summary { padding: 16px 18px; font-weight: 600; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
  .curriculum ol { list-style: none; padding: 0 8px 10px; }
  .lesson-item { display: flex; gap: 12px; align-items: center; padding: 10px 10px; border-radius: 8px; font-size: .95rem; }
  .lesson-item svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
  .lesson-item .dur { margin-left: auto; color: var(--muted); font-size: .85rem; }
  a.lesson-item { text-decoration: none; }
  a.lesson-item:hover { background: var(--surface-2); }
  .outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
  .outcomes li { display: flex; gap: 10px; }
  .outcomes svg { width: 20px; height: 20px; flex: none; color: var(--ok); margin-top: 3px; }
  @media (max-width: 960px) { .course-hero + .section .buy-box { margin-top: 0; } .outcomes { grid-template-columns: 1fr; } }

  .learn { display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-height: calc(100vh - 68px); }
  .learn-main { padding: 24px clamp(16px, 3vw, 40px) 60px; }
  .learn-side { border-left: 1px solid var(--line); background: var(--surface); max-height: calc(100vh - 68px); overflow-y: auto; position: sticky; top: 68px; }
  .learn-side h2 { font-size: 1rem; padding: 18px 18px 6px; }
  .player { aspect-ratio: 16/9; background: #000; border-radius: 14px; overflow: hidden; }
  .player video, .player iframe { width: 100%; height: 100%; border: 0; }
  .doc-frame { width: 100%; height: min(80vh, 900px); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
  .progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
  .progress > span { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
  .lesson-item.current { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
  .lesson-item.done svg { color: var(--ok); }
  @media (max-width: 960px) { .learn { grid-template-columns: 1fr; } .learn-side { position: static; max-height: none; border-left: 0; border-top: 1px solid var(--line); } }

  /* ---------- Auth ---------- */
  .auth { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 1fr 1fr; }
  .auth-side { background: var(--brand); color: #fff; padding: clamp(32px, 6vw, 72px); display: flex; flex-direction: column; justify-content: center; gap: 20px; position: relative; overflow: hidden; }
  .auth-side img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .22; }
  .auth-side > *:not(img) { position: relative; }
  .auth-side p { opacity: .92; font-size: 1.08rem; }
  .auth-main { display: grid; place-items: center; padding: 40px 16px; }
  .auth-card { width: min(100%, 440px); display: grid; gap: 18px; }
  @media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-side { display: none; } }

  /* ---------- Account ---------- */
  .acc { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 32px; padding-block: 32px 60px; }
  .acc-nav { display: grid; gap: 4px; align-content: start; position: sticky; top: 92px; }
  .acc-nav a { padding: 12px 14px; border-radius: 10px; text-decoration: none; font-weight: 500; display: flex; gap: 10px; align-items: center; }
  .acc-nav a:hover { background: var(--surface-2); }
  .acc-nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); }
  .acc-nav svg { width: 20px; height: 20px; }
  .stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
  .stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
  .stat span { color: var(--muted); font-size: .88rem; }
  .stat strong { display: block; font-size: 1.6rem; margin-top: 4px; }
  @media (max-width: 860px) { .acc { grid-template-columns: 1fr; } .acc-nav { position: static; display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; } .acc-nav a { white-space: nowrap; border: 1px solid var(--line); } }

  .pay-grid { display: grid; grid-template-columns: 300px 1fr; gap: 28px; align-items: start; }
  .pay-grid img.qr { width: 100%; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
  @media (max-width: 760px) { .pay-grid { grid-template-columns: 1fr; } .pay-grid img.qr { max-width: 300px; margin-inline: auto; } }

  .error-page { text-align: center; padding-block: 100px; }
  .error-page .code { font-family: var(--font-display); font-size: 5.5rem; font-weight: 800; color: var(--brand); line-height: 1; }
}

@layer utils {
  /* Trên điện thoại: danh sách thẻ trang chủ trượt ngang thay vì xếp chồng (trang ngắn lại một nửa) */
  @media (max-width: 700px) {
    .rail { grid-auto-flow: column; grid-auto-columns: 84%; grid-template-columns: none; gap: 14px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; margin-inline: -16px; padding: 4px 16px 14px; scroll-padding-inline: 16px; scrollbar-width: none; }
    .rail::-webkit-scrollbar { display: none; }
    .rail > * { scroll-snap-align: start; }
    .rail .card:hover { transform: none; }
  }
  .muted { color: var(--muted); }
  .small { font-size: .88rem; }
  .center { text-align: center; }
  .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 40px; }
  .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
  .w-full { width: 100%; }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  .nowrap { white-space: nowrap; }
}
