/*
 * mdBook TUI: monospace terminal feel (phosphor green on black).
 * Expects body.mdbook-tui (theme/index.hbs). Uses mdBook CSS variables + a few overrides.
 */

html:has(body.mdbook-tui) {
  /* mdBook default caps prose; main column width comes from page margins below */
  --content-max-width: none;
  /* One scale for menu bar height + rule thickness (mdBook default menu height overridden above) */
  --menu-bar-height: 5rem;
  --mdbook-tui-rule: 0.25rem;
  /* Terminal-style motion (honours prefers-reduced-motion below) */
  --mdbook-tui-blink-period: 1.05s;
  --mdbook-tui-ease-chrome: cubic-bezier(0.22, 1, 0.36, 1);
  --mdbook-tui-chrome-fade-duration: 0.42s;
  --mdbook-tui-phosphor-pulse-period: 2.25s;
  --page-padding: 0;
}

@keyframes mdbook-tui-caret-blink {
  0%,
  45% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@keyframes mdbook-tui-chrome-fade-in {
  from {
    opacity: 0.72;
  }
  to {
    opacity: 1;
  }
}

@keyframes mdbook-tui-phosphor-pulse {
  0%,
  100% {
    text-shadow:
      0 0 0.2em color-mix(in srgb, var(--sidebar-active) 45%, transparent),
      0 0 0.55em color-mix(in srgb, var(--links) 35%, transparent);
    filter: drop-shadow(0 0 0.08em color-mix(in srgb, var(--sidebar-active) 50%, transparent));
  }
  50% {
    text-shadow:
      0 0 0.45em color-mix(in srgb, var(--sidebar-active) 65%, transparent),
      0 0 1em color-mix(in srgb, var(--links) 45%, transparent);
    filter: drop-shadow(0 0 0.18em color-mix(in srgb, var(--sidebar-active) 70%, transparent));
  }
}

/* Same phosphor look for fenced blocks: glow the <pre> box (links use text/glyph glow above). */
@keyframes mdbook-tui-phosphor-pulse-pre {
  0%,
  100% {
    box-shadow:
      0 0 0.35em color-mix(in srgb, var(--sidebar-active) 38%, transparent),
      0 0 0.85em color-mix(in srgb, var(--links) 25%, transparent),
      inset 0 0 0.2em color-mix(in srgb, var(--sidebar-active) 12%, transparent);
  }
  50% {
    box-shadow:
      0 0 0.7em color-mix(in srgb, var(--sidebar-active) 58%, transparent),
      0 0 1.25em color-mix(in srgb, var(--links) 40%, transparent),
      inset 0 0 0.35em color-mix(in srgb, var(--sidebar-active) 20%, transparent);
  }
}

@media (prefers-reduced-motion: no-preference) {
  body.mdbook-tui #mdbook-body-container {
    animation: mdbook-tui-chrome-fade-in var(--mdbook-tui-chrome-fade-duration)
      var(--mdbook-tui-ease-chrome) both;
  }

  body.mdbook-tui #mdbook-sidebar .chapter a:hover,
  body.mdbook-tui .content main a:hover {
    animation: mdbook-tui-phosphor-pulse var(--mdbook-tui-phosphor-pulse-period) ease-in-out
      infinite;
  }

  body.mdbook-tui #mdbook-menu-bar a:hover .fa-svg,
  body.mdbook-tui #mdbook-menu-bar button:hover .fa-svg {
    animation: mdbook-tui-phosphor-pulse var(--mdbook-tui-phosphor-pulse-period) ease-in-out
      infinite;
  }

  body.mdbook-tui .nav-chapters.nav-bottom-link:hover {
    animation: mdbook-tui-phosphor-pulse var(--mdbook-tui-phosphor-pulse-period) ease-in-out
      infinite;
  }

  body.mdbook-tui .content main pre:hover,
  body.mdbook-tui .content main pre:focus-within {
    animation: mdbook-tui-phosphor-pulse-pre var(--mdbook-tui-phosphor-pulse-period) ease-in-out
      infinite;
  }

  body.mdbook-tui #mdbook-sidebar a.header-in-summary.current-header {
    position: relative;
  }

  body.mdbook-tui #mdbook-sidebar a.header-in-summary.current-header::after {
    content: "";
    display: inline-block;
    width: 0.4em;
    min-height: 1em;
    margin-left: 0.3em;
    vertical-align: -0.12em;
    background-color: var(--bg);
    animation: mdbook-tui-caret-blink var(--mdbook-tui-blink-period) step-end infinite;
  }

  body.mdbook-tui #mdbook-menu-bar .icon-button {
    transition: color 0.12s ease, transform 0.08s ease;
  }

  body.mdbook-tui #mdbook-menu-bar .icon-button:active {
    transform: scale(0.96);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.mdbook-tui #mdbook-body-container {
    animation: none;
  }

  body.mdbook-tui #mdbook-sidebar .chapter a:hover,
  body.mdbook-tui .content main a:hover,
  body.mdbook-tui #mdbook-menu-bar a:hover .fa-svg,
  body.mdbook-tui #mdbook-menu-bar button:hover .fa-svg,
  body.mdbook-tui .nav-chapters.nav-bottom-link:hover {
    animation: none;
  }

  body.mdbook-tui .content main pre:hover,
  body.mdbook-tui .content main pre:focus-within {
    animation: none;
  }

  body.mdbook-tui #mdbook-sidebar a.header-in-summary.current-header::after {
    content: none;
  }
}

