/* Financial Knowledge Atlas — giao diện */
:root {
  --bg: #f6f4ef; --surface: #ffffff; --surface-2: #f0ede6; --surface-3: #e8e4da;
  --ink: #1c2127; --ink-2: #454d57; --ink-3: #737b85; --line: #e0dbd0; --line-2: #cfc8ba;
  --accent: #1d5c8a; --accent-2: #154a71; --accent-soft: #e2edf5; --accent-ink: #fff;
  --ok: #2b7a4b; --ok-soft: #e2f1e8; --warn: #a86a12; --warn-soft: #f7ecd9; --bad: #b4372f; --bad-soft: #f7e3e1;
  --dom-A: #2f6fb0; --dom-B: #17846a; --dom-C: #c06a22; --dom-D: #7449b0; --dom-E: #b03447; --dom-F: #a8820f;
  --e-causal: #39424d; --e-conditional: #b7791f; --e-correlation: #4f78b8; --e-prereq: #9aa1aa; --e-contrast: #a3559a; --e-related: #8f98a3;
  --chain: #d1495b; --path: #0f8b8d;
  --serif: "Noto Serif", "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 10px; --shadow: 0 1px 2px rgba(20, 24, 30, .05), 0 6px 20px rgba(20, 24, 30, .06);
  --side-w: 252px; --top-h: 56px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #14171b; --surface: #1b1f24; --surface-2: #22272d; --surface-3: #2a3038;
  --ink: #e7e9ec; --ink-2: #b9c0c8; --ink-3: #8a929c; --line: #2d333b; --line-2: #3a414b;
  --accent: #6aaee0; --accent-2: #8cc2ea; --accent-soft: #1d3346; --accent-ink: #0d1620;
  --ok: #5fc08a; --ok-soft: #173326; --warn: #e2a74a; --warn-soft: #382a14; --bad: #ef7d73; --bad-soft: #3b1e1b;
  --dom-A: #6ea6e0; --dom-B: #4fc3a1; --dom-C: #eb9c58; --dom-D: #a98ae0; --dom-E: #e8707f; --dom-F: #dcbc4f;
  --e-causal: #c4cbd3; --e-conditional: #e2a74a; --e-correlation: #7fa6e3; --e-prereq: #6c747e; --e-contrast: #cf86c6; --e-related: #7b848f;
  --chain: #ff6b7d; --path: #3fd0d2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.25; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.005em; }
h1 { font-size: 2rem; } h2 { font-size: 1.45rem; } h3 { font-size: 1.15rem; } h4 { font-size: 1rem; font-family: var(--sans); }
p { margin: 0 0 .85em; }
ul, ol { margin: 0 0 .9em; padding-left: 1.3em; } li { margin: .25em 0; }
strong { font-weight: 650; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- khung ---------- */
#app { display: flex; min-height: 100vh; }
#sidebar { width: var(--side-w); flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px 24px; display: flex; flex-direction: column; gap: 14px; z-index: 40; }
.brand { display: flex; gap: 10px; align-items: center; color: var(--ink); padding: 4px 8px 10px; border-bottom: 1px solid var(--line); }
.brand:hover { text-decoration: none; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--ink); color: var(--bg); font-family: var(--serif); font-weight: 700; font-size: 17px; flex: none; }
.brand b { display: block; font-family: var(--serif); font-size: 15px; line-height: 1.2; }
.brand small { display: block; color: var(--ink-3); font-size: 12px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-size: 14.5px; }
#nav a .n { font: 600 11px var(--mono); color: var(--ink-3); width: 18px; }
#nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
#nav a.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
:root[data-theme="dark"] #nav a.active { color: var(--accent-2); }
#nav a.active .n { color: var(--accent); }
.nav-sep { height: 1px; background: var(--line); margin: 8px 6px; }
.side-progress { margin-top: auto; padding: 12px 10px; border-radius: 10px; background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.side-progress .bar { margin: 6px 0 4px; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar { position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 10px; padding: 0 18px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
#menu-btn { display: none; }
.search-box { position: relative; flex: 1; max-width: 560px; }
.search-box input { width: 100%; height: 38px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); padding: 0 12px 0 34px; outline: none; }
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; font-size: 14px; }
.search-box kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
kbd { font: 11px var(--mono); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--ink-3); background: var(--surface-2); }
.search-drop { position: absolute; top: 44px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); max-height: 70vh; overflow: auto; display: none; z-index: 50; }
.search-drop.open { display: block; }
.search-drop a { display: flex; gap: 10px; align-items: baseline; padding: 9px 12px; color: var(--ink); border-bottom: 1px solid var(--line); }
.search-drop a:last-child { border-bottom: 0; }
.search-drop a:hover, .search-drop a.kb { background: var(--surface-2); text-decoration: none; }
.search-drop .k { font-size: 11px; color: var(--ink-3); min-width: 74px; text-transform: uppercase; letter-spacing: .04em; }
.search-drop .s { color: var(--ink-3); font-size: 13px; margin-left: auto; text-align: right; }
.top-actions { margin-left: auto; display: flex; gap: 6px; }
#view { flex: 1; min-width: 0; }
.page { max-width: 1120px; margin: 0 auto; padding: 30px 28px 90px; }
.page.narrow { max-width: 860px; }

