@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700&family=Source+Serif+4:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --bg: #f6f5f1;
  --paper: #ffffff;
  --fg: #1d2127;
  --muted: #5d6570;
  --border: #e3dfd6;
  --accent: #1d4ed8;
  --accent-soft: #eaf0fd;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --hl-k: #fde68a;   /* ý chính / câu overview / thesis */
  --hl-v: #bbf7d0;   /* từ vựng - collocation */
  --hl-g: #bfdbfe;   /* ngữ pháp - cấu trúc câu */
  --hl-l: #fbcfe8;   /* liên kết - cohesion */
  --slot: #8a3b12;
  --slot-bg: #ffedd5;
  --map-land: #f3f0e6;
  --map-green: #cfe8c3;
  --map-water: #bfdcf5;
  --map-build: #e6d6bf;
  --map-road: #cfcfcf;
  --map-new: #f8c7a3;
  --map-sport: #e3f0a6;
  --map-sand: #f2e2b0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171b; --paper: #1d2026; --fg: #e8e9eb; --muted: #a2a9b3; --border: #343842;
    --accent: #8fb0ff; --accent-soft: #23304d; --ok: #6ed49a; --ok-soft: #1c3326;
    --warn: #f3b562; --warn-soft: #3a2d18; --bad: #f59393; --bad-soft: #3d2020;
    --hl-k: rgba(250, 204, 21, .32); --hl-v: rgba(74, 222, 128, .28); --hl-g: rgba(96, 165, 250, .32); --hl-l: rgba(244, 114, 182, .3);
    --slot: #ffcf9e; --slot-bg: #4a2b14;
    --map-land: #2a2c31; --map-green: #2f4a2a; --map-water: #22405e; --map-build: #4d4232; --map-road: #50525a; --map-new: #6b3f22; --map-sport: #485225; --map-sand: #5c5030;
  }
}
:root[data-theme="dark"] {
  --bg: #15171b; --paper: #1d2026; --fg: #e8e9eb; --muted: #a2a9b3; --border: #343842;
  --accent: #8fb0ff; --accent-soft: #23304d; --ok: #6ed49a; --ok-soft: #1c3326;
  --warn: #f3b562; --warn-soft: #3a2d18; --bad: #f59393; --bad-soft: #3d2020;
  --hl-k: rgba(250, 204, 21, .32); --hl-v: rgba(74, 222, 128, .28); --hl-g: rgba(96, 165, 250, .32); --hl-l: rgba(244, 114, 182, .3);
  --slot: #ffcf9e; --slot-bg: #4a2b14;
  --map-land: #2a2c31; --map-green: #2f4a2a; --map-water: #22405e; --map-build: #4d4232; --map-road: #50525a; --map-new: #6b3f22; --map-sport: #485225; --map-sand: #5c5030;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: "Be Vietnam Pro", "Segoe UI", system-ui, Arial, sans-serif;
  font-size: 15.5px; line-height: 1.65;
}
a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.3; margin: 1.2em 0 .5em; }
h1 { font-size: 1.9rem; margin-top: .3em; }
h2 { font-size: 1.4rem; border-bottom: 2px solid var(--border); padding-bottom: .25em; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- header / nav ---------- */
.site { background: var(--paper); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.site .in { max-width: 1040px; margin: 0 auto; padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.site .brand { font-weight: 700; text-decoration: none; color: var(--fg); margin-right: 8px; }
.site .grp { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13px; }
.site .grp b { color: var(--muted); font-weight: 600; margin-right: 2px; }
.site .grp a { text-decoration: none; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--fg); }
.site .grp a.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.site .tools { margin-left: auto; display: flex; gap: 6px; }
.site button { font: inherit; font-size: 12.5px; padding: 3px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); cursor: pointer; }

main.wrap { max-width: 1040px; margin: 0 auto; padding: 16px 16px 64px; }
.lead { font-size: 1.05rem; color: var(--muted); }

/* ---------- cards / boxes ---------- */
.card { background: var(--paper); border: 1px solid var(--border); border-radius: 14px; padding: 20px 24px; margin: 22px 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.sample { border-top: 5px solid var(--accent); }
.sample-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; }
.sample-head h2 { border: 0; margin: 0 0 6px; padding: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; white-space: nowrap; }
.chip.band { background: var(--ok-soft); color: var(--ok); }

.prompt { background: var(--accent-soft); border-left: 4px solid var(--accent); padding: 12px 16px; border-radius: 8px; margin: 10px 0 14px; font-family: "Source Serif 4", Georgia, serif; font-size: 16.5px; }
.prompt .inst { display: block; font-family: "Be Vietnam Pro", system-ui, sans-serif; font-size: 13px; color: var(--muted); margin-top: 6px; font-style: italic; }
.box { border-radius: 10px; padding: 12px 16px; margin: 12px 0; border: 1px solid var(--border); }
.box.tip { background: var(--ok-soft); border-color: transparent; }
.box.warn { background: var(--warn-soft); border-color: transparent; }
.box.bad { background: var(--bad-soft); border-color: transparent; }
.box.info { background: var(--accent-soft); border-color: transparent; }
.box > :first-child { margin-top: 0; }
.box > :last-child { margin-bottom: 0; }
.box-title { font-weight: 700; display: block; margin-bottom: 4px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---------- essay ---------- */
.essay { font-family: "Source Serif 4", Georgia, serif; font-size: 17px; line-height: 1.8; background: var(--paper); border: 1px dashed var(--border); border-radius: 10px; padding: 14px 18px; position: relative; }
.essay p { margin: 0 0 .9em; }
.essay p:last-child { margin-bottom: 0; }
.pl { font-family: "Be Vietnam Pro", system-ui, sans-serif; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; margin-right: 6px; vertical-align: 2px; }
.wc { position: absolute; top: -11px; right: 12px; font-family: "Be Vietnam Pro", system-ui, sans-serif; font-size: 12px; background: var(--ok); color: #fff; padding: 1px 10px; border-radius: 999px; }

mark { color: inherit; padding: 0 2px; border-radius: 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
mark.k { background: var(--hl-k); }
mark.v { background: var(--hl-v); }
mark.g { background: var(--hl-g); }
mark.l { background: var(--hl-l); }
mark sup, sup.n { font-family: "Be Vietnam Pro", system-ui, sans-serif; font-size: .62em; font-weight: 700; color: var(--accent); margin-left: 1px; }
body.plain mark { background: transparent; padding: 0; }
body.plain mark sup { display: none; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13.5px; margin: 8px 0; }
.legend span mark { padding: 1px 8px; }

/* ---------- notes ---------- */
ol.notes { padding-left: 1.6em; margin: 10px 0; }
ol.notes li { margin: 0 0 8px; padding-left: 4px; }
ol.notes li::marker { font-weight: 700; color: var(--accent); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 4px; margin-right: 6px; vertical-align: 1px; color: var(--fg); }
.tag.k { background: var(--hl-k); } .tag.v { background: var(--hl-v); } .tag.g { background: var(--hl-g); } .tag.l { background: var(--hl-l); }
ol.notes .en { font-weight: 700; }
ol.notes .vi { font-style: italic; color: var(--muted); }
ol.notes .ex { display: block; font-size: 14px; color: var(--muted); }
ol.notes .ex::before { content: "Ví dụ: "; font-weight: 600; }

.why { margin: 12px 0 0; }
.why table { width: 100%; }

/* ---------- template ---------- */
.template { font-family: "Source Serif 4", Georgia, serif; font-size: 16.5px; line-height: 1.9; background: var(--paper); border: 2px solid var(--accent); border-radius: 12px; padding: 14px 18px; }
.template p { margin: 0 0 .8em; }
.template .lab { display: inline-block; font-family: "Be Vietnam Pro", system-ui, sans-serif; font-size: 12px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 4px; padding: 0 7px; margin-right: 6px; vertical-align: 1px; }
.slot { background: var(--slot-bg); color: var(--slot); border-radius: 4px; padding: 0 5px; font-family: "Be Vietnam Pro", system-ui, sans-serif; font-size: .86em; font-weight: 600; }
.alt { color: var(--muted); font-size: .9em; }

/* ---------- tables ---------- */
table { border-collapse: collapse; font-size: 14px; margin: 8px 0; }
table.data, table.t { width: 100%; }
th, td { border: 1px solid var(--border); padding: 6px 9px; vertical-align: top; text-align: left; }
th { background: var(--accent-soft); font-weight: 600; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; }
.data-cap { font-weight: 600; font-size: 14px; margin: 4px 0; }

/* ---------- charts ---------- */
.chart { margin: 8px 0 4px; }
.chart-title { font-weight: 700; font-size: 14.5px; text-align: center; margin-bottom: 2px; }
.chart-svg { width: 100%; max-width: 700px; display: block; margin: 0 auto; height: auto; }
.chart-svg text { fill: var(--fg); font-family: "Be Vietnam Pro", system-ui, sans-serif; }
.chart-svg .tick { font-size: 12px; fill: var(--muted); }
.chart-svg .val { font-size: 10.5px; font-weight: 600; }
.chart-svg .axis-label { font-size: 12px; fill: var(--muted); }
.chart-svg .legend { font-size: 12.5px; }
.chart-svg .grid { stroke: var(--border); stroke-width: 1; }
.chart-svg .axis { stroke: var(--muted); stroke-width: 1.2; }
.chart-svg .slice { stroke: var(--paper); stroke-width: 1.5; }
.chart-svg .pct-in { fill: #fff; font-size: 12.5px; font-weight: 700; }
.chart-svg .pie-title { font-size: 13.5px; font-weight: 700; }
details.dt { margin: 4px 0 8px; font-size: 14px; }
details.dt summary { cursor: pointer; color: var(--accent); font-weight: 600; }

/* ---------- process ---------- */
.process { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; margin: 10px 0; padding: 0; list-style: none; counter-reset: st; }
.process li { counter-increment: st; background: var(--paper); border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 12px 10px 12px; position: relative; font-size: 14px; line-height: 1.45; }
.process li::before { content: counter(st); display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; align-items: center; justify-content: center; margin-right: 6px; }
.process li b { display: block; margin: 4px 0 2px; }
.process li small { color: var(--muted); display: block; }
.process li.branch { border-style: dashed; }
.flow-note { font-size: 13.5px; color: var(--muted); text-align: center; }

/* ---------- maps ---------- */
.maps { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 10px 0; }
@media (max-width: 680px) { .maps { grid-template-columns: 1fr; } }
.map-t { text-align: center; font-weight: 700; font-size: 14.5px; margin-bottom: 4px; }
.map { position: relative; aspect-ratio: 1 / 1; border: 2px solid var(--muted); background: var(--map-land); border-radius: 8px; overflow: hidden; font-size: 11.5px; line-height: 1.15; }
.map .a { position: absolute; display: flex; align-items: center; justify-content: center; text-align: center; border-radius: 4px; padding: 2px; color: var(--fg); }
.map .green { background: var(--map-green); }
.map .water { background: var(--map-water); }
.map .build { background: var(--map-build); border: 1px solid var(--muted); }
.map .road { background: var(--map-road); border-radius: 0; font-size: 10.5px; }
.map .new { background: var(--map-new); border: 1.5px solid var(--warn); }
.map .sport { background: var(--map-sport); }
.map .sand { background: var(--map-sand); }
.map .vt { writing-mode: vertical-rl; font-size: 10px; }
.map .ring { border: 3px dashed var(--muted); background: transparent; align-items: flex-end; font-size: 10px; }
.map .compass { position: absolute; right: 6px; top: 4px; font-weight: 700; font-size: 12px; }
.map-key { font-size: 13px; color: var(--muted); text-align: center; margin-top: 4px; }

/* ---------- misc ---------- */
.toc { columns: 2; column-gap: 28px; }
@media (max-width: 680px) { .toc { columns: 1; } }
.toc li { break-inside: avoid; margin-bottom: 4px; }
.pill-ok { color: var(--ok); font-weight: 700; }
.pill-bad { color: var(--bad); font-weight: 700; }
.small { font-size: 13.5px; color: var(--muted); }
.kbd { font-family: Consolas, monospace; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; font-size: .9em; }
.outline { margin: 6px 0 12px; }
.outline li { margin-bottom: 3px; }
.cmp td:first-child { font-weight: 600; white-space: nowrap; }
.bad-ex { color: var(--bad); text-decoration: line-through; }
.good-ex { color: var(--ok); font-weight: 600; }
footer.f { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px; }

@media (max-width: 560px) {
  .card { padding: 16px; }
  .essay { padding: 12px; font-size: 16px; }
  h1 { font-size: 1.55rem; }
}

@media print {
  .site, .no-print { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  main.wrap { max-width: none; padding: 0; }
  .card { border: 1px solid #ccc; break-inside: auto; }
  .essay, .chart, .template, .maps, .process, ol.notes li, .prompt { break-inside: avoid; }
  .sample { break-before: page; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  details.dt { display: none; }
}
