:root {
  --brand: #635bff;
  --brand-soft: #f1f0ff;
  --text: #3c4257;
  --heading: #1a1f36;
  --muted: #697386;
  --border: #e3e8ee;
  --bg: #ffffff;
  --bg-subtle: #f6f9fc;
  --code-bg: #0a2540;
  --sidebar-w: 272px;
  --toc-w: 220px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--heading); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark {
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}
.brand-name { font-size: 15px; }

.topbar-links { margin-left: auto; display: flex; gap: 20px; font-size: 14px; }
.topbar-links a { color: var(--muted); }
.topbar-links a:hover { color: var(--heading); text-decoration: none; }

.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--heading);
}

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1400px;
  margin: 0 auto;
}

/* ---------- sidebar ---------- */

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 28px 20px 60px;
  border-right: 1px solid var(--border);
}

.nav-group { margin-bottom: 26px; }
.nav-section {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a {
  display: block;
  padding: 6px 10px;
  margin-left: -10px;
  border-radius: 6px;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.45;
}
.sidebar a:hover { background: var(--bg-subtle); color: var(--heading); text-decoration: none; }
.sidebar a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.ext { color: var(--muted); font-size: 11px; }

/* ---------- content ---------- */

.content { padding: 44px 56px 90px; min-width: 0; }
.prose { max-width: 760px; }

.prose h1 {
  font-size: 36px;
  line-height: 1.25;
  color: var(--heading);
  margin: 0 0 18px;
  letter-spacing: -0.02em;
}
.prose h2 {
  font-size: 24px;
  color: var(--heading);
  margin: 46px 0 14px;
  letter-spacing: -0.01em;
  scroll-margin-top: 80px;
}
.prose h3 {
  font-size: 18px;
  color: var(--heading);
  margin: 32px 0 10px;
  scroll-margin-top: 80px;
}
.prose p { margin: 0 0 18px; }
.prose ul, .prose ol { margin: 0 0 18px; padding-left: 22px; }
.prose li { margin: 6px 0; }
.prose li > ul, .prose li > ol { margin: 6px 0; }
.prose strong { color: var(--heading); font-weight: 600; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }
.prose blockquote {
  margin: 0 0 20px;
  padding: 2px 18px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

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

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 24px;
  font-size: 14.5px;
  display: block;
  overflow-x: auto;
}
.prose th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  white-space: nowrap;
}
.prose td { border-bottom: 1px solid var(--border); padding: 11px 12px; vertical-align: top; }
.prose tbody tr:last-child td { border-bottom: 0; }

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

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: #0a2540;
  overflow-wrap: break-word;
}
.prose pre {
  background: var(--code-bg);
  color: #e6edf7;
  border-radius: 10px;
  padding: 18px 20px;
  overflow-x: auto;
  margin: 0 0 24px;
  font-size: 13.5px;
  line-height: 1.6;
}
.prose pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.highlight, .highlighter-rouge { background: none; }