/* ---------- thành phần chung ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 14px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); line-height: 1.6; white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
button.chip { cursor: pointer; }
button.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); }
button.chip.off { opacity: .55; }
.chip.dom { background: transparent; }
.dom-A { color: var(--dom-A); } .dom-B { color: var(--dom-B); } .dom-C { color: var(--dom-C); } .dom-D { color: var(--dom-D); } .dom-E { color: var(--dom-E); } .dom-F { color: var(--dom-F); }
.chip.dom { border-color: currentColor; }
.chip.dom span { color: var(--ink-2); }
.lvl { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.lvl b { letter-spacing: 1px; color: var(--ink-2); font-weight: 500; }
.tag { font-size: 12px; padding: 1px 7px; border-radius: 5px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.cfa { background: transparent; border-style: dashed; }
.st { font-size: 12px; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.st-new { background: var(--surface-2); color: var(--ink-3); }
.st-learning { background: var(--warn-soft); color: var(--warn); }
.st-understood { background: var(--ok-soft); color: var(--ok); }
.st-review { background: var(--bad-soft); color: var(--bad); }
.eyebrow { font: 600 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.lead { font-size: 1.08rem; color: var(--ink-2); max-width: 760px; }
.page-head { margin-bottom: 26px; }
.muted { color: var(--ink-3); }
.small { font-size: 13.5px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card h3 { margin-bottom: .35em; }
a.card { display: block; color: var(--ink); transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--line-2); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; }
.bar .b-ok { background: var(--ok); } .bar .b-learn { background: var(--warn); } .bar .b-rev { background: var(--bad); }
.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 12px 16px; border-radius: 0 8px 8px 0; margin: 0 0 1em; }
.callout p:last-child { margin: 0; }
.formula { font-family: var(--mono); font-size: 14.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0 0 1em; overflow-x: auto; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--line); border-radius: 8px; }
table.md-table, table.tbl { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.md-table th, .md-table td, .tbl th, .tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md-table th, .tbl th { background: var(--surface-2); font-weight: 600; font-size: 13.5px; }
.md-table tr:last-child td, .tbl tr:last-child td { border-bottom: 0; }
.xref { border-bottom: 1px dotted currentColor; }
.xref:hover { text-decoration: none; border-bottom-style: solid; }
.broken { color: var(--ink-3); border-bottom: 1px dashed var(--line-2); cursor: help; }
textarea.input, input.input, select.input { width: 100%; border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; padding: 9px 11px; outline: none; }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.55; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { height: 36px; padding: 0 8px; }
.empty { padding: 30px; text-align: center; color: var(--ink-3); border: 1px dashed var(--line-2); border-radius: var(--r); }
details > summary { cursor: pointer; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 14px; z-index: 100; box-shadow: var(--shadow); }

/* ---------- bản đồ ---------- */
#view.full { overflow: hidden; }
.map-wrap { position: relative; height: calc(100vh - var(--top-h)); height: calc(100dvh - var(--top-h)); display: grid; grid-template-columns: minmax(0, 1fr) 380px; }
.map-stage { position: relative; min-width: 0; display: grid; grid-template: auto minmax(0, 1fr) / minmax(0, 1fr); background:
  radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 0) 0 0 / 22px 22px, var(--bg); }