/* Narrow screens: default mdBook overlay sidebar (flush to edge) */
@media (max-width: 619px) {
  body.mdbook-tui #mdbook-sidebar.sidebar {
    left: 0 !important;
    right: auto !important;
  }

  [dir="rtl"] body.mdbook-tui #mdbook-sidebar.sidebar {
    right: 0 !important;
    left: auto !important;
  }
}

/* ─── Dark terminal (Coal / Navy) ─── */
html.coal:has(body.mdbook-tui),
html.navy:has(body.mdbook-tui) {
  --bg: #050505;
  --fg: #c8f0c8;
  --sidebar-bg: #080808;
  --sidebar-fg: #a8d4a8;
  --sidebar-non-existant: #3d5c3d;
  --sidebar-active: #7fff7f;
  --sidebar-spacer: #1a2e1a;
  --scrollbar: #2a4a2a;
  --icons: #5a8a5a;
  --icons-hover: #afffaf;
  --links: #62ff62;
  --inline-code-color: #9fff9f;
  --theme-popup-bg: #0a120a;
  --theme-popup-border: #2d5c2d;
  --theme-hover: #143014;
  --searchbar-bg: #080808;
  --searchbar-fg: #c8f0c8;
  --searchbar-border-color: #2d5c2d;
  --searchbar-shadow-color: #1a3d1a;
  --searchresults-border-color: #2d5c2d;
  --searchresults-header-fg: #8fdf8f;
  --searchresults-li-bg: #0c180c;
  --table-border-color: #2d4a2d;
  --table-header-bg: #0a140a;
  --table-alternate-bg: #081008;
  --sidebar-header-border-color: #5fff5f;
  --search-mark-bg: #ffff66;
  --quote-bg: #081008;
  --quote-border: #1a3d1a;
}

/* Light theme: clean neutral, not sepia */
html.light:has(body.mdbook-tui),
html.rust:has(body.mdbook-tui) {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --sidebar-bg: #f0f0f0;
  --sidebar-fg: #2a2a2a;
  --sidebar-non-existant: #999;
  --sidebar-active: #0a6e3a;
  --scrollbar: #bbb;
  --icons: #666;
  --icons-hover: #0a6e3a;
  --links: #0a6e3a;
  --inline-code-color: #1a5c2a;
  --theme-popup-bg: #fff;
  --theme-popup-border: #ddd;
  --theme-hover: #e8e8e8;
  --searchbar-bg: #fff;
  --searchbar-fg: #1a1a1a;
  --searchbar-border-color: #ccc;
  --searchresults-border-color: #ddd;
  --table-border-color: #ddd;
  --table-header-bg: #f0f0f0;
  --sidebar-header-border-color: #0a6e3a;
  --quote-bg: #f5f5f5;
  --quote-border: #ddd;
}

html.ayu:has(body.mdbook-tui) {
  --bg: #0a0f0a;
  --fg: #b8e0b8;
  --sidebar-bg: #0c120c;
  --sidebar-fg: #98c898;
  --sidebar-non-existant: #4a6a4a;
  --sidebar-active: #ffb454;
  --links: #7fe07f;
  --icons: #7a9a7a;
  --icons-hover: #ffb454;
  --theme-popup-bg: #0c140c;
  --theme-popup-border: #3a5c3a;
  --theme-hover: #1a301a;
  --searchbar-bg: #0a100a;
  --searchbar-fg: #c8e8c8;
  --searchbar-border-color: #3a5c3a;
  --quote-bg: #0c100c;
  --quote-border: #2a4030;
  --inline-code-color: #9fff9f;
}

