/* Nenkin Việt: one calm stylesheet. System fonts with full Vietnamese diacritics, light + dark, mobile first. */
:root {
  --bg: #fbf8f3; --panel: #ffffff; --ink: #1c2322; --muted: #56605e; --line: #e5dfd4; --soft: #f3eee5;
  --brand: #1f6f6b; --brand-ink: #155552; --accent: #c2622d; --link: #11618f;
  --ok: #2f7d4f; --ok-bg: #e7f3ec; --warn-bg: #fbf0dc; --warn: #8a5a08; --info-bg: #e6f0f0;
  --radius: 12px; --max: 44rem;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14191a; --panel: #1b2223; --ink: #e9e6e0; --muted: #a6aeac; --line: #2d3637; --soft: #202829;
    --brand: #5cbcb5; --brand-ink: #8fd6d0; --accent: #ef9a62; --link: #7cc3ef;
    --ok: #5fbf86; --ok-bg: #1d2e24; --warn-bg: #2f2919; --warn: #e6bf6a; --info-bg: #1b2b2c;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  /* system-ui / Segoe UI / Roboto / SF all carry the full Vietnamese range */
  font: 17px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.3; }
h1 { font-size: clamp(1.6rem, 6vw, 2.3rem); margin: .2em 0 .45em; }
h2 { font-size: 1.3rem; margin: 2em 0 .5em; }
h3 { font-size: 1.07rem; margin: 1.5em 0 .4em; }
p, ul, ol, table { margin: 0 0 1em; }
li { margin-bottom: .3em; }
small, .muted { color: var(--muted); }
.small { font-size: .88rem; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--panel); padding: .5rem 1rem; z-index: 9; }

/* layout */
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 1.05rem; }
header.site { border-bottom: 1px solid var(--line); background: var(--panel); }
header.site .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1.1rem; padding-top: .65rem; padding-bottom: .65rem; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: .5rem; margin-right: auto; font-size: 1.05rem; }
.brand svg { width: 30px; height: 30px; }
nav.top { display: flex; flex-wrap: wrap; gap: .1rem .9rem; }
nav.top a { color: var(--ink); text-decoration: none; font-size: .93rem; padding: .25rem 0; }
nav.top a:hover, nav.top a[aria-current] { color: var(--brand-ink); text-decoration: underline; }
main { padding: 1rem 0 3rem; }
footer.site { border-top: 1px solid var(--line); background: var(--panel); font-size: .9rem; color: var(--muted); padding: 1.5rem 0 2.4rem; }
footer.site a { color: var(--muted); }
.crumbs { font-size: .84rem; color: var(--muted); margin-top: .6rem; }
.crumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.crumbs li { margin: 0; }
.crumbs li + li::before { content: "›"; margin-right: .3rem; }
.crumbs a { color: var(--muted); }

/* blocks */
.lede { font-size: 1.1rem; color: var(--muted); }
.answer { border-left: 5px solid var(--brand); background: var(--info-bg); padding: .85rem 1.05rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 1rem 0 1.4rem; }
.answer > strong:first-child { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .15rem; }
.answer p:last-child { margin-bottom: 0; }
.rule { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem .4rem; margin: 1.3rem 0; }
.rule h2, .rule h3 { margin-top: .2rem; }
.checked { font-size: .84rem; color: var(--muted); }
.box { background: var(--soft); border-radius: var(--radius); padding: .9rem 1.1rem; margin: 1.2rem 0; }
.box h2, .box h3 { margin-top: .2rem; }
.warn { background: var(--warn-bg); border-radius: var(--radius); padding: .8rem 1rem; }
.warn strong { color: var(--warn); }
.notjps { font-size: .9rem; border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem; background: var(--panel); }
footer .notjps { background: transparent; }
.grid { display: grid; gap: .9rem; }
@media (min-width: 640px) { .grid.two { grid-template-columns: 1fr 1fr; } }
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.05rem; color: var(--ink); text-decoration: none; }
a.card:hover { border-color: var(--brand); }
.card h3 { margin: 0 0 .25rem; color: var(--brand-ink); font-size: 1.02rem; }
.card p { margin: 0; color: var(--muted); font-size: .94rem; }
ol.steps { counter-reset: s; list-style: none; padding: 0; }
ol.steps > li { counter-increment: s; position: relative; padding: 0 0 .9rem 2.6rem; margin: 0; }
ol.steps > li::before { content: counter(s); position: absolute; left: 0; top: .05rem; width: 1.85rem; height: 1.85rem; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: .95rem; }
@media (prefers-color-scheme: dark) { ol.steps > li::before { color: #10201f; } }
ul.check { list-style: none; padding: 0; }
ul.check li { padding-left: 1.7rem; position: relative; }
ul.check li::before { content: ""; position: absolute; left: 0; top: .3rem; width: 1.05rem; height: 1.05rem; border: 2px solid var(--brand); border-radius: 4px; }
.sources { font-size: .88rem; padding-left: 1.1rem; }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: .05rem .45rem; border-radius: 99px; vertical-align: 2px; background: var(--ok-bg); color: var(--ok); white-space: nowrap; }
.tag.est { background: var(--warn-bg); color: var(--warn); }

/* tables */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 1.1rem; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; background: var(--panel); }
caption { text-align: left; font-size: .86rem; color: var(--muted); padding: 0 0 .4rem; }
th, td { text-align: left; vertical-align: top; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
thead th { font-size: .8rem; color: var(--muted); font-weight: 600; }
th[scope=row] { font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.examples td small { color: var(--muted); }

/* diagrams (own drawings) */
figure { margin: 1.3rem 0; }
figcaption { font-size: .86rem; color: var(--muted); margin-top: .4rem; }
.diagram { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; }
.diagram svg { width: 100%; display: block; }
.diagram text { font: 13px system-ui, "Segoe UI", Roboto, sans-serif; fill: var(--ink); }
.diagram text.h { font-weight: 700; font-size: 14px; }
.diagram .box2 { fill: var(--soft); stroke: var(--line); stroke-width: 1.5; }
.diagram .num { fill: var(--brand); } .diagram .numt { fill: #fff; font-weight: 700; }
.diagram .disc { fill: var(--info-bg); }
.diagram .stroke { stroke: var(--brand); fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.diagram .flow { stroke: var(--accent); stroke-width: 3; stroke-dasharray: 5 4; }

/* tools */
form.calc { display: grid; gap: .85rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.05rem; }
@media (min-width: 600px) { form.calc { grid-template-columns: 1fr 1fr; } form.calc .full { grid-column: 1 / -1; } }
label { font-weight: 600; font-size: .92rem; display: block; margin-bottom: .25rem; }
select, input[type=number], input[type=date] { width: 100%; font: inherit; padding: .55rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); min-height: 2.75rem; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; font-size: .92rem; margin-bottom: .25rem; padding: 0; }
.seg { display: flex; gap: .4rem; flex-wrap: wrap; }
.seg label { font-weight: 500; border: 1px solid var(--line); border-radius: 8px; padding: .45rem .7rem; margin: 0; cursor: pointer; background: var(--bg); }
.seg input { accent-color: var(--brand); margin-right: .3rem; }
.hint { font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.result { margin-top: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.05rem; }
.result[hidden] { display: none; }
.big { font-size: 1.9rem; font-weight: 700; color: var(--brand-ink); line-height: 1.15; font-variant-numeric: tabular-nums; }
.working { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85rem; background: var(--soft); padding: .7rem .85rem; border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.btn { display: inline-block; background: var(--brand); color: #fff; border-radius: 9px; padding: .6rem 1.05rem; text-decoration: none; font-weight: 600; }
.btn:hover { background: var(--brand-ink); color: #fff; }
@media (prefers-color-scheme: dark) { .btn, .btn:hover { color: #10201f; } }
.disclosure[hidden] { display: none; }
.disclosure { font-size: .88rem; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem 1rem; margin: 1rem 0; }
details { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .65rem .95rem; margin: .55rem 0; }
summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: .4rem; }
details p:last-child { margin-bottom: 0; }
.hero { padding: .8rem 0 .2rem; }
.hero h1 { max-width: 24ch; }
.hero .art { border-radius: var(--radius); background: var(--info-bg); aspect-ratio: 16 / 7; display: grid; place-items: center; color: var(--muted); font-size: .85rem; margin: .6rem 0 1rem; }
