/* NodeCrypto help documents (help-docs.md §3). No external resources: must work offline. */
:root {
  color-scheme: light dark;
  --bg: #f8fafc;
  --surface: #ffffff;
  --fg: #0f172a;
  --fg-secondary: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --panel: #f1f5f9;
  --panel-hover: #e2e8f0;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --accent-fg: #1e40af;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07);
  --warn-bg: #fffbeb; --warn-border: #f59e0b; --warn-fg: #78350f;
  --info-bg: #eff6ff; --info-border: #60a5fa; --info-fg: #1e3a8a;
  --ok-bg: #ecfdf5; --ok-border: #34d399; --ok-fg: #065f46;
  --err-bg: #fef2f2; --err-border: #f87171; --err-fg: #991b1b;
  --data-bg: #dbeafe; --data-bd: #60a5fa; --data-fg: #1e3a8a;
  --pad-bg: #fef3c7; --pad-bd: #f59e0b; --pad-fg: #78350f;
  --len-bg: #f3e8ff; --len-bd: #c084fc; --len-fg: #581c87;
  --tok-kw: #9333ea; --tok-fn: #2563eb; --tok-type: #0d9488; --tok-lit: #d97706; --tok-com: #64748b;
  --port-bytes: #3b82f6; --port-string: #10b981; --port-int: #f59e0b; --port-bool: #a855f7; --port-set: #ec4899; --port-any: #94a3b8;
}

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) {
    --bg: #0b1120;
    --surface: #111827;
    --fg: #f1f5f9;
    --fg-secondary: #cbd5e1;
    --muted: #94a3b8;
    --border: #1e293b;
    --border-strong: #334155;
    --panel: #1e293b;
    --panel-hover: #334155;
    --link: #60a5fa;
    --link-hover: #93c5fd;
    --accent: #3b82f6;
    --accent-soft: rgba(59, 130, 246, 0.18);
    --accent-fg: #93c5fd;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
    --warn-bg: rgba(120, 53, 15, 0.28); --warn-border: #d97706; --warn-fg: #fde68a;
    --info-bg: rgba(30, 58, 138, 0.28); --info-border: #3b82f6; --info-fg: #bfdbfe;
    --ok-bg: rgba(6, 95, 70, 0.28); --ok-border: #10b981; --ok-fg: #a7f3d0;
    --err-bg: rgba(153, 27, 27, 0.28); --err-border: #ef4444; --err-fg: #fecaca;
    --data-bg: #1e3a8a55; --data-bd: #3b82f680; --data-fg: #bfdbfe;
    --pad-bg: #78350f55; --pad-bd: #f59e0b80; --pad-fg: #fde68a;
    --len-bg: #581c8755; --len-bd: #a855f780; --len-fg: #e9d5ff;
    --tok-kw: #d8b4fe; --tok-fn: #93c5fd; --tok-type: #5eead4; --tok-lit: #fcd34d; --tok-com: #94a3b8;
  }
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #111827;
  --fg: #f1f5f9;
  --fg-secondary: #cbd5e1;
  --muted: #94a3b8;
  --border: #1e293b;
  --border-strong: #334155;
  --panel: #1e293b;
  --panel-hover: #334155;
  --link: #60a5fa;
  --link-hover: #93c5fd;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.18);
  --accent-fg: #93c5fd;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  --warn-bg: rgba(120, 53, 15, 0.28); --warn-border: #d97706; --warn-fg: #fde68a;
  --info-bg: rgba(30, 58, 138, 0.28); --info-border: #3b82f6; --info-fg: #bfdbfe;
  --ok-bg: rgba(6, 95, 70, 0.28); --ok-border: #10b981; --ok-fg: #a7f3d0;
  --err-bg: rgba(153, 27, 27, 0.28); --err-border: #ef4444; --err-fg: #fecaca;
  --data-bg: #1e3a8a55; --data-bd: #3b82f680; --data-fg: #bfdbfe;
  --pad-bg: #78350f55; --pad-bd: #f59e0b80; --pad-fg: #fde68a;
  --len-bg: #581c8755; --len-bd: #a855f780; --len-fg: #e9d5ff;
  --tok-kw: #d8b4fe; --tok-fn: #93c5fd; --tok-type: #5eead4; --tok-lit: #fcd34d; --tok-com: #94a3b8;
}

