/* ==========================================================================
   Agentic Patterns: shared styles
   A calm, reference-style look: system fonts, hairline rules, one accent.
   ========================================================================== */

:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --surface-2: #f1f1ed;
  --ink: #1b1b1a;
  --ink-2: #2e2e2c;
  --muted: #5e5d58;
  --line: #dad9d3;
  --line-strong: #b4b3ab;
  --accent: #1d4f91;
  --accent-ink: #ffffff;
  --accent-soft: #e5ecf6;
  --amber: #875800;
  --amber-soft: #f5edda;
  --good: #2d6a3e;
  --bad: #a3302a;
  --bad-soft: #f7e3e1;
  --code-bg: #f3f3ef;
  --code-ink: #1b1b1a;

  --radius: 3px;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --font: var(--font-sans); /* kept for older markup */

  --measure: 70ch;
  --header-h: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151514;
    --surface: #1c1c1b;
    --surface-2: #242422;
    --ink: #e8e6e1;
    --ink-2: #d9d7d1;
    --muted: #a5a29a;
    --line: #34332f;
    --line-strong: #4c4b46;
    --accent: #8fb5ea;
    --accent-ink: #10161f;
    --accent-soft: #1f2a3a;
    --amber: #e2b86c;
    --amber-soft: #372e1e;
    --good: #84c595;
    --bad: #ee8b81;
    --bad-soft: #3b2321;
    --code-bg: #1f1f1d;
    --code-ink: #e8e6e1;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #151514;
  --surface: #1c1c1b;
  --surface-2: #242422;
  --ink: #e8e6e1;
  --ink-2: #d9d7d1;
  --muted: #a5a29a;
  --line: #34332f;
  --line-strong: #4c4b46;
  --accent: #8fb5ea;
  --accent-ink: #10161f;
  --accent-soft: #1f2a3a;
  --amber: #e2b86c;
  --amber-soft: #372e1e;
  --good: #84c595;
  --bad: #ee8b81;
  --bad-soft: #3b2321;
  --code-bg: #1f1f1d;
  --code-ink: #e8e6e1;
  color-scheme: dark;
}

/* ---------- Base ---------- */

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

html {
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-2);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-serif);
  color: var(--ink);
  line-height: 1.2;
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 4.5vw, 2.6rem);
  margin: 0 0 0.25em;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.5rem;
  margin: 2.6em 0 0.7em;
  padding-top: 0.7em;
  border-top: 1px solid var(--line);
}

h3 {
  font-size: 1.15rem;
  margin: 1.8em 0 0.5em;
}

h4 {
  font-size: 1rem;
  margin: 1.4em 0 0.4em;
}

p,
ul,
ol,
dl {
  margin: 0 0 1em;
}

ul,
ol {
  padding-left: 1.4em;
}

li {
  margin-bottom: 0.35em;
}

li > ul,
li > ol {
  margin: 0.35em 0 0;
}

strong {
  color: var(--ink);
}

code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-2);
  padding: 0.08em 0.3em;
  border-radius: 2px;
}

pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.55;
  background: var(--code-bg);
  color: var(--code-ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 1.2em;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

img,
svg {
  max-width: 100%;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2em 0;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -40px;
  z-index: 20;
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--line-strong);
  padding: 6px 10px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.skip-link:focus {
  top: 8px;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-sans);
}

.site-header__inner {
  max-width: 1160px;
  min-height: var(--header-h);
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.15rem;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px 18px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 0.92rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.theme-toggle {
  font: 500 0.85rem var(--font-sans);
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 4px 10px;
  min-width: 4.2em;
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--surface-2);
}

.lang-switch {
  font: 500 0.85rem var(--font-sans);
  letter-spacing: 0.02em;
}

/* ---------- Pattern page layout ---------- */

.layout {
  max-width: 1160px;
  margin: 0 auto;
  padding: 32px 16px 80px;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 56px;
}

