/* ==========================================================================
   GPU by Example
   A book theme: quiet pages, loud code, green accents.
   ========================================================================== */

:root {
  --brand: #76b900;
  --brand-strong: #5a9100;
  --brand-soft: rgba(118, 185, 0, 0.1);
  --brand-line: rgba(118, 185, 0, 0.35);

  --bg: #ffffff;
  --bg-subtle: #f7f9f6;
  --surface: #ffffff;
  --surface-2: #f3f6f1;
  --ink: #14181d;
  --ink-2: #333d47;
  --ink-3: #66717d;
  --line: #e5e9e4;
  --line-strong: #d2d9d0;

  --link: #4a7a00;
  --link-hover: #335500;

  --code-bg: #0d1117;
  --code-bg-2: #11161d;
  --code-line: #1e2631;
  --code-fg: #e6edf3;
  --code-muted: #8b98a8;
  --code-green: #9be564;

  --inline-bg: #f1f6ec;
  --inline-fg: #31530a;

  --shadow-sm: 0 1px 2px rgba(15, 23, 20, 0.06);
  --shadow-md: 0 18px 50px -28px rgba(15, 23, 20, 0.35);

  --sidebar-w: 306px;
  --topbar-h: 58px;
  --content-w: 788px;
  --toc-w: 210px;

  --font-sans: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;

  color-scheme: light;
}

[data-theme="dark"] {
  --brand: #8ed10a;
  --brand-strong: #a8e05f;
  --brand-soft: rgba(142, 209, 10, 0.12);
  --brand-line: rgba(142, 209, 10, 0.4);

  --bg: #0e1217;
  --bg-subtle: #0b0f14;
  --surface: #131920;
  --surface-2: #161d25;
  --ink: #dde4ec;
  --ink-2: #b3becb;
  --ink-3: #8492a2;
  --line: #222a34;
  --line-strong: #303a47;

  --link: #a3dd4a;
  --link-hover: #c3f27a;

  --inline-bg: #1c2418;
  --inline-fg: #b9e77f;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 24px 60px -30px rgba(0, 0, 0, 0.8);

  color-scheme: dark;
}

/* ---------- base ---------- */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 24px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--brand);
  color: #0a0d0a;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--link) 38%, transparent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--link-hover);
  text-decoration-color: currentColor;
}

svg {
  display: block;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  transition: top 0.15s;
}

.skip-link:focus {
  top: 12px;
  color: var(--bg);
}

/* ---------- top bar ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 16px;
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  width: 27px;
  height: 27px;
  color: var(--brand-strong);
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

.brand:hover .brand-mark {
  transform: rotate(-8deg) scale(1.06);
}

.brand-gpu {
  color: var(--brand-strong);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.readout {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  min-width: 34px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu-btn {
  display: none;
}

#theme-toggle .icon-moon {
  display: none;
}

[data-theme="dark"] #theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] #theme-toggle .icon-moon {
  display: block;
}

/* ---------- layout ---------- */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  z-index: 40;
  width: var(--sidebar-w);
  background: var(--bg-subtle);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 18px 14px 22px;
}

.sidebar-search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 4px 6px;
}

.sidebar-search svg {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.6;
}

.sidebar-search input {
  width: 100%;
  height: 35px;
  padding: 0 34px 0 31px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sidebar-search input::placeholder {
  color: var(--ink-3);
}

.sidebar-search input:focus {
  outline: none;
  border-color: var(--brand-line);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.sidebar-search kbd {
  position: absolute;
  right: 9px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  background: var(--bg-subtle);
}

.nav-part {
  margin-top: 22px;
}

.nav-part-title {
  padding: 0 10px 7px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

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

.nav-list li {
  margin: 1px 0;
}

.chapter-link {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6.5px 10px 6.5px 12px;
  border-radius: 7px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13.4px;
  line-height: 1.4;
}

.chapter-link:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.chapter-num {
  flex: none;
  width: 17px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  transition: color 0.15s;
}

.chapter-title {
  flex: 1;
}

.chapter-check {
  flex: none;
  font-size: 11px;
  color: var(--brand-strong);
  opacity: 0;
  transform: translateY(1px);
  transition: opacity 0.2s;
}

.chapter-link.visited .chapter-check {
  opacity: 0.85;
}

.chapter-link.visited .chapter-num {
  color: var(--brand-strong);
}

.chapter-link.active {
  background: var(--brand-soft);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--brand);
}

.chapter-link.active .chapter-num {
  color: var(--brand-strong);
}

.chapter-link.is-hidden,
.nav-part.is-hidden {
  display: none;
}

.sidebar-foot {
  margin-top: auto;
  padding: 30px 8px 4px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 7px;
}

.progress-label span:last-child {
  font-family: var(--font-mono);
  letter-spacing: 0;
}

.progress-track {
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-strong), var(--brand));
  transition: width 0.4s ease;
}

