/* cw-system v1 — shared by chasewang.me and cbti.club.
   Byte-identical in both repositories (scripts/check-shared.mjs). One writer: chasewang-me.
   Layers: fonts → tokens → base → layout → components → reduced motion.
   Guizang Swiss: paper, ink, one accent (IKB). Mono is for metadata only. */

/* ── Fonts: self-hosted, same origin, no third-party requests (R-deep T2) ── */
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-wght.v5.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Same file. Leaves ‘ ’ “ ” — … to the Chinese system font inside [lang|=zh] text. */
@font-face {
  font-family: "Inter Han-safe";
  src: url("/assets/fonts/inter-latin-wght.v5.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-2013, U+2015-2017, U+201A-201B, U+201E-2025, U+2027-206F,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-latin-400.v5.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Chinese double quotes “ ” as full-width glyphs. PingFang SC draws them proportional (0.55em, measured);
   Hiragino Sans GB (macOS) draws them 1em. Single quotes stay out so English apostrophes do not widen. */
@font-face {
  font-family: "CJK Quotes";
  src: local("Hiragino Sans GB W3"), local("HiraginoSansGB-W3");
  font-weight: 100 500;
  unicode-range: U+201C-201D;
}
@font-face {
  font-family: "CJK Quotes";
  src: local("Hiragino Sans GB W6"), local("HiraginoSansGB-W6");
  font-weight: 600 900;
  unicode-range: U+201C-201D;
}
/* Metric-matched local fallback while Inter loads (values computed from the Inter v5 and Arial files). */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial"), local("ArialMT");
  font-weight: 100 500;
  size-adjust: 107.57%;
  ascent-override: 90.06%;
  descent-override: 22.42%;
  line-gap-override: 0%;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial Bold"), local("Arial-BoldMT");
  font-weight: 600 900;
  size-adjust: 107.57%;
  ascent-override: 90.06%;
  descent-override: 22.42%;
  line-gap-override: 0%;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter Fallback Han-safe";
  src: local("Arial"), local("ArialMT");
  font-weight: 100 500;
  size-adjust: 107.57%;
  ascent-override: 90.06%;
  descent-override: 22.42%;
  line-gap-override: 0%;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-2013, U+2015-2017, U+201A-201B, U+201E-2025, U+2027-206F,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter Fallback Han-safe";
  src: local("Arial Bold"), local("Arial-BoldMT");
  font-weight: 600 900;
  size-adjust: 107.57%;
  ascent-override: 90.06%;
  descent-override: 22.42%;
  line-gap-override: 0%;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-2013, U+2015-2017, U+201A-201B, U+201E-2025, U+2027-206F,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Tokens ── */
:root {
  /* Palette (Guizang Swiss). gray-700 is the one addition: paragraph-length secondary text. */
  --cw-paper: #fafaf8;
  --cw-ink: #0a0a0a;
  --cw-gray-100: #f0f0ee;
  --cw-gray-300: #d4d4d2;
  --cw-gray-500: #737373;
  --cw-gray-700: #3d3d3b;
  --cw-hairline: rgba(10, 10, 10, 0.14);
  --cw-ikb: #002fa7;

  /* Semantic roles. Light theme only in v1; a dark theme redefines these, not the palette. */
  --surface: var(--cw-paper);
  --surface-raised: var(--cw-gray-100);
  --text: var(--cw-ink);            /* 18.94:1 on paper, 17.35:1 on raised */
  --text-2: var(--cw-gray-700);     /* 10.42:1 on paper, 9.54:1 on raised */
  --text-muted: var(--cw-gray-500); /* 4.54:1 on paper only (4.16:1 on raised) — one-line metadata; never on raised */
  --line: var(--cw-hairline);
  --line-strong: var(--cw-ink);
  --line-soft: var(--cw-gray-300);
  --accent: var(--cw-ikb);          /* 10.23:1 on paper, 9.37:1 on raised */
  --on-accent: var(--cw-paper);     /* 10.23:1 on accent */
  --focus: var(--cw-ikb);
  --selection-bg: var(--cw-ikb);
  --selection-text: var(--cw-paper);

  /* Product data layer: categorical series. Products override these four (cbti: quadrants). */
  --data-1: var(--cw-ink);
  --data-2: var(--cw-ikb);
  --data-3: var(--cw-gray-500);
  --data-4: var(--cw-gray-300);

  /* Type */
  --font-cjk: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "Noto Sans SC";
  --font-sans: "Inter", "Inter Fallback", "Helvetica Neue", Helvetica, Arial, var(--font-cjk), sans-serif;
  --font-sans-zh: "Inter Han-safe", "Inter Fallback Han-safe", "CJK Quotes", var(--font-cjk), "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, var(--font-cjk), monospace;

  --fs-micro: 0.75rem;                                      /* 12 */
  --fs-meta: 0.8125rem;                                     /* 13 */
  --fs-small: 0.9375rem;                                    /* 15 */
  --fs-body: 1.0625rem;                                     /* 17 */
  --fs-h3: 1.1875rem;                                       /* 19 */
  --fs-lede: clamp(1.25rem, 1.05rem + 0.8vw, 1.625rem);     /* 20 → 26 */
  --fs-h2: clamp(1.375rem, 1.2rem + 0.6vw, 1.75rem);        /* 22 → 28 */
  --fs-h1: clamp(2.25rem, 1.6rem + 2.6vw, 3.5rem);          /* 36 → 56 */
  --fs-display: clamp(2.875rem, 1.9rem + 4.2vw, 5.25rem);   /* 46 → 84 */

  --lh-display: 0.96;
  --lh-heading: 1.12;
  --lh-snug: 1.3;
  --lh-body: 1.6;
  --lh-zh: 1.8;

  --tr-display: -0.04em;
  --tr-heading: -0.025em;
  --tr-title: -0.012em;

  /* Space: 4px base */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;
  --sp-9: 6rem;
  --sp-10: 8rem;
  --section-gap: clamp(3.5rem, 2.4rem + 4vw, 6.5rem);

  /* Layout: 12 columns */
  --page-max: 77.5rem;                       /* 1240 */
  --gutter: clamp(1rem, 0.4rem + 3vw, 2.5rem); /* 16 → 40 */
  --col-gap: clamp(1rem, 0.6rem + 1.2vw, 1.5rem);
  --measure: 66ch;
  --measure-zh: 40em;

  /* Shape, motion */
  --radius: 0;
  --bw: 1px;
  --dur-1: 120ms;
  --dur-2: 200ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ── Base ── */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  font-size: 100%;
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--surface);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-padding-top: var(--sp-6);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-body);
  overflow-wrap: break-word;
}

