/* Labeling guide (标注指南): a reading page with small live demos. Colours are tokens with a dark variant. */
:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --sunken: #f3f3f0;
  --line: #e4e4df;
  --ink: #1d1d1f;
  --ink-2: #4a4a4f;
  --ink-3: #85858b;
  --a: #1f6feb;
  --a-soft: #e7effd;
  --b: #e0700f;
  --b-soft: #fdf0e3;
  --p: #5b5bd6;
  --ok: #1f8a4c;
  --ok-soft: #e5f4ea;
  --bad: #c42b1c;
  --bad-soft: #fbe9e7;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618; --surface: #1f1f22; --sunken: #26262a; --line: #34343a;
    --ink: #ececef; --ink-2: #b9b9c0; --ink-3: #8a8a93;
    --a: #5b95ff; --a-soft: #1c2a45; --b: #ff9a45; --b-soft: #3b2715; --p: #8f8ff0;
    --ok: #4cc27f; --ok-soft: #173323; --bad: #ff6b5c; --bad-soft: #3d1c19;
  }
}
/* Parallel content: show the current language only (lang.js sets data-lang on <html>). */
html[data-lang="en"] [data-l="zh"], html[data-lang="zh"] [data-l="en"] { display: none !important; }
html[lang="en"] { --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.8 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--a); }
code, kbd { font-family: var(--mono); font-size: .88em; }
code { background: var(--sunken); padding: 1px 5px; border-radius: 4px; }
kbd { padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 48px; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.toc { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; padding: 32px 0; font-size: 13.5px; line-height: 1.5; }
.toc .brand { font-weight: 700; margin-bottom: 16px; display: flex; gap: 8px; align-items: center; }
.toc .brand i { width: 16px; height: 16px; border-radius: 4px; background: linear-gradient(90deg, var(--a) 0 50%, var(--b) 50% 100%); }
.toc .lang-seg { margin-left: auto; display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--sunken); font-weight: 400; }
.toc .lang-seg button { border: 0; background: transparent; color: var(--ink-3); padding: 1px 8px; border-radius: 6px; font: inherit; font-size: 12px; cursor: pointer; }
.toc .lang-seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); font-weight: 600; }
.gloss { font-size: 13px; margin: 10px 0 0; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 2px 0; }
.toc a { display: block; padding: 3px 10px; border-radius: 6px; color: var(--ink-2); text-decoration: none; border-left: 2px solid transparent; }
.toc a:hover { color: var(--ink); background: var(--sunken); }
.toc a.on { color: var(--ink); border-left-color: var(--ink); background: var(--sunken); font-weight: 600; }
.toc .sub a { padding-left: 22px; font-size: 12.5px; }

main { padding: 40px 0 120px; min-width: 0; }
.prose { max-width: 40em; }
h1 { font-size: 34px; line-height: 1.25; margin: 0 0 12px; letter-spacing: .01em; }
h2 { font-size: 24px; line-height: 1.35; margin: 64px 0 12px; padding-top: 8px; scroll-margin-top: 16px; }
h3 { font-size: 18px; line-height: 1.45; margin: 36px 0 8px; scroll-margin-top: 16px; }
h4 { font-size: 16px; font-weight: 650; margin: 26px 0 6px; color: var(--ink); }
p { margin: 0 0 14px; }
.lead { font-size: 18px; color: var(--ink-2); }
.muted { color: var(--ink-3); }
ul.tight, ol.tight { padding-left: 1.3em; margin: 0 0 14px; }
ol.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 18px; }
ol.steps > li { counter-increment: s; position: relative; padding-left: 40px; margin: 0 0 12px; }
ol.steps > li::before {
  content: counter(s); position: absolute; left: 0; top: 2px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 700; display: grid; place-items: center;
}
.callout { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 14px 18px; margin: 16px 0 20px; }
.callout.key { border-left: 4px solid var(--ink); }
.callout.warn { border-left: 4px solid var(--b); }
.callout b:first-child { display: block; margin-bottom: 2px; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 22px 0; }
.cards a { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-decoration: none; color: var(--ink); }
.cards a:hover { border-color: var(--ink-3); }
.cards b { display: block; font-size: 15px; }
.cards span { font-size: 13px; color: var(--ink-3); line-height: 1.5; display: block; margin-top: 4px; }

table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 1.6; margin: 10px 0 20px; }
th, td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 12.5px; color: var(--ink-3); font-weight: 600; border-bottom-color: var(--ink-3); }
td.nowrap, th.nowrap { white-space: nowrap; }
.tag-name { font-weight: 650; white-space: nowrap; }
[data-tags] td:first-child { white-space: nowrap; }
.kind { display: inline-block; font-size: 11.5px; padding: 0 7px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; }
.kind.problem { background: var(--bad-soft); color: var(--bad); }
.kind.strength { background: var(--ok-soft); color: var(--ok); }
.tablewrap { overflow-x: auto; }

/* demos */
.demo { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); margin: 18px 0 26px; overflow: hidden; }
.demo-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.demo-head b { font-size: 14.5px; }
.demo-head span { font-size: 12.5px; color: var(--ink-3); }
.demo-body { padding: 18px 16px; }
.demo-try { border-top: 1px solid var(--line); padding: 10px 16px 12px; font-size: 13.5px; color: var(--ink-2); background: var(--sunken); }
.demo-try b { color: var(--ink); }
.demo-try ul { margin: 4px 0 0; padding-left: 1.2em; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-bottom: 14px; font-size: 13.5px; color: var(--ink-2); }
.controls label { display: inline-flex; align-items: center; gap: 8px; }
.controls input[type="range"] { width: 160px; }
.controls output { font-family: var(--mono); font-size: 12.5px; color: var(--ink); min-width: 4.5em; }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--sunken); }
.seg button { border: 0; background: transparent; color: var(--ink-2); padding: 4px 10px; border-radius: 6px; font: inherit; font-size: 13px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); font-weight: 600; }
.btn { font: inherit; font-size: 13.5px; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.btn:hover { background: var(--sunken); }
.side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.side-by-side > div > .cap { font-size: 12.5px; color: var(--ink-3); margin-bottom: 6px; }
.readout { font-family: var(--mono); font-size: 13px; color: var(--ink-2); margin-top: 10px; }
.pass { color: var(--ok); font-weight: 650; }
.fail { color: var(--bad); font-weight: 650; }

/* mini pages inside demos always use a fixed light look so they read like web pages */
.mini { background: #fff; color: #1d1d1f; border: 1px solid #e3e3df; border-radius: 10px; padding: 18px; overflow: hidden; font-family: var(--font); }
.mini * { margin: 0; }

/* squint demo */
.squint .mini { transition: filter .2s; min-height: 210px; }
.squint .hero h5 { font-size: 26px; line-height: 1.2; margin-bottom: 8px; }
.squint .hero p { font-size: 13px; color: #555; margin-bottom: 14px; line-height: 1.6; }
.squint .hero .cta { display: inline-block; background: #1f6feb; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.squint .hero .row { display: flex; gap: 8px; margin-top: 16px; }
.squint .hero .row i { flex: 1; height: 40px; border-radius: 8px; background: #eef0f3; }
.squint .flat h5 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.squint .flat p { font-size: 13px; color: #555; margin-bottom: 8px; line-height: 1.6; }
.squint .flat .cta { display: inline-block; color: #1d1d1f; border: 1px solid #ccc; padding: 4px 10px; border-radius: 6px; font-size: 13px; }
.squint .flat .row { display: flex; gap: 8px; margin-top: 10px; }
.squint .flat .row i { flex: 1; height: 40px; border-radius: 8px; background: #d9dce1; }
.squint .flat .row i:nth-child(2) { background: #c8e0ff; }
.squint .flat .row i:nth-child(3) { background: #ffd9b8; }

/* proximity demo */
.prox .mini { font-size: 13.5px; line-height: 1.45; }
.prox .group h6 { font-size: 12px; color: #86868b; font-weight: 600; letter-spacing: .04em; }
.prox .item { padding: 0; }
.prox .item b { display: block; font-size: 14px; }
.prox .item span { color: #666; font-size: 12.5px; }
.prox.even .mini > * + * { margin-top: 14px; }
.prox.even .group > * + * { margin-top: 14px; }
.prox.grouped .mini > * + * { margin-top: 26px; }
.prox.grouped .group > * + * { margin-top: 6px; }
.prox.grouped .group h6 { margin-bottom: 2px; }

/* alignment demo */
.align .mini { position: relative; }
.align .cardrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.align .card { background: #f4f5f7; border-radius: 8px; padding: 12px; font-size: 12.5px; line-height: 1.5; }
.align .card b { display: block; font-size: 14px; margin-bottom: 4px; }
.align .card i { display: block; height: 46px; border-radius: 6px; background: #dde3ea; margin-bottom: 8px; }
.align.off .card:nth-child(1) { padding-left: 16px; }
.align.off .card:nth-child(2) b { margin-left: 6px; }
.align.off .card:nth-child(2) { padding-top: 18px; }
.align.off .card:nth-child(3) i { width: 86%; margin-left: 9px; }
.align.off .title { margin-left: 7px; }
.align .title { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.align .guides { position: absolute; inset: 0; pointer-events: none; display: none; }
.align.show-guides .guides { display: block; }
.align .guides i { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(224, 112, 15, .8); }

/* contrast demo */
.contrast .swatch { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-radius: 10px; overflow: hidden; border: 1px solid #e3e3df; }
.contrast .swatch > div { padding: 16px; }
.contrast .swatch .big { font-size: 24px; font-weight: 700; line-height: 1.3; }
.contrast .swatch .small { font-size: 14px; line-height: 1.6; margin-top: 4px; }

/* line length demo */
.measure .mini { padding: 18px 22px; }
.measure .col { font-size: 16px; line-height: 1.8; margin: 0 auto 0 0; transition: max-width .15s; }

/* CJK demo */
.cjk .mini { font-size: 16px; line-height: 1.8; }
.cjk .fake-italic { font-style: italic; }
.cjk .tight { line-height: 1.35; }

/* palette demo */
.palette .dash { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.palette .tile { border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: #1d1d1f; background: #f4f5f7; }
.palette .tile b { display: block; font-size: 18px; }
.palette .bar { height: 8px; border-radius: 4px; margin-top: 8px; background: #d5d9df; }
.palette .bar i { display: block; height: 100%; border-radius: 4px; }

/* motion demos */
.track { position: relative; height: 34px; margin: 8px 0; border-radius: 17px; background: var(--sunken); }
.track .dot { position: absolute; left: 4px; top: 4px; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); }
.track .lbl { position: absolute; right: 12px; top: 6px; font-size: 12px; color: var(--ink-3); }
.ease-row { display: grid; grid-template-columns: 70px 1fr; gap: 12px; align-items: center; }
.ease-row svg { width: 70px; height: 52px; }
.ease-row svg path { fill: none; stroke: var(--ink); stroke-width: 2; }
.ease-row svg rect { fill: none; stroke: var(--line); }
.panel-demo { position: relative; height: 150px; border-radius: 10px; background: var(--sunken); overflow: hidden; }
.panel-demo .sheet { position: absolute; left: 0; right: 0; bottom: 0; height: 110px; background: var(--surface); border-top: 1px solid var(--line); border-radius: 12px 12px 0 0; transform: translateY(100%); padding: 12px 16px; font-size: 13.5px; }
.panel-demo .sheet.open { transform: translateY(0); }
.stagger { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; min-height: 64px; }
.stagger i { display: block; height: 56px; border-radius: 8px; background: var(--a-soft); border: 1px solid var(--line); opacity: 0; transform: translateY(12px); }
.stagger.in i { opacity: 1; transform: none; transition: opacity .32s cubic-bezier(.2, 0, 0, 1), transform .32s cubic-bezier(.2, 0, 0, 1); }
.morph-stage { position: relative; height: 190px; border-radius: 10px; background: var(--sunken); overflow: hidden; }
.morph-stage .thumb { position: absolute; left: 18px; top: 18px; width: 120px; height: 80px; border-radius: 10px; background: var(--b); color: #fff; font-size: 13px; padding: 10px; cursor: pointer; border: 0; text-align: left; }
.morph-stage .detail { position: absolute; left: 18px; top: 18px; right: 18px; bottom: 18px; border-radius: 12px; background: var(--b); color: #fff; padding: 16px; transform-origin: 0 0; font-size: 14px; display: none; }
.read-demo .mini { position: relative; font-size: 15px; line-height: 1.8; }
.read-demo .badge { position: absolute; right: 16px; top: 14px; width: 34px; height: 34px; border-radius: 50%; background: #e0700f; }
.read-demo.loop .badge { animation: bounce .7s cubic-bezier(.3, 0, .3, 1) infinite alternate; }
@keyframes bounce { to { transform: translateY(18px) scale(1.15); } }

/* interaction demos */
.btn-row { display: flex; gap: 14px; flex-wrap: wrap; }
.btn-row .col { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; font-size: 12.5px; color: var(--ink-3); }
.mini .b-none, .mini .b-good, .mini .b-over { font: 600 14px var(--font); padding: 9px 18px; border-radius: 9px; border: 0; background: #1d1d1f; color: #fff; cursor: default; }
.mini .b-none:focus { outline: none; }
.mini .b-good { cursor: pointer; transition: background .12s, transform .1s cubic-bezier(.2, 0, 0, 1), box-shadow .12s; }
.mini .b-good:hover { background: #3a3a3e; }
.mini .b-good:active { transform: scale(.97); background: #000; }
.mini .b-good:focus-visible { outline: 2px solid #1f6feb; outline-offset: 2px; }
.mini .b-over { cursor: pointer; transition: transform .6s cubic-bezier(.3, 1.8, .4, 1); }
.mini .b-over:hover { transform: scale(1.18) rotate(-4deg); }
.mini .b-over:active { transform: scale(.7) rotate(8deg); }
.dm .bars { display: flex; align-items: flex-end; gap: 6px; height: 90px; margin-top: 10px; }
.dm .bars i { flex: 1; background: #1f6feb; border-radius: 4px 4px 0 0; }

details.research { border: 1px dashed var(--line); border-radius: 12px; padding: 10px 16px; margin: 20px 0; }
details.research summary { cursor: pointer; font-weight: 650; }
.glossary { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14.5px; }
.glossary dt { font-weight: 650; white-space: nowrap; }
.glossary dd { margin: 0; color: var(--ink-2); }
/* English terms and questions are longer: let them wrap in a bounded first column. */
html[lang="en"] .glossary { grid-template-columns: minmax(8em, 15em) 1fr; }
html[lang="en"] .glossary dt { white-space: normal; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 0; padding: 0 16px; }
  .toc { position: static; max-height: none; padding: 20px 0 0; }
  .toc ol { display: none; }
  .side-by-side { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  h1 { font-size: 28px; }
  .controls input[type="range"] { width: 120px; }
  .align .cardrow, .palette .dash { grid-template-columns: 1fr 1fr; }
  html[lang] .glossary { grid-template-columns: 1fr; gap: 2px; }
  .glossary dt { white-space: normal; }
  .glossary dd { margin-bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .read-demo.loop .badge { animation: none; }
}