.sidebar-note {
  margin: 16px 0 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-3);
}

.sidebar-scrim {
  display: none;
}

/* ---------- main ---------- */

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
}

.content-wrap {
  display: grid;
  grid-template-columns: minmax(0, var(--content-w)) var(--toc-w);
  gap: 68px;
  max-width: calc(var(--content-w) + var(--toc-w) + 68px + 96px);
  margin: 0 auto;
  padding: 44px 48px 88px;
}

.article {
  min-width: 0;
}

/* ---------- page head ---------- */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 14px;
}

.breadcrumb a {
  color: var(--ink-3);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--link);
}

.breadcrumb span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-head h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 2.55rem);
  line-height: 1.12;
  letter-spacing: -0.032em;
  font-weight: 750;
}

.page-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line-strong);
}

.page-head {
  padding-bottom: 26px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

/* ---------- prose ---------- */

.article > p,
.article > ul,
.article > ol {
  font-size: 16.5px;
}

.article p {
  margin: 0 0 1.15em;
}

.article h2 {
  margin: 2.7em 0 0.7em;
  padding-bottom: 0.32em;
  border-bottom: 1px solid var(--line);
  font-size: 1.48rem;
  line-height: 1.25;
  letter-spacing: -0.018em;
  font-weight: 700;
  scroll-margin-top: 80px;
}

.article h3 {
  margin: 2.1em 0 0.55em;
  font-size: 1.14rem;
  line-height: 1.35;
  letter-spacing: -0.012em;
  font-weight: 650;
  scroll-margin-top: 80px;
}

.article h4 {
  margin: 1.8em 0 0.5em;
  font-size: 1rem;
  font-weight: 650;
}

.article h2:first-child,
.article h3:first-child {
  margin-top: 0;
}

.anchor {
  margin-left: 0.35em;
  color: var(--ink-3);
  text-decoration: none;
  opacity: 0;
  font-weight: 400;
  transition: opacity 0.15s;
}

h2:hover > .anchor,
h3:hover > .anchor,
.anchor:focus {
  opacity: 0.55;
}

.article ul,
.article ol {
  margin: 0 0 1.3em;
  padding-left: 1.45em;
}

.article li {
  margin: 0.32em 0;
}

.article li > ul {
  margin: 0.3em 0 0.4em;
}

.article strong {
  font-weight: 650;
}

.article code {
  font-family: var(--font-mono);
  font-size: 0.855em;
  padding: 0.16em 0.4em;
  border-radius: 5px;
  background: var(--inline-bg);
  color: var(--inline-fg);
  border: 1px solid color-mix(in srgb, var(--inline-fg) 10%, transparent);
  white-space: nowrap;
}

.article a code {
  color: inherit;
}

hr.rule {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 2.5em 0;
}

blockquote {
  margin: 1.6em 0;
  padding: 0.2em 0 0.2em 1.2em;
  border-left: 3px solid var(--line-strong);
  color: var(--ink-2);
  font-style: italic;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* ---------- tables ---------- */

.table-wrap {
  margin: 1.5em 0 1.8em;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.8px;
  line-height: 1.5;
}

th,
td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 650;
  background: var(--surface-2);
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: color-mix(in srgb, var(--brand-soft) 55%, transparent);
}

td code {
  white-space: nowrap;
}

/* ---------- callouts ---------- */

.callout {
  --co: #4b7d00;
  --co-bg: rgba(118, 185, 0, 0.07);
  display: flow-root;
  margin: 1.7em 0;
  padding: 15px 18px 4px;
  border: 1px solid color-mix(in srgb, var(--co) 22%, var(--line));
  border-left: 3px solid var(--co);
  border-radius: 9px;
  background: var(--co-bg);
  font-size: 15.2px;
}

.callout-body > :last-child {
  margin-bottom: 0.9em;
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--co);
}

.callout-icon {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--co);
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
}

.callout-note {
  --co: #3b6ea5;
  --co-bg: rgba(59, 110, 165, 0.06);
}

.callout-tip {
  --co: #0e7490;
  --co-bg: rgba(14, 116, 144, 0.06);
}

.callout-warn {
  --co: #b45309;
  --co-bg: rgba(180, 83, 9, 0.06);
}

.callout-quote {
  --co: var(--ink-3);
  --co-bg: transparent;
  font-style: italic;
}

.callout-details {
  --co: var(--ink-3);
  --co-bg: var(--surface-2);
}

[data-theme="dark"] .callout {
  --co-bg: rgba(255, 255, 255, 0.025);
}

[data-theme="dark"] .callout-note {
  --co: #7fb3e8;
}

[data-theme="dark"] .callout-tip {
  --co: #4ecdc4;
}

[data-theme="dark"] .callout-warn {
  --co: #f0b45f;
}

[data-theme="dark"] .callout-key {
  --co: #a3dd4a;
}

/* ---------- code ---------- */

.code-block {
  margin: 1.6em 0 1.9em;
  border-radius: 11px;
  overflow: hidden;
  background: var(--code-bg);
  border: 1px solid #1d2530;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), var(--shadow-md);
}

.code-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 39px;
  padding: 6px 8px 6px 15px;
  background: var(--code-bg-2);
  border-bottom: 1px solid var(--code-line);
}

.code-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.8px;
  color: #c6d2df;
  white-space: nowrap;
}

.code-title::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px rgba(118, 185, 0, 0.12);
}

.code-lang {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6d7c8d;
  padding: 2px 7px;
  border: 1px solid #27303c;
  border-radius: 999px;
  white-space: nowrap;
}

.code-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.code-actions .icon-btn {
  height: 27px;
  min-width: 27px;
  padding: 0 7px;
  border-radius: 6px;
  color: #8b99a9;
  font-size: 11.5px;
}

.code-actions .icon-btn svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
  stroke: none;
}

.code-actions .icon-btn:hover {
  background: #1c242f;
  color: #e6edf3;
}

.code-actions .run-btn {
  color: #c8e6a0;
  border: 1px solid rgba(118, 185, 0, 0.35);
  background: rgba(118, 185, 0, 0.12);
  padding: 0 9px;
}

.code-actions .run-btn:hover {
  background: rgba(118, 185, 0, 0.22);
  border-color: rgba(118, 185, 0, 0.6);
  color: #e6ffc9;
}

.code-actions .run-btn.is-done {
  color: #9be564;
}

.code-actions .copy-btn.copied {
  color: #9be564;
}

.code-block pre {
  margin: 0;
  padding: 17px 20px 19px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.9px;
  line-height: 1.65;
  color: var(--code-fg);
  tab-size: 4;
  -webkit-overflow-scrolling: touch;
}

.code-block pre code {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  white-space: pre;
}

.code-block[data-lang="console"] pre,
.code-block[data-lang="bash"] pre,
.code-block[data-lang="sh"] pre {
  font-size: 12.6px;
}