.content {
  min-width: 0;
  max-width: 50rem;
}

/* Prose blocks keep a readable measure; figures, forms and tables use the full column */
.content > :where(p, ul, ol, dl, h1, h2, h3, h4, .aka, .intent, .callout, .analogy, .note, .relations, .steps, .legend, .apply) {
  max-width: var(--measure);
}

.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.4;
  padding-right: 4px;
}

.sidebar__nav > summary {
  display: none;
}

.sidebar__family,
.sidebar h4 {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin: 1.4em 0 0.35em;
}

.sidebar__nav nav > .sidebar__family:first-child,
.sidebar > h4:first-child {
  margin-top: 0;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar li {
  margin: 0;
}

.sidebar a,
.sidebar .soon {
  display: block;
  padding: 3px 0 3px 10px;
  color: var(--ink-2);
  text-decoration: none;
  border-left: 1px solid var(--line);
}

.sidebar a:hover {
  color: var(--accent);
  border-left-color: var(--line-strong);
}

.sidebar a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  border-left: 2px solid var(--ink);
  padding-left: 9px;
}

.sidebar .soon {
  color: var(--muted);
}

.toc-block {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid var(--line);
}

.toc-block > :first-child {
  margin-top: 0;
}

.toc a {
  color: var(--muted);
  font-size: 0.86rem;
}

.toc a.is-active {
  color: var(--ink);
  border-left: 2px solid var(--accent);
  padding-left: 9px;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-top: 0;
  }

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
  }

  .sidebar__nav > summary {
    display: list-item;
    cursor: pointer;
    padding: 10px 0;
    font-weight: 600;
    color: var(--ink);
  }

  .sidebar__nav[open] > summary {
    border-bottom: 1px solid var(--line);
  }

  .sidebar__nav nav {
    padding: 4px 0 16px;
    columns: 2 160px;
    column-gap: 24px;
  }

  .sidebar__nav nav > .sidebar__family {
    break-after: avoid;
  }

  .sidebar__nav nav > ul {
    break-inside: avoid;
  }

  .sidebar .toc-block {
    display: none;
  }
}

/* ---------- Pattern page pieces ---------- */

.breadcrumbs {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 12px;
}

.breadcrumbs a {
  color: var(--muted);
}

.aka {
  color: var(--muted);
  font-style: italic;
  margin: 0 0 6px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 0;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--muted);
}

.tag {
  margin: 0;
}

.tag + .tag::before {
  content: "\00B7";
  padding: 0 0.55em;
  color: var(--line-strong);
}

.tag--accent {
  color: var(--ink);
  font-weight: 600;
}

/* Intent: the pattern in two or three sentences, set larger */
.intent {
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--ink);
  margin: 0 0 1.2em;
}

.intent > :last-child {
  margin-bottom: 0;
}

/* Callout: a short aside worth stopping for */
.callout {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 1.4em 0;
}

.callout > :last-child {
  margin-bottom: 0;
}

.callout__title {
  display: block;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  margin-bottom: 4px;
}

/* Note: a small confidence or caveat remark */
.note {
  font-size: 0.93rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 0.6em;
  margin: 1.2em 0;
}

.note strong {
  color: var(--ink-2);
}

/* Analogy: plain prose, set apart by a tint */
.analogy {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 0 0 1.2em;
}

.analogy > :last-child,
.analogy > div > :last-child {
  margin-bottom: 0;
}

.analogy__icon {
  display: none;
}

/* ---------- Figures and diagrams ---------- */

.figure {
  margin: 1.6em 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  overflow-x: auto;
}

.figure svg {
  display: block;
  width: 100%;
  min-width: 560px;
  height: auto;
}

.figure--compact svg {
  min-width: 0;
  max-width: 480px;
  margin: 0 auto;
}

.figure figcaption {
  font-family: var(--font-sans);
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--muted);
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  position: sticky;
  left: 0;
}