main { flex: 1 0 auto; display: block; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: var(--lh-heading); }
p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
time, .cw-num { font-variant-numeric: tabular-nums; }
abbr[title] { text-decoration: none; }
::selection { background: var(--selection-bg); color: var(--selection-text); }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--line);
  text-underline-offset: 0.2em;
  transition: color var(--dur-1) var(--ease), text-decoration-color var(--dur-1) var(--ease);
}
a:hover { color: var(--accent); text-decoration-color: currentColor; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: var(--radius);
}
:where(a, button, summary):focus:not(:focus-visible) { outline: none; }

/* Font stacks switch only at explicit lang boundaries (the lang attribute) and are inherited from there,
   so a Chinese page cannot push its stack onto English content or onto mono metadata below it.
   Chinese: system CJK fonts, 400/600 only, no letter-spacing, no faux italics (R-deep T2 D4–D7). */
:where(html, [lang|="en"]) { font-family: var(--font-sans); }
:where([lang|="zh"]) {
  font-family: var(--font-sans-zh);
  letter-spacing: 0;
  text-autospace: normal;
}
/* Mono metadata stays mono all the way down, including interface strings that carry their own lang. */
:where(.cw-mono, .cw-kicker, .cw-seg button, .cw-section-aside, .cw-subhead, .cw-row-date, .cw-row-tags,
  .cw-row-chans, .cw-badge, .cw-chan, .cw-kv dt, .cw-footer-label, .cw-footer-base) [lang] { font-family: inherit; }
