/* Urban Economics — the monocentric city · stylesheet (V2)

   Tokens follow the World Bank Data Visualization Style Guide (wbg-vis-design.vercel.app):
   text #111111, subtle #666666, greys 300 #8A969F · 200 #CED4DE · 100 #EBEEF4, selection #0071BC.
   Page grid follows the Distill article template (text column 704 px, margin column for notes).
   Type: Source Serif 4 (reading), Source Sans 3 (headings, figures, interface), KaTeX (maths).
   See nghien_cuu/NGHIEN_CUU_V2.md for the sources of every value. */

@import url("../vendor/phong.css");

:root {
  --text: #111111;
  --text-2: #444444;
  --subtle: #666666;
  --grey-300: #8A969F;
  --grey-200: #CED4DE;
  --grey-100: #EBEEF4;
  --panel: #F5F7FA;
  --accent: #0071BC;
  --accent-soft: #E3F0F9;
  --warn: #B65F0C;
  --serif: "Source Serif 4", "Noto Serif", "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", "Noto Sans", Arial, sans-serif;
  --text-col: 704px;
  --margin-col: 240px;
  --gap: 48px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: #fff; color: var(--text);
  font: 400 19px/1.6 var(--serif);
  font-feature-settings: "kern", "liga";
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, .tabular { font-variant-numeric: tabular-nums lining-nums; }
.missing { background: #FDE8E8; color: #AA0000; }

/* ── header ── */
.site-header { position: sticky; top: 0; z-index: 50; background: #fff; border-bottom: 1px solid var(--grey-100); font-family: var(--sans); }
.site-header .inner { max-width: 1240px; margin: 0 auto; padding: 0 24px; height: 52px; display: flex; align-items: center; gap: 24px; }
.site-header .course { color: var(--text); text-decoration: none; font-weight: 600; font-size: 16px; white-space: nowrap; }
.site-header .course span { font-weight: 400; color: var(--subtle); }
.site-header nav { display: flex; gap: 20px; margin-left: auto; font-size: 15px; }
.site-header nav a { color: var(--text); text-decoration: none; padding: 14px 0; border-bottom: 2px solid transparent; white-space: nowrap; }
.site-header nav a[aria-current="page"] { border-bottom-color: var(--accent); }
.site-header nav a:hover { color: var(--accent); }
.lang { display: flex; font-size: 14px; border: 1px solid var(--grey-200); border-radius: 3px; overflow: hidden; }
.lang a, .lang span { padding: 3px 9px; text-decoration: none; color: var(--subtle); }
.lang span { background: var(--text); color: #fff; }

/* ── page grid ── */
.page { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.layout { display: grid; grid-template-columns: 196px minmax(0, var(--text-col)) var(--margin-col); column-gap: var(--gap); }
.toc { grid-column: 1; }
.main { grid-column: 2; min-width: 0; }
.toc nav { position: sticky; top: 84px; font: 400 14px/1.4 var(--sans); padding-top: 8px; }
.toc .toc-title { font-weight: 600; color: var(--subtle); margin-bottom: 10px; }
.toc a { display: block; color: var(--text-2); text-decoration: none; padding: 5px 0 5px 12px; border-left: 2px solid var(--grey-100); }
.toc a.active { color: var(--text); border-left-color: var(--accent); }
.toc a:hover { color: var(--accent); }

/* ── lesson head ── */
.lesson-head { padding: 56px 0 8px; }
.lesson-no { font: 400 17px/1.3 var(--sans); color: var(--subtle); margin: 0 0 10px; }
h1 { font: 600 42px/1.12 var(--sans); letter-spacing: -0.012em; margin: 0 0 20px; }
.standfirst { font-size: 22px; line-height: 1.5; color: var(--text-2); margin: 0 0 20px; }
.meta { font: 400 14px/1.5 var(--sans); color: var(--subtle); border-top: 1px solid var(--grey-100); padding-top: 12px; margin: 0; }

.objectives { background: var(--panel); padding: 20px 26px 8px; margin: 32px 0 8px; }
.objectives h2 { font: 600 17px/1.3 var(--sans); margin: 0 0 8px; border: 0; padding: 0; }
.objectives ol { margin: 0 0 12px; padding-left: 22px; font-size: 18px; }
.objectives li { margin-bottom: 6px; }

/* ── text ── */
h2 { font: 600 27px/1.25 var(--sans); margin: 64px 0 18px; padding-top: 22px; border-top: 1px solid var(--grey-100); scroll-margin-top: 70px; }
h2 .sec { color: var(--subtle); font-weight: 400; margin-right: 0.45em; }
h3 { font: 600 20px/1.3 var(--sans); margin: 36px 0 10px; }
p { margin: 0 0 1em; }
ol, ul { padding-left: 1.4em; }
li { margin-bottom: 0.35em; }
em.term { font-style: italic; }
.assumptions { list-style: none; padding: 0; counter-reset: a; }
.assumptions li { counter-increment: a; position: relative; padding-left: 44px; margin-bottom: 10px; }
.assumptions li::before { content: "A" counter(a); position: absolute; left: 0; top: 2px; font: 600 15px/1.5 var(--sans); color: var(--accent); }

/* margin notes (Tufte): float into the margin column on wide screens */
.note { float: right; clear: right; width: var(--margin-col); margin-right: calc(-1 * (var(--margin-col) + var(--gap))); margin-top: 4px; margin-bottom: 16px;
  font: 400 14.5px/1.45 var(--sans); color: var(--text-2); }
.note b { color: var(--text); font-weight: 600; }
.note .src { display: block; color: var(--subtle); margin-top: 4px; font-size: 13px; }

/* equations */
.eq { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; margin: 18px 0 22px; }
.eq .katex-display { margin: 0; }
.eq .eq-no { font: 400 16px var(--sans); color: var(--subtle); padding-left: 16px; }
.katex { font-size: 1.08em; }

/* quotations — text is inserted from du_lieu/trich_dan.js, which is checked against the PDF */
.quote { margin: 26px 0; padding: 2px 0 2px 22px; border-left: 3px solid var(--grey-200); }
.quote p { margin: 0 0 8px; color: #222; }
.quote .cite { font: 400 14px/1.45 var(--sans); color: var(--subtle); margin: 0; }
.quote .tr { font: 400 16px/1.5 var(--sans); color: var(--text-2); margin: 6px 0 8px; }
.quote .tr b { font-weight: 600; color: var(--subtle); }

.interp { border-left: 3px solid #FF9800; padding: 2px 0 2px 20px; margin: 24px 0; }
.interp .label { font: 600 14px var(--sans); color: var(--warn); display: block; margin-bottom: 4px; }

/* ── figures (World Bank anatomy: label + title above, Source/Note below) ── */
.fig { margin: 40px 0 36px; clear: both; }
.fig.wide { width: calc(100% + var(--margin-col) + var(--gap)); }
.fig-head { font: 600 18px/1.35 var(--sans); margin: 0 0 4px; }
.fig-label { color: var(--accent); margin-right: 0.4em; }
.fig-sub { font: 400 15px/1.4 var(--sans); color: var(--subtle); margin: 0 0 12px; }
.fig-body { position: relative; }
.fig-foot { font: 400 13.5px/1.5 var(--sans); color: var(--subtle); margin-top: 12px; border-top: 1px solid var(--grey-100); padding-top: 8px; }
.fig-foot p { margin: 0 0 4px; }
.fig-foot b { color: var(--text); font-weight: 600; }
.fig-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.fig-2col > div { min-width: 0; }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; font-family: var(--sans); }
.chart .tick text { font-size: 13px; fill: var(--subtle); font-variant-numeric: tabular-nums; }
.chart .axis-label { font-size: 13px; font-weight: 600; fill: var(--text); }
.chart .direct { font-size: 13px; font-weight: 600; }
.chart .series { transition: opacity .3s ease; }
.chart path.line { fill: none; stroke-linejoin: round; stroke-linecap: round; transition: d .35s ease; }
.chart .panel-title { font-size: 15px; font-weight: 600; fill: var(--text); }
.kinds { display: flex; flex-wrap: wrap; gap: 18px; font: 400 13px var(--sans); color: var(--subtle); margin-top: 6px; }
.kinds span { display: inline-flex; align-items: center; gap: 6px; }
.kinds svg { display: block; }
.tip { position: absolute; z-index: 20; pointer-events: none; background: #fff; border: .5px solid var(--grey-200);
  box-shadow: 4px 4px 4px rgba(17,17,17,.15); padding: 7px 10px; font: 400 13px/1.35 var(--sans); color: var(--text); white-space: nowrap; }
.tip .v { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tip .k { color: var(--subtle); }

/* stepped figures */
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; font-family: var(--sans); }
.steps button { font: 400 14.5px var(--sans); color: var(--text); background: #fff; border: 1px solid var(--grey-200); border-radius: 3px; padding: 5px 12px; cursor: pointer; }
.steps button:hover { border-color: var(--grey-300); }
.steps button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.steps .hint { font-size: 13px; color: var(--subtle); align-self: center; margin-left: auto; }
.step-text { border-left: 3px solid var(--accent); padding: 4px 0 4px 18px; margin: 16px 0 0; min-height: 4.8em; }
.step-text [data-step] { display: none; }
.step-text [data-step].on { display: block; }
.step-text p { margin: 0; font-size: 18px; }

/* sandbox controls */
.controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 22px; margin: 6px 0 18px; font-family: var(--sans); }
.control label { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.control label output { font-weight: 400; color: var(--subtle); font-variant-numeric: tabular-nums; }
.control input[type=range] { width: 100%; accent-color: var(--accent); }
.control .desc { font-size: 12.5px; color: var(--subtle); }
.btn { font: 400 14px var(--sans); background: #fff; color: var(--text); border: 1px solid var(--grey-200); border-radius: 3px; padding: 5px 12px; cursor: pointer; }
.btn:hover { border-color: var(--grey-300); }
.readout { font: 400 15px/1.5 var(--sans); color: var(--subtle); margin: 0 0 14px; min-height: 1.5em; }
.readout b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* tables */
.table-wrap { overflow-x: auto; margin: 8px 0 4px; }
table.data { border-collapse: collapse; width: 100%; font: 400 15px/1.4 var(--sans); }
table.data caption { text-align: left; }
table.data th { font-weight: 600; text-align: left; border-bottom: 1px solid var(--text); padding: 6px 10px 6px 0; vertical-align: bottom; }
table.data td { border-bottom: 1px solid var(--grey-100); padding: 7px 10px 7px 0; vertical-align: top; }
table.data .r { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.hl td { background: var(--accent-soft); }

/* maps */
.map { position: relative; height: 540px; border: 1px solid var(--grey-100); background: #F3F4F6; }
.map .maplibregl-canvas { outline: none; }
.legend { position: absolute; z-index: 5; left: 12px; top: 12px; background: rgba(255,255,255,.95); border: 1px solid var(--grey-200); padding: 9px 12px 8px; font: 400 12.5px/1.3 var(--sans); color: var(--subtle); }
.legend.outside { position: static; display: inline-block; margin-top: 10px; background: #fff; }
.legend .t { font-weight: 600; color: var(--text); font-size: 13px; margin-bottom: 6px; max-width: 290px; }
.legend .bins { display: flex; }
.legend .bins i { display: block; width: 50px; height: 10px; border: .5px solid var(--grey-300); margin-right: -.5px; }
.legend .ticks { position: relative; height: 16px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.legend .ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.legend .sym { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.place { font: 600 13px/1 var(--sans); color: var(--text); white-space: nowrap; pointer-events: none;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff; }
.place.minor { font-weight: 400; font-size: 12px; color: #222; }
.place .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--text); border: 1px solid #fff; margin-right: 5px; vertical-align: 1px; }
.ring-label { font: 400 11.5px/1 var(--sans); color: var(--subtle); pointer-events: none; text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff; }
.maplibregl-ctrl-scale { border-color: var(--grey-300) !important; color: var(--subtle) !important; font: 400 11px var(--sans) !important; background: rgba(255,255,255,.85) !important; }
.maplibregl-ctrl-attrib { font: 400 11px var(--sans) !important; }

/* scrolled 3D scene (Map 2.2): steps scroll on the left, the map stays on the right.
   Scenes are declared as data in assets/scene3d.js; scrolling, the step buttons and the
   ← → keys all call the same function. */
.scrolly-grid { display: grid; grid-template-columns: 290px minmax(0, 1fr); column-gap: 28px; margin-top: 6px; }
.scrolly-stage-wrap { grid-column: 2; grid-row: 1; }
.scrolly-stage { position: sticky; top: 64px; height: min(680px, calc(100vh - 84px)); border: 1px solid var(--grey-100); background: #F2F3F5; overflow: hidden; }
.scrolly-stage .map { position: absolute; inset: 0; height: auto; border: 0; }
.scrolly-text { grid-column: 1; grid-row: 1; padding: 8vh 0 34vh; }
.scene { min-height: 62vh; padding: 14px 0; opacity: .38; transition: opacity .35s ease; }
.scene.on { opacity: 1; }
.scene h4 { font: 600 17px/1.3 var(--sans); margin: 0 0 8px; color: var(--text); }
.scene h4 span { color: var(--accent); margin-right: .35em; }
.scene p { font-size: 17.5px; line-height: 1.55; margin: 0 0 .8em; }
.scene .kind { display: inline-block; font: 600 12.5px var(--sans); color: var(--subtle); border: 1px solid var(--grey-200); border-radius: 3px; padding: 0 6px; margin-bottom: 6px; }
.stage-legend { position: absolute; left: 12px; bottom: 30px; z-index: 5; background: rgba(255,255,255,.95); border: 1px solid var(--grey-200); padding: 9px 12px 8px; font: 400 12.5px/1.35 var(--sans); color: var(--subtle); max-width: 320px; transition: opacity .3s ease; }
.stage-legend .t { font-weight: 600; color: var(--text); font-size: 13px; margin-bottom: 6px; }
.stage-legend .bins { display: flex; }
.stage-legend .bins i { display: block; width: 44px; height: 10px; border: .5px solid var(--grey-300); margin-right: -.5px; }
.stage-legend .ticks { position: relative; height: 16px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stage-legend .ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.stage-legend .row { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.stage-legend .sw { display: inline-block; width: 14px; height: 10px; border: .5px solid var(--grey-300); }
.stage-legend .h { margin-top: 6px; border-top: 1px solid var(--grey-100); padding-top: 5px; }
.stage-tools { position: absolute; right: 12px; bottom: 30px; z-index: 5; display: flex; gap: 6px; }
.stage-hint { position: absolute; left: 12px; top: 10px; z-index: 5; font: 400 12.5px var(--sans); color: var(--subtle); background: rgba(255,255,255,.9); padding: 3px 8px; border: 1px solid var(--grey-100); }
.stage-scene { position: absolute; right: 56px; top: 10px; z-index: 5; font: 600 13px var(--sans); color: var(--text); background: rgba(255,255,255,.92); padding: 3px 9px; border: 1px solid var(--grey-200); }

/* "About the data" (Our World in Data style) */
.about-data { margin-top: 10px; font: 400 14px/1.5 var(--sans); }
.about-data summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.about-data summary span { color: var(--subtle); font-weight: 400; }
.about-data section { border-top: 1px solid var(--grey-100); padding: 12px 0 4px; }
.about-data h5 { font: 600 15px var(--sans); margin: 0 0 6px; color: var(--text); }
.about-data dl { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 4px 16px; margin: 0; }
.about-data dt { color: var(--subtle); }
.about-data dd { margin: 0; color: var(--text); }
.about-data dd ul { margin: 0; padding-left: 1.1em; }
.about-data dd.cite { color: var(--text-2); font-size: 13px; }
.about-data .proc { margin: 10px 0 0; color: var(--text-2); }
@media (max-width: 700px) { .about-data dl { grid-template-columns: 1fr; } .about-data dt { margin-top: 6px; } }

/* scrolled map with overlaid cards (Map 2.2): the map is sticky, the cards scroll over its left side */
.sc2 { display: grid; margin-top: 8px; }
.sc2 > .sc2-stage, .sc2 > .sc2-cards { grid-area: 1 / 1; }
.sc2-stage { position: sticky; top: 60px; height: min(760px, calc(100vh - 76px)); border: 1px solid var(--grey-100); background: #F4F5F6; overflow: hidden; }
.sc2-stage .map { position: absolute; inset: 0; height: auto; border: 0; background: #F4F5F6; }
.sc2-cards { position: relative; z-index: 6; pointer-events: none; padding: 42vh 0 46vh; }
.sc2-card { pointer-events: auto; width: 360px; margin: 0 0 78vh 18px; background: rgba(255,255,255,.97); border: 1px solid var(--grey-200); box-shadow: 0 2px 10px rgba(17,17,17,.08); padding: 16px 18px 6px; }
.sc2-card h4 { font: 600 18px/1.3 var(--sans); margin: 0 0 8px; }
.sc2-card h4 span { color: var(--accent); margin-right: .35em; }
.sc2-card p { font-size: 16.5px; line-height: 1.55; margin: 0 0 .75em; }
.sc2-card .chart { margin: 4px 0 10px; }
.sc2-legend { position: absolute; right: 12px; bottom: 30px; z-index: 5; background: rgba(255,255,255,.96); border: 1px solid var(--grey-200); padding: 9px 12px 8px; font: 400 12.5px/1.35 var(--sans); color: var(--subtle); max-width: 330px; }
.sc2-legend .t { font-weight: 600; color: var(--text); font-size: 13px; margin-bottom: 6px; }
.sc2-legend .row { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.sc2-legend .bins { display: flex; margin-top: 2px; }
.sc2-legend .bins i { display: block; width: 34px; height: 10px; border: .5px solid var(--grey-300); margin-right: -.5px; }
.sc2-legend .ticks { position: relative; height: 16px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.sc2-legend .ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; font-size: 11.5px; }
.sc2-legend .brace { position: relative; height: 14px; border-top: 1.5px solid var(--text); margin-top: 3px; font-size: 11.5px; color: var(--text); padding-top: 1px; }
.sc2-legend .h { margin-top: 6px; border-top: 1px solid var(--grey-100); padding-top: 5px; }
.sc2-credit { position: absolute; left: 10px; bottom: 6px; z-index: 5; font: 400 11.5px var(--sans); color: var(--subtle); background: rgba(255,255,255,.85); padding: 1px 6px; }
.sc2-year { position: absolute; right: 54px; top: 10px; z-index: 5; font: 600 34px/1 var(--sans); color: var(--text); background: rgba(255,255,255,.9); padding: 4px 10px; border: 1px solid var(--grey-200); font-variant-numeric: tabular-nums; }
.sc2-year small { display: block; font: 400 12px var(--sans); color: var(--subtle); margin-top: 3px; }
.place.uc { color: #0B3C8C; }
.sc2-card.on { border-color: var(--grey-300); }
@media (max-width: 900px) {
  .sc2-stage { top: 52px; height: 62vh; }
  .sc2-cards { padding: 56vh 0 20vh; }
  .sc2-card { width: auto; margin: 0 8px 60vh; }
  .sc2-legend { left: 6px; top: 6px; right: auto; bottom: auto; max-width: 74%; padding: 6px 8px; font-size: 12px; }
  .sc2-year { left: 6px; bottom: 30px; right: auto; top: auto; }
  .sc2-legend .bins i { width: 24px; }
  .sc2-year { font-size: 24px; }
}

/* exercises */
.exercise { border: 1px solid var(--grey-200); padding: 18px 24px 8px; margin: 32px 0; }
.exercise .ex-head { font: 600 17px/1.35 var(--sans); margin: 0 0 8px; }
.exercise .ex-head span { color: var(--accent); margin-right: .4em; }
.exercise details { font-family: var(--sans); font-size: 16px; margin: 4px 0 12px; }
.exercise summary { cursor: pointer; color: var(--accent); }
.exercise details > div { margin-top: 8px; padding: 10px 14px; background: var(--panel); }

/* references and appendix */
.references { font-size: 16px; line-height: 1.5; padding-left: 0; list-style: none; }
.references li { padding-left: 1.6em; text-indent: -1.6em; margin-bottom: 8px; }
.licence { font: 400 13px var(--sans); color: var(--subtle); }
.checked { font: 400 13px var(--sans); color: #0C7C68; }

/* home */
.home-head { padding: 72px 0 28px; }
.lesson-list { list-style: none; padding: 0; margin: 24px 0; border-top: 1px solid var(--text); }
.lesson-list li { display: grid; grid-template-columns: 56px 1fr; gap: 8px 16px; padding: 22px 0; border-bottom: 1px solid var(--grey-200); }
.lesson-list .n { font: 600 28px/1 var(--sans); color: var(--grey-300); }
.lesson-list h2 { border: 0; padding: 0; margin: 0 0 6px; font-size: 24px; }
.lesson-list h2 a { color: var(--text); text-decoration: none; }
.lesson-list h2 a:hover { color: var(--accent); }
.lesson-list p { margin: 0 0 6px; }
.lesson-list .meta { border: 0; padding: 0; }

.site-footer { margin-top: 96px; border-top: 1px solid var(--grey-100); font: 400 13.5px/1.5 var(--sans); color: var(--subtle); }
.site-footer .inner { max-width: 1240px; margin: 0 auto; padding: 20px 24px 40px; }

/* ── responsive ── */
@media (max-width: 900px) {
  .scrolly-grid { grid-template-columns: minmax(0, 1fr); }
  .scrolly-stage-wrap { grid-column: 1; grid-row: 1; position: sticky; top: 52px; z-index: 3; height: 56vh; }
  .scrolly-stage { position: relative; top: 0; height: 56vh; }
  .scrolly-text { grid-column: 1; grid-row: 2; padding: 4vh 0 20vh; }
  .scene { min-height: 58vh; opacity: 1; }
  .scene > div { background: #fff; border: 1px solid var(--grey-200); padding: 12px 14px; }
  .stage-legend { bottom: 26px; max-width: 70%; padding: 6px 8px; }
  .stage-legend .bins i { width: 30px; }
  .stage-hint { display: none; }
}
@media (max-width: 1239px) {
  .layout { grid-template-columns: minmax(0, var(--text-col)); justify-content: center; }
  .toc { display: none; }
  .main { grid-column: 1; }
  .note { float: none; width: auto; margin: 4px 0 18px; padding: 8px 14px; border-left: 2px solid var(--grey-200); background: var(--panel); }
  .fig.wide { width: 100%; }
}
@media (max-width: 760px) {
  body { font-size: 17.5px; }
  h1 { font-size: 32px; }
  .standfirst { font-size: 19px; }
  h2 { font-size: 23px; }
  .site-header .course span { display: none; }
  .site-header nav { gap: 14px; font-size: 14px; }
  .site-header nav .long { display: none; }
  .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fig-2col { grid-template-columns: 1fr; }
  .map { height: 420px; }
  .legend .bins i { width: 38px; }
  .steps .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .chart path.line, .chart .series { transition: none; }
}
@media print {
  .site-header, .toc, .steps, .controls, .maplibregl-control-container { display: none; }
  .fig { break-inside: avoid; }
}

/* Lesson 1 · Figure 1.2 — land rent surface (assets/mat_gia_thue.js) */
.fig-surface { grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); align-items: start; }
.surface { position: relative; overflow: hidden; }
.surface canvas { display: block; cursor: grab; }
.surface canvas:active { cursor: grabbing; }
.s-labels span { position: absolute; transform: translate(-50%, -100%); font: 600 13px/1.2 var(--sans); color: var(--text); white-space: nowrap; pointer-events: none;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; }
.s-labels span.g { color: #2F6B40; transform: translate(0, -100%); }
.s-labels span.d { font-weight: 400; font-size: 12px; color: var(--subtle); transform: translate(-50%, 0); }
.legend sub, .control sub { font-size: .72em; line-height: 0; vertical-align: -.2em; }
.s-hint { font: 400 13px var(--sans); color: var(--subtle); margin: 4px 0 0; }
.surface.no-3d p { font: 400 14px/1.5 var(--sans); color: var(--subtle); border: 1px dashed var(--grey-200); padding: 16px; margin: 0; }
@media (max-width: 900px) { .fig-surface { grid-template-columns: 1fr; } }

/* Lesson 2 · Map 2.3 — the section raised over the city (assets/mat_cat_3d.js, assets/lop3d.js) */
.s3d-stage { position: relative; height: min(660px, 82vh); border: 1px solid var(--grey-100); background: #F4F5F6; overflow: hidden; }
.s3d-stage .map { position: absolute; inset: 0; height: auto; border: 0; }
.l3d-labels { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.l3d-labels span { position: absolute; transform: translate(-50%, -100%); font: 600 12.5px/1.2 var(--sans); color: var(--text); white-space: nowrap; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; }
.l3d-labels .truc-y { transform: translate(-100%, -50%); font-weight: 400; color: var(--subtle); }
.l3d-labels .truc-t { transform: translate(-10px, -100%); }
.l3d-labels .uc { color: #0B3C8C; font-weight: 400; }
.l3d-labels .fit { transform: translate(0, -50%); font-weight: 400; }
.l3d-labels .moc { color: #5C0000; }
.s3d-legend { position: absolute; left: 10px; bottom: 24px; z-index: 5; background: rgba(255,255,255,.94); border: 1px solid var(--grey-200); padding: 7px 10px 6px; font: 400 12px/1.3 var(--sans); color: var(--subtle); max-width: 290px; }
.s3d-legend .row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.s3d-legend .h { margin-top: 6px; border-top: 1px solid var(--grey-100); padding-top: 5px; }
@media (max-width: 900px) { .s3d-stage { height: 70vh; } .s3d-legend { max-width: 70%; font-size: 11.5px; padding: 6px 8px; bottom: 20px; } }

/* Lesson 2 · Map 2.2 — the price surface (assets/non_gia_3d.js) */
.s3d-scale { position: absolute; left: 10px; top: 10px; z-index: 6; display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,.94); border: 1px solid var(--grey-200); padding: 4px 6px; font: 400 12.5px var(--sans); color: var(--subtle); }
.s3d-scale span { margin-right: 4px; }
.s3d-scale button { font: 400 12.5px var(--sans); color: var(--text); background: #fff; border: 1px solid var(--grey-200); border-radius: 3px; padding: 2px 8px; cursor: pointer; }
.s3d-scale button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.s3d-legend .bins3 { display: flex; width: 190px; margin-top: 4px; }
.s3d-legend .bins3 i { flex: 1; height: 9px; border: .5px solid #fff; }
.s3d-legend .ticks3 { position: relative; width: 190px; height: 14px; font-size: 11px; }
.s3d-legend .ticks3 span { position: absolute; top: 1px; transform: translateX(-50%); }
.l3d-labels .gia { transform: translate(0, -50%); font-weight: 400; color: #2F3B47; font-size: 11.5px; }
.l3d-labels .nn { transform: translate(0, -50%); font-weight: 400; color: #27795A; }
#map-cone .step-text { min-height: 7.4em; }
@media (max-width: 900px) { .s3d-scale { font-size: 11.5px; } .s3d-scale button { font-size: 11.5px; padding: 2px 6px; } }
.s3d-legend.ngoai { position: static; max-width: none; border: 0; background: none; padding: 10px 0 0; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 30px; font-size: 13px; }
.s3d-legend.ngoai .nhom { display: flex; flex-wrap: wrap; gap: 3px 18px; max-width: 640px; }
.s3d-legend.ngoai .row { margin-top: 0; }
.s3d-legend.ngoai .t { margin-bottom: 1px; }
.s3d-legend.ngoai .ghi { flex-basis: 100%; }
@media (max-width: 900px) { .s3d-legend.ngoai { max-width: none; font-size: 12px; padding: 8px 0 0; } }

/* Lesson 3 · Map 3.1 — mode and view switches, taller map, four-year table in the tooltip (assets/lesson3.js) */
.toggles { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -6px 0 12px; font: 400 13.5px var(--sans); color: var(--subtle); }
.toggles .lbl { margin: 0 2px 0 8px; }
.toggles .lbl:first-child { margin-left: 0; }
.toggles button { font: 400 13.5px var(--sans); color: var(--text); background: #fff; border: 1px solid var(--grey-200); border-radius: 3px; padding: 3px 10px; cursor: pointer; }
.toggles button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.map.tall { height: 620px; }
.tip .tip-t { border-collapse: collapse; margin-top: 3px; font-variant-numeric: tabular-nums; }
.tip .tip-t td { padding: 0 6px 0 0; color: var(--subtle); }
.tip .tip-t td.r { text-align: right; color: var(--text); }
.tip .tip-t tr.on td { font-weight: 700; color: var(--text); }
@media (max-width: 900px) { .map.tall { height: 480px; } .toggles { font-size: 12.5px; } .toggles button { font-size: 12.5px; padding: 3px 8px; } }
#tab-3-1 td.r { white-space: nowrap; }

/* Lesson 4 · Figure 4.1 — six cities side by side (assets/lesson4.js) */
.small-multiples { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.small-multiples .sm canvas { width: 100%; height: auto; display: block; border: 1px solid var(--grey-100); image-rendering: pixelated; }
.small-multiples .sm-cap { font: 400 13px/1.35 var(--sans); color: var(--subtle); margin-top: 4px; }
.small-multiples .sm-cap b { display: block; color: var(--text); font-size: 14px; }
@media (max-width: 700px) { .small-multiples { grid-template-columns: repeat(2, 1fr); } }

/* Lesson 4 · Section 4.3 — two charts side by side (Figure 4.2), grouped table header (Table 4.2) */
.pair-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 760px) { .pair-charts { grid-template-columns: 1fr; } }
table.data th.c { text-align: center; }
table.data tr.sep td { border-top: 1.5px solid var(--grey-300); }
#tab-4-2 th { white-space: nowrap; }
#tab-4-2 thead th.c { border-bottom: 1px solid var(--grey-200); }
.katex-display { overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; }
@media (max-width: 760px) { .s-labels span.g { transform: translate(-100%, -100%); } }

/* Lesson 5 · legends of Map 5.1 (three groups of classes) and Map 5.2 (continuous ramp) */
.legend.legend-cols { display: flex; flex-wrap: wrap; gap: 6px 26px; }
.legend-cols .col { min-width: 190px; }
.legend .sym i { display: inline-block; width: 16px; height: 11px; border: .5px solid var(--grey-300); }
.legend .ramp { margin-top: 2px; }