/* Classes used inside inline SVGs */
.d-box {
  fill: var(--surface);
  stroke: var(--ink);
  stroke-width: 1.25;
}

rect.d-box {
  rx: 3px;
  ry: 3px;
}

.d-box--soft {
  fill: var(--surface-2);
  stroke: var(--line-strong);
}

.d-box--accent {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 1.75;
}

.d-box--amber {
  fill: var(--amber-soft);
  stroke: var(--amber);
}

.d-box--bad {
  fill: var(--bad-soft);
  stroke: var(--bad);
}

.d-title {
  fill: var(--ink);
  font: 600 15px var(--font-sans);
}

.d-text {
  fill: var(--ink-2);
  font: 13px var(--font-sans);
}

.d-small {
  fill: var(--muted);
  font: 12px var(--font-sans);
}

.d-mono {
  fill: var(--muted);
  font: 11.5px var(--font-mono);
}

.d-bad {
  fill: var(--bad);
  font: 600 13px var(--font-sans);
}

.d-accent {
  fill: var(--accent);
  font: 600 13px var(--font-sans);
}

.d-line {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.4;
}

.d-line--dashed {
  stroke-dasharray: 5 4;
}

.d-line--accent {
  stroke: var(--accent);
  stroke-width: 1.75;
}

.d-line--bad {
  stroke: var(--bad);
}

.d-arrowhead {
  fill: var(--muted);
}

.d-arrowhead--accent {
  fill: var(--accent);
}

.d-arrowhead--bad {
  fill: var(--bad);
}

.d-badge circle {
  fill: var(--ink);
}

.d-badge text {
  fill: var(--bg);
  font: 700 12px var(--font-sans);
  text-anchor: middle;
  dominant-baseline: central;
  font-variant-numeric: tabular-nums;
}

.d-dot {
  fill: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .d-dot {
    display: none;
  }
}

/* Numbered legend under structure diagrams (numbers match the .d-badge numbers) */
.legend {
  list-style: none;
  padding: 0;
  counter-reset: legend;
}

.legend li {
  counter-increment: legend;
  position: relative;
  padding-left: 36px;
  margin-bottom: 0.8em;
}

.legend li::before {
  content: counter(legend);
  position: absolute;
  left: 0;
  top: 0.2em;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font: 700 0.75rem/22px var(--font-sans);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  margin: 1.4em 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

.table caption {
  text-align: left;
  color: var(--muted);
  font-size: 0.85rem;
  padding-bottom: 8px;
}

.table th,
.table td {
  text-align: left;
  vertical-align: top;
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--line);
}

.table thead th {
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid var(--line-strong);
}

.table tbody th {
  font-weight: 600;
  color: var(--ink);
}

.table td.num,
.table th.num {
  text-align: right;
}

/* ---------- Lists used on pattern pages ---------- */

/* Numbered steps (Solution, How to implement) */
.steps {
  list-style: none;
  padding: 0;
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 2em;
  margin-bottom: 0.75em;
}

