/* ---------- 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-kubernetes { color: #3fb950; }
.terminal .r-host { color: #d29922; }
.terminal .r-in-container { color: #39c5cf; }
.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; }
}
