.kpress {
  background: var(--kpress-doc-bg);
  box-sizing: border-box;
  color: var(--kpress-doc-text);
  font-family: var(--kpress-font-body, system-ui, sans-serif);
  font-weight: var(--kpress-font-weight-sans-regular);
  /* Allow height transitions to/from `auto` (e.g. <details> expansion). */
  interpolate-size: allow-keywords;
  line-height: var(--kpress-line-height-normal, 1.5);
  overflow-wrap: break-word;
}

.kpress *,
.kpress *::before,
.kpress *::after {
  box-sizing: inherit;
}

/* Cap #1 of the width chain (see components.css "the width chain"): the article
   holds the reading column plus its inset plus the page gutter. Every term is
   named, because the failure this fixes was a cap that added some of them and
   not others -- the measure then meant "text" at one width and "text minus
   padding" at another. box-sizing is border-box (.kpress above), so the gutter
   belongs inside the cap. */
.kpress-doc {
  margin: 0 auto;
  max-width: min(
    100%,
    calc(var(--kpress-measure) + 2 * var(--kpress-column-inset) + 2 * var(--kpress-doc-gutter))
  );
  padding: 2rem var(--kpress-doc-gutter) 3rem;
}

.kpress-print-surface {
  background: var(--kpress-doc-bg);
}

.kpress-doc-header,
.kpress-source-header {
  border-bottom: 1px solid var(--kpress-doc-border);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
}

.kpress-metadata {
  color: var(--kpress-doc-text);
}

.kpress-doc-header h1,
.kpress-source-header h1 {
  font-family: var(--kpress-font-prose, Georgia, serif);
  font-size: clamp(
    calc(var(--kpress-font-size-base) * 1.75),
    4.5vw,
    calc(var(--kpress-font-size-base) * 2.3)
  );
  font-weight: var(--_kpress-font-weight-prose);
  line-height: 1.12;
  margin: 0;
}

.kpress-source-meta {
  color: var(--kpress-doc-muted);
  font-family: var(--kpress-font-sans, system-ui, sans-serif);
  font-weight: var(--kpress-font-weight-sans-regular);
  margin: 0.5rem 0 0;
}

.kpress-frontmatter-error,
.kpress-source-truncation-warning {
  background: color-mix(in srgb, var(--kpress-doc-danger) 8%, var(--kpress-doc-bg));
  border: 1px solid color-mix(in srgb, var(--kpress-doc-danger) 42%, var(--kpress-doc-border));
  border-radius: var(--kpress-radius-sm);
  color: color-mix(in srgb, var(--kpress-doc-danger) 84%, var(--kpress-doc-text));
  font-family: var(--kpress-font-sans, system-ui, sans-serif);
  font-weight: var(--kpress-font-weight-sans-regular);
  font-size: var(--kpress-font-size-small);
  line-height: 1.35;
  margin: 1rem 0;
  padding: 0.65rem 0.8rem;
}

.kpress-frontmatter-error strong,
.kpress-source-truncation-warning strong {
  display: block;
  font-weight: var(--kpress-font-weight-sans-bold, 650);
  margin-bottom: 0.15rem;
}

/* Cap #2 of the width chain: the column box, text plus its inset. Capping this
   at the bare measure is what clamped the column below the measure in the
   single-column bands -- the inset was then subtracted from a box already
   sized to the text. */
.kpress-doc-layout {
  margin: 0 auto;
  max-width: calc(var(--kpress-measure) + 2 * var(--kpress-column-inset));
}

.kpress-prose {
  font-family: var(--kpress-font-prose, Georgia, serif);
  font-size: var(--kpress-font-size-normal);
  font-weight: var(--_kpress-font-weight-prose);
  line-height: var(--kpress-line-height-normal, 1.5);
}

.kpress-prose h1,
.kpress-prose h2,
.kpress-prose h3,
.kpress-prose h4,
.kpress-prose h5,
.kpress-prose h6 {
  font-feature-settings: var(--kpress-font-features-sans, normal);
  font-family: var(--kpress-font-sans, system-ui, sans-serif);
  font-weight: var(--kpress-font-weight-sans-bold, 650);
  line-height: var(--kpress-line-height-tight, 1.2);
}

.kpress-prose h1 {
  font-family: var(--kpress-font-prose, Georgia, serif);
  font-size: calc(var(--kpress-font-size-base) * 1.7);
  font-weight: var(--_kpress-font-weight-prose);
  margin: 2rem 0 1rem;
}