body.mdbook-tui {
  font-family: "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;
  /* mdBook sets html to 62.5% — use rem only on body; prose below uses `em` so it scales here */
  font-size: 1.5rem;
  line-height: 1.6;
}

body.mdbook-tui .menu-title,
body.mdbook-tui .content main,
body.mdbook-tui #mdbook-sidebar {
  font-family: inherit;
}

/* Title bar */
body.mdbook-tui .menu-title {
  font-weight: 500 !important;
  color: var(--sidebar-active) !important;
}

/* Flat chrome (`pre` excluded so phosphor box-shadow can animate on hover) */
body.mdbook-tui .theme-popup,
body.mdbook-tui #mdbook-help-popup {
  border-radius: 0 !important;
  box-shadow: none !important;
}

body.mdbook-tui .sidebar,
body.mdbook-tui #mdbook-menu-bar {
  box-shadow: none !important;
}

body.mdbook-tui pre {
  border-radius: 0 !important;
}

body.mdbook-tui .sidebar {
  border-right: 1px solid var(--theme-popup-border);
}

body.mdbook-tui #mdbook-menu-bar {
  border-block-end: 1px solid var(--theme-popup-border);
}

body.mdbook-tui #mdbook-content {
  width: 100%;
  margin-inline: 0;
  box-sizing: border-box;
}

body.mdbook-tui .content main {
  max-width: none;
  width: 100%;
  padding-top: 1rem;
}

body.mdbook-tui .content main h1 {
  font-size: clamp(1.45rem, 3.7vw, 1.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

body.mdbook-tui .content main p,
body.mdbook-tui .content main li {
  font-size: 1em;
  line-height: 1.68;
}

body.mdbook-tui .content main h2,
body.mdbook-tui .content main h3,
body.mdbook-tui .content main h4 {
  line-height: 1.35;
}

/* Fenced code blocks (pre > code.hljs): horizontal inset */
body.mdbook-tui .content main pre {
  margin-left: 2vw;
  margin-right: 3vw;
  margin-top: 1rem;
  margin-bottom: 1rem;
  padding: 1rem 2rem;
  box-sizing: border-box;
  background: transparent;
}

/*
 * Syntax highlighting: mdBook’s highlight.css uses a light gray box / rainbow;
 * remap .hljs to the same palette as prose (--fg, --links, --sidebar-active, …).
 */
body.mdbook-tui pre code.hljs {
  background: var(--quote-bg) !important;
  color: var(--fg) !important;
}

body.mdbook-tui .hljs-comment,
body.mdbook-tui .hljs-quote {
  color: var(--sidebar-non-existant) !important;
}

body.mdbook-tui .hljs-keyword,
body.mdbook-tui .hljs-selector-tag {
  color: var(--sidebar-active) !important;
}

body.mdbook-tui .hljs-string,
body.mdbook-tui .hljs-symbol,
body.mdbook-tui .hljs-bullet {
  color: var(--links) !important;
}

body.mdbook-tui .hljs-number,
body.mdbook-tui .hljs-meta,
body.mdbook-tui .hljs-built_in,
body.mdbook-tui .hljs-builtin-name,
body.mdbook-tui .hljs-literal,
body.mdbook-tui .hljs-type,
body.mdbook-tui .hljs-params {
  color: var(--inline-code-color) !important;
}

body.mdbook-tui .hljs-variable,
body.mdbook-tui .hljs-template-variable,
body.mdbook-tui .hljs-attribute,
body.mdbook-tui .hljs-attr,
body.mdbook-tui .hljs-tag,
body.mdbook-tui .hljs-name,
body.mdbook-tui .hljs-regexp,
body.mdbook-tui .hljs-link,
body.mdbook-tui .hljs-selector-id,
body.mdbook-tui .hljs-selector-class {
  color: color-mix(in srgb, var(--links) 75%, var(--sidebar-active) 25%) !important;
}

body.mdbook-tui .hljs-title,
body.mdbook-tui .hljs-section {
  color: var(--sidebar-active) !important;
}

body.mdbook-tui .hljs-emphasis {
  font-style: italic;
  color: var(--fg) !important;
}

body.mdbook-tui .hljs-strong {
  font-weight: bold;
  color: var(--fg) !important;
}

body.mdbook-tui .hljs-addition {
  color: var(--links) !important;
  background-color: color-mix(in srgb, var(--links) 12%, var(--quote-bg)) !important;
}

body.mdbook-tui .hljs-deletion {
  color: color-mix(in srgb, #f07178 85%, var(--fg)) !important;
  background-color: color-mix(in srgb, #f07178 10%, var(--quote-bg)) !important;
}

/* Sidebar: force readable link colors (mdBook vars on `html`) */
body.mdbook-tui #mdbook-sidebar .chapter a {
  color: var(--sidebar-fg) !important;
}
body.mdbook-tui #mdbook-sidebar .chapter a:hover,
body.mdbook-tui #mdbook-sidebar .chapter a.active {
  color: var(--sidebar-active) !important;
}

/*
 * Terminal-style selection: mdBook sets .active (current chapter) and
 * .current-header on .header-in-summary (subsection from scroll / #anchor).
 */
body.mdbook-tui #mdbook-sidebar .chapter a.active:not(.header-in-summary) {
  background-color: color-mix(in srgb, var(--sidebar-active) 18%, transparent);
  color: var(--sidebar-active) !important;
  padding: 0.2em 0.45em;
  margin: 0.1em -0.45em;
  display: inline-block;
  max-width: 100%;
  box-sizing: border-box;
  box-shadow: inset 0.2em 0 0 0 var(--sidebar-active);
}

body.mdbook-tui #mdbook-sidebar a.header-in-summary {
  display: block;
  padding: 0.28em 0.5em;
  margin-inline: -0.5em;
  border-radius: 0;
  text-decoration: none !important;
}