.map-host { grid-area: 2 / 1; min-height: 0; min-width: 0; }
.graph-svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.graph-svg.dragging { cursor: grabbing; }
.map-toolbar { position: relative; grid-area: 1 / 1; padding: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; pointer-events: none; z-index: 6; }
.map-toolbar > * { pointer-events: auto; }
.tb-group { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 4px; box-shadow: var(--shadow); align-items: center; }
.tb-group select { height: 28px; border: 0; background: transparent; max-width: 230px; font-size: 13.5px; }
.map-search { position: relative; }
.map-search input { height: 28px; border: 0; background: transparent; width: 190px; padding: 0 6px; outline: none; font-size: 13.5px; }
.map-search .search-drop { top: 36px; width: 300px; }
.map-legend { display: none; position: absolute; left: 12px; bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); font-size: 12.5px; max-width: calc(100% - 68px); z-index: 5; }
.map-legend.is-open { display: block; }
.map-legend .lg-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.map-legend .lg-row + .lg-row { margin-top: 7px; }
.map-legend .lg-t { color: var(--ink-3); font-size: 11.5px; min-width: 64px; }
.lg-line { display: inline-block; width: 22px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 2px; }
.lg-causal { border-color: var(--e-causal); } .lg-conditional { border-color: var(--e-conditional); border-top-style: dashed; }
.lg-correlation { border-color: var(--e-correlation); border-top-style: dotted; border-top-width: 3px; }
.lg-prereq { border-color: var(--e-prereq); border-top-width: 1px; } .lg-contrast { border-color: var(--e-contrast); border-top-style: dashed; }
.lg-related { border-color: var(--e-related); border-top-width: 1px; border-top-style: dotted; }
.zoom-ctl { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 4px; z-index: 5; }
.map-panel { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 18px 18px 40px; }
.map-panel h1 { font-size: 1.55rem; }
.map-panel h3 { font-size: 1.3rem; margin: 6px 0 2px; }
.map-panel .en { color: var(--ink-3); font-size: 14px; margin-bottom: 10px; }
.map-panel .sec { margin-top: 18px; }
.map-panel .sec-t { font: 600 11.5px var(--mono); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin-bottom: 6px; }
.rel-item { display: block; width: 100%; text-align: left; padding: 7px 9px; border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 14px; line-height: 1.4; color: var(--ink); }
.rel-item:hover { background: var(--surface-2); border-color: var(--line); }
.rel-item .rl { color: var(--ink-3); font-size: 12.5px; display: block; margin-top: 1px; }
.rtype { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; border: 1px solid; margin-right: 4px; vertical-align: 1px; white-space: nowrap; }
.rt-causal { color: var(--e-causal); } .rt-conditional { color: var(--e-conditional); } .rt-correlation { color: var(--e-correlation); }
.rt-prereq { color: var(--ink-3); } .rt-contrast { color: var(--e-contrast); } .rt-related { color: var(--e-related); }
.edge-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; margin: 6px 0 10px; }
.edge-head .arrow { color: var(--ink-3); }
.type-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface-2); font-size: 13.5px; color: var(--ink-2); margin: 10px 0; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { position: relative; padding: 6px 8px 8px 36px; border-radius: 8px; cursor: pointer; }
.steps li:hover { background: var(--surface-2); }
.steps li::before { counter-increment: s; content: counter(s); position: absolute; left: 6px; top: 7px; width: 22px; height: 22px; border-radius: 50%; background: var(--chain); color: #fff; font: 600 12px/22px var(--mono); text-align: center; }
.steps.path li::before { background: var(--path); }
.steps li.active { background: var(--surface-2); outline: 1px solid var(--line-2); }
.steps li b { display: block; font-size: 14.5px; }
.steps li span { display: block; font-size: 13.5px; color: var(--ink-2); }
.conseq-d { font: 600 12px var(--mono); color: var(--ink-3); margin: 10px 0 2px; }

/* SVG */
.hub-link { stroke: var(--line-2); stroke-width: 1; opacity: .55; }
.hub-links.dim { opacity: .25; }
.edge { fill: none; stroke-width: 1.5; opacity: .62; transition: opacity .15s; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 12; cursor: pointer; }
.et-causal .edge { stroke: var(--e-causal); }
.et-conditional .edge { stroke: var(--e-conditional); stroke-dasharray: 7 4; }
.et-correlation .edge { stroke: var(--e-correlation); stroke-dasharray: 1.5 4; stroke-linecap: round; stroke-width: 2.2; }
.et-prereq .edge { stroke: var(--e-prereq); stroke-width: 1; opacity: .5; }
.et-contrast .edge { stroke: var(--e-contrast); stroke-dasharray: 9 3 2 3; }
.et-related .edge { stroke: var(--e-related); stroke-dasharray: 2 3; stroke-width: 1.2; }
.ah-causal { fill: var(--e-causal); } .ah-conditional { fill: var(--e-conditional); } .ah-prereq { fill: var(--e-prereq); }
.ah-chain { fill: var(--chain); } .ah-path { fill: var(--path); }
.edge-g:hover .edge { opacity: 1; stroke-width: 2.6; }
.edge-g.hl .edge { opacity: .95; stroke-width: 2.4; }
.edge-g.sel .edge { opacity: 1; stroke-width: 3.4; }
.edge-g.dim .edge { opacity: .07; }
.edge-g.dim .edge-count { opacity: .2; }
.edge-count { font: 600 11px var(--sans); fill: var(--ink-2); text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; pointer-events: none; }
.node { cursor: pointer; }
.node .node-c { stroke: var(--bg); stroke-width: 2; }
.node .ring { fill: none; stroke: transparent; stroke-width: 2.5; }
.node[data-status="learning"] .ring { stroke: var(--warn); }
.node[data-status="understood"] .ring { stroke: var(--ok); }
.node[data-status="review"] .ring { stroke: var(--bad); stroke-dasharray: 3 2; }
.node-label { font: 500 12.5px var(--sans); fill: var(--ink); text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.node:hover .node-c { stroke: var(--ink); }
.node:hover .node-label { font-weight: 650; }
.node.sel .node-c { stroke: var(--ink); stroke-width: 3; }
.node.sel .node-label { font-weight: 700; }
.node.dim { opacity: .16; }
.graph-svg.far .node-label { font-size: 15px; }
.hub .node-c { stroke-width: 0; }
.hub .hub-halo { fill: none; stroke-width: 1.5; stroke-dasharray: 3 4; opacity: .6; }
.hub-letter { font: 700 22px var(--serif); fill: #fff; text-anchor: middle; pointer-events: none; }
.hub-label { font: 700 14.5px var(--serif); text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 5px; pointer-events: none; }
.hub-count { font: 500 11.5px var(--sans); fill: var(--ink-3); text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; pointer-events: none; }
.graph-svg.far .is-collapsed .hub-letter { font-size: max(22px, calc(8px / var(--map-zoom, 1))); }
.graph-svg.far .is-collapsed .hub-label { font-size: max(14.5px, calc(10px / var(--map-zoom, 1))); }
.graph-svg.far .is-collapsed .hub-count { display: none; }
/* Khi thu nhỏ xa: giữ vòng tròn cụm đủ lớn để chứa chữ cái, và đẩy nhãn xuống dưới vòng tròn */
.graph-svg.far .is-collapsed .node-c { r: max(30px, calc(9px / var(--map-zoom, 1))); }
.graph-svg.far .is-collapsed .hub-halo { r: max(37px, calc(12px / var(--map-zoom, 1))); }
.graph-svg.far .is-collapsed .hub-label { transform: translateY(max(0px, calc(23px / var(--map-zoom, 1) - 52px))); }
.nd-A .node-c { fill: var(--dom-A); } .nd-B .node-c { fill: var(--dom-B); } .nd-C .node-c { fill: var(--dom-C); }
.nd-D .node-c { fill: var(--dom-D); } .nd-E .node-c { fill: var(--dom-E); } .nd-F .node-c { fill: var(--dom-F); }
.nd-A .hub-halo { stroke: var(--dom-A); } .nd-B .hub-halo { stroke: var(--dom-B); } .nd-C .hub-halo { stroke: var(--dom-C); }
.nd-D .hub-halo { stroke: var(--dom-D); } .nd-E .hub-halo { stroke: var(--dom-E); } .nd-F .hub-halo { stroke: var(--dom-F); }
.nd-A .hub-label { fill: var(--dom-A); } .nd-B .hub-label { fill: var(--dom-B); } .nd-C .hub-label { fill: var(--dom-C); }
.nd-D .hub-label { fill: var(--dom-D); } .nd-E .hub-label { fill: var(--dom-E); } .nd-F .hub-label { fill: var(--dom-F); }
:root[data-theme="dark"] .hub-letter { fill: #111; }
.chain-seg { fill: none; stroke: var(--chain); stroke-width: 4; opacity: .9; stroke-linecap: round; }
.chain-seg.path { stroke: var(--path); }
.chain-seg.et-conditional, .chain-seg.et-contrast { stroke-dasharray: 10 6; }
.chain-seg.et-correlation, .chain-seg.et-related { stroke-dasharray: 2 6; }
.chain-seg.active { stroke-width: 6.5; opacity: 1; }
.chain-seg.faded { opacity: .35; }
.badge circle { fill: var(--chain); stroke: var(--bg); stroke-width: 2; }
.badges .badge text { font: 700 11.5px var(--sans); fill: #fff; text-anchor: middle; }
.badge.active circle { r: 14; }

/* ---------- thư viện & lĩnh vực ---------- */
.dom-card { position: relative; overflow: hidden; }
.dom-card .letter { font: 700 40px/1 var(--serif); opacity: .9; }
.dom-card .meta { display: flex; gap: 10px; color: var(--ink-3); font-size: 13px; margin-top: 10px; }
.dom-card .bar { margin-top: 10px; }
.path-list { list-style: none; padding: 0; margin: 0; counter-reset: p; }
.path-list li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 6px; border-bottom: 1px solid var(--line); margin: 0; }
.path-list li::before { counter-increment: p; content: counter(p, decimal-leading-zero); font: 600 13px var(--mono); color: var(--ink-3); padding-top: 3px; }
.path-list .pt a { font-weight: 600; font-size: 15.5px; color: var(--ink); }
.path-list .pt .en { color: var(--ink-3); font-size: 13.5px; margin-left: 6px; }
.path-list .pt p { margin: 3px 0 0; color: var(--ink-2); font-size: 14px; }
.path-list .pm { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.outline { columns: 2; column-gap: 28px; padding: 0; list-style: none; margin: 0; }
.outline li { break-inside: avoid; padding: 6px 0; border-bottom: 1px dashed var(--line); margin: 0; font-size: 14.5px; }
.outline .cov { display: block; font-size: 13px; }
.outline .todo { color: var(--ink-3); font-size: 12.5px; }

/* ---------- trang khái niệm ---------- */
.concept-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 36px; align-items: start; }
.concept-head .titles h1 { font-size: 2.15rem; margin-bottom: 2px; }
.concept-head .en-title { font-size: 1.1rem; color: var(--ink-3); font-family: var(--serif); font-style: italic; margin-bottom: 12px; }
.concept-head .row { margin-bottom: 16px; }
.core-box { border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 var(--r) var(--r) 0; padding: 16px 18px; margin-bottom: 22px; }
.core-box .lab { font: 600 11.5px var(--mono); text-transform: uppercase; letter-spacing: .07em; color: var(--accent); margin-bottom: 4px; }
.core-box .sum { font-family: var(--serif); font-size: 1.16rem; line-height: 1.5; margin: 0 0 10px; }
.core-box .def p:last-child { margin: 0; }
.csec { padding: 22px 0 8px; border-top: 1px solid var(--line); scroll-margin-top: 70px; }
.csec > h2 { font-size: 1.3rem; display: flex; gap: 10px; align-items: baseline; }
.csec > h2 .num { font: 600 13px var(--mono); color: var(--accent); }
.csec .body { font-size: 16.5px; line-height: 1.72; }
.phrases { list-style: none; padding: 0; margin: 14px 0 0; }
.phrases li { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0 0 8px; font-size: 15px; }
.phrases .q { font-family: var(--serif); font-style: italic; font-weight: 600; }
.phrases-t { font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-top: 16px; }
.conn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.conn-box { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 12px 14px; }
.conn-box h4 { font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 6px; }
.conn-box details { border-top: 1px solid var(--line); padding: 7px 0; font-size: 14.5px; }
.conn-box details:first-of-type { border-top: 0; }
.conn-box summary { list-style: none; }
.conn-box summary::-webkit-details-marker { display: none; }
.conn-box summary .lab { color: var(--ink-3); font-size: 13px; display: block; }
.conn-box .why { margin: 6px 0 2px; padding: 8px 10px; background: var(--surface-2); border-radius: 6px; font-size: 14px; }
.conn-box .why p:last-child { margin: 0; }
.clink { font-weight: 600; color: var(--ink); }
.clink .dot, .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: 1px; }
.dot.A { background: var(--dom-A); } .dot.B { background: var(--dom-B); } .dot.C { background: var(--dom-C); } .dot.D { background: var(--dom-D); } .dot.E { background: var(--dom-E); } .dot.F { background: var(--dom-F); }
.q-item { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; background: var(--surface); margin-bottom: 12px; }
.q-item .qq { font-weight: 600; margin-bottom: 10px; }
.q-item .ans { margin-top: 10px; padding: 12px 14px; background: var(--ok-soft); border-radius: 8px; font-size: 15px; }
:root[data-theme="dark"] .q-item .ans { color: var(--ink); }
.q-item .ans p:last-child { margin: 0; }
.sources { font-size: 14px; color: var(--ink-2); }
.c-aside { position: sticky; top: calc(var(--top-h) + 18px); display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - var(--top-h) - 30px); overflow-y: auto; padding-bottom: 10px; }
.c-aside .card { padding: 14px; }
.c-aside h4 { font: 600 11.5px var(--mono); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin-bottom: 8px; }
.toc a { display: block; padding: 3px 0; font-size: 13.5px; color: var(--ink-2); }
.status-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.status-pick button { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 5px 4px; font-size: 12.5px; cursor: pointer; }
.status-pick button.on.new { background: var(--surface-3); }
.status-pick button.on.learning { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.status-pick button.on.understood { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.status-pick button.on.review { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.saved { font-size: 12px; color: var(--ok); min-height: 16px; margin-top: 4px; }
.prevnext { display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; }
.prevnext a { flex: 1; max-width: 48%; }
.prevnext .nx { text-align: right; margin-left: auto; }

/* ---------- từ điển ---------- */
.vocab-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 26px; align-items: start; }
.vcats { position: sticky; top: calc(var(--top-h) + 16px); display: flex; flex-direction: column; gap: 1px; max-height: calc(100vh - var(--top-h) - 30px); overflow: auto; }
.vcats button { display: flex; justify-content: space-between; gap: 8px; text-align: left; border: 0; background: transparent; padding: 6px 9px; border-radius: 7px; cursor: pointer; font-size: 13.5px; color: var(--ink-2); line-height: 1.35; }
.vcats button:hover { background: var(--surface-2); }
.vcats button.on { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.vcats .ct { color: var(--ink-3); font: 12px var(--mono); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters .input { max-width: 320px; height: 36px; }
.filters select.input { width: auto; max-width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; font-size: 13.5px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--bg); }
.vrow { display: block; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 12px 16px; margin-bottom: 9px; color: var(--ink); }
a.vrow:hover { border-color: var(--line-2); text-decoration: none; box-shadow: var(--shadow); }
.vrow .vt { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.vrow .vt b { font-family: var(--serif); font-size: 16.5px; }
.vrow .vt .vi { color: var(--ink-2); }
.vrow .vs { color: var(--ink-2); font-size: 14.5px; margin-top: 4px; }
.vrow .vm { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.vrow .kind { font: 600 10.5px var(--mono); text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 4px; }
.kind.core { background: var(--accent-soft); color: var(--accent-2); }
.kind.jargon { background: var(--surface-3); color: var(--ink-2); }
details.vrow summary { list-style: none; }
details.vrow summary::-webkit-details-marker { display: none; }
details.vrow[open] { border-color: var(--accent); }
.jbody { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 15px; }
.jbody .use { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
.flash-overlay { position: fixed; inset: 0; background: rgba(10, 12, 16, .55); z-index: 90; display: grid; place-items: center; padding: 16px; }
.flash { background: var(--surface); border-radius: 14px; width: min(620px, 100%); padding: 26px; box-shadow: var(--shadow); }
.flash .front { font-family: var(--serif); font-size: 1.7rem; text-align: center; padding: 24px 0 10px; }
.flash .back { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.flash .ctr { display: flex; gap: 8px; justify-content: space-between; margin-top: 18px; flex-wrap: wrap; }

/* ---------- thế giới ---------- */
.factor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 26px; }
.factor-grid .card h4 { margin-bottom: 4px; }
.factor-grid .card p { font-size: 14px; color: var(--ink-2); margin: 0; }
.quick-matrix td, .quick-matrix th { white-space: nowrap; }
.quick-matrix td:first-child { font-weight: 600; }
.cmp-table { table-layout: fixed; min-width: 760px; }
.cmp-table th:first-child, .cmp-table td:first-child { width: 170px; background: var(--surface-2); font-weight: 600; font-size: 13.5px; }
.cmp-table td { font-size: 14px; }
.cmp-table td p:last-child { margin: 0; }
.country-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 16px; }
.profile { margin-top: 14px; }
.profile .figs { font-size: 13.5px; }

/* ---------- tình huống & lab ---------- */
.case-card .period { font: 600 12px var(--mono); color: var(--ink-3); }
.case-card h3 { margin-top: 6px; }
.case-card p { color: var(--ink-2); font-size: 14.5px; }
.filters-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.case-sec { padding: 20px 0 6px; border-top: 1px solid var(--line); }
.case-sec h2 { font-size: 1.25rem; }
.case-sec .body { font-size: 16.5px; line-height: 1.72; }
.lab-card .role { font-size: 13px; color: var(--ink-3); }
.scenario-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 16px; }
.scenario-box h3 { font-size: 1.05rem; font-family: var(--sans); }
.answer-area textarea { min-height: 260px; font-size: 15.5px; }
.cov-list { list-style: none; padding: 0; margin: 0; }
.cov-list li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.cov-list .mk { width: 22px; flex: none; font-weight: 700; }
.cov-list .hit .mk { color: var(--ok); } .cov-list .miss .mk { color: var(--ink-3); }
.rubric { display: grid; gap: 12px; }
.rubric .rb { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
.rubric .rb .opts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.rubric .rb .opts button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 7px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.rubric .rb .opts button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.rubric .desc { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.reveal { border: 1px solid var(--accent); border-radius: var(--r); padding: 18px 20px; background: var(--surface); margin: 18px 0; }
.attempt { border-top: 1px solid var(--line); padding: 10px 0; font-size: 14px; }

/* ---------- CFA, ghi chú ---------- */
.cfa-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cfa-area { border-top: 1px solid var(--line); padding: 10px 0; }
.cfa-area h4 { margin-bottom: 6px; font-size: 14.5px; }
.cfa-area .cl { display: flex; flex-wrap: wrap; gap: 5px; }
.cfa-area .cl a { font-size: 13px; }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat b { display: block; font: 650 1.7rem/1.1 var(--serif); }
.stat span { color: var(--ink-3); font-size: 13px; }
.note-item { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 12px 16px; margin-bottom: 10px; }
.note-item .nt { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.note-item pre { white-space: pre-wrap; font: inherit; margin: 6px 0 0; color: var(--ink-2); font-size: 14.5px; }

/* ---------- đáp ứng ---------- */
@media (max-width: 1180px) {
  .map-wrap { grid-template-columns: minmax(0, 1fr) 330px; }
  .concept-layout { grid-template-columns: minmax(0, 1fr); }
  .c-aside { position: static; max-height: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .c-aside .toc-card { display: none; }
}
@media (max-width: 900px) {
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.nav-open #sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 35; }
  #menu-btn { display: inline-flex; }
  #topbar { padding: 0 12px; }
  .search-box kbd { display: none; }
  .page { padding: 22px 16px 80px; }
  h1 { font-size: 1.6rem; } .concept-head .titles h1 { font-size: 1.75rem; }
  .g2, .g3, .cfa-cols, .conn-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vocab-layout { grid-template-columns: minmax(0, 1fr); }
  .vcats { position: static; flex-direction: row; overflow-x: auto; max-height: none; padding-bottom: 6px; }
  .vcats button { white-space: nowrap; }
  .outline { columns: 1; }
  .map-wrap { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(290px, 1fr) 42dvh; min-height: calc(290px + 42dvh); }
  .map-panel { border-left: 0; border-top: 1px solid var(--line); padding: 14px 16px 30px; }
  .map-legend { position: relative; grid-area: 2 / 1; align-self: start; inset: auto; margin: 0 56px 0 12px; max-width: none; max-height: min(165px, 28dvh); overflow: auto; }
  .map-search input { width: 130px; }
  .tb-group select { max-width: 150px; }
  .path-list li { grid-template-columns: 28px minmax(0, 1fr); }
  .path-list .pm { grid-column: 2; flex-direction: row; align-items: center; }
}
@media print {
  #sidebar, #topbar, .c-aside, .prevnext { display: none !important; }
  .concept-layout { display: block; }
  body { background: #fff; }
}
