/* ML Systems Taxonomy, styled like established taxonomy sites (MITRE ATT&CK,
   ATLAS, SFIA): a matrix home, entry pages with a sidebar tree, a facts box,
   and tables. Neutral surfaces matching mlsysbook.ai; color carries no
   category, and crimson marks interaction only. */
.bok {
  --bok-ink: #111;
  --bok-muted: #5b5f66;
  --bok-faint: #8a8f97;
  --bok-page: var(--bs-body-bg, #fff);
  --bok-surface: #fff;
  --bok-band: #f6f6f7;
  --bok-line: rgba(0, 0, 0, 0.1);
  --bok-line-strong: rgba(0, 0, 0, 0.22);
  --bok-edge: #b4b8bf;
  --bok-accent: #a51c30;
  --bok-accent-soft: rgba(165, 28, 48, 0.07);
  --bok-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  max-width: 1240px;
  margin: 0 auto;
  padding: 2.2rem 24px 4rem;
  color: var(--bok-ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}
body.quarto-dark .bok {
  --bok-ink: #e6e6e6;
  --bok-muted: #a9adb4;
  --bok-faint: #80858d;
  --bok-surface: #16171b;
  --bok-band: #111215;
  --bok-line: rgba(255, 255, 255, 0.1);
  --bok-line-strong: rgba(255, 255, 255, 0.24);
  --bok-edge: #5a6069;
  --bok-accent: #ff6b81;
  --bok-accent-soft: rgba(255, 107, 129, 0.12);
  --bok-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
body:has(.bok) #title-block-header { display: none; }
.bok *, .bok *::before, .bok *::after { box-sizing: border-box; }
.bok [hidden] { display: none !important; }
.bok :is(h1, h2, h3, h4, p, ul, ol, dl, dd, figure) { margin: 0; padding: 0; }
#quarto-content .bok :is(h1, h2, h3, h4) { border: 0; padding: 0; background: none; color: var(--bok-ink); font-family: inherit; }
.bok :is(h2, h3)::before, .bok :is(h2, h3)::after { content: none !important; }
.bok a { color: inherit; text-decoration: none; }
.bok :focus-visible { outline: 2px solid var(--bok-accent); outline-offset: 2px; border-radius: 3px; }
.bok-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.bok-code, .bok-mono { font: 600 0.82em/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--bok-faint); }
.bok-code { margin-right: 0.5em; }
.bok code { font-size: 0.86em; color: var(--bok-ink); background: var(--bok-band); padding: 1px 5px; border-radius: 4px; }
.bok a.is-background { color: var(--bok-muted); }
.bok-loading { padding: 3rem 0; color: var(--bok-muted); }

/* ------------------------------------------------------------------- hero */
.bok-eyebrow { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--bok-muted); }
.bok-draft { margin-left: 0.6rem; padding: 0.1rem 0.45rem; border: 1px solid var(--bok-line-strong); border-radius: 999px; font-size: 0.66rem; letter-spacing: 0.08em; }
#quarto-content .bok .bok-title { margin-top: 0.5rem; font-size: clamp(1.9rem, 3.8vw, 2.7rem); font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; }
.bok-lede { max-width: 46rem; margin-top: 0.7rem !important; font-size: 1.05rem; color: var(--bok-muted); }
.bok-lede strong { color: var(--bok-ink); font-weight: 600; }

/* ---------------------------------------------------------------- toolbar */
.bok-toolbar { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; margin-top: 1.6rem; padding-bottom: 12px; border-bottom: 1px solid var(--bok-line); scroll-margin-top: 80px; }
.bok-search { position: relative; flex: 1 1 340px; max-width: 480px; }
.bok-search > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--bok-faint); pointer-events: none; }
.bok-search input { width: 100%; height: 40px; padding: 0 40px 0 38px; border: 1px solid var(--bok-line-strong); border-radius: 8px; background: var(--bok-surface); color: var(--bok-ink); font: inherit; font-size: 0.93rem; }
.bok :is(input, select)::placeholder { color: var(--bok-faint); }
.bok :is(.bok-search, .bok-picker, .bok-gloss-bar) input:focus { outline: none; border-color: var(--bok-accent); box-shadow: 0 0 0 3px var(--bok-accent-soft); }
.bok-kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); padding: 0 6px; border: 1px solid var(--bok-line-strong); border-radius: 5px; font: 600 0.72rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--bok-faint); }
.bok-results { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0; list-style: none; max-height: 380px; overflow-y: auto; padding: 6px !important; border: 1px solid var(--bok-line); border-radius: 10px; background: var(--bok-surface); box-shadow: var(--bok-shadow); }
.bok-results li { display: grid; grid-template-columns: 64px 1fr auto; column-gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.bok-results li[aria-selected="true"], .bok-results li:hover { background: var(--bok-accent-soft); }
.bok-res-kind { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--bok-faint); }
.bok-res-label { font-weight: 550; font-size: 0.92rem; }
.bok-res-where { font: 600 0.74rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--bok-faint); }
.bok-results .bok-noresult { display: block; color: var(--bok-muted); cursor: default; }
.bok-views { display: inline-flex; gap: 24px; }
.bok-views a { padding: 8px 0; border-bottom: 2px solid transparent; font-size: 0.92rem; font-weight: 550; color: var(--bok-muted); }
.bok-views a:hover { color: var(--bok-ink); }
.bok-views a[aria-current="page"] { color: var(--bok-ink); border-bottom-color: var(--bok-ink); }

/* ----------------------------------------------------------------- matrix */
.bok-matrix-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-top: 1.2rem; }
.bok-matrix-stats { font-size: 0.84rem; color: var(--bok-muted); font-variant-numeric: tabular-nums; }
.bok-matrix-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.bok-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.bok-filter-label { margin-right: 4px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--bok-faint); }
.bok-filter button, #bok-show-concepts, .bok-cite-actions button { height: 28px; padding: 0 10px; border: 1px solid var(--bok-line); border-radius: 6px; background: var(--bok-surface); color: var(--bok-muted); font: inherit; font-size: 0.8rem; cursor: pointer; }
.bok-filter button:hover, #bok-show-concepts:hover, .bok-cite-actions button:hover { border-color: var(--bok-line-strong); color: var(--bok-ink); }
.bok-filter button[aria-pressed="true"], #bok-show-concepts[aria-pressed="true"] { border-color: var(--bok-ink); background: var(--bok-ink); color: var(--bok-page); }
.bok-band { margin-top: 1.6rem; }
#quarto-content .bok .bok-band-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--bok-ink); font-size: 0.95rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.bok-band-head span:last-child { font-size: 0.8rem; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--bok-muted); }
.bok-cols { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0 10px; margin-top: 10px; }
.bok-col-head { display: block; min-height: 2.9em; font-size: 0.9rem; font-weight: 650; line-height: 1.3; }
.bok-col-head:hover span:last-child { color: var(--bok-accent); }
.bok-col-head .bok-code { display: block; margin: 0 0 2px; }
.bok-col-count { margin: 2px 0 6px !important; font-size: 0.74rem; color: var(--bok-faint); }
.bok-col ul { list-style: none; display: grid; gap: 4px; }
.bok-cell { display: block; padding: 6px 8px; border: 1px solid var(--bok-line); border-radius: 4px; background: var(--bok-surface); font-size: 0.82rem; line-height: 1.3; transition: border-color 0.12s, opacity 0.12s; }
.bok-cell:hover { border-color: var(--bok-accent); }
.bok-cell:hover .bok-cell-label { color: var(--bok-accent); }
.bok-cell .bok-code { display: block; margin: 0 0 1px; font-size: 0.68rem; }
.bok-cell.is-dim { opacity: 0.32; }
.bok-cell-concepts { display: block; margin-top: 4px; font-size: 0.72rem; line-height: 1.4; color: var(--bok-muted); }