:root:has(> head > meta[name="color-scheme"][content="light"]) {
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.7 system-ui, -apple-system, "Segoe UI", Roboto, "Malgun Gothic", sans-serif;
}
a { color: var(--link); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--link-hover); text-decoration: underline; }

/* Sticky Top Header */
header.site {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}
header.site .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--fg);
  margin-right: auto;
  letter-spacing: -0.01em;
}
header.site .brand-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
header.site .brand-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}
header.site nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
header.site nav a {
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
header.site nav a:hover {
  background: var(--panel);
  color: var(--fg);
  text-decoration: none;
}
header.site nav a.active {
  background: var(--accent-soft);
  color: var(--accent-fg);
  font-weight: 600;
}

/* Header Tools (Quick Search + Theme Toggle + Lang Switch) */
.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}
.quick-search-wrap {
  position: relative;
}
.quick-search-input {
  width: 190px;
  padding: 5px 28px 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--fg);
  font-size: 0.84rem;
  transition: width 0.2s, border-color 0.15s;
}
.quick-search-input:focus {
  width: 240px;
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.quick-search-kbd {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  pointer-events: none;
}
.quick-search-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 320px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: none;
  z-index: 60;
}
.quick-search-dropdown.open { display: block; }
.quick-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--fg);
  text-decoration: none;
}
.quick-search-item:hover, .quick-search-item.active {
  background: var(--accent-soft);
  color: var(--accent-fg);
  text-decoration: none;
}
.quick-search-item code {
  font-size: 0.74rem;
  color: var(--muted);
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.theme-btn:hover {
  background: var(--panel);
  color: var(--fg);
  border-color: var(--border-strong);
}

/* Page Shell: Main + Right Sticky Rail */
.doc-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
@media (min-width: 1080px) {
  .doc-shell.has-rail {
    grid-template-columns: minmax(0, 880px) 250px;
  }
}

main {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 36px;
  box-shadow: var(--shadow-sm);
}
@media (max-width: 640px) {
  main { padding: 20px 18px; border-radius: 10px; }
  .doc-shell { padding: 14px 10px 32px; }
}

/* Right Rail (Sticky TOC + Ad Slot) */
.doc-rail {
  display: none;
}
@media (min-width: 1080px) {
  .doc-shell.has-rail .doc-rail {
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
  }
}
.toc-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.toc-title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 10px;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--border);
}
.toc-list li { margin: 0; }
.toc-list a {
  display: block;
  padding: 4px 10px;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--muted);
  border-left: 2px solid transparent;
  margin-left: -2px;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.toc-list a.toc-h3 { padding-left: 20px; font-size: 0.78rem; }
.toc-list a:hover { color: var(--fg); }
.toc-list a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
  background: var(--accent-soft);
  border-radius: 0 4px 4px 0;
}

/* Typography & Section Headings */
h1 {
  font-size: 1.85rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0 0 0.45em;
}
h2 {
  font-size: 1.32rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin: 2.1em 0 0.55em;
  padding-top: 0.75em;
  border-top: 1px solid var(--border);
  scroll-margin-top: 72px;
  display: flex;
  align-items: center;
  gap: 8px;
}
h2:first-of-type { margin-top: 1.4em; }
h3 {
  font-size: 1.06rem;
  margin: 1.4em 0 0.4em;
  color: var(--fg);
  scroll-margin-top: 72px;
}
h2:target, h3:target {
  background: var(--accent-soft);
  padding-left: 8px;
  border-radius: 6px;
}
.meta {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0 0 1em;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

/* Hero Banner (Main Page & Section Landings) */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: center;
  padding: 26px 28px;
  margin-bottom: 26px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background:
    radial-gradient(circle at 90% 15%, var(--accent-soft), transparent 55%),
    linear-gradient(135deg, var(--surface) 0%, var(--panel) 100%);
}
@media (max-width: 780px) {
  .hero { grid-template-columns: 1fr; padding: 20px; }
}
.hero h1 { font-size: 2rem; margin: 0 0 10px; }
.hero p { margin: 0 0 16px; color: var(--fg-secondary); font-size: 0.98rem; }
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--fg-secondary);
}
.hero-badge strong { color: var(--accent); }
.hero-art svg {
  width: 100%;
  max-width: 360px;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Bento / Topic Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin: 1.2em 0 1.8em;
  list-style: none;
  padding: 0;
}
.doc-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
}
.doc-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.doc-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.doc-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.doc-card-icon svg { width: 20px; height: 20px; }
.doc-card-title {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  color: var(--fg);
}
.doc-card-title a { color: inherit; text-decoration: none; }
.doc-card-title a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
}
.doc-card-desc {
  font-size: 0.87rem;
  color: var(--fg-secondary);
  line-height: 1.55;
  margin: 0;
  flex: 1;
}
.doc-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  position: relative;
  z-index: 2;
}