.steps li::before {
  content: counter(step) ".";
  position: absolute;
  left: 0;
  top: 0;
  font: 600 0.95rem/1.78 var(--font-sans);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Applicability: "Use it when" / "Avoid it when" */
.apply {
  list-style: none;
  padding: 0;
  border-top: 1px solid var(--line);
}

.apply li {
  padding: 0.65em 0 0.65em 1.6em;
  margin: 0;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.apply li::before {
  content: "+";
  position: absolute;
  left: 0.2em;
  top: 0.6em;
  font: 600 1rem var(--font-sans);
  color: var(--good);
}

.apply--avoid li::before {
  content: "\2212";
  color: var(--bad);
}

/* Pros and cons */
.pros-cons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 40px;
  margin: 1em 0 1.4em;
}

.pros-cons > div {
  border-top: 1px solid var(--line-strong);
  padding-top: 4px;
}

.pros-cons h3 {
  margin: 0.4em 0 0.6em;
  font-size: 1.05rem;
}

.pros-cons ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.pros-cons li {
  padding-left: 1.4em;
  position: relative;
  margin-bottom: 0.6em;
}

.pros-cons li::before {
  position: absolute;
  left: 0.1em;
  font: 600 1rem var(--font-sans);
}

.pros li::before {
  content: "+";
  color: var(--good);
}

.cons li::before {
  content: "\2212";
  color: var(--bad);
}

/* Failure modes: definition list of failure / mitigation */
.failures {
  margin: 0 0 1.2em;
  border-top: 1px solid var(--line);
}

.failures dt {
  font-weight: 700;
  color: var(--ink);
  padding-top: 0.65em;
}

.failures dd {
  margin: 0.2em 0 0;
  padding-bottom: 0.65em;
  border-bottom: 1px solid var(--line);
}

.failures dd p {
  margin: 0 0 0.4em;
}

.failures dd > :last-child {
  margin-bottom: 0;
}

.fix-label {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

@media (max-width: 640px) {
  .pros-cons {
    grid-template-columns: 1fr;
  }
}

/* Relations */
.relations li {
  margin-bottom: 0.7em;
}

.soon-inline {
  color: var(--muted);
  font-weight: 600;
}

/* Further reading */
.reading li {
  margin-bottom: 0.6em;
}

/* ---------- Prompt generator ---------- */

.pg {
  display: grid;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 1.2em 0 0;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.45;
}

.pg-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.pg label,
.pg legend {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
}

.pg legend {
  padding: 0;
  margin-bottom: 8px;
}

.pg-hint,
.pg-mini em {
  font-weight: 400;
  font-style: normal;
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 4px;
}

.pg input[type="text"],
.pg input[type="number"],
.pg textarea,
.pg select {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 7px 9px;
}

.pg textarea {
  resize: vertical;
}

.pg input:focus,
.pg textarea:focus,
.pg select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.pg-list {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.pg-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  padding: 12px 84px 12px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 2px;
}

.pg-row .pg-wide {
  grid-column: 1 / -1;
}

.pg-mini {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.pg .pg-mini,
.pg-mini > span {
  font-weight: 400;
  font-size: 0.84rem;
  color: var(--muted);
}

.pg-mini em {
  margin-left: 0;
  font-size: 0.8rem;
}

.pg-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 2px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  font: 500 0.82rem var(--font-sans);
  line-height: 1;
  cursor: pointer;
}

.pg-remove:hover {
  color: var(--bad);
  border-color: var(--bad);
}

.pg-add,
.pg-actions button,
.pg-copy {
  justify-self: start;
  font: 500 0.88rem var(--font-sans);
  padding: 6px 12px;
  border-radius: 2px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.pg-add:hover,
.pg-actions button:hover,
.pg-copy:hover {
  background: var(--surface-2);
  border-color: var(--ink);
}

.pg-add {
  color: var(--accent);
}

.pg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.pg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
}

.pg-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pg label.pg-check {
  font-weight: 400;
}

.pg-radios {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding-top: 2px;
}

.pg-radios label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
}

.pg input[type="checkbox"],
.pg input[type="radio"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  margin: 0;
}

@media (max-width: 640px) {
  .pg {
    padding: 14px;
  }

  .pg-row {
    grid-template-columns: 1fr;
    padding: 40px 10px 10px;
  }

  .pg-remove {
    top: 8px;
    right: 8px;
  }
}

.pg-output-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 8px;
  font-family: var(--font-sans);
}

.pg-output-head h3 {
  margin: 0;
}

.pg-output pre {
  background: var(--code-bg);
  color: var(--code-ink);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 640px;
  overflow-y: auto;
}

.pg-output code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.pg-val {
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 2px;
}

.pg-empty {
  color: var(--amber);
  background: var(--amber-soft);
  border-radius: 2px;
}

.pg-legend {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
}