/* ------------------------------------------------------- download & cite */
.bok-release { margin-top: 3rem; }
#quarto-content .bok .bok-release h2, #quarto-content .bok .bok-entry-head h2 { font-size: clamp(1.5rem, 2.8vw, 2rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.bok-release-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 28px; margin-top: 0.6rem; }
.bok-release-lede { max-width: 40rem; margin-bottom: 0.6rem !important; font-size: 0.92rem; color: var(--bok-muted); }
.bok-files td:first-child a { font-weight: 600; }
.bok-files td:nth-child(2) { font: 600 0.74rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--bok-faint); white-space: nowrap; }
.bok-cite { align-self: start; padding: 16px 18px; border: 1px solid var(--bok-line); border-radius: 6px; background: var(--bok-band); }
.bok-cite-text { margin-top: 0.4rem !important; font-size: 0.9rem; line-height: 1.55; }
.bok-cite-actions { display: flex; align-items: center; gap: 12px; margin-top: 0.8rem !important; font-size: 0.86rem; }
.bok-cite-actions a { font-weight: 600; border-bottom: 1px solid var(--bok-line-strong); }
.bok-cite-meta { margin-top: 0.8rem !important; font-size: 0.76rem; color: var(--bok-faint); }
.bok-cite-meta a { text-decoration: underline; }

/* ---------------------------------------------------------------- tables */
.bok-table { width: 100%; margin-top: 0.4rem; border-collapse: collapse; font-size: 0.88rem; }
/* Quarto's theme stripes and shades every table; these are plain reference tables. */
.bok .bok-table { --bs-table-bg: transparent; --bs-table-striped-bg: transparent; --bs-table-accent-bg: transparent; margin-bottom: 0; }
.bok .bok-table > :is(thead, tbody) > tr > :is(th, td) { background: transparent !important; box-shadow: none !important; color: inherit; }
.bok .bok-table tr { background: transparent !important; }
/* The site theme forces nowrap on table cells at phone width; reference tables must wrap. */
.bok .bok-table, .bok .bok-table :is(th, td) { white-space: normal !important; overflow: visible; }
.bok .bok-table td.bok-mono { white-space: nowrap !important; }
#quarto-content .bok .bok-section + .bok-table { margin-top: 0.4rem; }
.bok-table th { padding: 7px 10px; border-bottom: 1px solid var(--bok-line-strong); text-align: left; font-size: 0.78rem; font-weight: 600; color: var(--bok-muted); }
.bok-table td { padding: 8px 10px; border-bottom: 1px solid var(--bok-line); vertical-align: top; }
.bok-table td:first-child { white-space: normal; min-width: 9rem; }
.bok-table td.bok-mono { min-width: 0; width: 4.5rem; white-space: nowrap; }
.bok-table td.bok-mono + td { min-width: 12rem; }
.bok-table td a { font-weight: 550; }
.bok-table td a:hover { color: var(--bok-accent); }
.bok-table .bok-num { text-align: right; font-variant-numeric: tabular-nums; }
.bok-tag { margin-left: 4px; padding: 0 6px; border: 1px dashed var(--bok-line-strong); border-radius: 999px; font-size: 0.68rem; font-weight: 400; color: var(--bok-muted); }
.bok-rels td:first-child { width: 45%; }
.bok-rels b { font-weight: 650; }
.bok-rels tr.bok-group-start td { border-top: 1px solid var(--bok-line-strong); }
.bok-rels td:last-child { color: var(--bok-muted); font-size: 0.82rem; }

