/* =============================================================================
   jundoc — shared styles for every doc page
   ============================================================================= */

:root {
  --bg: #f5f7fb;
  --bg-grid: rgba(15, 23, 42, 0.045);
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --code-bg: #0b1220;
  --code-ink: #e2e8f0;
  --code-muted: #64748b;

  --blue: #2563eb;
  --green: #059669;
  --purple: #7c3aed;
  --orange: #ea580c;
  --pink: #db2777;
  --red: #dc2626;
  --yellow: #b45309;
  --yellow-ink: #0f172a;

  --sidebar-w: 268px;
  --toc-w: 220px;
  --radius: 16px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0f1c;
    --bg-grid: rgba(148, 163, 184, 0.06);
    --surface: #111827;
    --surface-2: #0f172a;
    --ink: #f1f5f9;
    --ink-2: #cbd5e1;
    --muted: #94a3b8;
    --line: #1f2a3d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --code-bg: #060a14;
    --blue: #60a5fa;
    --green: #34d399;
    --purple: #a78bfa;
    --orange: #fb923c;
    --pink: #f472b6;
    --red: #f87171;
    --yellow: #f59e0b;
    --yellow-ink: #0f172a;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0f1c;
  --bg-grid: rgba(148, 163, 184, 0.06);
  --surface: #111827;
  --surface-2: #0f172a;
  --ink: #f1f5f9;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --line: #1f2a3d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --code-bg: #060a14;
  --blue: #60a5fa;
  --green: #34d399;
  --purple: #a78bfa;
  --orange: #fb923c;
  --pink: #f472b6;
  --red: #f87171;
  --yellow: #f59e0b;
  --yellow-ink: #0f172a;
}

/* ---------------------------------------------------------------- language */
html[data-lang="en"] [lang="vi"],
html[data-lang="vi"] [lang="en"] {
  display: none !important;
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
code, pre, kbd { font-family: var(--mono); }
:not(pre) > code {
  font-size: 0.88em;
  padding: 0.1em 0.4em;
  border-radius: 6px;
  background: color-mix(in srgb, var(--purple) 10%, transparent);
  color: var(--ink);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------- shell */
.jd-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.jd-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  color: var(--ink);
}
.jd-brand:hover { text-decoration: none; }
.jd-logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 15px;
  background: linear-gradient(135deg, var(--blue), var(--purple) 55%, var(--pink));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--purple) 40%, transparent);
}
.jd-spacer { flex: 1; }
.jd-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 10px;
  height: 36px;
  padding: 0 12px;
  font: 600 13px var(--font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.jd-btn:hover { border-color: var(--muted); color: var(--ink); }
.jd-seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.jd-seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  height: 34px;
  padding: 0 12px;
  font: 700 12px var(--font);
  letter-spacing: 0.04em;
  cursor: pointer;
}
.jd-seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.jd-menu-btn { display: none; }