/* 3-Step Visual Workflow Strip */
.step-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 1.2em 0 1.8em;
}
@media (max-width: 760px) {
  .step-grid { grid-template-columns: 1fr; }
}
.step-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 6px;
}
.step-card strong { font-size: 0.92rem; }
.step-card p { margin: 6px 0 0; font-size: 0.84rem; color: var(--fg-secondary); }

/* Node Index Filter Bar & Node Grid */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 16px 0 22px;
}
.filter-search {
  flex: 1 1 220px;
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg);
  font-size: 0.9rem;
}
.filter-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.filter-pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-pill:hover { border-color: var(--accent); color: var(--fg); }
.filter-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0.8em 0 1.6em;
}
.node-grid > li {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--cat-color, var(--accent));
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.86rem;
  line-height: 1.45;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.node-grid > li:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.node-grid > li a {
  font-weight: 600;
  font-size: 0.93rem;
}
.node-grid > li code {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--panel);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Visual Canvas Node Card Preview (Individual Node Pages) */
.node-overview-grid {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 22px;
  align-items: start;
  margin: 12px 0 18px;
}
@media (max-width: 740px) {
  .node-overview-grid { grid-template-columns: 1fr; }
}
.node-preview-card {
  background: #0f172a;
  color: #f1f5f9;
  border: 1px solid #334155;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  font-size: 0.8rem;
}
.node-preview-head {
  padding: 8px 12px;
  background: linear-gradient(90deg, var(--cat-color, #2563eb), color-mix(in srgb, var(--cat-color, #2563eb) 65%, #0f172a));
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.node-preview-head strong {
  font-size: 0.84rem;
  color: #fff;
  letter-spacing: 0.01em;
}
.node-preview-head span {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.45);
  color: #e2e8f0;
  font-family: ui-monospace, Consolas, monospace;
}
.node-preview-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 10px 12px;
}
.node-preview-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.node-preview-col.out { align-items: flex-end; text-align: right; }
.node-preview-col-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  margin-bottom: 2px;
}
.node-port-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: #e2e8f0;
  padding: 2px 5px;
  border-radius: 4px;
  transition: opacity 0.15s, background 0.15s;
}
.node-port-row.dimmed { opacity: 0.28; }
.node-port-row.highlighted { background: rgba(59, 130, 246, 0.25); }
.port-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--port-bytes);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}
.port-dot[data-type="string"] { background: var(--port-string); }
.port-dot[data-type="int"] { background: var(--port-int); }
.port-dot[data-type="bool"] { background: var(--port-bool); }
.port-dot[data-type="set"] { background: var(--port-set); }
.port-dot[data-type="any"] { background: var(--port-any); }
.node-preview-foot {
  padding: 6px 10px;
  background: #1e293b;
  border-top: 1px solid #334155;
  font-size: 0.7rem;
  color: #94a3b8;
  display: flex;
  justify-content: space-between;
}

/* Interactive Mode Filter Bar on Conditional Port Pages */
.mode-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 10px 0;
  font-size: 0.8rem;
}
.mode-filter-bar strong { color: var(--fg-secondary); margin-right: 4px; }
tr.dimmed-row { opacity: 0.35; }
tr.highlighted-row { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }

/* Visual Wiring Flow Diagram (Examples section) */
.wiring-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  margin: 10px 0 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}
.wiring-node {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}
.wiring-node.current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-fg);
}
.wiring-arrow {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  user-select: none;
}