/* ----------------------------------------------------------- entry pages */
.bok-entry-main { min-width: 0; }
.bok-entry-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 36px; margin-top: 1.4rem; }
.bok-tree { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 96px); overflow-y: auto; padding-right: 8px; font-size: 0.84rem; }
.bok-tree-box summary { display: none; }
.bok-tree-group { margin: 1rem 0 0.3rem !important; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--bok-faint); }
.bok-tree-box > .bok-tree-group:first-of-type { margin-top: 0 !important; }
.bok-tree ul { list-style: none; }
.bok-tree li a { display: block; padding: 3px 6px; border-left: 2px solid transparent; border-radius: 0 4px 4px 0; color: var(--bok-muted); }
.bok-tree li a:hover { color: var(--bok-ink); }
.bok-tree li a.is-open { color: var(--bok-ink); font-weight: 600; }
.bok-tree li a[aria-current="page"] { border-left-color: var(--bok-accent); background: var(--bok-accent-soft); color: var(--bok-ink); font-weight: 600; }
.bok-tree li ul { margin: 2px 0 6px 10px !important; }
.bok-tree .bok-code { margin-right: 0.4em; }
.bok-crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.82rem; color: var(--bok-faint); }
.bok-crumbs a { color: var(--bok-muted); }
.bok-crumbs a:hover { color: var(--bok-accent); }
.bok-entry-head { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 28px; margin-top: 0.8rem; }
.bok-entry-head:has(> :only-child) { grid-template-columns: minmax(0, 1fr); }
.bok-lead { max-width: 46rem; margin-top: 0.6rem !important; font-size: 1.05rem; line-height: 1.6; }
.bok-text { max-width: 46rem; margin-top: 0.5rem !important; font-size: 0.9rem; color: var(--bok-muted); }
.bok-text-label, .bok-facts-label { display: block; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--bok-faint); }
.bok-text-label { margin-top: 1rem !important; }
.bok-aliases { margin-top: 0.3rem !important; font-size: 0.86rem; color: var(--bok-faint); }
.bok-facts { align-self: start; padding: 12px 14px; border: 1px solid var(--bok-line-strong); border-radius: 6px; font-size: 0.86rem; }
.bok-facts p + p { margin-top: 0.6rem !important; padding-top: 0.6rem !important; border-top: 1px solid var(--bok-line); }
.bok-facts a { font-weight: 550; }
.bok-facts a:hover { color: var(--bok-accent); }
.bok-list { margin: 0.4rem 0 0 1.1rem !important; max-width: 46rem; font-size: 0.88rem; color: var(--bok-muted); }
.bok-list li { margin: 0.2rem 0; }
.bok-list a { color: var(--bok-ink); font-weight: 550; }
.bok-list a:hover { color: var(--bok-accent); }
#quarto-content .bok .bok-section { margin-top: 1.8rem; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--bok-faint); }

/* The concept map sits in the page as a figure, at full text size. */
.bok-mapbox { margin-top: 1.6rem; padding: 12px 0 8px; border-top: 1px solid var(--bok-line); border-bottom: 1px solid var(--bok-line); }
.bok-canvas { width: 100%; height: 320px; }
.bok-mapbox figcaption { margin-top: 0.4rem; font-size: 0.78rem; color: var(--bok-faint); text-align: center; }
.bok-relate { margin-top: 0.4rem; }
.bok-picker { position: relative; max-width: 380px; margin-top: 0.5rem; }
.bok-picker input, .bok-gloss-bar input, .bok-gloss-bar select { width: 100%; height: 34px; padding: 0 12px; border: 1px solid var(--bok-line-strong); border-radius: 6px; background: var(--bok-surface); color: var(--bok-ink); font: inherit; font-size: 0.86rem; }
.bok-path { margin-top: 1rem; }
.bok-path ol { margin: 0.3rem 0 0 1.2rem !important; }
.bok-path li { padding: 5px 0; font-size: 0.92rem; }
.bok-path a { font-weight: 600; }
.bok-path a:hover, .bok-trail a:hover { color: var(--bok-accent); }
.bok-verb { margin: 0 0.25rem; color: var(--bok-muted); font-style: italic; }
.bok-cond { margin-top: 2px !important; font-size: 0.8rem; color: var(--bok-faint); }
.bok-trail { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 1.6rem !important; font-size: 0.84rem; color: var(--bok-faint); }
.bok-trail > span:first-child { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.bok-trail a { color: var(--bok-ink); }
.bok-note { margin-top: 1.4rem !important; font-size: 0.76rem; color: var(--bok-faint); }

/* --------------------------------------------------------------- glossary */
.bok-glossary { margin-top: 1.4rem; }
.bok-gloss-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 1.2rem; }
.bok-gloss-bar input { flex: 1 1 260px; max-width: 380px; }
.bok-gloss-bar select { width: auto; }
.bok-gloss-count { margin-left: auto; font-size: 0.8rem; color: var(--bok-faint); font-variant-numeric: tabular-nums; }
.bok-jump { position: sticky; top: 64px; z-index: 5; display: flex; flex-wrap: wrap; gap: 2px; margin-top: 0.8rem; padding: 8px 0; background: var(--bok-page); border-bottom: 1px solid var(--bok-line); }
.bok-jump a { min-width: 26px; padding: 3px 6px; border-radius: 4px; text-align: center; font-size: 0.82rem; font-weight: 600; color: var(--bok-muted); }
.bok-jump a:hover { background: var(--bok-accent-soft); color: var(--bok-accent); }
.bok-jump a.is-empty { opacity: 0.3; pointer-events: none; }
.bok-gloss { margin-top: 0.4rem; }
.bok-gloss tbody { scroll-margin-top: 120px; }
.bok-gloss .bok-letter-row th { padding-top: 1.2rem; border-bottom: 1px solid var(--bok-line-strong); font-size: 1rem; font-weight: 700; color: var(--bok-faint); }
.bok-gloss td:first-child { width: 26%; }
.bok-gloss td:last-child { width: 4.5rem; text-align: right; }
.bok-gloss .bok-alias { display: block; margin-top: 2px; font-size: 0.74rem; color: var(--bok-faint); }
.bok-term { scroll-margin-top: 130px; transition: background 0.4s; }
.bok-term.is-focus { background: var(--bok-accent-soft); }

/* ------------------------------------------------------------------ about */
.bok-about { max-width: 46rem; margin-top: 0.8rem; }
.bok-about summary { cursor: pointer; font-size: 0.88rem; font-weight: 600; color: var(--bok-muted); }
.bok-about summary:hover { color: var(--bok-ink); }
.bok-about-body { display: grid; gap: 0.7rem; max-width: 50rem; margin-top: 0.9rem; font-size: 0.88rem; color: var(--bok-muted); }
.bok-known-gaps ul { margin: 0.3rem 0 0 1.1rem !important; columns: 2 260px; }
.bok-known-gaps a { text-decoration: underline; text-decoration-color: var(--bok-line-strong); }
.bok-known-gaps ul.bok-cases { columns: 1; }
.bok-known-gaps li { break-inside: avoid; }
.bok-known-gaps p + ul + p { margin-top: 0.7rem; }
.bok-method { font-size: 0.76rem; color: var(--bok-faint); }
.bok-print-outline { display: none; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .bok-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 10px; }
}
@media (max-width: 900px) {
  .bok-entry-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .bok-tree { position: static; max-height: none; padding: 0; }
  .bok-tree-box summary { display: block; padding: 8px 0; cursor: pointer; font-size: 0.86rem; font-weight: 600; color: var(--bok-muted); border-bottom: 1px solid var(--bok-line); }
  .bok-entry-head { grid-template-columns: minmax(0, 1fr); }
  .bok-release-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .bok { padding: 1.6rem 16px 3rem; }
  .bok-kbd { display: none; }
  .bok-views { width: 100%; justify-content: space-between; }
  .bok-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bok-table, .bok-table tbody, .bok-table tr, .bok-table td { display: block; width: 100% !important; }
  .bok-table thead { display: none; }
  .bok-table tr { padding: 8px 0; border-bottom: 1px solid var(--bok-line); }
  .bok-table td { padding: 2px 0; border: 0; text-align: left !important; }
  .bok-gloss-count { margin-left: 0; }
  .bok-picker { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bok * { transition: none !important; }
}

/* Print / Save as PDF: the full outline only. */
@media print {
  body.bok-printing :is(#quarto-header, .quarto-announcement, .alert-primary, footer, .nav-footer) { display: none !important; }
  body.bok-printing .bok > :not(.bok-print-outline) { display: none !important; }
  body.bok-printing .bok-print-outline { display: block; font-size: 10.5pt; }
  body.bok-printing .bok-print-outline h2 { font-size: 18pt; margin-bottom: 8pt; }
  body.bok-printing .bok-print-outline h3 { margin-top: 14pt; font-size: 13pt; border-bottom: 1.5pt solid #000; }
  body.bok-printing .bok-print-outline h4 { margin-top: 10pt; font-size: 11pt; break-after: avoid; }
  body.bok-printing .bok-print-outline dt { margin-top: 5pt; font-weight: 600; break-after: avoid; }
  body.bok-printing .bok-print-outline dd { margin: 0 0 0 12pt; break-inside: avoid; }
  body.bok-printing .bok { padding: 0; max-width: none; }
}
