/* cw-system v1 — reading template (both sites). Load after cw.css.
   Structure: .cw-article > .cw-article-head + .cw-article-layout (.cw-article-rail + .cw-prose) + .cw-article-foot.
   .cw-prose styles exactly the element set the x-auto adapter emits:
   p strong em del a pre/code table figure/figcaption h2–h4 hr blockquote ul/ol. */

.cw-article-head {
  padding-top: clamp(2.5rem, 1.6rem + 4vw, 5.5rem);
  padding-bottom: clamp(2rem, 1.4rem + 2vw, 3rem);
}
.cw-article-head > * + * { margin-top: var(--sp-4); }
.cw-article-title {
  max-width: 22em;
  font-size: var(--fs-h1);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: var(--tr-heading);
  text-wrap: balance;
}
.cw-article-title:lang(zh) { max-width: 20em; line-height: 1.3; }
.cw-article-dek {
  max-width: 36em;
  font-size: var(--fs-lede);
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text-2);
  text-wrap: pretty;
}
.cw-article-dek:lang(zh) { line-height: 1.6; letter-spacing: 0; }
.cw-byline { color: var(--text); font-size: var(--fs-small); font-weight: 500; }
.cw-byline:lang(zh) { font-weight: 400; }

/* Rail (details) + text column on the 12-column grid; stacked on narrow screens. */
.cw-article-layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  border-top: var(--bw) solid var(--line-strong);
  padding-top: var(--sp-6);
}
.cw-article-rail { grid-column: 1 / span 3; align-self: start; }
.cw-article-rail > * + * { margin-top: var(--sp-5); }
.cw-article-rail .cw-chanlist { display: grid; gap: var(--sp-1); margin: 0; padding: 0; list-style: none; }
.cw-article-body { grid-column: 4 / span 8; min-width: 0; }
.cw-article-foot { margin-top: var(--sp-8); }
.cw-article-foot-inner {
  display: grid;
  gap: var(--sp-3);
  padding-top: var(--sp-5);
  border-top: var(--bw) solid var(--line);
  color: var(--text-2);
  font-size: var(--fs-small);
}
@media (min-width: 64rem) {
  .cw-article-rail { position: sticky; top: var(--sp-6); }
}
@media (max-width: 56rem) {
  .cw-article-layout { display: block; padding-top: var(--sp-4); }
  .cw-article-rail {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3) var(--sp-6);
    padding-bottom: var(--sp-5);
    margin-bottom: var(--sp-6);
    border-bottom: var(--bw) solid var(--line);
  }
  .cw-article-rail > * + * { margin-top: 0; }
  .cw-article-rail .cw-kv { grid-auto-flow: column; grid-auto-columns: max-content; column-gap: var(--sp-6); }
}
@media (max-width: 40rem) {
  .cw-article-rail .cw-kv { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Actions under the body: original channel(s), more writing. */
.cw-sources { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin: var(--sp-7) 0 0; padding: 0; list-style: none; }

/* ── Prose ── */
.cw-prose {
  max-width: var(--measure);
  font-size: var(--fs-body);
  line-height: 1.65;
  color: var(--text);
  text-wrap: pretty;
  hanging-punctuation: first;
}
.cw-prose:lang(zh) { max-width: var(--measure-zh); line-height: var(--lh-zh); }
.cw-prose > :first-child,
.cw-prose > :first-child > :first-child { margin-top: 0; }
.cw-prose :where(p, ul, ol, pre, blockquote, figure, table, hr) { margin: 0; }
.cw-prose :where(p, ul, ol, pre, blockquote) + :where(p, ul, ol, pre, blockquote) { margin-top: 1.15em; }
.cw-prose :where(h2, h3, h4) { color: var(--text); text-wrap: balance; }
.cw-prose h2 {
  margin-top: 2.6em;
  margin-bottom: 0.8em;
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.cw-prose h3 {
  margin-top: 2.1em;
  margin-bottom: 0.6em;
  font-size: 1.1875rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.cw-prose h4 {
  margin-top: 1.8em;
  margin-bottom: 0.5em;
  font-size: 1.0625rem;
  line-height: 1.4;
}
.cw-prose :where(h2, h3, h4):lang(zh) { letter-spacing: 0; line-height: 1.45; }
.cw-prose a {
  color: var(--accent);
  text-decoration-color: currentColor;
  text-decoration-thickness: 1px;
}
.cw-prose a:hover { color: var(--text); }
.cw-prose strong, .cw-prose b { font-weight: 600; }
.cw-prose del { color: var(--text-muted); }
.cw-prose :where(ul, ol) { padding-left: 1.3em; }
.cw-prose li + li { margin-top: 0.55em; }
.cw-prose li > :where(ul, ol) { margin-top: 0.55em; }
.cw-prose li::marker { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cw-prose hr {
  margin: 3em 0;
  border: 0;
  border-top: var(--bw) solid var(--line);
}
.cw-prose blockquote {
  margin-block: 1.8em;
  padding-left: var(--sp-5);
  border-left: 2px solid var(--accent);
  color: var(--text);
}
.cw-prose blockquote > * + * { margin-top: 0.7em; }
.cw-prose code {
  padding: 0.08em 0.3em;
  background: var(--surface-raised);
  font-family: var(--font-mono);
  font-size: 0.88em;
  overflow-wrap: anywhere;
}
.cw-prose pre {
  margin-block: 1.6em;
  padding: var(--sp-4) var(--sp-5);
  overflow-x: auto;
  background: var(--surface-raised);
  font-size: 0.875rem;
  line-height: 1.6;
}
.cw-prose pre code { padding: 0; background: none; font-size: inherit; overflow-wrap: normal; }
.cw-prose figure { margin-block: 2.2em; }
.cw-prose figure img { width: 100%; border: var(--bw) solid var(--line); background: #fff; }
.cw-prose figcaption {
  margin-top: var(--sp-3);
  color: var(--text-2);
  font-size: var(--fs-small);
  line-height: 1.5;
}
/* Tables: any wrapper that directly holds a table scrolls sideways instead of overflowing the page. */
.cw-prose div:has(> table) { margin-block: 2em; overflow-x: auto; }
.cw-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
  line-height: 1.5;
}
.cw-prose :where(th, td) {
  padding: var(--sp-3) var(--sp-4) var(--sp-3) 0;
  border-bottom: var(--bw) solid var(--line);
  text-align: left;
  vertical-align: top;
}
.cw-prose thead th {
  border-bottom-color: var(--line-strong);
  color: var(--text-2);
  font-weight: 600;
  white-space: nowrap;
}
.cw-prose img { max-width: 100%; height: auto; }

@media (max-width: 40rem) {
  .cw-prose h2 { font-size: 1.3125rem; }
  .cw-prose blockquote { padding-left: var(--sp-4); }
  /* Four or more columns: keep cells readable and let the wrapper scroll sideways. */
  .cw-prose table:has(tr > :nth-child(4)) { min-width: 36rem; }
}