:where(p, li, dd, blockquote, figcaption, td, th):lang(zh) { line-height: var(--lh-zh); }
:where(em, i, cite, blockquote, dfn):lang(zh) { font-style: normal; }
:is(h1, h2, h3, h4, .cw-display, .cw-title, .cw-row-title, .cw-article-title):lang(zh) { letter-spacing: 0; }

/* Interface language (chasewang.me EN/中 control). Content keeps its own lang. */
html:not([data-lang="zh"]) .i-zh,
html[data-lang="zh"] .i-en { display: none !important; }

.cw-mono { font-family: var(--font-mono); font-weight: 400; letter-spacing: 0; }
.cw-muted { color: var(--text-muted); }
.cw-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.cw-clamp-2,
.cw-clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cw-clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.cw-clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }

/* ── Layout ── */
.cw-container {
  width: 100%;
  max-width: calc(var(--page-max) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.cw-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
}
.cw-stack > * + * { margin-top: var(--stack, var(--sp-4)); }

/* ── Skip link ── */
.cw-skip {
  position: absolute;
  left: var(--gutter);
  top: var(--sp-3);
  z-index: 100;
  padding: var(--sp-2) var(--sp-3);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--fs-small);
  font-weight: 500;
  text-decoration: none;
}
.cw-skip:not(:focus) {
  width: 1px; height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Brand: IKB square + wordmark (the wordmark text differs per site) ── */
.cw-mark {
  display: inline-block;
  flex: none;
  width: 0.72em;
  height: 0.72em;
  background: var(--accent);
}
.cw-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: var(--tr-title);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}
.cw-brand:hover { color: var(--text); }
.cw-brand:hover .cw-wordmark { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.25em; }

/* ── Site header ── */
.cw-header { border-bottom: var(--bw) solid var(--line); }
.cw-header-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "brand nav tools";
  align-items: center;
  column-gap: var(--sp-6);
  min-height: 4rem;
}
.cw-header .cw-brand { grid-area: brand; }
.cw-nav { grid-area: nav; justify-self: end; }
.cw-header-tools {
  grid-area: tools;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}
.cw-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-6);
  margin: 0;
  padding: 0;
  list-style: none;
}
.cw-nav a {
  display: inline-block;
  padding-block: var(--sp-2);
  color: var(--text);
  font-size: var(--fs-small);
  font-weight: 500;
  text-decoration: none;
}
.cw-nav a:lang(zh) { font-weight: 400; }
.cw-nav a:hover { color: var(--accent); }
.cw-nav a[aria-current="page"],
.cw-nav a[aria-current="true"] {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.45em;
}
.cw-header-link {
  color: var(--text);
  font-size: var(--fs-small);
  text-decoration: none;
  white-space: nowrap;
}
.cw-header-link:hover { color: var(--accent); }

@media (max-width: 40rem) {
  .cw-header-inner {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand tools" "nav nav";
    column-gap: var(--sp-4);
    row-gap: 0;
    padding-top: var(--sp-3);
    padding-bottom: var(--sp-1);
    min-height: 0;
  }
  .cw-nav { justify-self: start; }
  .cw-nav ul { gap: 0 var(--sp-5); }
  .cw-nav a { padding-block: var(--sp-3); }
}

/* ── Segmented control (language, filters). State = fill + weight, not color alone. ── */
.cw-seg {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0;
  border: var(--bw) solid var(--line-strong);
}
.cw-seg button {
  min-height: 2.25rem;
  margin: 0;
  padding: 0 var(--sp-3);
  border: 0;
  border-left: var(--bw) solid var(--line-strong);
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  line-height: 1;
  transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.cw-seg button:first-child { border-left: 0; }
.cw-seg button:hover { background: var(--surface-raised); }
.cw-seg button[aria-pressed="true"] { background: var(--text); color: var(--surface); }
.cw-seg button:focus-visible { outline-offset: 2px; position: relative; z-index: 1; }

/* Quiet variant for the header language control: "EN / 中". */
.cw-seg--quiet { border: 0; gap: var(--sp-1); }
.cw-seg--quiet button {
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0 var(--sp-1);
  border: 0;
  color: var(--text-muted);
  text-decoration: none;
}
.cw-seg--quiet button:hover { background: transparent; color: var(--text); }
.cw-seg--quiet button[aria-pressed="true"] {
  background: transparent;
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.45em;
}
.cw-seg--quiet .cw-seg-sep { align-self: center; color: var(--line-soft); font-family: var(--font-mono); font-size: var(--fs-meta); }

/* ── Page head (index pages) ── */
.cw-pagehead {
  padding-top: clamp(3rem, 2rem + 4vw, 6rem);
  padding-bottom: clamp(2rem, 1.5rem + 2vw, 3.5rem);
}
.cw-kicker {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--text-muted);
}
.cw-kicker a { color: inherit; }
.cw-kicker a:hover { color: var(--accent); }
.cw-display {
  font-size: var(--fs-display);
  font-weight: 600;
  line-height: var(--lh-display);
  letter-spacing: var(--tr-display);
}
.cw-title {
  font-size: var(--fs-h1);
  font-weight: 600;
  line-height: var(--lh-heading);
  letter-spacing: var(--tr-heading);
  text-wrap: balance;
}
.cw-lede {
  font-size: var(--fs-lede);
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text);
  max-width: 34em;
  text-wrap: pretty;
}
.cw-lede:lang(zh) { line-height: 1.6; letter-spacing: 0; }
.cw-body-copy {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-2);
  max-width: var(--measure);
  text-wrap: pretty;
}
.cw-body-copy:lang(zh) { line-height: var(--lh-zh); max-width: var(--measure-zh); }

/* ── Section: strong rule + 12-column head aligned with index rows ── */
.cw-section { margin-top: var(--section-gap); }
.cw-section-head {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  align-items: baseline;
  padding-top: var(--sp-4);
  padding-bottom: var(--sp-5);
  border-top: var(--bw) solid var(--line-strong);
}
.cw-section-title {
  grid-column: 1 / span 2;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: var(--tr-heading);
}
.cw-section-title a { color: inherit; text-decoration: none; }
.cw-section-title a:hover { color: var(--accent); }
.cw-section-desc {
  grid-column: 3 / span 7;
  color: var(--text-2);
  font-size: var(--fs-small);
  line-height: 1.5;
  max-width: 44em;
  text-wrap: pretty;
}
.cw-section-desc:lang(zh) { line-height: 1.7; }
.cw-section-aside {
  grid-column: 10 / span 3;
  justify-self: end;
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  color: var(--text-muted);
  text-align: right;
}
.cw-section-aside a { color: var(--accent); text-decoration-color: currentColor; }
.cw-section-aside a:hover { color: var(--text); }
.cw-subhead {
  margin-top: var(--sp-6);
  padding-block: var(--sp-3);
  border-top: var(--bw) solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  font-weight: 400;
  color: var(--text-muted);
}