.kpress-prose h2 {
  font-family: var(--kpress-font-prose, Georgia, serif);
  font-size: var(--kpress-font-size-h2);
  font-style: italic;
  font-weight: var(--_kpress-font-weight-prose);
  margin: 2rem 0 1rem;
}

.kpress-prose h3 {
  font-size: calc(var(--kpress-font-size-h3) * var(--kpress-caps-heading-size-multiplier, 1));
  font-variant-caps: var(--kpress-caps-variant, normal);
  font-weight: var(--kpress-font-weight-sans-medium, 550);
  letter-spacing: var(--kpress-caps-spacing, 0);
  line-height: var(--kpress-caps-heading-line-height, 1.2);
  margin: 1.4rem 0 0.7rem;
  text-transform: var(--kpress-caps-transform, none);
}

.kpress-prose h4 {
  font-size: var(--kpress-font-size-h4);
  font-style: italic;
  font-weight: 540;
  letter-spacing: 0.015em;
  margin: 1rem 0 0.7rem;
}

.kpress-prose h5 {
  font-family: var(--kpress-font-prose, Georgia, serif);
  font-size: var(--kpress-font-size-base);
  font-weight: 700;
  margin: 0.7rem 0 0.5rem;
}

.kpress-prose h6 {
  font-family: var(--kpress-font-prose, Georgia, serif);
  font-size: var(--kpress-font-size-base);
  font-style: italic;
  font-weight: var(--_kpress-font-weight-prose);
  margin: 0.7rem 0 0.5rem;
}

.kpress-prose h2 + h3 {
  margin-top: 1.1rem;
}

.kpress-prose p,
.kpress-prose pre {
  margin-block: 0.75rem;
}

/* Tighten the gap after a low-level heading (declared after `p` so the
   higher-specificity adjacent selector is not a descending-specificity
   override). */
.kpress-prose h4 + p,
.kpress-prose h5 + p,
.kpress-prose h6 + p {
  margin-top: 0;
}

.kpress-prose ul,
.kpress .concepts ul {
  list-style-type: none;
  margin-bottom: 0.7rem;
  margin-left: 1.8rem;
  padding-left: 0;
}

.kpress-prose li,
.kpress .concepts li {
  margin-block-start: 0.7rem;
  position: relative;
}

.kpress-prose li > p {
  margin-block-end: 0;
}

/* The square is DRAWN, not set. It used to be the glyph U+25AA, which no face
   KPress ships carries: it fell down the prose stack to whatever the reader had
   (Georgia on a Mac, something else elsewhere) and put 16 KB of embedded Georgia
   into a printed PDF for 48 bullets. A currentColor box depends on no font and
   is the same mark on every machine.

   The numbers reproduce what Georgia drew, measured in Chromium at a 16px base:
   a 3.255 x 3.255 px square whose ink began 0.921px right of the pen and whose
   centre sat 11.051px left of and 13.143px below the item's top-left corner.
   0.226em of the marker size is that square; the two added offsets move the box
   from the old text origin onto the ink the glyph actually put there, and both
   are in em of the marker size, so the same pair serves the print rule at its
   smaller size. See print.css and the .claim rule in components.css.

   One consequence beyond the face: .claim's marker used to come out 60% larger
   than this one, because its stack is the sans and a different fallback answered
   it. All three bulleted lists now draw the one square --kpress-bullet-size
   describes.

   The inline offset is logical, not physical. The glyph used `left`, and so did
   this box at first, which put the marker on the far side of a right-to-left
   item and pointed the 0.064em ink nudge away from the text instead of toward
   it. `inset-inline-start` resolves to `right` under `dir="rtl"` and the nudge
   follows it, so one pair of numbers serves both directions.

   Forced colors need their own rule; components.css carries it, because that
   file loads later and .claim's marker rule lives there. */
.kpress-prose ul > li::before,
.kpress .concepts ul > li::before {
  background: currentColor;
  content: "";
  font-size: var(--kpress-bullet-size);
  height: 0.226em;
  inset-inline-start: calc(var(--kpress-font-size-base) * -0.85 + 0.064em);
  position: absolute;
  top: calc(var(--kpress-font-size-base) * 0.1 + 0.689em);
  width: 0.226em;
}

.kpress-prose ol {
  list-style-type: decimal;
  margin-bottom: 0.7rem;
  margin-left: 1.8rem;
  padding-left: 0;
}