.highlight .c, .highlight .c1, .highlight .cm { color: #7d8fa8; font-style: italic; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .se { color: #7fd1a8; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kc, .highlight .kr { color: #c39bff; }
.highlight .nt { color: #7fb2ff; }
.highlight .na { color: #9ad7ff; }
.highlight .m, .highlight .mi, .highlight .mf { color: #ffb86b; }
.highlight .nf, .highlight .nb, .highlight .nn { color: #7fb2ff; }
.highlight .o, .highlight .p, .highlight .nx { color: #c7d3e3; }
.highlight .err { color: #ff9c9c; }

/* ---------- callout ---------- */

.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  background: var(--bg-subtle);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 0 0 26px;
}
.callout p { margin: 0; }
.callout-title {
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 6px;
  font-size: 14px;
}

/* ---------- cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 16px;
  margin: 0 0 30px;
}
.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  background: #fff;
  color: var(--text);
  display: block;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.card:hover {
  box-shadow: 0 4px 16px rgba(10, 37, 64, 0.08);
  transform: translateY(-1px);
  text-decoration: none;
}
.card-title { font-weight: 600; color: var(--heading); font-size: 15.5px; margin-bottom: 5px; }
.card-body { font-size: 14px; color: var(--muted); line-height: 1.55; }

/* ---------- on this page ---------- */

.toc {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 44px 20px 60px;
  font-size: 13.5px;
}
.toc-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: block;
  padding: 4px 0 4px 10px;
  color: var(--muted);
  line-height: 1.45;
  border-left: 2px solid transparent;
}
.toc a:hover { color: var(--brand); text-decoration: none; }
.toc a.active { color: var(--brand); border-left-color: var(--brand); }
.toc .lvl3 a { padding-left: 22px; font-size: 13px; }

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

.page-footer {
  max-width: 760px;
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
}
.page-footer a { color: var(--muted); }

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

@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
  .content { padding: 40px 40px 90px; }
}

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .menu-toggle { display: block; }
  .topbar { padding: 0 16px; }
  .topbar-links a:not(:last-child) { display: none; }
  .sidebar {
    display: none;
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: 284px;
    height: calc(100vh - var(--topbar-h));
    background: #fff;
    z-index: 25;
    box-shadow: 0 8px 30px rgba(10, 37, 64, 0.12);
  }
  .sidebar.open { display: block; }
  .content { padding: 32px 22px 80px; }
  .prose h1 { font-size: 29px; }
  .prose h2 { font-size: 21px; }
}

/* per-page agent handoff toolbar */
.page-tools {
  max-width: 760px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 22px;
}
.page-tools a,
.page-tools button {
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}
.page-tools a:hover,
.page-tools button:hover { color: var(--heading); border-color: var(--muted); text-decoration: none; }

.button {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
}
.button:hover { color: #fff; opacity: 0.9; text-decoration: none; }

/* mermaid diagrams */
.mermaid { margin: 0 0 26px; overflow-x: auto; text-align: center; }
.mermaid svg { max-width: 100%; height: auto; }

/* diagram lightbox */
.mermaid { cursor: zoom-in; }
.diagram-zoom {
  width: min(96vw, 1400px);
  max-width: none;
  max-height: 92vh;
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: zoom-out;
}
.diagram-zoom::backdrop { background: rgba(26, 31, 54, 0.6); }
.diagram-zoom svg { display: block; width: 100%; min-width: 720px; height: auto; max-width: none !important; }

/* warning callouts and outcome badges */
.callout-warn { border-left-color: #b45309; }
.callout + .callout { margin-top: -10px; }
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}
.badge-ok { background: #e6f7ee; color: #0b6b3a; }
.badge-no { background: #fdecec; color: #a12622; }

/* showcase: app image links with a label beside each */
.prose .showcase { list-style: none; padding: 0; margin: 8px 0 34px; }
.prose .showcase li { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 0 0 18px; }
.showcase a { flex: none; }
/* icon text matches the 20px label */
.showcase img { display: block; width: auto; height: 48px; border-radius: 10px; transition: box-shadow 0.15s ease, transform 0.15s ease; }
.showcase a:hover img { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(10, 37, 64, 0.25); }
/* long labels wrap beside the icon; they only drop below it on narrow screens */
.showcase-label { flex: 1 1 14em; color: var(--heading); font-size: 20px; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
/* YID Wallet's hero gradient (#9c93ff, #e0b25a, #3ddc97), deepened to stay readable on white */
.showcase-grad { background: linear-gradient(90deg, #6d62e8, #c28a2c 60%, #179e68); -webkit-background-clip: text; background-clip: text; color: transparent; }
.showcase-more { display: inline-block; margin-left: 8px; vertical-align: 3px; white-space: nowrap; letter-spacing: 0; font-size: 14px; font-weight: 600; line-height: 1.5; color: var(--brand); border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px; }
.showcase-more:hover { background: var(--brand-soft); border-color: var(--brand); text-decoration: none; }
/* popup for the video and dashboard; tall images scroll inside it */
.showcase-popup { width: min(96vw, 1100px); max-width: none; max-height: 92vh; overflow: auto; padding: 0; border: 0; border-radius: 12px; background: #09111f; }
.showcase-popup::backdrop { background: rgba(26, 31, 54, 0.7); }
.showcase-popup video, .showcase-popup img { display: block; width: 100%; height: auto; }
.showcase-close { position: sticky; top: 10px; z-index: 1; float: right; margin: 10px 10px -46px 0; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.92); color: var(--heading); font-size: 22px; line-height: 1; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }
