/* ---------- Palette ---------- */
:root {
  --md-primary-fg-color: #0d1117;
  --md-primary-fg-color--light: #161b22;
  --md-primary-fg-color--dark: #010409;
  --md-primary-bg-color: #c9d1d9;
  --md-primary-bg-color--light: #8b949e;
  --stk-green: #2da44e;
  --stk-cyan: #1b7c83;
  --stk-amber: #9a6700;
  --stk-red: #cf222e;
  --stk-muted: #57606a;
  --stk-line: #d0d7de;
  --stk-panel: #f6f8fa;
  --stk-term-bg: #0d1117;
  --stk-term-fg: #c9d1d9;
  --stk-l0: #eaeef2;
  --stk-l1: #b6e3c4;
  --stk-l2: #57c27a;
  --stk-l3: #1a7f37;
}

[data-md-color-scheme="slate"] {
  --md-default-bg-color: #0d1117;
  --md-default-fg-color--light: #8b949e;
  --md-code-bg-color: #161b22;
  --md-typeset-a-color: #39c5cf;
  --md-accent-fg-color: #3fb950;
  --stk-green: #3fb950;
  --stk-cyan: #39c5cf;
  --stk-amber: #d29922;
  --stk-red: #f85149;
  --stk-muted: #8b949e;
  --stk-line: #30363d;
  --stk-panel: #161b22;
  --stk-l0: #161b22;
  --stk-l1: #0e4429;
  --stk-l2: #006d32;
  --stk-l3: #26a641;
}

[data-md-color-scheme="default"] {
  --md-typeset-a-color: #1b7c83;
  --md-accent-fg-color: #2da44e;
}

/* ---------- Header / tabs ---------- */
.md-header,
.md-tabs {
  background-color: #0d1117;
  color: #c9d1d9;
}
.md-header { border-bottom: 1px solid #30363d; box-shadow: none; }
.md-tabs { border-bottom: 1px solid #30363d; }
.md-tabs__link--active, .md-tabs__link:hover { color: #3fb950; }
.md-header__title { font-family: var(--md-code-font-family); font-weight: 600; }
.md-header__topic:first-child::before { content: ">_ "; color: #3fb950; }

/* ---------- Typography ---------- */
.md-typeset h1, .md-typeset h2, .md-typeset h3, .md-typeset h4 {
  font-family: var(--md-code-font-family);
  letter-spacing: -0.01em;
}
.md-typeset h1 { font-weight: 700; color: var(--md-default-fg-color); }
.md-typeset h2 { border-bottom: 1px solid var(--stk-line); padding-bottom: .25em; }
.md-typeset h2::before { content: "## "; color: var(--stk-green); opacity: .7; }
.md-typeset h3::before { content: "### "; color: var(--stk-green); opacity: .5; }
.md-typeset code { border-radius: 4px; }
.md-nav__title, .md-nav__link { font-family: var(--md-code-font-family); font-size: .66rem; }

/* ---------- Layer bar ---------- */
.stackbar {
  display: grid;
  grid-template-columns: repeat(9, 1fr) 0.9fr 0.9fr;
  gap: 3px;
  margin: .2em 0 .8em;
  font-family: var(--md-code-font-family);
}
.md-typeset .stackbar .seg {
  display: block;
  padding: .3em .2em;
  border: 1px solid var(--stk-line);
  border-radius: 3px;
  background: var(--stk-panel);
  color: var(--stk-muted);
  font-size: .55rem;
  line-height: 1.25;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.md-typeset .stackbar .seg span { display: block; font-weight: 700; font-size: .62rem; }
.md-typeset .stackbar .seg.on {
  background: var(--stk-green);
  border-color: var(--stk-green);
  color: #0d1117;
}
.md-typeset .stackbar .seg.extra { border-style: dashed; }
.md-typeset .stackbar .seg:hover { border-color: var(--stk-cyan); color: var(--stk-cyan); }
.md-typeset .stackbar .seg.on:hover { color: #0d1117; }

/* ---------- Badges ---------- */
.badges { display: flex; gap: .4em; margin: 0 0 1.2em; }
.md-typeset .badge {
  display: inline-block;
  font-family: var(--md-code-font-family);
  font-size: .6rem;
  font-weight: 600;
  padding: .1em .6em;
  border-radius: 2em;
  border: 1px solid currentColor;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.md-typeset .badge::before { content: "● "; }
.md-typeset .badge.m-concept { color: var(--stk-muted); }
.md-typeset .badge.m-implemented { color: var(--stk-cyan); }
.md-typeset .badge.m-lab-tested { color: var(--stk-amber); }
.md-typeset .badge.m-gpu-validated { color: var(--stk-green); }
.md-typeset .badge.stub { color: var(--stk-muted); border-style: dashed; }
.md-typeset .badge.stub::before { content: "○ "; }
.maturity-legend { list-style: none; padding-left: 0 !important; }
.md-typeset .maturity-legend li { margin-left: 0; }

/* ---------- Terminal ---------- */
.terminal {
  background: var(--stk-term-bg);
  border: 1px solid #30363d;
  border-radius: 8px;
  margin: 1em 0 1.5em;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
.term-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
}
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: #f85149; }
.term-bar i:nth-child(2) { background: #d29922; }
.term-bar i:nth-child(3) { background: #3fb950; }
.term-bar span {
  margin-left: 10px;
  color: #8b949e;
  font-family: var(--md-code-font-family);
  font-size: .62rem;
}
.md-typeset .terminal pre {
  margin: 0;
  padding: 1em 1.2em;
  background: transparent;
  color: var(--stk-term-fg);
  font-family: var(--md-code-font-family);
  font-size: .64rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}
.terminal .prompt { color: #3fb950; font-weight: 600; }
.terminal .path { color: #58a6ff; }
.terminal .cmd { color: #f0f6fc; }
.terminal .hdr { color: #8b949e; }
.terminal .role { color: #d2a8ff; }
.terminal .r-cluster { color: #3fb950; }
.terminal .r-node { color: #d29922; }
.terminal .r-container { color: #39c5cf; }
.terminal .r-external { color: #d2a8ff; }
.md-typeset .term-note { font-size: 0.68rem; color: var(--md-default-fg-color--light); margin-top: -0.6em; }
.md-typeset .term-note em { color: #d29922; font-style: normal; font-family: var(--md-code-font-family); }
.terminal .cursor { color: #3fb950; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Hero ---------- */
.hero-tag {
  font-family: var(--md-code-font-family);
  color: var(--stk-green);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-bottom: 0;
}
.md-typeset .hero-title { font-size: 2rem; margin: .2em 0 .3em; }
.md-typeset .hero-title::before { content: none; }
.hero-sub { font-size: .9rem; color: var(--md-default-fg-color--light); max-width: 46em; }

/* ---------- Matrix ---------- */
.matrix-wrap { overflow-x: auto; margin: 1em 0 .5em; }
.md-typeset table.stack-matrix {
  display: table;
  border: none;
  border-collapse: separate;
  border-spacing: 3px;
  font-family: var(--md-code-font-family);
  font-size: .62rem;
  background: transparent;
}
.md-typeset .stack-matrix th,
.md-typeset .stack-matrix td {
  padding: 0;
  border: none;
  background: transparent;
  text-align: center;
  vertical-align: middle;
}
.md-typeset .stack-matrix thead th a {
  display: block;
  white-space: nowrap;
  padding: .35em .5em;
  color: var(--stk-muted);
  font-weight: 700;
}
.md-typeset .stack-matrix thead th.corner {
  text-align: left;
  color: var(--stk-muted);
  font-weight: 400;
  padding-right: 1em;
}
.md-typeset .stack-matrix th.rowh { text-align: left; padding-right: 1em; white-space: nowrap; }
.md-typeset .stack-matrix th.rowh a { color: var(--md-default-fg-color); font-weight: 600; }
.md-typeset .stack-matrix th.rowh a::before { content: "› "; color: var(--stk-green); }
.md-typeset .stack-matrix .cell {
  display: block;
  min-width: 4.2em;
  padding: .45em .2em;
  border-radius: 3px;
  font-size: .55rem;
  letter-spacing: -.05em;
  color: transparent;
  transition: transform .1s, outline-color .1s;
  outline: 1px solid transparent;
}
.md-typeset .stack-matrix .cell.lvl-0 { background: var(--stk-l0); color: var(--stk-muted); }
.md-typeset .stack-matrix .cell.lvl-1 { background: var(--stk-l1); }
.md-typeset .stack-matrix .cell.lvl-2 { background: var(--stk-l2); }
.md-typeset .stack-matrix .cell.lvl-3 { background: var(--stk-l3); }
.md-typeset .stack-matrix .cell:hover { outline-color: var(--stk-cyan); transform: scale(1.08); }
.md-typeset .stack-matrix tr:hover th.rowh a { color: var(--stk-cyan); }
.md-typeset .stack-matrix .col-hl a { color: var(--stk-cyan) !important; }
.md-typeset .stack-matrix td.col-hl .cell { outline-color: var(--stk-line); }
.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2em;
  font-family: var(--md-code-font-family);
  font-size: .6rem;
  color: var(--stk-muted);
}
.matrix-legend span { display: flex; align-items: center; gap: .4em; }
.matrix-legend i.cell {
  display: inline-block;
  width: 18px;
  height: 12px;
  border-radius: 2px;
  font-style: normal;
  font-size: 0;
}
.matrix-legend i.lvl-0 { background: var(--stk-l0); border: 1px solid var(--stk-line); }
.matrix-legend i.lvl-1 { background: var(--stk-l1); }
.matrix-legend i.lvl-2 { background: var(--stk-l2); }
.matrix-legend i.lvl-3 { background: var(--stk-l3); }

/* ---------- Cards / admonitions ---------- */
.md-typeset .grid.cards > ul > li,
.md-typeset .grid > .card {
  border: 1px solid var(--stk-line);
  border-radius: 6px;
  background: var(--stk-panel);
}
.md-typeset .grid.cards > ul > li:hover { border-color: var(--stk-green); box-shadow: none; }
.md-typeset .admonition, .md-typeset details {
  border-radius: 4px;
  font-size: .72rem;
}
.md-typeset .admonition.abstract,
.md-typeset details.abstract { border-color: var(--stk-line); }

/* ---------- Home cards: four across on wide screens ---------- */
@media screen and (min-width: 76.25em) {
  .md-typeset .grid.cards.four { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Clickable stack map ---------- */
.stackmap { margin: 1.2em 0 1.6em; }
.sm-grid {
  display: grid;
  grid-template-columns: 7.5em minmax(0, 1fr) 12em;
  column-gap: 12px;
  row-gap: 6px;
}
.sm-plane {
  grid-column: 1;
  display: flex;
  align-items: center;
  border-right: 2px solid var(--stk-line);
  padding-right: 10px;
  font-family: var(--md-code-font-family);
  font-size: .62rem;
  font-weight: 700;
  color: var(--stk-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.plane-start { margin-top: 14px; }
.md-typeset a.sm-layer {
  grid-column: 2;
  display: flex;
  align-items: stretch;
  border: 1px solid var(--stk-line);
  border-radius: 6px;
  background: var(--stk-panel);
  color: var(--md-default-fg-color);
  transition: border-color .12s, transform .12s;
}
.md-typeset a.sm-layer.dashed { border-style: dashed; background: transparent; }
.md-typeset a.sm-layer:hover { border-color: var(--stk-cyan); transform: translateX(3px); }
.sm-num {
  flex: 0 0 3.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--stk-line);
  font-family: var(--md-code-font-family);
  font-weight: 700;
  font-size: .7rem;
  color: var(--stk-green);
}
.sm-text { display: flex; flex-direction: column; padding: .45em .8em; min-width: 0; }
.sm-name { font-weight: 600; font-size: .74rem; line-height: 1.3; }
.sm-ex {
  font-size: .62rem;
  color: var(--stk-muted);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.md-typeset a.sm-cp {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 2px solid var(--stk-cyan);
  border-radius: 8px;
  background: color-mix(in srgb, var(--stk-cyan) 10%, transparent);
  color: var(--md-default-fg-color);
  padding: 1em .6em;
  transition: background .12s;
}
.md-typeset a.sm-cp:hover { background: color-mix(in srgb, var(--stk-cyan) 18%, transparent); }
.sm-cp-name { font-family: var(--md-code-font-family); font-weight: 700; font-size: .8rem; }
.sm-cp-sub { font-size: .62rem; color: var(--stk-muted); margin-bottom: .6em; }
.md-typeset .sm-cp ul { list-style: none; margin: 0; padding: 0; font-size: .64rem; line-height: 1.55; }
.md-typeset .sm-cp ul li { margin: 0; }
.md-typeset a.sm-cross {
  display: block;
  margin-top: 12px;
  padding: .7em 1em;
  border: 1px solid var(--stk-line);
  border-radius: 6px;
  background: var(--stk-panel);
  text-align: center;
  font-size: .7rem;
  color: var(--md-default-fg-color);
}
.md-typeset a.sm-cross:hover { border-color: var(--stk-cyan); }
@media screen and (max-width: 44.9375em) {
  .sm-grid { grid-template-columns: minmax(0, 1fr); }
  .sm-plane { display: none; }
  .md-typeset a.sm-layer, .md-typeset a.sm-cp { grid-column: 1; grid-row: auto !important; }
  .plane-start { margin-top: 6px; }
  .md-typeset a.sm-cp { margin-top: 10px; }
}

/* Author profile card */
.author-card { text-align: center; margin: 0.5em 0 2.2em; }
.author-card::after {
  content: ""; display: block; width: 72px; height: 2px; margin: 1.4em auto 0;
  background: linear-gradient(90deg, #3fb950, #39c5cf);
  border-radius: 2px;
}
.author-ring {
  position: relative; width: 196px; height: 196px; margin: 0 auto 1.1em;
  border-radius: 50%;
  box-shadow: 0 0 28px rgba(57, 197, 207, 0.28), 0 0 60px rgba(63, 185, 80, 0.12);
}
.author-ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(#3fb950, #39c5cf, #1f6feb, #39c5cf, #3fb950);
  animation: author-spin 9s linear infinite;
}
.author-ring p { margin: 0; }
.md-typeset .author-ring img {
  position: relative; z-index: 1; display: block;
  width: 188px; height: 188px; margin: 4px;
  border-radius: 50%; object-fit: cover; object-position: 50% 30%;
  border: 4px solid var(--md-default-bg-color);
  transition: transform 0.4s ease;
}
.md-typeset .author-ring:hover img { transform: scale(1.04); }
.md-typeset .author-name {
  margin: 0; font-size: 1.6em; font-weight: 700; letter-spacing: 0.01em;
  color: var(--md-default-fg-color);
}
.md-typeset .author-role { margin: 0.2em 0 0.5em; color: var(--md-default-fg-color--light); }
.md-typeset .author-tag {
  margin: 0; font-family: var(--md-code-font-family); font-size: 0.82em; color: #3fb950;
}
.author-tag .caret {
  display: inline-block; width: 0.55em; height: 1.05em; margin-left: 0.25em;
  vertical-align: text-bottom; background: #3fb950;
  animation: author-blink 1.1s steps(1) infinite;
}
@keyframes author-spin { to { transform: rotate(360deg); } }
@keyframes author-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .author-ring::before, .author-tag .caret { animation: none; }
}

/* Diagram viewer */
.md-typeset div.mermaid { cursor: zoom-in; border-radius: 6px; transition: box-shadow 0.2s; }
.md-typeset div.mermaid:hover,
.md-typeset div.mermaid:focus-visible { box-shadow: 0 0 0 1px #39c5cf55, 0 0 18px #39c5cf22; outline: none; }
.md-typeset .dgv-hint {
  font-family: var(--md-code-font-family); font-size: 0.68rem; text-align: right;
  color: #39c5cf; opacity: 0.8; margin: 0.6em 0 -0.6em;
}
.md-typeset .diagram-desc {
  font-size: 0.72rem; color: var(--md-default-fg-color--light);
  border-left: 2px solid #3fb950; padding-left: 0.8em; margin-top: 0.4em;
}
html.dgv-open { overflow: hidden; }
.dgv[hidden] { display: none; }
.dgv { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.dgv-backdrop { position: absolute; inset: 0; background: rgba(1, 4, 9, 0.82); backdrop-filter: blur(3px); }
.dgv-window {
  position: relative; display: flex; flex-direction: column;
  width: min(1400px, 94vw); max-height: 92vh;
  background: #0d1117; border: 1px solid #39c5cf66; border-radius: 10px;
  box-shadow: 0 0 0 1px #3fb95022, 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px #39c5cf1a;
  animation: dgv-in 0.18s ease-out;
}
.dgv-bar {
  display: flex; align-items: center; gap: 0.8em; padding: 0.55em 0.9em;
  background: #161b22; border-bottom: 1px solid #30363d; border-radius: 10px 10px 0 0;
  font-family: var(--md-code-font-family, monospace); font-size: 0.75rem;
}
.dgv-dots { display: inline-flex; gap: 6px; }
.dgv-dots i { width: 11px; height: 11px; border-radius: 50%; background: #f85149; }
.dgv-dots i:nth-child(2) { background: #d29922; }
.dgv-dots i:nth-child(3) { background: #3fb950; }
.dgv-title { flex: 1; color: #3fb950; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dgv-close {
  font: inherit; color: #c9d1d9; background: transparent; cursor: pointer;
  border: 1px solid #30363d; border-radius: 6px; padding: 0.25em 0.7em;
}
.dgv-close:hover, .dgv-close:focus-visible { border-color: #f85149; color: #f85149; outline: none; }
.dgv-close kbd { font: inherit; opacity: 0.6; margin-left: 0.3em; }
.dgv-body { overflow: auto; padding: 1.4em; flex: 1; background:
  radial-gradient(circle at 1px 1px, #ffffff0d 1px, transparent 0) 0 0 / 22px 22px; }
.dgv-body div.mermaid { cursor: default; box-shadow: none; }
.dgv-desc {
  padding: 0.75em 1.1em; border-top: 1px solid #30363d; color: #8b949e;
  font-size: 0.78rem; line-height: 1.5;
}
.dgv-desc::before { content: "// "; color: #3fb950; font-family: var(--md-code-font-family, monospace); }
.dgv-desc[hidden] { display: none; }
@keyframes dgv-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .dgv-window { animation: none; } }
.dgv-body div.mermaid { text-align: center; }
@media (max-width: 700px) {
  .dgv-window { width: 96vw; max-height: 88vh; }
  .dgv-body { padding: 0.8em; }
  .dgv-body div.mermaid { min-width: 860px; }
}

/* ---- Tech touches ------------------------------------------------------- */

/* 1. Reading progress line */
.k-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 10;
  background: linear-gradient(90deg, #3fb950, #39c5cf);
  transform: scaleX(0); transform-origin: 0 50%;
  box-shadow: 0 0 8px #39c5cf88;
  pointer-events: none;
}

/* 2. Terminal status bar */
.k-status {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; height: 22px;
  display: flex; align-items: center; gap: 0; overflow: hidden;
  font-family: var(--md-code-font-family); font-size: 11px; line-height: 22px;
  background: #161b22; color: #8b949e; border-top: 1px solid #30363d;
}
.k-status > span { padding: 0 0.9em; white-space: nowrap; border-right: 1px solid #30363d; }
.k-status .ks-mode { background: #3fb950; color: #0d1117; font-weight: 700; border-right: 0; }
.k-status .ks-path { color: #c9d1d9; flex: 1; overflow: hidden; text-overflow: ellipsis; border-right: 0; }
.k-status .ks-layers { color: #39c5cf; }
.k-status .ks-maturity { color: #d29922; }
.k-status .ks-pos { color: #c9d1d9; min-width: 4.5em; text-align: right; border-right: 0; }
.md-footer { margin-bottom: 22px; }
@media (max-width: 600px) {
  .k-status .ks-layers, .k-status .ks-maturity, .k-status .ks-read { display: none; }
}
@media print { .k-status, .k-progress { display: none; } }

/* 4. Code blocks as terminal windows */
.md-typeset .highlight .k-codebar {
  display: flex; align-items: center; gap: 0.8em; padding: 0.35em 0.9em;
  background: #161b22; border: 1px solid #30363d; border-bottom: 0;
  border-radius: 6px 6px 0 0;
  font-family: var(--md-code-font-family); font-size: 0.68rem; color: #8b949e;
}
.md-typeset .highlight .k-codebar .dgv-dots i { width: 9px; height: 9px; }
.md-typeset .highlight .k-codebar + pre,
.md-typeset .highlight .k-codebar ~ pre { margin-top: 0; }
.md-typeset .highlight .k-codebar ~ pre > code { border-radius: 0 0 6px 6px; border: 1px solid #30363d; border-top: 0; }

/* 5. Copied toast (ours) and Material's own copy dialog, terminal style */
.k-toast, .md-dialog {
  font-family: var(--md-code-font-family);
  background: #0d1117 !important; color: #3fb950 !important;
  border: 1px solid #3fb95066; border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 16px #3fb9501f;
}
.md-dialog { bottom: 34px; }
.md-dialog__inner { color: #3fb950; font-size: 0.72rem; }
.md-dialog__inner::before { content: "✓ "; }
.k-toast {
  position: fixed; right: 1.2rem; bottom: 34px; z-index: 1001;
  padding: 0.55em 0.95em; font-size: 0.72rem;
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.k-toast.show { opacity: 1; transform: none; }

/* 3. Keyboard help panel (reuses the diagram window styles) */
.k-help-window { width: min(440px, 92vw); }
.k-help-body { padding: 1em 1.2em 1.2em; display: grid; gap: 0.55em; }
.k-help-row { display: flex; gap: 1em; align-items: baseline; font-size: 0.78rem; color: #c9d1d9; }
.k-help-row kbd {
  min-width: 7.5em; font-family: var(--md-code-font-family); font-size: 0.72rem;
  color: #3fb950; background: #161b22; border: 1px solid #30363d; border-radius: 4px;
  padding: 0.1em 0.5em; box-shadow: none;
}

/* 7. Terminal 404 */
.k-404 { max-width: 760px; margin: 2rem auto 4rem; }
.k-404-win { border: 1px solid #39c5cf55; border-radius: 10px; overflow: hidden;
  box-shadow: 0 0 40px #39c5cf14; background: #0d1117; }
.k-404-bar { display: flex; gap: 0.8em; align-items: center; padding: 0.5em 0.9em;
  background: #161b22; border-bottom: 1px solid #30363d;
  font-family: var(--md-code-font-family); font-size: 0.72rem; color: #8b949e; }
.md-typeset pre.k-404-body, pre.k-404-body {
  margin: 0; padding: 1.2em 1.4em; background: transparent; color: #c9d1d9;
  font-family: var(--md-code-font-family); font-size: 0.8rem; line-height: 1.8; white-space: pre-wrap; }
.k-404-body .p { color: #3fb950; } .k-404-body .d { color: #39c5cf; }
.k-404-body a { color: #39c5cf; }
.k-404-body .caret { display: inline-block; width: 0.55em; height: 1.05em; margin-left: 0.2em;
  vertical-align: text-bottom; background: #3fb950; animation: author-blink 1.1s steps(1) infinite; }
.k-404-note { text-align: center; color: #8b949e; font-family: var(--md-code-font-family); font-size: 0.72rem; margin-top: 1.2em; }

/* 9. Selection and scrollbars */
::selection { background: #3fb95055; color: inherit; }
* { scrollbar-width: thin; scrollbar-color: #30363d transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #3fb95099; }
::-webkit-scrollbar-track { background: transparent; }
[data-md-color-scheme="default"] .md-typeset .highlight .k-codebar { background: #f6f8fa; border-color: #d0d7de; color: #57606a; }
[data-md-color-scheme="default"] .md-typeset .highlight .k-codebar ~ pre > code { border-color: #d0d7de; }

/* ---- Same chassis, different cars ------------------------------------------- */
.md-typeset .chassis-scene {
  margin: 1.6em 0 2em; background: #0d1117; border: 1px solid #39c5cf44; border-radius: 10px;
  overflow: hidden; box-shadow: 0 0 0 1px #3fb9501a, 0 12px 40px rgba(0, 0, 0, 0.35), 0 0 36px #39c5cf14;
}
.md-typeset .chassis-bar {
  display: flex; align-items: center; gap: 0.8em; padding: 0.5em 0.9em;
  background: #161b22; border-bottom: 1px solid #30363d;
  font-family: var(--md-code-font-family); font-size: 0.68rem; color: #8b949e;
}
.md-typeset .chassis-note {
  margin-left: auto; color: #d29922; border: 1px solid #d2992255; border-radius: 4px;
  padding: 0 0.5em; font-size: 0.62rem; letter-spacing: 0.04em;
}
.md-typeset pre.chassis-art {
  margin: 0; padding: 1.1em 1.2em 1.2em; overflow-x: auto; background:
    radial-gradient(circle at 1px 1px, #ffffff0a 1px, transparent 0) 0 0 / 18px 18px, #0d1117;
  color: #8b949e; font-family: var(--md-code-font-family); font-size: 0.6rem; line-height: 1.4;
}
.chassis-art .c-dim { color: #6e7681; }
.chassis-art .c-cmd { color: #c9d1d9; }
.chassis-art .c-green { color: #3fb950; }
.chassis-art .c-amber { color: #d29922; }
.chassis-art .c-red { color: #f85149; }
.chassis-art .c-car-fast { color: #39c5cf; text-shadow: 0 0 6px #39c5cf66; }
.chassis-art .c-car-slow { color: #8b949e; }
.chassis-art .c-chassis {
  background: linear-gradient(90deg, #3fb950, #39c5cf 50%, #3fb950);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.chassis-art .c-chassis-txt { color: #c9d1d9; }
.chassis-art .c-speed, .chassis-art .c-smoke, .chassis-art .c-gauge, .chassis-art .c-gauge-low {
  display: inline-block;
}
.chassis-art .c-speed { color: #39c5cf; animation: chassis-speed 0.9s linear infinite; }
.chassis-art .c-speed.s3 { animation-delay: 0.15s; }
.chassis-art .c-speed.s4 { animation-delay: 0.3s; }
.chassis-art .c-smoke { color: #6e7681; animation: chassis-smoke 2.4s ease-in-out infinite; }
.chassis-art .c-smoke.m4 { animation-delay: 0.6s; }
.chassis-art .c-gauge { color: #3fb950; text-shadow: 0 0 6px #3fb95066; animation: chassis-fill 1.8s ease-out both; }
.chassis-art .c-gauge-low { color: #d29922; animation: chassis-fill 1.8s ease-out both; }
.chassis-art .c-cursor { color: #3fb950; animation: author-blink 1.1s steps(1) infinite; }
@keyframes chassis-speed {
  0% { opacity: 0.25; transform: translateX(4px); }
  50% { opacity: 1; }
  100% { opacity: 0.25; transform: translateX(-4px); }
}
@keyframes chassis-smoke {
  0%, 100% { opacity: 0.2; transform: translateY(0); }
  50% { opacity: 0.9; transform: translateY(-3px); }
}
@keyframes chassis-fill { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) {
  .chassis-art .c-speed, .chassis-art .c-smoke, .chassis-art .c-gauge,
  .chassis-art .c-gauge-low, .chassis-art .c-cursor { animation: none; }
}

.md-typeset .chassis-teaser {
  font-family: var(--md-code-font-family); font-size: 0.72rem; color: #3fb950;
  border: 1px dashed #3fb95055; border-radius: 6px; padding: 0.5em 0.9em; margin: 1.2em 0;
}
.md-typeset .chassis-teaser a { color: #39c5cf; }
.md-typeset .chassis-bar > span:nth-child(2) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.md-typeset .chassis-note { flex-shrink: 0; }

/* Chassis scene as a clickable diagram */
.md-typeset .chassis-scene { cursor: zoom-in; transition: box-shadow 0.2s; }
.md-typeset .chassis-scene:hover,
.md-typeset .chassis-scene:focus-visible { outline: none; box-shadow: 0 0 0 1px #39c5cf77, 0 0 26px #39c5cf33; }
.dgv-body .chassis-scene { cursor: default; margin: 0 auto; border: 0; box-shadow: none; width: max-content; max-width: 100%; }
.dgv-body .chassis-scene .chassis-bar { display: none; }
.dgv-body pre.chassis-art { font-size: 0.82rem; background: transparent; }
@media (max-width: 700px) { .dgv-body pre.chassis-art { font-size: 0.66rem; } }

/* ---- Active-item markers ---------------------------------------------------- */
/* Left: current page gets a steady ▸; right: current section gets a blinking ▌;
   top: active tab gets a ▸. Markers sit outside the text so nothing shifts.      */
.md-nav--primary a.md-nav__link--active,
.md-nav--secondary a.md-nav__link--active,
.md-tabs__item--active .md-tabs__link { position: relative; overflow: visible; }

.md-nav--primary a.md-nav__link--active:not(.md-nav--secondary a)::before {
  content: "▸"; position: absolute; left: -0.95em; top: 50%; transform: translateY(-50%);
  color: currentColor; font-family: var(--md-code-font-family); font-size: 0.85em;
}

.md-nav--secondary a.md-nav__link--active::before {
  content: "▌"; position: absolute; left: -0.85em; top: 50%; transform: translateY(-50%);
  color: currentColor; font-family: var(--md-code-font-family); font-size: 0.9em;
  animation: author-blink 1.1s steps(1) infinite;
}

.md-tabs__item--active .md-tabs__link::before {
  content: "▸"; position: absolute; left: -0.9em; top: 50%; transform: translateY(-50%);
  color: #3fb950; font-family: var(--md-code-font-family); font-size: 0.85em;
}

@media (prefers-reduced-motion: reduce) {
  .md-nav--secondary a.md-nav__link--active::before { animation: none; }
}
/* Room for the TOC cursor inside the sidebar's scroll area */
.md-sidebar--secondary .md-nav--secondary > .md-nav__list { padding-left: 1em; }
/* Phone / tablet drawer: keep the page marker inside the drawer's padding */
@media screen and (max-width: 76.234375em) {
  .md-nav--primary a.md-nav__link--active:not(.md-nav--secondary a)::before { left: 0.25em; }
}
@media screen and (max-width: 76.234375em) {
  .md-nav--primary label.md-nav__link--active[for="__toc"] { position: relative; overflow: visible; }
  .md-nav--primary label.md-nav__link--active[for="__toc"]::before {
    content: "▸"; position: absolute; left: 0.25em; top: 50%; transform: translateY(-50%);
    color: currentColor; font-family: var(--md-code-font-family); font-size: 0.85em;
  }
}

/* "cd -" back link above the page title */
.md-typeset .k-back {
  display: flex; align-items: baseline; gap: 0.8em; flex-wrap: wrap;
  margin: 0 0 0.6em; font-family: var(--md-code-font-family); font-size: 0.68rem;
}
.md-typeset .k-back a {
  color: #3fb950; border: 1px solid #3fb95055; border-radius: 4px; padding: 0.05em 0.55em;
  transition: background 0.15s, border-color 0.15s;
}
.md-typeset .k-back a:hover, .md-typeset .k-back a:focus-visible {
  background: #3fb9501f; border-color: #3fb950; outline: none;
}
.md-typeset .k-back-to { color: var(--md-default-fg-color--light); }
.md-typeset .k-back-to em { font-style: normal; color: #39c5cf; }

/* ---- Trace a Request ---------------------------------------------------------- */
.k-trace { margin: 1.4em 0 0.4em; }
.k-trace .kt-picker { display: flex; flex-wrap: wrap; gap: 0.5em; margin-bottom: 0.8em; }
.k-trace .kt-picker .kt-pick {
  font-family: var(--md-code-font-family); font-size: 0.72rem; cursor: pointer;
  color: #c9d1d9; background: #161b22; border: 1px solid #30363d; border-radius: 6px;
  padding: 0.35em 0.9em; transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.k-trace .kt-picker .kt-pick:hover, .k-trace .kt-picker .kt-pick:focus-visible { border-color: #39c5cf; outline: none; }
.k-trace .kt-picker .kt-pick.on { color: #0d1117; background: #3fb950; border-color: #3fb950; font-weight: 700; }
.k-trace .kt-picker .kt-pick.on::before { content: "▸ "; }

.k-trace .kt-body { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: 0.9em; align-items: start; }
.k-trace .kt-term {
  background: #0d1117; border: 1px solid #39c5cf44; border-radius: 10px; overflow: hidden;
  box-shadow: 0 0 0 1px #3fb9501a, 0 12px 36px rgba(0, 0, 0, 0.3);
}
.k-trace .kt-term .kt-bar {
  display: flex; align-items: center; gap: 0.7em; flex-wrap: wrap; padding: 0.45em 0.8em;
  background: #161b22; border-bottom: 1px solid #30363d;
  font-family: var(--md-code-font-family); font-size: 0.66rem; color: #8b949e;
}
.k-trace .kt-bar .kt-title { color: #3fb950; }
.k-trace .kt-bar .kt-ctrls { display: inline-flex; gap: 0.35em; margin-left: auto; flex-wrap: wrap; }
.k-trace .kt-bar .kt-btn {
  font: inherit; color: #c9d1d9; background: transparent; cursor: pointer;
  border: 1px solid #30363d; border-radius: 5px; padding: 0.15em 0.55em;
}
.k-trace .kt-bar .kt-btn:hover, .k-trace .kt-bar .kt-btn:focus-visible { border-color: #3fb950; color: #3fb950; outline: none; }
.k-trace .kt-bar .kt-note { color: #d29922; border: 1px solid #d2992255; border-radius: 4px; padding: 0 0.45em; font-size: 0.6rem; }

.k-trace .kt-term pre.kt-out {
  margin: 0; padding: 1em 1.1em; min-height: 22em; max-height: 34em; overflow: auto;
  background: radial-gradient(circle at 1px 1px, #ffffff0a 1px, transparent 0) 0 0 / 18px 18px, #0d1117;
  color: #c9d1d9; font-family: var(--md-code-font-family); font-size: 0.66rem; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word; border: 0; box-shadow: none;
}
.k-trace .kt-out .kt-prompt { color: #3fb950; }
.k-trace .kt-out .kt-path { color: #39c5cf; }
.k-trace .kt-out .kt-cmd { color: #e6edf3; }
.k-trace .kt-out .kt-line { display: grid; grid-template-columns: 7.5em 9.5em minmax(0, 1fr); column-gap: 0.6em; }
.k-trace .kt-out .kt-tagwrap { color: #6e7681; }
.k-trace .kt-out a.kt-tag { color: #39c5cf; text-decoration: none; }
.k-trace .kt-out a.kt-tag:hover { text-decoration: underline; }
.k-trace .kt-out .kt-comp { color: #d2a8ff; }
.k-trace .kt-out .kt-dim { opacity: 0.45; }
.k-trace .kt-out .kt-dim a.kt-tag { color: #8b949e; }
.k-trace .kt-out .kt-cursor { color: #3fb950; animation: author-blink 1.1s steps(1) infinite; }

.k-trace .kt-map { display: flex; flex-direction: column; gap: 3px; }
.k-trace .kt-map a.kt-part {
  display: grid; grid-template-columns: 2.4em 1fr auto; align-items: center; gap: 0.4em;
  padding: 0.28em 0.55em; border: 1px solid #30363d; border-radius: 5px; background: #0d1117;
  font-family: var(--md-code-font-family); font-size: 0.62rem; color: #8b949e; text-decoration: none;
  transition: background 0.25s, border-color 0.25s, color 0.25s, box-shadow 0.25s;
}
.k-trace .kt-map a.kt-part[data-key="CP"], .k-trace .kt-map a.kt-part[data-key="XC"] { border-style: dashed; }
.k-trace .kt-map .kt-key { font-weight: 700; color: #6e7681; }
.k-trace .kt-map .kt-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-trace .kt-map .kt-state { font-size: 0.9em; color: #d29922; }
.k-trace .kt-map a.kt-part.seen { color: #c9d1d9; border-color: #3fb95077; background: #3fb95014; }
.k-trace .kt-map a.kt-part.seen .kt-key { color: #3fb950; }
.k-trace .kt-map a.kt-part.on { color: #0d1117; background: #39c5cf; border-color: #39c5cf; box-shadow: 0 0 14px #39c5cf88; }
.k-trace .kt-map a.kt-part.on .kt-key { color: #0d1117; }
.k-trace .kt-map a.kt-part.unused { opacity: 0.45; text-decoration: line-through; }

@media screen and (max-width: 60em) {
  .k-trace .kt-body { grid-template-columns: 1fr; }
  .k-trace .kt-map { order: -1; flex-direction: row; flex-wrap: wrap; }
  .k-trace .kt-map a.kt-part { grid-template-columns: auto; padding: 0.25em 0.5em; }
  .k-trace .kt-map .kt-name, .k-trace .kt-map .kt-state { display: none; }
  .k-trace .kt-out .kt-line { grid-template-columns: auto minmax(0, 1fr); margin-bottom: 0.35em; }
  .k-trace .kt-out .kt-text { grid-column: 1 / -1; padding-left: 1em; }
}

/* Trace inside the full-view pop-up */
.dgv-body .k-trace { margin: 0; }
.dgv-body .k-trace .kt-body { grid-template-columns: minmax(0, 1fr) 17rem; }
.dgv-body .k-trace .kt-term pre.kt-out { font-size: 0.8rem; max-height: none; min-height: 26em; }
.dgv-body .k-trace .kt-bar .kt-btn[data-a="full"] { display: none; }
@media screen and (max-width: 60em) { .dgv-body .k-trace .kt-body { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  .k-trace .kt-out .kt-cursor { animation: none; }
  .k-trace .kt-map a.kt-part { transition: none; }
}

/* Centred footer: copyright and disclaimer */
.md-footer-meta__inner { justify-content: center; }
.md-footer-meta .md-copyright { width: 100%; margin: 0 auto; text-align: center; padding: 0.5em 0; }
.md-copyright .k-disclaimer {
  display: inline-block; max-width: 46em; margin-top: 0.3em;
  font-size: 0.9em; line-height: 1.5; color: var(--md-footer-fg-color--lighter);
}