.pg-legend .pg-val,
.pg-legend .pg-empty {
  padding: 0 0.2em;
}

/* ---------- Prev / next ---------- */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 64px;
  padding-top: 16px;
  border-top: 1px solid var(--line-strong);
  font-family: var(--font-sans);
}

.pager a {
  display: block;
  text-decoration: none;
  color: var(--ink);
  padding: 4px 0;
}

.pager small,
.pager span {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
}

.pager strong {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--accent);
}

.pager a:hover strong {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.pager .prev {
  grid-column: 1;
}

.pager .next {
  text-align: right;
  grid-column: 2;
}

/* ---------- Home page ---------- */

.home {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 16px 80px;
}

.home > section,
.home > .intro {
  max-width: 60rem;
}

.intro {
  padding: 56px 0 8px;
}

.intro h1 {
  font-size: clamp(2.1rem, 5vw, 3rem);
  max-width: 18em;
}

.lead {
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 36em;
}

.section {
  padding: 8px 0;
}

.section > p,
.section > ul,
.section > ol,
.section > .callout {
  max-width: var(--measure);
}

.section-intro {
  color: var(--muted);
  max-width: var(--measure);
}

.family {
  margin: 0 0 8px;
}

.family > h3 {
  margin: 2em 0 0.2em;
  font-size: 1.2rem;
}

.family__note {
  margin: 0 0 0.6em;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: var(--measure);
}

.catalog {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
  column-gap: 40px;
  border-top: 1px solid var(--line);
}

.catalog__item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 14px 0;
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.catalog__thumb {
  display: block;
  width: 64px;
  height: 40px;
  margin-top: 4px;
}

.catalog__thumb .d-box,
.catalog__thumb .d-line {
  stroke-width: 1.25;
}

.catalog__name {
  font-weight: 700;
  font-size: 1.08rem;
  text-decoration: none;
}

.catalog__name:hover {
  text-decoration: underline;
}

.catalog__item p {
  margin: 2px 0 0;
  font-size: 0.97rem;
  color: var(--ink-2);
}

.choose {
  list-style: none;
  padding: 0;
  counter-reset: choose;
  max-width: var(--measure);
}

.choose > li {
  counter-increment: choose;
  position: relative;
  padding: 0.7em 0 0.7em 2em;
  margin: 0;
  border-top: 1px solid var(--line);
}

.choose > li::before {
  content: counter(choose) ".";
  position: absolute;
  left: 0;
  top: 0.7em;
  font: 600 0.95rem/1.78 var(--font-sans);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.choose ul {
  margin: 0.4em 0 0;
  padding-left: 1.2em;
}

.choose ul li {
  margin-bottom: 0.25em;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.site-footer__inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px 16px 36px;
}

.site-footer p {
  margin: 0;
}

/* ---------- Narrow screens ---------- */

@media (max-width: 600px) {
  .site-header {
    position: static;
  }

  .site-header__inner {
    flex-wrap: wrap;
    gap: 4px 16px;
  }

  .site-nav {
    flex-basis: 100%;
    margin-left: 0;
    justify-content: flex-start;
    gap: 4px 16px;
  }

  .site-nav .theme-toggle,
  .site-nav .lang-switch {
    margin-left: auto;
  }

  .site-nav .lang-switch + .theme-toggle {
    margin-left: 0;
  }

  html {
    scroll-padding-top: 16px;
  }
}


@media (max-width: 520px) {
  body {
    font-size: 1rem;
  }

  h2 {
    font-size: 1.35rem;
  }

  .intent {
    font-size: 1.1rem;
  }


  .figure {
    padding: 12px;
    margin-left: -4px;
    margin-right: -4px;
  }

  .intro {
    padding-top: 32px;
  }
}

/* ---------- Print ---------- */

@media print {
  .site-header,
  .sidebar,
  .pager,
  .pg,
  .pg-copy,
  .theme-toggle {
    display: none;
  }

  .layout {
    display: block;
  }
}