body.mdbook-tui #mdbook-sidebar a.header-in-summary.current-header {
  background-color: var(--sidebar-active);
  color: var(--bg) !important;
  font-weight: 600;
  box-shadow: inset 0.35em 0 0 0 var(--bg);
}

/*
 * Sidebar top band: same height as #mdbook-menu-bar (--menu-bar-height).
 * One horizontal rule via background (avoids double lines vs menu border + li border + .spacer).
 */
body.mdbook-tui #mdbook-sidebar .sidebar-scrollbox {
  padding-top: var(--menu-bar-height);
  padding-bottom: 0.625rem;
  padding-inline: 0.625rem;
  padding-left: 2rem;
  padding-right: 2rem;
  box-sizing: border-box;
  /* background-color: var(--sidebar-bg);
  background-image: linear-gradient(
    var(--theme-popup-border),
    var(--theme-popup-border)
  );
  background-size: 100% var(--mdbook-tui-rule);
  background-position: left var(--menu-bar-height);
  background-repeat: no-repeat; */
}

body.mdbook-tui #mdbook-sidebar .chapter > li.chapter-item:first-child {
  margin-block-start: 0;
  min-height: var(--menu-bar-height);
  box-sizing: border-box;
  display: grid;
  align-items: center;
  line-height: 1.35;
}

body.mdbook-tui #mdbook-sidebar .chapter > li.chapter-item:first-child .chapter-link-wrapper {
  align-items: center;
  width: 100%;
}

/* Search field */
body.mdbook-tui #mdbook-searchbar:focus {
  outline: var(--mdbook-tui-rule) solid var(--sidebar-active);
  outline-offset: 0;
}

/* Chapter nav: bottom bar with titles (overrides mdBook fixed side arrows) */
body.mdbook-tui .nav-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  gap: 1rem 1.5rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: var(--mdbook-tui-rule) solid var(--theme-popup-border);
  max-width: 100%;
  margin-bottom: 3rem;
}

body.mdbook-tui .nav-bottom-prev {
  justify-self: start;
  min-width: 0;
}

body.mdbook-tui .nav-bottom-next {
  justify-self: end;
  text-align: end;
  min-width: 0;
}

body.mdbook-tui .nav-chapters.nav-bottom-link {
  float: none;
  position: static;
  inset: auto;
  top: auto;
  bottom: auto;
  left: auto;
  right: auto;
  margin: 0;
  max-width: none;
  min-width: 0;
  max-height: none;
  font-size: 1em;
  font-weight: 600;
  line-height: 1.35;
  text-align: inherit;
  flex-direction: row;
  align-items: center;
  align-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 0;
  color: var(--icons);
  transition: color 0.15s, background-color 0.15s;
}

body.mdbook-tui .nav-chapters.nav-bottom-link:hover {
  color: var(--sidebar-active);
  background-color: var(--theme-hover);
}

body.mdbook-tui .nav-chapters.nav-bottom-link .fa-svg {
  flex-shrink: 0;
  font-size: 1.1em;
}

body.mdbook-tui .nav-bottom-label {
  text-decoration: underline;
  text-underline-offset: 0.15em;
  word-break: break-word;
}

body.mdbook-tui .nav-chapters.previous.nav-bottom-link {
  flex-direction: row;
}

[dir="rtl"] body.mdbook-tui .nav-bottom {
  direction: rtl;
}

[dir="rtl"] body.mdbook-tui .nav-bottom-link {
  text-align: inherit;
}

/*
 * Desktop: [ 30vw sidebar ][ 70vw main column → 5vw | 60vw prose | 5vw ]
 * The 5% margins sit inside the 70% content band; reading width is 60% of viewport.
 */
@media (min-width: 620px) {
  html:has(body.mdbook-tui) {
    --sidebar-target-width: 30vw !important;
  }

  body.mdbook-tui #mdbook-sidebar.sidebar {
    left: 1rem !important;
    top: 0.625rem;
  }

  [dir="rtl"] body.mdbook-tui #mdbook-sidebar.sidebar {
    left: unset !important;
    right: 0 !important;
  }

  body.mdbook-tui .page {
    padding-inline: 0;
  }

  body.mdbook-tui
    #mdbook-sidebar-toggle-anchor:checked
    ~ #mdbook-page-wrapper.page-wrapper {
    margin-inline-start: calc(
      var(--sidebar-width) + var(--sidebar-resize-indicator-width)
    ) !important;
    margin-inline-end: 0 !important;
  }

  body.mdbook-tui
    #mdbook-sidebar-toggle-anchor:not(:checked)
    ~ #mdbook-page-wrapper.page-wrapper {
    margin-inline: 0 !important;
  }

  body.mdbook-tui
    #mdbook-sidebar-toggle-anchor:checked
    ~ #mdbook-page-wrapper
    #mdbook-content {
    padding-inline: 12.5vw;
    max-width: none;
  }

  body.mdbook-tui
    #mdbook-sidebar-toggle-anchor:not(:checked)
    ~ #mdbook-page-wrapper
    #mdbook-content {
    max-width: 70vw;
    margin-inline: auto;
    padding-inline: 12.5vw;
  }
}

/* ── Interactive animation building blocks ─────────────────────────────
   All colours derive from mdBook's own CSS variables (--fg, --bg, --links,
   --sidebar-active, --table-border-color) so they adapt to ANY theme
   automatically — light, dark, coal, ayu, or this TUI phosphor theme.
   ──────────────────────────────────────────────────────────────────── */

.anim-block {
  padding: 0.75rem 1.25rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  color: var(--fg);
  font-family: var(--mono-font, monospace);
  font-size: 0.85rem;
  text-align: center;
}

.anim-block--gpu  { border-color: var(--links); background: rgba(100,200,100,0.1); }
.anim-block--cpu  { border-color: var(--sidebar-active); background: rgba(200,150,80,0.1); }
.anim-block--alt1 { border-color: rgba(255,255,255,0.2); }
.anim-block--alt2 { border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.08); }

/* Pipeline (horizontal flow) */
.anim-pipeline {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  margin: 1.5rem 0;
  overflow-x: auto;
  font-size: 0.65em; /* scale down relative to parent so it fits in one row */
}

.anim-pipeline__step {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 0.5rem;
  padding: 0.5em 0.75em;
  color: var(--fg);
  font-size: 1em;
  text-align: center;
  white-space: nowrap;
  flex: 0 0 auto;
}

.anim-pipeline__arrow {
  font-size: 1.25em;
  color: rgba(255,255,255,0.4);
  flex: 0 0 auto;
}

/* Vertical stack (memory layout, buffer diagrams) */
.anim-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 40rem;
  margin: 1.5rem auto;
  align-items: stretch;
}

.anim-stack__label {
  font-weight: bold;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.6);
  text-align: center;
  margin-bottom: 0.25rem;
}

/* Tile grid (SIMD matrix, thread mapping) */
.anim-tile-grid {
  display: grid;
  gap: 2px;
  margin: 1.5rem auto;
  max-width: 40rem;
}

.anim-tile-cell,
.tile-cell {
  padding: 0.3rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 2px;
  text-align: center;
  font-size: 0.7em;
  font-family: inherit;
  color: var(--fg);
}

/* Alternating colours for thread distinction */
.anim-tile-cell:nth-child(4n+1),
.anim-tile-cell:nth-child(4n+2),
.tile-cell:nth-child(4n+1),
.tile-cell:nth-child(4n+2) {
  background: rgba(100,200,100,0.1);
  border-color: rgba(100,200,100,0.3);
}
.anim-tile-cell:nth-child(4n+3),
.anim-tile-cell:nth-child(4n),
.tile-cell:nth-child(4n+3),
.tile-cell:nth-child(4n) {
  background: rgba(100,160,255,0.1);
  border-color: rgba(100,160,255,0.3);
}

/* Timeline (chain decode GPU/CPU) */
.anim-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 50rem;
  margin: 1.5rem auto;
}

.anim-timeline__label {
  font-weight: bold;
  text-align: center;
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
}

.anim-timeline__row {
  display: flex;
  flex-direction: row;
  gap: 0.25rem;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.7em;
}

.anim-timeline__gpu {
  background: rgba(100,200,100,0.15);
  border: 1px solid var(--links);
  color: var(--fg);
  padding: 0.4rem 0.6rem;
  border-radius: 0.3rem;
  font-size: 0.75rem;
}

.anim-timeline__cpu {
  background: rgba(200,150,80,0.15);
  border: 1px solid var(--sidebar-active);
  color: var(--fg);
  padding: 0.4rem 0.6rem;
  border-radius: 0.3rem;
  font-size: 0.75rem;
}

/* Caption under animations */
.anim-caption {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.55);
  text-align: center;
  margin-top: 0.25rem;
}

/* Callout blocks */
.note {
  background: rgba(100,200,100,0.08);
  border-left: 4px solid var(--links);
  padding: 0.8em 1.2em;
  margin: 1em 0;
  border-radius: 0 6px 6px 0;
}

.warning {
  background: rgba(200,150,80,0.08);
  border-left: 4px solid var(--sidebar-active);
  padding: 0.8em 1.2em;
  margin: 1em 0;
  border-radius: 0 6px 6px 0;
}

.tip {
  background: rgba(255,255,255,0.06);
  border-left: 4px solid rgba(150,200,100,0.7);
  padding: 0.8em 1.2em;
  margin: 1em 0;
  border-radius: 0 6px 6px 0;
}

/* ── Modal-inspired polish ────────────────────────────────────────── */

/* Terminal window inset: the whole page floats on a darker background */
@media (min-width: 768px) {
  body.mdbook-tui {
    padding: 0.5rem;
    background: #030503;
  }
  body.mdbook-tui #mdbook-body-container {
    border: 1px solid var(--theme-popup-border);
    border-radius: 6px;
    overflow: hidden;
  }
}

/* Dashed sidebar right border (Modal-style gradient dashes) */
body.mdbook-tui #mdbook-sidebar {
  background-image: linear-gradient(to bottom, var(--links) 50%, transparent 50%);
  background-size: 1px 10px;
  background-position: right;
  background-repeat: repeat-y;
  border-right: none !important;
}

/* Thin scrollbar, only visible on hover */
body.mdbook-tui * {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
body.mdbook-tui *:hover {
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

/* Heading breathing room */
body.mdbook-tui .content main h1 {
  margin-top: 2.5em;
  margin-bottom: 0.75em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
body.mdbook-tui .content main h1:first-child {
  margin-top: 0;
}
body.mdbook-tui .content main h2 {
  margin-top: 2em;
  margin-bottom: 0.6em;
}
body.mdbook-tui .content main h3 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

/* Code blocks: subtle hover border like Modal */
body.mdbook-tui .content main pre {
  border: 1px solid rgba(255,255,255,0.06);
  transition: border-color 0.2s;
}
body.mdbook-tui .content main pre:hover {
  border-color: rgba(255,255,255,0.15);
}

/* Blockquotes: cleaner */
body.mdbook-tui .content main blockquote {
  border-left: 2px solid var(--links);
  padding: 0.5em 1em;
  margin: 1.5em 0;
  opacity: 0.85;
}

/* Links: underline only on hover */
body.mdbook-tui .content main a {
  text-decoration: none;
}
body.mdbook-tui .content main a:hover {
  text-decoration: underline;
}

/* Table polish */
body.mdbook-tui .content main table {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
}
body.mdbook-tui .content main th {
  text-transform: uppercase;
  font-size: 0.85em;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

/* Footnotes: smaller, dimmer */
body.mdbook-tui .content main .footnote-definition {
  font-size: 0.85em;
  opacity: 0.7;
}

/* Selection color: monochromatic green */
body.mdbook-tui ::selection {
  background: rgba(98,255,98,0.2);
  color: inherit;
}