.kpress-prose ol > li {
  padding-left: 0.25rem;
}

.kpress a {
  color: var(--kpress-doc-link);
  text-decoration: none;
  transition: color var(--kpress-transition-fast);
}

.kpress a:hover {
  color: var(--color-primary-light);
  text-decoration: underline;
}

/* GFM strikethrough: keep the text legible (body colour) but draw the line in the
   muted tone so it reads as struck-through without the heavy dark rule. */
.kpress del,
.kpress s {
  text-decoration-color: var(--kpress-doc-muted);
}

.kpress img,
.kpress-image {
  height: auto;
  margin-block: 1rem;
  max-width: 100%;
}

.kpress-figure {
  margin: 1.5rem auto;
  text-align: center;
}

.kpress-figure .kpress-image {
  display: block;
  margin: 0 auto;
}

.kpress-figcaption {
  color: var(--kpress-doc-muted);
  font-family: var(--kpress-font-sans, system-ui, sans-serif);
  font-weight: var(--kpress-font-weight-sans-regular);
  font-size: var(--kpress-font-size-small);
  line-height: 1.35;
  margin-block-start: 0.55rem;
}

.kpress .thumbnail {
  border-radius: var(--kpress-radius-lg);
  display: block;
  margin: 1rem auto 2rem;
  max-height: 24rem;
  object-fit: contain;
}

.kpress blockquote {
  border-inline-start: 3px solid var(--kpress-doc-border);
  color: var(--kpress-doc-muted);
  margin-block: 1.5rem;
  margin-inline: 1rem 4rem;
  padding-inline-start: 1rem;
}

.kpress code,
.kpress-code {
  background: var(--kpress-doc-surface-bg);
  font-family: var(--kpress-font-mono, ui-monospace, monospace);
  font-size: var(--kpress-font-size-mono);
  letter-spacing: -0.025em;
}

.kpress code {
  transition: color var(--kpress-transition-slow);
}

/* Keyboard input and sample output are code-ish runs too: without this they fall
   through to the user agent's monospace, beside code set in the shipped face. */
.kpress kbd,
.kpress samp {
  font-family: var(--kpress-font-mono, ui-monospace, monospace);
  font-size: var(--kpress-font-size-mono);
}

.kpress code:not(pre code) {
  border: 1px solid var(--kpress-code-border);
  border-radius: var(--kpress-code-radius);
  /* A compact tint rather than a chip: dense technical prose can carry many
     identifiers without turning into a row of padded controls. */
  padding: 0.1em 0.25em;
}

.kpress-code {
  border: 1px solid var(--kpress-code-border);
  border-radius: var(--kpress-code-radius);
  line-height: 1.5;
  margin: 0;
  overflow-x: auto;
  overflow-wrap: normal;
  padding: 0.45rem 0.5rem;
  scrollbar-color: var(--color-scrollbar) transparent;
  scrollbar-width: thin;
  transition:
    background-color var(--kpress-transition-slow),
    border-color var(--kpress-transition-slow);
  white-space: pre;
}

.kpress-source {
  margin: 0;
  padding: 1.25rem;
}

.kpress-frontmatter {
  border: 1px solid var(--kpress-doc-border);
  font-family: var(--kpress-font-sans, system-ui, sans-serif);
  font-weight: var(--kpress-font-weight-sans-regular);
  margin: 1rem 0;
}

.kpress-frontmatter dl {
  display: grid;
  gap: 0.35rem 0.75rem;
  grid-template-columns: max-content minmax(0, 1fr);
}

/* Distinguish keys from values: keys are medium-weight in the document text
   color, values are muted. Without this both render in the same tertiary grey
   (see the .kpress .kpress-frontmatter rule below), which reads as unstyled. */
.kpress-frontmatter dt {
  color: var(--kpress-doc-text);
  font-weight: var(--kpress-font-weight-sans-medium, 550);
}

.kpress-frontmatter dd {
  color: var(--kpress-doc-muted);
  margin: 0;
}

.kpress details {
  border: 1px solid var(--kpress-doc-border);
  color: var(--kpress-doc-text);
  font-family: var(--kpress-font-sans, system-ui, sans-serif);
  font-weight: var(--kpress-font-weight-sans-regular);
  font-feature-settings: var(--kpress-font-features-sans, normal);
  margin: 0.75rem 0;
}