/* Semantic Pill Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}
.badge-req { background: var(--err-bg); color: var(--err-fg); border: 1px solid var(--err-border); }
.badge-opt { background: var(--panel); color: var(--muted); border: 1px solid var(--border-strong); }
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); border: 1px solid var(--ok-border); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-border); }
.badge-info { background: var(--info-bg); color: var(--info-fg); border: 1px solid var(--info-border); }
.badge-type {
  font-family: ui-monospace, Consolas, monospace;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--fg);
}

/* Responsive Tables (modern-web-guidance: responsive-table) */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  container-type: inline-size;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 1em 0;
  background: var(--surface);
}
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 0.88rem;
  margin: 0;
}
.table-wrapper + .table-wrapper, main > table {
  margin: 1em 0;
}
thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
}
th, td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
th:last-child, td:last-child { border-right: none; }
tbody tr:last-child td { border-bottom: none; }
th {
  background: var(--panel);
  font-weight: 600;
  color: var(--fg-secondary);
}
tbody tr:hover {
  background: color-mix(in srgb, var(--panel) 50%, transparent);
}

/* Alerts, Examples & Byte Visualizations */
.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-left-width: 4px;
  color: var(--warn-fg);
  padding: 12px 16px;
  border-radius: 8px;
  margin: 1em 0;
  font-size: 0.9rem;
}
.example {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 1em 0;
}
.example .cap {
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--fg-secondary);
}
.bytes {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  font: 11px/1 ui-monospace, Consolas, monospace;
}
.bytes span {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid;
  border-radius: 4px;
  font-weight: 700;
}
.bytes span.blk { margin-left: 8px; }
.b-data { background: var(--data-bg); border-color: var(--data-bd); color: var(--data-fg); }
.b-pad { background: var(--pad-bg); border-color: var(--pad-bd); color: var(--pad-fg); }
.b-len { background: var(--len-bg); border-color: var(--len-bd); color: var(--len-fg); }
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 8px;
}
.legend i {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 1px solid;
  border-radius: 2px;
  vertical-align: -1px;
  margin-right: 4px;
}

/* Inline SVG Diagrams */
.diagram {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin: 1.1em 0;
}
.diagram svg {
  max-width: 620px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
.diagram .dk { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .diagram .dk { display: block; }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .diagram .lt { display: none; }
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .diagram .dk { display: block; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) .diagram .lt { display: none; }

/* Code Blocks & Copy Button & Script I/O Panel */
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
p code, li code, td code {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.86em;
}
.code-block-wrap {
  position: relative;
  margin: 1em 0;
}
pre {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 1em 0;
  font-size: 0.86rem;
  line-height: 1.6;
}
.code-block-wrap pre { margin: 0; }
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.85;
  transition: all 0.15s;
}
.copy-btn:hover { opacity: 1; color: var(--fg); border-color: var(--accent); }
.copy-btn.copied { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-border); }

.script-io {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  padding: 8px 12px;
  margin-top: -6px;
  margin-bottom: 1em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 10px 10px;
  font-size: 0.78rem;
}
.script-io-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
.script-io-label {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.tok-kw { color: var(--tok-kw); font-weight: 600; }
.tok-fn { color: var(--tok-fn); }
.tok-type { color: var(--tok-type); }
.tok-lit { color: var(--tok-lit); }
.tok-com { color: var(--tok-com); font-style: italic; }

/* Sub-navigation Pill Bar (Script pages) */
.subnav-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 0 0 20px;
}
.subnav-pills a {
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--fg-secondary);
  text-decoration: none;
}
.subnav-pills a:hover { background: var(--surface); color: var(--fg); }
.subnav-pills a.active {
  background: var(--accent);
  color: #fff;
}

/* Google AdSense Reserved Containers (CLS-safe, hidden when disabled/offline) */
.ad-slot {
  display: none;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
  overflow: hidden;
}
.ad-slot.ad-active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ad-slot-rail {
  min-height: 250px;
  width: 100%;
  padding: 8px;
}
.ad-slot-banner {
  min-height: 90px;
  width: 100%;
  margin: 28px 0 8px;
  padding: 8px;
}
.ad-slot-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}

/* Site Footer */
footer.site-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 24px 36px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.83rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}
.footer-copy {
  line-height: 1.5;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}
.footer-links a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 3px;
  transition: color 0.15s, text-decoration-color 0.15s, background 0.15s;
}
.footer-links a:hover {
  color: var(--accent-fg);
  text-decoration-color: var(--accent-fg);
}
.footer-links a.footer-app-link {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--info-border);
  background: var(--accent-soft);
  color: var(--accent-fg);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
}
.footer-links a.footer-app-link:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
}
@media (max-width: 740px) {
  footer.site-footer {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px 16px 28px;
    gap: 10px;
  }
}
kbd {
  font: 0.8em/1.2 ui-monospace, Consolas, monospace;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
}