/* ── Index rows: date | title + dek | tags / channels ── */
.cw-index { margin: 0; padding: 0; list-style: none; }
.cw-row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: auto 1fr;
  column-gap: var(--col-gap);
  padding-block: var(--sp-5);
  border-top: var(--bw) solid var(--line);
}
.cw-row:first-child { border-top-color: transparent; }
.cw-section-head + .cw-index > .cw-row:first-child { border-top-color: var(--line); }
.cw-row-date {
  grid-column: 1 / span 2;
  grid-row: 1 / span 2;
  padding-top: 0.2em;
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  line-height: 1.4;
  color: var(--text-muted);
  white-space: nowrap;
}
.cw-row-main { grid-column: 3 / span 7; grid-row: 1 / span 2; min-width: 0; }
.cw-row-tags,
.cw-row-chans {
  grid-column: 10 / span 3;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-1) var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  line-height: 1.5;
}
.cw-row-tags { grid-row: 1; color: var(--text-2); }
.cw-row-chans { grid-row: 2; align-self: start; margin-top: var(--sp-1); column-gap: var(--sp-4); }
.cw-row-title {
  font-size: var(--fs-h3);
  font-weight: 600;
  line-height: var(--lh-snug);
  letter-spacing: var(--tr-title);
  text-wrap: pretty;
}
.cw-row-title:lang(zh) { font-size: 1.125rem; line-height: 1.5; }
.cw-row-title a { color: var(--text); text-decoration: none; }
.cw-row-title a:hover { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.cw-row-sub { font-weight: 400; color: var(--text-2); }
.cw-row-dek {
  margin-top: var(--sp-2);
  max-width: 40em;
  color: var(--text-2);
  font-size: var(--fs-small);
  line-height: 1.55;
  text-wrap: pretty;
}
.cw-row-dek:lang(zh) { line-height: 1.75; }
.cw-row--compact { padding-block: var(--sp-4); }

@media (max-width: 56rem) {
  .cw-section-title { grid-column: 1 / span 3; }
  .cw-section-desc { grid-column: 4 / span 6; }
  .cw-row-date { grid-column: 1 / span 3; }
  .cw-row-main { grid-column: 4 / span 6; }
  .cw-row-tags, .cw-row-chans { grid-column: 10 / span 3; }
}
@media (max-width: 40rem) {
  .cw-section-head { grid-template-columns: 1fr auto; row-gap: var(--sp-2); }
  .cw-section-title { grid-column: 1; font-size: 1.25rem; }
  .cw-section-aside { grid-column: 2; grid-row: 1; }
  .cw-section-desc { grid-column: 1 / -1; }
  .cw-row {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto;
    column-gap: var(--sp-3);
    row-gap: var(--sp-2);
    padding-block: var(--sp-4) var(--sp-5);
  }
  .cw-row-date { grid-column: 1; grid-row: 1; padding-top: 0; }
  .cw-row-tags { grid-column: 2; grid-row: 1; color: var(--text-muted); }
  .cw-row-main { grid-column: 1 / -1; grid-row: 2; }
  .cw-row-chans { grid-column: 1 / -1; grid-row: 3; margin-top: 0; }
}

/* ── Badges and channel links (mono metadata) ── */
.cw-badge {
  display: inline-block;
  padding: 0 0.4em;
  border: var(--bw) solid var(--line-soft);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  line-height: 1.6;
  white-space: nowrap;
}
.cw-badge--solid { border-color: var(--text); background: var(--text); color: var(--surface); }
.cw-badge--accent { border-color: var(--accent); color: var(--accent); }
.cw-sep { color: var(--line-soft); }
.cw-tag + .cw-tag::before {
  content: "·";
  margin-right: var(--sp-3);
  color: var(--text-muted);
}
.cw-chan {
  display: inline-block;
  padding-block: 0.25rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}
.cw-chan:hover { color: var(--text); text-decoration: underline; }
.cw-chan-lang { color: var(--text-muted); }
.cw-chan:hover .cw-chan-lang { color: inherit; }

/* ── Links and buttons ── */
.cw-link {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: currentColor;
  text-underline-offset: 0.25em;
}
.cw-link:hover { color: var(--text); }
.cw-arrow { display: inline-block; margin-left: 0.2em; font-family: var(--font-mono); font-weight: 400; }
.cw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 2.75rem;
  padding: 0 var(--sp-5);
  border: var(--bw) solid var(--text);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.cw-btn:hover { background: var(--text); color: var(--surface); }
.cw-btn--primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.cw-btn--primary:hover { border-color: var(--text); background: var(--text); color: var(--surface); }
.cw-btn--quiet { border-color: transparent; padding-inline: var(--sp-2); }
.cw-btn--quiet:hover { background: transparent; color: var(--accent); }
.cw-btn:active { transform: translateY(1px); }
.cw-btn:disabled,
.cw-btn[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; transform: none; }
.cw-btn:disabled:hover,
.cw-btn[aria-disabled="true"]:hover { background: transparent; color: var(--text); }
.cw-btn--primary:disabled:hover,
.cw-btn--primary[aria-disabled="true"]:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ── Card: only for a self-contained object (a product, a callout). Border, no shadow. ── */
.cw-card {
  padding: var(--sp-5);
  border: var(--bw) solid var(--line);
  background: var(--surface);
}
a.cw-card { display: block; color: inherit; text-decoration: none; transition: border-color var(--dur-1) var(--ease); }
a.cw-card:hover { border-color: var(--text); color: inherit; }

/* ── Key–value list (facts, article details) ── */
.cw-kv { display: grid; gap: var(--sp-3); margin: 0; }
.cw-kv > div { display: grid; gap: 0.1rem; }
.cw-kv dt { font-family: var(--font-mono); font-size: var(--fs-micro); line-height: 1.5; color: var(--text-muted); }
.cw-kv dd { margin: 0; font-size: var(--fs-small); line-height: 1.5; color: var(--text); }
.cw-kv--inline > div { grid-template-columns: minmax(6rem, 1fr) 3fr; gap: var(--sp-4); align-items: baseline; }

/* ── Meter and progress: product data bars (fill uses a --data-* series) ── */
.cw-meter {
  position: relative;
  display: block;
  height: 0.375rem;
  background: var(--surface-raised);
  overflow: hidden;
}
.cw-meter > span {
  display: block;
  height: 100%;
  width: calc(var(--value, 0) * 100%);
  background: var(--meter-color, var(--accent));
}
progress.cw-progress {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 0.25rem;
  border: 0;
  background: var(--surface-raised);
  color: var(--accent);
}
progress.cw-progress::-webkit-progress-bar { background: var(--surface-raised); }
progress.cw-progress::-webkit-progress-value { background: var(--accent); transition: width var(--dur-2) var(--ease); }
progress.cw-progress::-moz-progress-bar { background: var(--accent); }

/* ── Footer ── */
.cw-footer {
  margin-top: var(--section-gap);
  border-top: var(--bw) solid var(--line-strong);
  font-size: var(--fs-small);
}
.cw-footer-inner {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  row-gap: var(--sp-5);
  padding-top: var(--sp-6);
  padding-bottom: var(--sp-7);
}
.cw-footer-brand { grid-column: 1 / span 4; }
.cw-footer-brand p { margin-top: var(--sp-3); color: var(--text-2); max-width: 26em; }
.cw-footer-nav { grid-column: 5 / span 3; }
.cw-footer-links { grid-column: 8 / span 5; }
.cw-footer-nav ul,
.cw-footer-links ul { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--sp-2); }
.cw-footer-links ul { grid-template-columns: repeat(2, minmax(0, max-content)); column-gap: var(--sp-6); }
.cw-footer a { color: var(--text); text-decoration: none; }
.cw-footer a:hover { color: var(--accent); text-decoration: underline; }
.cw-footer-label {
  margin-bottom: var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--text-muted);
}
.cw-footer-base {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-5);
  padding-top: var(--sp-4);
  border-top: var(--bw) solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--text-muted);
}
.cw-footer-base a { color: var(--text-muted); text-decoration: underline; text-decoration-color: var(--line); }
@media (max-width: 56rem) {
  .cw-footer-brand { grid-column: 1 / -1; }
  .cw-footer-nav { grid-column: 1 / span 5; }
  .cw-footer-links { grid-column: 6 / -1; }
}
@media (max-width: 40rem) {
  .cw-footer-nav, .cw-footer-links { grid-column: 1 / -1; }
  .cw-footer-links ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── 404 ── */
.cw-404 { padding-top: clamp(3rem, 2rem + 6vw, 8rem); }
.cw-404 .cw-title { margin-top: var(--sp-3); max-width: 16em; }
.cw-404 .cw-body-copy { margin-top: var(--sp-4); }
.cw-404-links { margin: var(--sp-6) 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: var(--sp-3); }

/* ── Motion: state feedback only ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .cw-btn:active { transform: none; }
}