/* Disclosure summary: a single background (no two-tone header) plus the canonical
   chevron toggle below. The label text uses the shared small-caps section-label
   treatment — same muted color, caps variant, weight, spacing, and size formula as
   `.kpress-toc-title` (all driven by the `--kpress-caps-*` tokens) so every toggle
   label and the TOC read as one design language. */
.kpress summary {
  align-items: center;
  color: var(--kpress-doc-muted);
  cursor: pointer;
  display: flex;
  font-family: var(--kpress-font-sans, system-ui, sans-serif);
  font-size: var(--kpress-caps-label-size);
  font-variant-caps: var(--kpress-caps-variant);
  font-weight: var(--kpress-font-weight-sans-medium);
  gap: 0.4rem;
  letter-spacing: var(--kpress-caps-spacing);
  line-height: var(--kpress-caps-heading-line-height);
  list-style: none;
  padding: 0.5rem 0.75rem;
  text-transform: var(--kpress-caps-transform);
  transition: color var(--kpress-transition-fast);
  user-select: none;
}

.kpress summary::-webkit-details-marker {
  display: none;
}

/* Canonical disclosure toggle: the shared Lucide `chevron-right` glyph (drawn via
   a mask so it inherits the summary color), rotated 90deg when open. One treatment
   for every <details> in KPress; host apps can mirror it for their own chrome. */
.kpress summary::before {
  background-color: currentColor;
  content: "";
  flex: none;
  /* Slightly smaller than the cap height, nudged down via `top` (not transform,
     which the open-state rotate owns) so the glyph sits on the label baseline. */
  height: 0.85em;
  mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E")
    center / contain no-repeat;
  position: relative;
  top: 0.06em;
  transition: transform var(--kpress-transition-fast);
  width: 0.85em;
}

.kpress details[open] summary::before {
  transform: rotate(90deg);
}

.kpress summary:hover {
  color: var(--color-primary-light);
}

.kpress details > :not(summary) {
  padding: 0.25rem 0.75rem 0.5rem;
}

.kpress details[open] summary {
  border-bottom: 1px solid var(--kpress-doc-border);
}

.kpress summary:focus-visible {
  outline: 3px solid var(--kpress-doc-link);
  outline-offset: 2px;
}

/* Gently animate expansion where the browser supports it; older browsers open
   instantly. `interpolate-size` lets the height transition to/from `auto`. */
.kpress details::details-content {
  block-size: 0;
  overflow: hidden;
  transition:
    block-size var(--kpress-transition-fast),
    content-visibility var(--kpress-transition-fast);
  transition-behavior: allow-discrete;
}

.kpress details[open]::details-content {
  block-size: auto;
}

.kpress details.metadata,
.kpress .kpress-frontmatter {
  color: var(--color-secondary);
}

.kpress details.metadata summary,
.kpress .kpress-frontmatter summary {
  color: var(--color-secondary);
  font-size: var(--kpress-caps-label-size);
  font-weight: var(--kpress-font-weight-sans-medium, 550);
  font-variant-caps: var(--kpress-caps-variant);
  letter-spacing: var(--kpress-caps-spacing);
  line-height: var(--kpress-caps-heading-line-height);
  text-transform: var(--kpress-caps-transform);
}

.kpress hr {
  border: 0;
  height: 1.5rem;
  margin: 0.5rem auto;
  overflow: visible;
  position: relative;
  text-align: center;
}

.kpress hr::before {
  border-top: 1px solid var(--kpress-doc-muted);
  content: "";
  display: block;
  left: calc(50% - 2rem);
  position: absolute;
  top: 50%;
  width: 4rem;
}

.kpress b,
.kpress strong {
  font-weight: var(--kpress-font-weight-sans-bold, 650);
}

.kpress ::selection {
  background-color: var(--color-selection);
  color: inherit;
}

/* Superscripts (footnote markers most of all) must never change the line box:
   the UA default `vertical-align: super` raises the sup's inline box and
   stretches any line that carries a marker, which reads as ragged leading on
   phones and in print. `line-height: 0` takes the sup out of line-box sizing
   entirely and the relative `top` nudge recreates the raised position
   visually, so lines with and without markers are exactly the same height at
   every pane width and on paper. Same treatment for sub, mirrored downward. */
.kpress sup,
.kpress sub {
  font-size: 85%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

.kpress sup {
  top: -0.45em;
}

.kpress sub {
  top: 0.3em;
}