/* syntax colors */
.tok-kw { color: #ff7b72; }
.tok-cu { color: #ffa657; }
.tok-type { color: #79c0ff; }
.tok-builtin { color: #d2a8ff; }
.tok-fn { color: #d2a8ff; }
.tok-str { color: #a5d6ff; }
.tok-num { color: #79c0ff; }
.tok-com { color: #7d8b9d; font-style: italic; }
.tok-const { color: #ffa657; }
.tok-pre { color: #ffa657; }
.tok-op { color: #9aa7b8; }
.tok-prompt { color: #7ee787; font-weight: 700; }

/* output panel */
.run-panel {
  border-top: 1px dashed #263320;
  background: #0a100c;
}

.run-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px 0;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6f8560;
}

.run-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7ee787;
  box-shadow: 0 0 0 3px rgba(126, 231, 135, 0.12);
}

.run-meta {
  margin-left: auto;
  letter-spacing: 0.04em;
  text-transform: none;
  color: #4f6250;
}

.run-body {
  margin: 0;
  padding: 8px 20px 16px;
  font-family: var(--font-mono);
  font-size: 12.4px;
  line-height: 1.6;
  color: #bfe3ad;
  overflow-x: auto;
  white-space: pre-wrap;
}

.run-panel.is-running .run-body {
  animation: replay 0.7s steps(14, end);
}

.run-panel.is-running .run-dot {
  animation: pulse 0.5s ease 2;
}

@keyframes replay {
  from {
    clip-path: inset(0 0 100% 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 6px rgba(126, 231, 135, 0.04);
  }
}

/* generic terminal block */
.code-block.is-term .code-head {
  background: #0a0e13;
}

/* ---------- hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  align-items: center;
  gap: 34px;
  margin: 6px 0 52px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 5px 11px 5px 8px;
  border: 1px solid var(--brand-line);
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand);
}

.hero h1 {
  margin: 0 0 18px;
  font-size: clamp(2.4rem, 5.2vw, 3.55rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
  font-weight: 780;
}

.hero h1 em {
  font-style: normal;
  color: var(--brand-strong);
  background: linear-gradient(transparent 62%, var(--brand-soft) 62%);
}

.hero .lede {
  font-size: 17.5px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 0 24px;
  max-width: 46ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 17px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 650;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.btn-primary {
  background: var(--brand);
  color: #0b1400;
  box-shadow: 0 8px 20px -12px rgba(94, 145, 0, 0.9);
}

.btn-primary:hover {
  background: #85cc09;
  color: #0b1400;
  transform: translateY(-1px);
}

.btn-ghost {
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  background: var(--surface);
}

.btn-ghost:hover {
  border-color: var(--brand-line);
  color: var(--ink);
  background: var(--brand-soft);
}

.hero-stats {
  display: flex;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
}

.hero-art {
  position: relative;
}

.hero-art svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.hero-caption {
  margin: 10px 0 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  text-align: center;
}

.art-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  fill: var(--ink-3);
}

.art-panel {
  fill: var(--surface);
  stroke: var(--line-strong);
  stroke-width: 1.2;
}

.art-core {
  fill: var(--surface-2);
  stroke: var(--line-strong);
  stroke-width: 1.2;
}

.art-wire {
  stroke: var(--line-strong);
  stroke-width: 1.4;
}

.art-grid {
  fill: var(--brand);
  opacity: 0.18;
}

.art-grid.hot {
  opacity: 0.9;
}

.art-flow {
  stroke: var(--brand);
  stroke-width: 1.6;
  stroke-dasharray: 4 7;
  animation: flow 1.8s linear infinite;
}

@keyframes flow {
  to {
    stroke-dashoffset: -22;
  }
}

/* ---------- widgets ---------- */

.widget {
  margin: 2em 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background:
    radial-gradient(120% 100% at 0% 0%, var(--brand-soft), transparent 55%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.w-head {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.w-kicker {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--brand-strong);
  margin-bottom: 3px;
}

.w-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.w-sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-3);
  max-width: 46ch;
}

.w-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
}

.field {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}

.field input[type="range"] {
  width: 84px;
  accent-color: var(--brand-strong);
}

.field output {
  min-width: 2ch;
  color: var(--ink);
  font-weight: 600;
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-subtle);
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 9px;
  border-radius: 5px;
  cursor: pointer;
}

.seg button:hover {
  color: var(--ink);
}

.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.w-stage {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-subtle);
  overflow-x: auto;
}

.grid-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.block-grid {
  display: grid;
  gap: 10px;
  justify-content: start;
  width: max-content;
  min-width: 100%;
}

.tblock {
  padding: 7px 8px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tblock.is-hot {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.tblock-label {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--ink-3);
  margin-bottom: 6px;
  white-space: nowrap;
}

.tthreads {
  display: grid;
  gap: 3px;
}

.tthread {
  width: 11px;
  height: 11px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--brand-strong) 35%, var(--line));
  border-radius: 2px;
  background: color-mix(in srgb, var(--brand) 16%, var(--surface));
  cursor: crosshair;
  transition: transform 0.1s, background 0.1s, box-shadow 0.1s;
}

.tthread:hover,
.tthread:focus-visible {
  background: var(--brand);
  border-color: var(--brand-strong);
  transform: scale(1.35);
  z-index: 2;
  outline: none;
  box-shadow: 0 0 0 2px var(--bg);
}

.w-readout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.stat {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.stat-k {
  display: block;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 2px;
}

.stat-v {
  display: block;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-v.muted {
  color: var(--ink-3);
}

.stat.wide {
  grid-column: span 2;
}

/* warp lanes */
.warp-code {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 7px;
  background: var(--code-bg);
  color: #d7e3ee;
  font-family: var(--font-mono);
  font-size: 11.5px;
  overflow-x: auto;
  white-space: pre;
}

.warp-code .c-kw { color: #ff7b72; }
.warp-code .c-fn { color: #d2a8ff; }
.warp-code .c-cu { color: #ffa657; }
.warp-code .c-num { color: #79c0ff; }

.lane-row {
  margin-bottom: 12px;
}

.lane-row:last-child {
  margin-bottom: 0;
}

.lane-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-bottom: 5px;
}

.lanes {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 4px;
}

.lane {
  position: relative;
  line-height: 1;
  display: grid;
  place-items: center;
  height: 23px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--ink-3);
}

.lane.on {
  background: color-mix(in srgb, var(--brand) 26%, var(--surface));
  border-color: color-mix(in srgb, var(--brand) 55%, var(--line));
  color: var(--ink);
}

.lane.off {
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 3px,
    color-mix(in srgb, var(--ink-3) 12%, transparent) 3px,
    color-mix(in srgb, var(--ink-3) 12%, transparent) 6px
  );
  color: color-mix(in srgb, var(--ink-3) 60%, transparent);
  border-style: dashed;
}

.lane.alt.on {
  background: color-mix(in srgb, #0e7490 22%, var(--surface));
  border-color: color-mix(in srgb, #0e7490 50%, var(--line));
}

.warp-verdict {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-2);
  background: var(--surface);
}

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

.pill.good {
  border-color: var(--brand-line);
  background: var(--brand-soft);
}

.pill.bad {
  border-color: rgba(180, 83, 9, 0.35);
  background: rgba(180, 83, 9, 0.08);
}

/* coalescing */
.seg-row {
  display: grid;
  grid-template-columns: repeat(32, minmax(0, 1fr));
  gap: 2px;
  margin-bottom: 4px;
}

.mem-cell {
  height: 30px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: var(--surface);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}

.mem-cell.hit {
  background: color-mix(in srgb, var(--brand) calc(14% + var(--load, 1) * 16%), var(--surface));
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
}

.mem-cell.hit::after {
  content: "";
  position: absolute;
  inset: auto 3px 3px auto;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--brand-strong);
}

.thread-row {
  display: grid;
  grid-template-columns: repeat(32, minmax(0, 1fr));
  gap: 2px;
  margin-top: 10px;
}

.thread-chip {
  height: 20px;
  line-height: 1;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 7.5px;
  color: var(--ink-3);
  display: grid;
  place-items: center;
}

.thread-chip.hit {
  background: color-mix(in srgb, var(--brand) 22%, var(--surface));
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  color: var(--ink-2);
}

.axis-note {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--ink-3);
  margin: 6px 0 14px;
}

/* occupancy bars */
.occ-bars {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.occ-bar {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 78px;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--ink-3);
}

.occ-track {
  display: block;
  height: 8px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}

.occ-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--brand-strong);
  transition: width 0.25s ease;
}

.occ-fill.limit {
  background: #b45309;
}

.occ-val {
  text-align: right;
  color: var(--ink-2);
}

/* ---------- page toc ---------- */

.page-toc {
  position: sticky;
  top: calc(var(--topbar-h) + 34px);
  align-self: start;
  max-height: calc(100vh - var(--topbar-h) - 60px);
  overflow-y: auto;
  padding: 4px 0 4px 16px;
  border-left: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.45;
}

.toc-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 9px;
}

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

.page-toc li {
  margin: 0 0 1px;
}

.page-toc a {
  display: block;
  padding: 4px 0;
  color: var(--ink-3);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -18px;
  padding-left: 16px;
}

.page-toc a:hover {
  color: var(--ink);
}

.page-toc a.active {
  color: var(--brand-strong);
  border-left-color: var(--brand);
  font-weight: 600;
}

.page-toc .toc-l3 a {
  padding-left: 28px;
  font-size: 11.8px;
}

.page-toc .toc-l3 a.active {
  padding-left: 28px;
}

.toc-top {
  display: inline-block;
  margin-top: 14px;
  font-size: 11px;
  color: var(--ink-3);
  text-decoration: none;
}

.toc-top:hover {
  color: var(--link);
}

/* ---------- footer / pager ---------- */

.page-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 58px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.page-nav-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.page-nav-card:hover {
  border-color: var(--brand-line);
  background: var(--brand-soft);
  transform: translateY(-1px);
}

.page-nav-card.next {
  text-align: right;
  grid-column: 2;
}

.page-nav-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.page-nav-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.end-note {
  margin-top: 34px;
  padding: 22px;
  border: 1px solid var(--brand-line);
  border-radius: 12px;
  background: var(--brand-soft);
  text-align: center;
}

.end-mark {
  color: var(--brand-strong);
  font-size: 18px;
}

.end-note p {
  margin: 6px 0 0;
  font-size: 14.5px;
  color: var(--ink-2);
}

.end-links {
  font-size: 13px !important;
}

.site-foot {
  max-width: calc(var(--content-w) + var(--toc-w) + 68px + 96px);
  margin: 0 auto;
  padding: 26px 48px 44px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  justify-content: space-between;
}

.site-foot p {
  margin: 0;
}

.foot-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.foot-links a {
  color: var(--ink-3);
}

.foot-links a:hover {
  color: var(--link);
}

/* ---------- responsive ---------- */

@media (max-width: 1240px) {
  .content-wrap {
    grid-template-columns: minmax(0, var(--content-w));
    max-width: calc(var(--content-w) + 96px);
    justify-content: center;
  }
  .page-toc {
    display: none;
  }
  .site-foot {
    max-width: calc(var(--content-w) + 96px);
  }
}

@media (max-width: 1020px) {
  .menu-btn {
    display: inline-flex;
  }

  .sidebar {
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-md);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    z-index: 39;
    background: rgba(8, 12, 10, 0.42);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }

  .sidebar-scrim.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .main {
    margin-left: 0;
  }

  .content-wrap {
    padding: 34px 28px 70px;
  }

  .site-foot {
    padding: 24px 28px 40px;
  }
}

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .hero-art {
    max-width: 360px;
  }

  .hero-stats {
    flex-wrap: wrap;
    gap: 10px 16px;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 16px;
  }

  .content-wrap {
    padding: 26px 18px 60px;
  }

  .site-foot {
    padding: 22px 18px 36px;
    display: block;
  }

  .site-foot p + p {
    margin-top: 8px;
  }

  .brand-text {
    font-size: 15px;
  }

  .readout {
    display: none;
  }

  .code-block {
    margin-left: -18px;
    margin-right: -18px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .code-block pre {
    padding: 15px 16px 17px;
    font-size: 12px;
  }

  .code-lang {
    display: none;
  }

  .copy-label {
    display: none;
  }

  .code-actions .icon-btn {
    padding: 0 6px;
  }

  .article p code,
  .article li code,
  .article td code {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .run-body {
    padding: 8px 16px 14px;
  }

  .page-nav {
    grid-template-columns: 1fr;
  }

  .page-nav-card.next {
    grid-column: auto;
    text-align: left;
  }

  .article h2 {
    font-size: 1.32rem;
  }

  .article h1 {
    font-size: 1.9rem;
  }

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

  .w-readout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat.wide {
    grid-column: span 2;
  }

  .occ-bar {
    grid-template-columns: 88px minmax(0, 1fr) 66px;
  }

  .thread-chip {
    font-size: 6px;
  }

  .lane {
    height: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .topbar,
  .sidebar,
  .page-toc,
  .page-nav,
  .site-foot,
  .widget,
  .code-actions {
    display: none !important;
  }
  .main {
    margin: 0;
    padding: 0;
  }
  .content-wrap {
    display: block;
    max-width: none;
    padding: 0;
  }
  .code-block {
    break-inside: avoid;
    box-shadow: none;
  }
  body {
    font-size: 11pt;
  }
  a {
    color: inherit;
  }
}


/* ---------- figures ---------- */

.hw-figure {
  margin: 1.8em 0;
  padding: 14px 14px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.hw-figure svg {
  width: 100%;
  height: auto;
}

.hw-figure figcaption {
  margin: 10px 4px 6px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-3);
  text-align: center;
}

.art-wire,
.art-flow {
  fill: none;
}