.jd-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  min-height: calc(100vh - 60px);
}
.jd-sidebar {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 20px 14px 40px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.jd-nav-group { margin-bottom: 18px; }
.jd-nav-title {
  font: 800 11px var(--font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 10px 6px;
}
summary.jd-nav-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  list-style: none;
}
summary.jd-nav-title::-webkit-details-marker { display: none; }
summary.jd-nav-title::after { content: "▾"; font-size: 14px; color: var(--muted); transition: transform 0.15s ease; }
details:not([open]) > summary.jd-nav-title::after { transform: rotate(-90deg); }
summary.jd-nav-title:hover { border-color: var(--muted); }
summary.jd-nav-title:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.jd-nav-count {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0;
}
details.jd-nav-group { margin-bottom: 4px; }
.jd-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14px;
}
.jd-nav-link:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.jd-nav-link.is-active {
  background: color-mix(in srgb, var(--purple) 12%, transparent);
  color: var(--purple);
}
.jd-nav-link .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  flex: none;
}
.jd-nav-link.is-soon { color: var(--muted); cursor: default; }
.jd-nav-link.is-soon:hover { background: none; }
.jd-soon {
  margin-left: auto;
  font: 700 10px var(--font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.jd-main { padding: 36px 44px 120px; min-width: 0; }
.jd-content { max-width: 1180px; margin: 0 auto; }

.jd-toc {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 36px 18px 40px 6px;
  font-size: 13px;
}
.jd-toc-title {
  font: 800 11px var(--font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.jd-toc a {
  display: block;
  padding: 5px 10px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-weight: 600;
}
.jd-toc a:hover { color: var(--ink); text-decoration: none; }
.jd-toc a.is-active { color: var(--purple); border-left-color: var(--purple); }

@media (max-width: 1280px) {
  .jd-layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .jd-toc { display: none; }
}
@media (max-width: 900px) {
  .jd-layout { grid-template-columns: minmax(0, 1fr); }
  .jd-menu-btn { display: inline-flex; }
  .jd-sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    width: min(300px, 86vw);
    z-index: 40;
    background: var(--surface);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
  }
  body.nav-open .jd-sidebar { transform: none; }
  .jd-main { padding: 24px 16px 100px; }
  .jd-brand-sub { display: none; }
}

/* ---------------------------------------------------------------- hero */
.jd-hero {
  position: relative;
  padding: 44px 44px 40px;
  border-radius: 24px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(1200px 400px at 0% 0%, rgba(96, 165, 250, 0.55), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(244, 114, 182, 0.45), transparent 60%),
    linear-gradient(135deg, #1e3a8a, #4c1d95 55%, #831843);
  box-shadow: var(--shadow);
}
.jd-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, #000, transparent);
  pointer-events: none;
}
.jd-hero > * { position: relative; z-index: 1; }
.jd-eyebrow {
  font: 800 12px var(--font);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.8;
}
.jd-hero h1 { color: #fff; font-size: clamp(40px, 6vw, 64px); font-weight: 900; margin: 8px 0 12px; }
.jd-hero p { font-size: 19px; max-width: 760px; margin: 0; color: rgba(255, 255, 255, 0.9); }
.jd-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.jd-chip {
  font: 700 13px var(--font);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
}

.jd-quickmap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.jd-quick {
  --c: var(--blue);
  display: block;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.jd-quick:hover { transform: translateY(-2px); border-color: var(--c); text-decoration: none; }
.jd-quick b { display: block; color: var(--c); font-size: 15px; }
.jd-quick span { font-size: 13px; color: var(--muted); }
.jd-quick .num {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--c);
  color: var(--c-ink, #fff);
  font: 800 12px var(--font);
  margin-bottom: 8px;
}

/* ---------------------------------------------------------------- sections */
.jd-section {
  --c: var(--blue);
  margin-top: 48px;
  padding: 32px;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative;
}
.jd-section::before {
  content: "";
  position: absolute;
  left: 32px;
  right: 32px;
  top: -1px;
  height: 4px;
  border-radius: 0 0 4px 4px;
  background: var(--c);
}
.jd-section-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 8px; }
.jd-badge {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font: 900 18px var(--font);
  color: var(--c-ink, #fff);
  background: var(--c);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--c) 40%, transparent);
}
.jd-section h2 { font-size: 28px; font-weight: 800; }
.jd-sub { color: var(--muted); margin: 4px 0 0; font-size: 15px; }
.jd-section h3 {
  font-size: 15px;
  font-weight: 800;
  color: var(--c);
  margin: 28px 0 12px;
  letter-spacing: 0.01em;
}
.c-blue { --c: var(--blue); --c-ink: #fff; }
.c-green { --c: var(--green); --c-ink: #fff; }
.c-purple { --c: var(--purple); --c-ink: #fff; }
.c-orange { --c: var(--orange); --c-ink: #fff; }
.c-pink { --c: var(--pink); --c-ink: #fff; }
.c-red { --c: var(--red); --c-ink: #fff; }
.c-yellow { --c: var(--yellow); --c-ink: var(--yellow-ink); }
.c-muted { --c: var(--muted); --c-ink: #fff; }

.jd-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.jd-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 1000px) {
  .jd-grid-2, .jd-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .jd-section { padding: 22px 18px; }
  .jd-section::before { left: 18px; right: 18px; }
}

.jd-callout {
  --c: var(--green);
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  background: color-mix(in srgb, var(--c) 9%, transparent);
  color: var(--ink-2);
  font-size: 15px;
}
.jd-callout b { color: var(--c); }

/* ---------------------------------------------------------------- nodes & wires */
.jd-flow {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 56px;
  padding: 8px 0;
}
.jd-flow.is-wrap { flex-wrap: wrap; }
.jd-flow.is-col { flex-direction: column; gap: 34px; }
@media (max-width: 1000px) {
  .jd-flow:not(.keep-row) { flex-direction: column; gap: 40px; }
}
.jd-flow > :not(.jd-wires):not(.jd-packet):not(.jd-token) { position: relative; z-index: 2; }
.jd-wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}
.jd-wire-base { fill: none; stroke-width: 2; opacity: 0.25; }
.jd-wire {
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 6 9;
  animation: jd-dash 1.1s linear infinite;
}
.jd-wire.is-dashed { opacity: 0.6; }
@keyframes jd-dash { to { stroke-dashoffset: -30; } }

.jd-packet {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  pointer-events: none;
  font: 700 11.5px var(--mono);
  white-space: nowrap;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--c-ink, #fff);
  background: var(--c, var(--blue));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--blue)) 25%, transparent),
    0 0 18px color-mix(in srgb, var(--c, var(--blue)) 70%, transparent);
  animation: jd-blink 1.2s ease-in-out infinite;
  will-change: transform;
}
.jd-packet.is-yellow, .jd-packet[style*="yellow"] {
  color: #0f172a !important;
  font-weight: 800;
}
@keyframes jd-blink { 50% { filter: brightness(1.35); } }

.jd-node {
  --c: var(--blue);
  flex: 1 1 0;
  min-width: 0;
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--surface);
  border: 1.5px solid color-mix(in srgb, var(--c) 55%, var(--line));
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s ease, transform 0.3s ease, border-color 0.3s ease, background 0.3s ease;
  word-break: break-word;
  overflow-wrap: break-word;
}
.jd-node.is-tint { background: color-mix(in srgb, var(--c) 7%, var(--surface)); }
.jd-node.is-opt { border-style: dashed; }
.jd-node .k {
  font: 800 11px var(--font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c);
}
.jd-node .t {
  display: block;
  font: 800 18px var(--font);
  color: var(--ink);
  margin: 2px 0 4px;
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.3;
}
.jd-node .t.mono {
  font: 700 16px var(--mono);
  color: var(--c);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.jd-node .p {
  font: 600 12.5px var(--mono);
  color: var(--muted);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.jd-node .d {
  font-size: 14px;
  color: var(--ink-2);
  margin-top: 6px;
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.5;
}
.jd-node .tag {
  float: right;
  font: 700 10.5px var(--font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
}
.jd-node.is-lit {
  border-color: var(--c);
  transform: translateY(-3px);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent),
    0 10px 30px color-mix(in srgb, var(--c) 35%, transparent);
}
.jd-node.is-done { background: color-mix(in srgb, var(--c) 6%, var(--surface)); }
.jd-node.is-ping { animation: jd-ping 0.6s ease; }
@keyframes jd-ping {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 50%, transparent); }
  100% { box-shadow: 0 0 0 14px transparent; }
}

/* ---------------------------------------------------------------- code / terminal */
.jd-term {
  position: relative;
  border-radius: 14px;
  background: var(--code-bg);
  color: var(--code-ink);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.12);
}
.jd-term-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  font: 600 12px var(--font);
  color: #94a3b8;
}
.jd-term-bar i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.jd-term-bar i:nth-child(1) { background: #f87171; }
.jd-term-bar i:nth-child(2) { background: #fbbf24; }
.jd-term-bar i:nth-child(3) { background: #34d399; }
.jd-term-bar span { margin-left: 8px; }
.jd-copy {
  margin-left: auto;
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: transparent;
  color: #cbd5e1;
  border-radius: 8px;
  padding: 3px 10px;
  font: 700 11.5px var(--font);
  cursor: pointer;
}
.jd-copy:hover { background: rgba(148, 163, 184, 0.15); }
.jd-term pre {
  margin: 0;
  padding: 16px 18px 18px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.7;
}
.jd-term .line-hl {
  display: inline-block;
  min-width: 100%;
  background: color-mix(in srgb, var(--purple) 22%, transparent);
  border-radius: 4px;
}
.tok-c { color: #64748b; font-style: italic; }
.tok-s { color: #fcd34d; }
.tok-k { color: #f472b6; }
.tok-f { color: #c4b5fd; font-weight: 700; }
.tok-n { color: #fdba74; }
.tok-p { color: #34d399; font-weight: 700; }
.tok-key { color: #7dd3fc; }
.tok-t { color: #93c5fd; }

/* ---------------------------------------------------------------- tabs */
.jd-tabs { border-radius: 14px; overflow: hidden; }
.jd-tablist { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.jd-tab {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 10px;
  padding: 6px 12px;
  font: 700 13px var(--font);
  cursor: pointer;
}
.jd-tab[aria-selected="true"] { color: var(--c-ink, #fff); background: var(--c); border-color: var(--c); }
.jd-tabpanel[hidden] { display: none; }

/* ---------------------------------------------------------------- player */
.jd-player { --c: var(--green); }
.jd-stage { position: relative; }
.jd-token {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 6;
  pointer-events: none;
  font: 800 12px var(--mono);
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--tc-ink, #fff);
  background: var(--tc, var(--green));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tc, var(--green)) 25%, transparent),
    0 0 26px color-mix(in srgb, var(--tc, var(--green)) 80%, transparent);
  transition: transform 0.55s cubic-bezier(0.65, 0, 0.35, 1), background 0.3s ease;
  animation: jd-blink 1s ease-in-out infinite;
}
.jd-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.jd-controls .jd-btn.primary { background: var(--c); color: var(--c-ink, #fff); border-color: var(--c); }
.jd-progress {
  flex: 1;
  min-width: 160px;
  height: 6px;
  border-radius: 6px;
  background: var(--line);
  overflow: hidden;
}
.jd-progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 0.4s ease;
}
.jd-caption {
  margin-top: 14px;
  min-height: 74px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.jd-caption .step {
  flex: none;
  font: 800 12px var(--mono);
  color: var(--tc-ink, #fff);
  background: var(--tc, var(--green));
  border-radius: 8px;
  padding: 4px 8px;
}
.jd-caption .txt { font-size: 15px; color: var(--ink-2); }
.jd-caption .txt b { color: var(--ink); }

/* request-flow layout */
.rf {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 32px 16px;
  align-items: stretch;
  position: relative;
}
.rf > :not(.jd-wires):not(.jd-packet):not(.jd-token) { position: relative; z-index: 2; }
.rf .jd-node { padding: 12px 10px; }
.rf .jd-node .t { font-size: 15px; }
.rf .jd-node .d { font-size: 12px; line-height: 1.4; }
.rf-mw {
  border: 1.5px dashed color-mix(in srgb, var(--green) 55%, var(--line));
  border-radius: 16px;
  padding: 12px;
  background: color-mix(in srgb, var(--green) 4%, transparent);
}
.rf-mw .k {
  font: 800 11px var(--font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green);
}
.rf-mw-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.rf-mw-grid .jd-node { padding: 8px 10px; border-radius: 10px; box-shadow: none; }
.rf-mw-grid .jd-node .t { font: 700 12.5px var(--mono); margin: 0; color: var(--ink); }
.rf-mw-grid .jd-node.is-lit { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent), 0 6px 22px color-mix(in srgb, var(--c) 45%, transparent); background: color-mix(in srgb, var(--c) 16%, var(--surface)); }
.rf-mw-grid .jd-node.is-done { background: color-mix(in srgb, var(--c) 8%, var(--surface)); }
.rf-mw-grid .jd-node .t small { color: var(--green); font-weight: 800; margin-right: 6px; }
.rf-db {
  display: grid;
  place-items: center;
  text-align: center;
  border-radius: 50% / 14%;
}
.rf-client { grid-column: 1; display: grid; place-content: center; text-align: center; }
.rf-mw { grid-column: 2 / 7; }
.rf-domain {
  grid-column: 2 / 6;
  margin-top: 14px;
  text-align: center;
  font-size: 13.5px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1.5px dashed color-mix(in srgb, var(--green) 55%, var(--line));
  color: var(--ink-2);
  background: color-mix(in srgb, var(--green) 4%, transparent);
}
@media (max-width: 1000px) {
  .rf { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .rf-domain, .rf-mw, .rf-client { grid-column: auto; margin-top: 0; }
}
@media (max-width: 760px) {
  .rf-mw-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .rf-mw-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* folder architecture mapping */
.jd-folder-map {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}
.jd-fmap-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.4fr) 20px minmax(90px, 1fr) minmax(160px, 2fr);
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13.5px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}
.jd-fmap-path {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--pink);
  word-break: break-word;
}
.jd-fmap-arr {
  text-align: center;
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
}
.jd-fmap-layer {
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--c, var(--green)) 12%, transparent);
  color: var(--c, var(--green));
  width: fit-content;
}
.jd-fmap-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
@media (max-width: 768px) {
  .jd-fmap-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .jd-fmap-arr { display: none; }
}

/* ---------------------------------------------------------------- misc blocks */
.jd-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.jd-kv dt { font: 700 13px var(--mono); color: var(--green); }
.jd-kv dd { margin: 0; color: var(--ink-2); }

.jd-map { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 120px; position: relative; }
.jd-map > :not(.jd-wires):not(.jd-packet):not(.jd-token) { position: relative; z-index: 2; }
.jd-map .jd-node { padding: 10px 14px; }
.jd-map .jd-node .t { font-size: 15px; margin: 0; }
@media (min-width: 701px) { .jd-map.is-wide { gap: 44px 110px; } }
@media (max-width: 700px) { .jd-map { gap: 12px 40px; } }

.jd-cheat-search {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  padding: 0 14px;
  font: 500 15px var(--font);
  margin: 6px 0 18px;
}
.jd-cheat-search:focus { outline: 2px solid var(--purple); outline-offset: 1px; }
.jd-cheat { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 28px; }
@media (max-width: 900px) { .jd-cheat { grid-template-columns: minmax(0, 1fr); } }
.jd-cheat-group h4 { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c); margin-bottom: 6px; }
.jd-cheat-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.jd-cheat-row code { background: none; padding: 0; font-weight: 700; font-size: 13px; word-break: break-word; }
.jd-cheat-row span { color: var(--muted); }
.jd-cheat-row button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 7px;
  font: 700 11px var(--font);
  padding: 3px 8px;
  cursor: pointer;
}
.jd-cheat-row button:hover { color: var(--ink); border-color: var(--muted); }
.jd-cheat-row[hidden] { display: none; }

.jd-footer {
  margin-top: 60px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.jd-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  opacity: 0;
  background: var(--ink);
  color: var(--surface);
  padding: 8px 16px;
  border-radius: 10px;
  font: 700 13px var(--font);
  transition: all 0.25s ease;
  z-index: 100;
  pointer-events: none;
}
.jd-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* home page cards */
.jd-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 24px; }
.jd-card {
  --c: var(--purple);
  display: block;
  padding: 22px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
a.jd-card:hover { transform: translateY(-3px); border-color: var(--c); text-decoration: none; }
.jd-card h3 { font-size: 18px; margin: 8px 0 6px; color: var(--ink); }
.jd-card p { margin: 0; font-size: 14px; color: var(--muted); }
.jd-card.is-soon { opacity: 0.6; }

/* index: one big tile per group, opens a popup with its pages */
.jd-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; margin-top: 24px; }
button.jd-card { width: 100%; text-align: left; font: inherit; cursor: pointer; padding: 32px 28px; }
button.jd-card:hover { transform: translateY(-3px); border-color: var(--c); }
button.jd-card:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; }
button.jd-card h3 { font-size: 28px; color: var(--c); }
.jd-pop {
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg);
  color: var(--ink-2);
  box-shadow: var(--shadow);
}
.jd-pop::backdrop { background: rgba(15, 23, 42, 0.5); }
.jd-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.jd-pop-head h2 { margin: 0; }
.jd-pop .jd-cards { margin-top: 16px; }

/* ---------------------------------------------------------------- code lines + explanations */
.jd-term .ln {
  display: inline-block;
  min-width: 100%;
  border-radius: 4px;
  transition: opacity 0.2s ease, background 0.2s ease;
}
.jd-term pre.has-focus .ln:not(.is-focus) { opacity: 0.28; }
.jd-term .ln.is-focus { background: color-mix(in srgb, var(--purple) 30%, transparent); }

.jd-explain { display: grid; gap: 10px; }
.jd-ex {
  --c: var(--purple);
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 4px 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.jd-ex:hover, .jd-ex.is-active {
  border-color: var(--c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent);
}
.jd-ex.is-pinned { transform: translateX(4px); }
.jd-ex:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; }
.jd-ex .n {
  grid-row: span 2;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 800 12px var(--font);
  color: var(--c-ink, #fff);
  background: var(--c);
}
.jd-ex .w { font: 700 14.5px var(--mono); color: var(--c); }
.jd-ex .x { font-size: 14.5px; color: var(--ink-2); }
.jd-ex .x .eg { display: block; margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.jd-hint { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.jd-sticky { position: sticky; top: 76px; }

/* ---------------------------------------------------------------- code lines as nodes (wired) */
.jd-codelines {
  position: relative;
  padding: 18px 18px 18px 110px;
  border-radius: 14px;
  background: var(--code-bg);
  color: var(--code-ink);
  font: 500 14px/1.5 var(--mono);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.jd-codelines .cl {
  position: relative;
  z-index: 2;
  width: fit-content;
  max-width: 100%;
  padding: 3px 8px;
  margin: 0 0 14px;
  border-radius: 6px;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(148, 163, 184, 0.08);
}
.jd-codelines .cl:last-child { margin-bottom: 0; }
.jd-codelines .cl.is-note { background: none; color: #64748b; font-style: italic; }
.jd-codelines .v { color: #fcd34d; font-weight: 700; }
.jd-codelines .fn { color: #93c5fd; }
.jd-codelines .jd-packet { font-size: 11px; }

/* ---------------------------------------------------------------- recipe cards (needs / makes) */
.jd-recipe {
  --c: var(--purple);
  position: relative;
  padding: 14px 16px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1.5px solid color-mix(in srgb, var(--c) 45%, var(--line));
  box-shadow: var(--shadow);
  transition: all 0.35s ease;
}
.jd-recipe .kind {
  font: 800 10.5px var(--font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c);
}
.jd-recipe .fn { display: block; font: 700 15px var(--mono); color: var(--ink); margin: 4px 0 10px; word-break: break-word; }
.jd-recipe .row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.jd-recipe .row b { font: 800 10.5px var(--font); letter-spacing: 0.1em; text-transform: uppercase; width: 58px; color: var(--muted); }
.jd-pill {
  --c: var(--blue);
  font: 700 12px var(--mono);
  padding: 3px 9px;
  border-radius: 8px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
}
.jd-pill.solid { color: var(--c-ink, #fff); background: var(--c); border-color: var(--c); }
.jd-pill.ghost { color: var(--muted); background: none; border-style: dashed; border-color: var(--line); }
.jd-recipe .st {
  position: absolute;
  top: -11px;
  right: 14px;
  font: 800 10.5px var(--font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  display: none;
}
.jd-recipe[data-state="asked"] {
  border-color: var(--orange);
  border-style: dashed;
  background: color-mix(in srgb, var(--orange) 7%, var(--surface));
}
.jd-recipe[data-state="asked"] .st.asked { display: inline-block; background: var(--orange); color: #fff; }
.jd-recipe[data-state="built"] {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 9%, var(--surface));
}
.jd-recipe[data-state="built"] .st.built { display: inline-block; background: var(--green); color: #fff; }
.jd-recipe[data-state="skipped"] { opacity: 0.45; filter: grayscale(1); }
.jd-recipe[data-state="skipped"] .st.skipped { display: inline-block; background: var(--muted); color: #fff; }
.jd-recipe.is-lit {
  transform: translateY(-3px);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent), 0 10px 30px color-mix(in srgb, var(--c) 30%, transparent);
}

/* Fx simulator board */
.fxsim {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px 42px;
  position: relative;
}
.fxsim > :not(.jd-wires):not(.jd-packet):not(.jd-token) { position: relative; z-index: 2; }
.fxsim .engine {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, #4c1d95, #7c3aed 60%, #db2777);
  box-shadow: 0 10px 30px rgba(124, 58, 237, 0.35);
}
.fxsim .engine .gear { font-size: 28px; }
.fxsim .engine b { font-size: 18px; }
.fxsim .engine span { opacity: 0.85; font-size: 14px; }
.fxsim .engine.is-lit { box-shadow: 0 0 0 5px rgba(167, 139, 250, 0.4), 0 10px 30px rgba(124, 58, 237, 0.5); }

/* Tier Banners: Architecture tiers */
.fxsim .fxsim-tier {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  position: relative;
  z-index: 3;
}
.fxsim .fxsim-tier.tier-1 { grid-row: 2; }
.fxsim .fxsim-tier.tier-2 { grid-row: 4; }
.fxsim .fxsim-tier.tier-3 { grid-row: 6; }
.fxsim .fxsim-tier-badge {
  font: 800 11px var(--font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--orange);
  background: color-mix(in srgb, var(--orange) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--orange) 32%, transparent);
  padding: 3px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.fxsim .fxsim-tier-desc {
  font-size: 13px;
  color: var(--muted);
}

/* Tier 1: Infrastructure & Data (Row 3, Left to Right) */
.fxsim [data-node="cfg"]  { grid-row: 3; grid-column: 1; }
.fxsim [data-node="db"]   { grid-row: 3; grid-column: 2; }
.fxsim [data-node="repo"] { grid-row: 3; grid-column: 3; }

/* Tier 2: Domain & HTTP Delivery (Row 5, Left to Right) */
.fxsim [data-node="svc"]  { grid-row: 5; grid-column: 1; }
.fxsim [data-node="hdl"]  { grid-row: 5; grid-column: 2; }
.fxsim [data-node="rts"]  { grid-row: 5; grid-column: 3; }

/* Tier 3: Startup Trigger & Lazy Example (Row 7) */
.fxsim [data-node="rpt"]  { grid-row: 7; grid-column: 1; }
.fxsim [data-node="inv"]  { grid-row: 7; grid-column: 3; }

/* In fxsim: keep everything peaceful and static by default */
.fxsim .jd-wire {
  animation: none !important;
  stroke-dasharray: 4 4 !important;
  opacity: 0.32;
  transition: opacity 0.3s ease, stroke-width 0.3s ease;
}
.fxsim .jd-wire-base {
  opacity: 0.12;
  transition: opacity 0.3s ease, stroke-width 0.3s ease;
}
.fxsim .jd-token {
  display: none !important;
}
.fxsim .jd-packet {
  display: none !important;
}

/* Pill Transfer Badges & Linking styles */
.jd-transfer-badge {
  font: 600 11px var(--font);
  color: var(--muted);
  opacity: 0.85;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.25s ease;
}
.jd-pill[data-pill-id] {
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.jd-pill[data-pill-id]:hover,
.jd-pill.is-linked {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 55%, white), 0 0 16px var(--c) !important;
  transform: scale(1.06);
  z-index: 10;
}
.jd-recipe .row.is-linked {
  background: color-mix(in srgb, var(--c, var(--blue)) 14%, transparent);
  border-radius: 8px;
  outline: 1.5px solid color-mix(in srgb, var(--c, var(--blue)) 45%, transparent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--c, var(--blue)) 20%, transparent);
  transition: all 0.25s ease;
}
.jd-recipe .row.is-linked .jd-transfer-badge {
  color: var(--ink);
  opacity: 1;
  font-weight: 700;
}

/* Chớp chớp (Pulsing) animations between provider and needs when step runs */
@keyframes jd-handoff-pulse {
  0%, 100% {
    box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--c) 40%, transparent);
    opacity: 0.9;
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--c) 70%, white),
                0 0 18px color-mix(in srgb, var(--c) 90%, transparent);
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes jd-row-pulse {
  0%, 100% {
    background: transparent;
    outline: 1.5px solid transparent;
  }
  50% {
    background: color-mix(in srgb, var(--c, var(--blue)) 18%, transparent);
    outline: 2px solid color-mix(in srgb, var(--c, var(--blue)) 65%, transparent);
    box-shadow: 0 0 16px color-mix(in srgb, var(--c, var(--blue)) 30%, transparent);
  }
}

@keyframes jd-wire-pulse {
  0%, 100% {
    opacity: 0.45;
    stroke-width: 2.5px;
  }
  50% {
    opacity: 1;
    stroke-width: 4.5px;
    filter: drop-shadow(0 0 10px currentColor);
  }
}

.jd-pill.is-pulsing {
  animation: jd-handoff-pulse 1.3s ease-in-out infinite !important;
  z-index: 10;
  position: relative;
}

.jd-recipe .row.is-pulsing-row {
  animation: jd-row-pulse 1.3s ease-in-out infinite;
  border-radius: 8px;
}

.jd-recipe .row.is-pulsing-row .jd-transfer-badge {
  color: var(--ink);
  font-weight: 700;
  opacity: 1;
}

/* Wires active lighting during step or hover */
.jd-wire.is-wire-active,
.jd-wire.is-wire-lit {
  animation: jd-wire-pulse 1.3s ease-in-out infinite !important;
  opacity: 1 !important;
}

.jd-wire-base.is-wire-active,
.jd-wire-base.is-wire-lit {
  opacity: 0.7 !important;
  stroke-width: 8px !important;
}

@media (max-width: 1000px) {
  .fxsim { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .fxsim [data-node] { grid-row: auto !important; grid-column: auto !important; }
  .fxsim .fxsim-tier { grid-row: auto !important; grid-column: 1 / -1; }
}

/* the "idea" visual: dependencies & provides with directional arrows */
.jd-idea {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px minmax(0, 1.25fr) 52px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}
.jd-idea .side {
  padding: 16px 18px;
  border-radius: 14px;
  border: 1.5px dashed var(--line);
  background: var(--surface-2);
  align-self: center;
}
.jd-idea .side h4 { font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 6px; }
.jd-idea .side.need { border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.jd-idea .side.need h4 { color: var(--green); }
.jd-idea .side.make { border-color: color-mix(in srgb, var(--orange) 50%, transparent); }
.jd-idea .side.make h4 { color: var(--orange); }

.jd-idea .fnbig {
  padding: 18px 22px;
  border-radius: 16px;
  background: var(--code-bg);
  color: var(--code-ink);
  font: 600 16px/1.6 var(--mono);
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  align-self: center;
}
.jd-idea .fnbig .need { background: rgba(5, 150, 105, 0.35); border-radius: 5px; padding: 1px 4px; }
.jd-idea .fnbig .make { background: rgba(234, 88, 12, 0.4); border-radius: 5px; padding: 1px 4px; }

.jd-arrow-connector {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  user-select: none;
  pointer-events: none;
}
.jd-arrow-connector.to-need {
  padding-top: 45px;
}
.jd-arrow-connector.to-make {
  padding-top: 122px;
}
.jd-arrow-svg {
  width: 52px;
  height: 24px;
  display: block;
}

@media (max-width: 900px) {
  .jd-idea {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .jd-idea .side,
  .jd-idea .fnbig {
    align-self: stretch;
  }
  .jd-arrow-connector {
    padding-top: 0 !important;
    height: 36px;
    align-items: center;
  }
  .jd-arrow-connector.to-need svg {
    transform: rotate(-90deg);
  }
  .jd-arrow-connector.to-make svg {
    transform: rotate(90deg);
  }
}

.jd-rules { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 22px; }
@media (max-width: 900px) { .jd-rules { grid-template-columns: minmax(0, 1fr); } }
.jd-rule { padding: 18px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.jd-rule .n {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--purple); color: #fff; font: 800 13px var(--font); margin-bottom: 8px;
}
.jd-rule h4 { font-size: 17px; margin-bottom: 4px; }
.jd-rule p { margin: 0; font-size: 14.5px; }

.jd-vs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
@media (max-width: 800px) { .jd-vs { grid-template-columns: minmax(0, 1fr); } }
.jd-vs > div { --c: var(--purple); padding: 16px 18px; border-radius: 14px; border: 1.5px solid var(--c); background: color-mix(in srgb, var(--c) 7%, var(--surface)); }
.jd-vs code.big { font-size: 16px; font-weight: 800; color: var(--c); background: none; padding: 0; }
.jd-vs p { margin: 6px 0 0; font-size: 14.5px; }

/* recipes table */
.jd-recipes { display: grid; gap: 12px; }
.jd-rc {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.5fr) minmax(0, 0.9fr);
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.jd-rc .q { font-weight: 800; color: var(--ink); font-size: 15px; }
.jd-rc pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--code-bg);
  color: var(--code-ink);
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
}
.jd-rc .why { font-size: 13.5px; color: var(--muted); }
@media (max-width: 900px) { .jd-rc { grid-template-columns: minmax(0, 1fr); } }

/* error cards + dictionary */
.jd-err { padding: 14px 18px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--red) 40%, transparent); background: color-mix(in srgb, var(--red) 7%, var(--surface)); }
.jd-err code.e { background: none; padding: 0; color: var(--red); font-weight: 800; font-size: 15px; }
.jd-err p { margin: 6px 0 0; font-size: 14.5px; }
.jd-err .fix { color: var(--ink); font-weight: 600; }
.jd-dict { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.jd-dict div { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-size: 14px; }
.jd-dict code { display: block; background: none; padding: 0; color: var(--purple); font-weight: 800; margin-bottom: 2px; }

/* colour modifiers last, so they beat every component's default --c */
.c-blue { --c: var(--blue); --c-ink: #fff; }
.c-green { --c: var(--green); --c-ink: #fff; }
.c-purple { --c: var(--purple); --c-ink: #fff; }
.c-orange { --c: var(--orange); --c-ink: #fff; }
.c-pink { --c: var(--pink); --c-ink: #fff; }
.c-red { --c: var(--red); --c-ink: #fff; }
.c-yellow { --c: var(--yellow); --c-ink: var(--yellow-ink); }
.c-muted { --c: var(--muted); --c-ink: #fff; }

/* ---------------------------------------------------------------- API reference */
.jd-ep-tabs > .jd-tablist { gap: 6px; }
.jd-ep-tabs > .jd-tablist .jd-tab { font-family: var(--mono); font-size: 12.5px; }
.jd-ep-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 6px 0 12px; }
.jd-method {
  font: 800 12px var(--mono);
  padding: 4px 9px;
  border-radius: 7px;
  color: #fff;
  background: var(--green);
}
.jd-method.post { background: var(--blue); }
.jd-ep-path { font: 700 17px var(--mono); color: var(--ink); }
.jd-auth {
  font: 700 12px var(--font);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.jd-auth.need { color: var(--orange); border-color: color-mix(in srgb, var(--orange) 50%, transparent); }
.jd-auth.secret { color: var(--red); border-color: color-mix(in srgb, var(--red) 50%, transparent); }
.jd-ep-desc { margin: 0 0 14px; font-size: 15px; }

.jd-params { width: 100%; border-collapse: collapse; font-size: 14px; margin: 4px 0 16px; }
.jd-params th {
  text-align: left;
  font: 800 11px var(--font);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.jd-params td { padding: 9px 8px; border-bottom: 1px dashed var(--line); vertical-align: top; }
.jd-params td:first-child,
[data-lang="vi"] .jd-params td[lang="en"]:first-child + td[lang="vi"] { font: 700 13px var(--mono); color: var(--c, var(--purple)); white-space: nowrap; }
.jd-params .req { font: 800 10px var(--font); letter-spacing: 0.06em; text-transform: uppercase; color: var(--red); margin-left: 6px; }
.jd-params .opt { font: 800 10px var(--font); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-left: 6px; }
.jd-params .rule { display: block; margin-top: 2px; font: 600 12px var(--mono); color: var(--muted); }
.jd-tablewrap { overflow-x: auto; }

.jd-errlist { display: grid; gap: 8px; }
.jd-errrow {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 14px;
}
.jd-errrow .code { font: 800 14px var(--mono); color: var(--red); }
.jd-errrow .code.w { color: var(--orange); }
.jd-errrow b { color: var(--ink); }
.jd-errrow .do { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }

/* node states used by small story players */
.jd-node[data-state="active"] { border-color: var(--green); background: color-mix(in srgb, var(--green) 10%, var(--surface)); }
.jd-node[data-state="used"] { border-color: var(--muted); border-style: dashed; opacity: 0.7; }
.jd-node[data-state="killed"] { border-color: var(--red); background: color-mix(in srgb, var(--red) 10%, var(--surface)); }
.jd-node[data-state="killed"] .t { text-decoration: line-through; }
.jd-node .stt { display: none; float: right; font: 800 10.5px var(--font); letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; color: #fff; }
.jd-node[data-state="active"] .stt.active { display: inline-block; background: var(--green); }
.jd-node[data-state="used"] .stt.used { display: inline-block; background: var(--muted); }
.jd-node[data-state="killed"] .stt.killed { display: inline-block; background: var(--red); }

/* token anatomy */
.jd-token-anatomy {
  font: 700 15px var(--mono);
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--code-bg);
  color: var(--code-ink);
  overflow-x: auto;
  white-space: nowrap;
}
.jd-token-anatomy .a { color: #f472b6; }
.jd-token-anatomy .b { color: #93c5fd; }
.jd-token-anatomy .c { color: #fcd34d; }
.jd-life { display: grid; gap: 14px; }
.jd-life-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 12px; font-size: 14px; }
.jd-life-bar { position: relative; height: 30px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.jd-life-bar i {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 50%, transparent));
  display: flex; align-items: center; padding-left: 10px;
  font: 700 12px var(--mono); color: #fff; font-style: normal; white-space: nowrap;
}

/* brute-force simulator */
.jd-sim { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
@media (max-width: 900px) { .jd-sim { grid-template-columns: minmax(0, 1fr); } }
.jd-meter { margin-bottom: 14px; }
.jd-meter .lbl { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 4px; }
.jd-meter .lbl b { color: var(--ink); }
.jd-meter .bar { height: 12px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.jd-meter .bar i { display: block; height: 100%; width: 0; background: var(--c); transition: width 0.3s ease; }
.jd-meter.is-full .bar i { background: var(--red); }
.jd-sim-btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 16px; }
.jd-sim-btns .bad { background: var(--red); color: #fff; border-color: var(--red); }
.jd-sim-btns .good { background: var(--green); color: #fff; border-color: var(--green); }
.jd-sim-log { font: 600 12.5px var(--mono); max-height: 150px; overflow-y: auto; padding: 10px 12px; border-radius: 10px; background: var(--code-bg); color: var(--code-ink); }
.jd-sim-log div { padding: 2px 0; }

.jd-grid3w { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 90px; position: relative; }
.jd-grid3w > :not(.jd-wires):not(.jd-packet):not(.jd-token) { position: relative; z-index: 2; }
@media (max-width: 900px) { .jd-grid3w { grid-template-columns: minmax(0, 1fr); gap: 36px; } .jd-grid3w > * { grid-column: auto !important; grid-row: auto !important; } }
.jd-sim-log:empty { display: none; }

/* long inline paths must wrap on phones */
:not(pre) > code { overflow-wrap: anywhere; }
.jd-section-head > div { min-width: 0; }

/* ---------------------------------------------------------------- package reference (junkit pages) */
.jd-syms { display: grid; gap: 16px; }
.jd-sym {
  border: 1px solid var(--line);
  border-left: 4px solid var(--c, var(--green)); /* no own --c, so c-* classes win */
  border-radius: 14px;
  padding: 16px 18px;
  background: var(--surface);
}
.jd-sym-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.jd-kind {
  font: 800 10.5px var(--font);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--c-ink, #fff);
  background: var(--c, var(--green));
}
.jd-sym-name { font: 800 16px var(--mono); color: var(--ink); }
.jd-sym > p { margin: 8px 0 0; font-size: 14.5px; }
.jd-sym .jd-term { margin-top: 6px; box-shadow: none; }
.jd-sym .jd-term pre { padding: 12px 14px; font-size: 13px; }
.jd-sym .jd-params { margin-bottom: 4px; }
.jd-sym ul { margin: 8px 0 0; padding-left: 20px; font-size: 14px; }
.jd-sym li { margin: 3px 0; }

.jd-pkg-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.jd-calc { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.jd-calc label { display: grid; gap: 4px; font: 700 12px var(--font); color: var(--muted); letter-spacing: 0.04em; }
.jd-calc input, .jd-calc select {
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  padding: 0 12px;
  font: 600 15px var(--mono);
}
.jd-calc input:focus, .jd-calc select:focus { outline: 2px solid var(--c, var(--purple)); outline-offset: 1px; }

/* long signatures must not widen API cards */
.jd-syms { grid-template-columns: minmax(0, 1fr); }

/* demo inputs must shrink on phones */
.jd-calc { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
.jd-calc input, .jd-calc select, .jd-calc textarea { width: 100%; min-width: 0; }

/* inline grid placement must not create extra columns on phones */
@media (max-width: 1000px) { .rf > * { grid-column: auto !important; } }

/* any pre and any grid cell may shrink and scroll instead of widening the page */
.jd-content pre { max-width: 100%; overflow-x: auto; }
.jd-grid-2 > *, .jd-grid-3 > * { min-width: 0; }

/* ---------------------------------------------------------------- build-a-feature page */
.bf-rf {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 46px 56px;
  position: relative;
}
.bf-rf > :not(.jd-wires):not(.jd-packet):not(.jd-token) { position: relative; z-index: 2; }
.bf-rf .jd-node { padding: 12px 12px; }
.bf-rf .jd-node .t { font-size: 15px; }
.bf-rf .jd-node .d { font-size: 12.5px; line-height: 1.4; }
.bf-rf [data-node="client"] { grid-area: 1 / 1; }
.bf-rf [data-node="router"] { grid-area: 1 / 2; }
.bf-rf [data-node="handler"] { grid-area: 1 / 3; }
.bf-rf [data-node="service"] { grid-area: 1 / 4; }
.bf-rf [data-node="repo"] { grid-area: 2 / 4; }
.bf-rf [data-node="db"] { grid-area: 2 / 3; }
.bf-note {
  grid-area: 2 / 1 / 3 / 3;
  align-self: center;
  font-size: 13.5px;
  line-height: 1.7;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1.5px dashed color-mix(in srgb, var(--green) 55%, var(--line));
  color: var(--ink-2);
  background: color-mix(in srgb, var(--green) 4%, transparent);
}
@media (max-width: 1000px) {
  .bf-rf { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .bf-rf > * { grid-area: auto !important; }
}

.bf-new {
  padding: 1px 6px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--yellow) 28%, transparent);
  color: var(--ink);
}
.bf-steps {
  position: relative;
  display: grid;
  gap: 34px;
  margin-top: 26px;
  padding-left: 58px;
}
.bf-steps::before {
  content: "";
  position: absolute;
  left: 21px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(var(--blue), var(--purple), var(--green), var(--orange), var(--pink));
  opacity: 0.55;
}
.bf-steps::after {
  content: "";
  position: absolute;
  left: 17px;
  top: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px 4px var(--purple);
  animation: bf-run 9s linear infinite;
}
@keyframes bf-run {
  0% { top: 0; box-shadow: 0 0 10px 4px var(--blue); }
  50% { box-shadow: 0 0 10px 4px var(--green); }
  100% { top: calc(100% - 11px); box-shadow: 0 0 10px 4px var(--pink); }
}
@media (prefers-reduced-motion: reduce) { .bf-steps::after { display: none; } }
.bf-step { --c: var(--purple); position: relative; min-width: 0; }
.bf-step > .n {
  position: absolute;
  left: -58px;
  top: -2px;
  width: 46px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font: 800 13px var(--mono);
  color: #fff;
  background: var(--c);
  box-shadow: 0 0 0 4px var(--surface), 0 6px 18px color-mix(in srgb, var(--c) 45%, transparent);
}
.bf-step h3 { margin: 0 0 2px; }
.bf-step .file { font: 600 12.5px var(--mono); color: var(--c); margin-bottom: 8px; overflow-wrap: anywhere; }
.bf-step > p { margin: 0 0 12px; color: var(--ink-2); }
@media (max-width: 700px) {
  .bf-steps { padding-left: 0; }
  .bf-steps::before, .bf-steps::after { display: none; }
  .bf-step > .n { position: static; display: inline-grid; margin-bottom: 8px; }
}
/* a params table whose first column is a sentence, not a field name */
.jd-params.is-prose td:first-child,
[data-lang="vi"] .jd-params.is-prose td[lang="en"]:first-child + td[lang="vi"] { font: 600 14px var(--font); color: var(--ink); white-space: normal; min-width: 140px; }
.bf-stack { display: grid; gap: 14px; min-width: 0; }
