@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Serif:wght@600;700&family=JetBrains+Mono:wght@400;500;700&display=swap");

:root {
  font-synthesis-weight: none;
  --bg: #f8f7f4;
  --surface: #ffffff;
  --surface-soft: #f2f0eb;
  --surface-warm: #fff7ec;
  --ink: #1b2733;
  --ink-strong: #102235;
  --muted: #66727f;
  --line: #ded9cf;
  --line-strong: #c7bfb2;
  --brand-blue: #19354e;
  --brand-slate: #66777c;
  --brand-amber: #b9792a;
  --accent: #ff5f46;
  --accent-dark: #a13e24;
  --ok: #267a4a;
  --warn: #a86617;
  --danger: #b7352a;
  --shadow: 0 22px 60px rgba(39, 33, 24, .08);
  --radius-sm: 10px;
  --radius: 18px;
  --radius-lg: 28px;
  --sidebar: 296px;
  --font-sans: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-display: "IBM Plex Serif", Georgia, serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", monospace;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 10%, rgba(185, 121, 42, .12), transparent 26rem),
    radial-gradient(circle at 90% 0%, rgba(25, 53, 78, .10), transparent 30rem),
    linear-gradient(180deg, #fbfaf7 0%, var(--bg) 52%, #f1eee8 100%);
  color: var(--ink);
}

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

code, pre { font-family: var(--font-mono); }
code {
  background: #f1ece3;
  border: 1px solid #e4d9ca;
  border-radius: 6px;
  color: #6f3d13;
  font-size: .88em;
  padding: .08rem .32rem;
}

pre {
  background: #152331;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--radius);
  box-shadow: 0 18px 45px rgba(11, 23, 35, .18);
  color: #e9f2f8;
  overflow: auto;
  padding: 1.15rem;
  position: relative;
}

pre code {
  background: transparent;
  border: 0;
  color: inherit;
  display: block;
  font-size: .86rem;
  line-height: 1.65;
  padding: 0;
}

.hljs { background: transparent; color: #e9f2f8; }
.hljs-keyword, .hljs-selector-tag, .hljs-title.function_ { color: #ffb86b; }
.hljs-string, .hljs-attr { color: #9ee493; }
.hljs-number, .hljs-literal { color: #8fd3ff; }
.hljs-comment { color: #8da3b7; }

.skip-link {
  background: var(--brand-blue);
  color: white;
  left: 1rem;
  padding: .6rem 1rem;
  position: absolute;
  top: -5rem;
  z-index: 999;
}
.skip-link:focus { top: 1rem; }

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

.sidebar {
  background:
    linear-gradient(180deg, rgba(255,255,255,.78), rgba(255,255,255,.62)),
    var(--surface-soft);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  left: 0;
  overflow-y: auto;
  position: fixed;
  top: 0;
  width: var(--sidebar);
  z-index: 20;
}

.brand-panel {
  border-bottom: 1px solid var(--line);
  padding: 1.35rem 1.25rem 1rem;
}

.brand {
  align-items: center;
  color: var(--ink-strong);
  display: flex;
  gap: .72rem;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark { height: 2.55rem; width: 2.55rem; }
.brand-text {
  font-family: var(--font-display);
  font-size: 1.23rem;
  font-weight: 700;
  letter-spacing: -.03em;
}
.brand-meta {
  color: var(--muted);
  display: block;
  font-size: .76rem;
  margin-top: .55rem;
}

.side-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: .12rem;
  padding: .95rem;
}

.nav-group {
  border-bottom: 1px solid rgba(222, 217, 207, .72);
  padding: .18rem 0 .42rem;
}
.nav-group:last-child { border-bottom: 0; }
.nav-group-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  font: 800 .68rem/1 var(--font-sans);
  justify-content: space-between;
  letter-spacing: .12em;
  margin: .5rem 0 .16rem;
  padding: .55rem .62rem;
  text-align: left;
  text-transform: uppercase;
  width: 100%;
}
.nav-group-toggle::after {
  color: var(--brand-amber);
  content: "›";
  font-size: 1rem;
  transform: rotate(0deg);
  transition: transform .16s ease;
}
.nav-group.open .nav-group-toggle::after { transform: rotate(90deg); }
.nav-group-links {
  display: none;
  flex-direction: column;
  gap: .12rem;
}
.nav-group.open .nav-group-links { display: flex; }

.side-nav a {
  border-radius: 10px;
  color: #3e4c58;
  font-size: .9rem;
  font-weight: 500;
  padding: .48rem .62rem;
}
.side-nav a:hover {
  background: rgba(185, 121, 42, .10);
  color: var(--brand-blue);
  text-decoration: none;
}
.side-nav a.active {
  background: var(--brand-blue);
  color: white;
}
.nav-label {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  margin: .82rem .62rem .18rem;
  text-transform: uppercase;
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  display: flex;
  gap: .8rem;
  padding: 1rem 1.25rem;
}

.content {
  margin-left: var(--sidebar);
  max-width: 1180px;
  padding: 2rem clamp(1.25rem, 4vw, 3.5rem) 5rem;
  width: 100%;
}

.hero {
  align-items: stretch;
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(0, 1.32fr) minmax(360px, .88fr);
  min-height: 58vh;
  padding: 2rem 0 2.6rem;
}

.hero-copy {
  align-self: center;
}
.hero-logo {
  display: block;
  height: auto;
  margin: .45rem 0 1.1rem;
  max-width: min(500px, 100%);
}

.eyebrow {
  color: var(--accent-dark);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .14em;
  margin: 0 0 .7rem;
  text-transform: uppercase;
}

h1, h2, h3 {
  color: var(--ink-strong);
  letter-spacing: -.035em;
  line-height: 1.08;
}
h1 {
  font-family: var(--font-display);
  font-size: clamp(2.45rem, 5.2vw, 4.7rem);
  margin: 0 0 .95rem;
  max-width: 900px;
}
.hero h1 {
  font-size: clamp(2.25rem, 4.45vw, 4.05rem);
}
h2 {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 3vw, 2.55rem);
  margin: 0 0 .95rem;
}
h3 {
  font-size: 1.15rem;
  margin: 0 0 .55rem;
}

.lead {
  color: #445260;
  font-size: clamp(1rem, 1.45vw, 1.16rem);
  line-height: 1.64;
  max-width: 800px;
}

.hero-actions, .pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  margin-top: 1.4rem;
}

.button {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-weight: 700;
  gap: .45rem;
  justify-content: center;
  min-height: 2.75rem;
  min-width: max-content;
  padding: .72rem 1.15rem;
  white-space: nowrap;
}
.button:hover { text-decoration: none; }
.button.primary {
  background: var(--brand-blue);
  box-shadow: 0 12px 28px rgba(25, 53, 78, .18);
  color: #fff;
}
.button.secondary {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--brand-blue);
}
.cta-button {
  min-width: 12.5rem;
}

.hero-card {
  align-self: center;
  background:
    linear-gradient(145deg, rgba(25,53,78,.98), rgba(43,65,79,.94)),
    var(--brand-blue);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(25, 53, 78, .22);
  color: white;
  overflow: hidden;
  padding: 2rem;
  position: relative;
}
.hero-card::after {
  background: radial-gradient(circle, rgba(185,121,42,.45), transparent 65%);
  content: "";
  height: 18rem;
  position: absolute;
  right: -8rem;
  top: -6rem;
  width: 18rem;
}
.hero-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.45rem;
  letter-spacing: -.035em;
  line-height: 1.1;
  max-width: 14rem;
  position: relative;
  z-index: 1;
}
.hero-card p {
  color: rgba(255,255,255,.78);
  line-height: 1.65;
  position: relative;
  z-index: 1;
}
.card-kicker {
  color: #f0c58c;
  display: block;
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .12em;
  margin-bottom: .6rem;
  position: relative;
  text-transform: uppercase;
  z-index: 1;
}
.pill-row span {
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  color: rgba(255,255,255,.86);
  flex: 0 0 auto;
  font-size: .78rem;
  padding: .35rem .65rem;
  position: relative;
  z-index: 1;
  white-space: nowrap;
}

.section {
  border-top: 1px solid var(--line);
  padding: 3.25rem 0;
}
.section-heading {
  max-width: 780px;
  margin-bottom: 1.8rem;
}
.section-heading p, .section > p, .split p {
  color: #4f5c68;
  line-height: 1.72;
}

.feature-grid, .contract-grid, .connector-tiles, .mode-grid, .info-grid {
  display: grid;
  gap: 1rem;
}
.feature-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.contract-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.connector-tiles {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.mode-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.info-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.feature-card, .contract-grid article, .connector-tiles a, .doc-card, .mode-card, .note, .page-card, .info-card {
  background: rgba(255,255,255,.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem;
}
.feature-card p, .contract-grid p, .connector-tiles span, .doc-card p, .mode-card p, .note p, .page-card p, .info-card p {
  color: var(--muted);
  line-height: 1.62;
  margin: 0;
}
.contract-grid span, .mode-card span, .doc-card span, .info-card span {
  color: var(--accent-dark);
  display: block;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 700;
  margin-bottom: .55rem;
}
.connector-tiles a {
  color: var(--ink);
  display: block;
  min-height: 9rem;
}
.connector-tiles a:hover {
  border-color: var(--brand-amber);
  text-decoration: none;
  transform: translateY(-2px);
}
.connector-tiles strong {
  color: var(--ink-strong);
  display: block;
  font-size: 1.05rem;
  margin-bottom: .55rem;
}

.split {
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(0, .8fr) minmax(360px, 1.2fr);
}

.diagram-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow-x: auto;
  padding: 1rem;
  position: relative;
}
.mermaid { min-width: 560px; }
.diagram-card-lg {
  padding: 1.35rem;
}
.diagram-card-lg .mermaid {
  min-width: 760px;
}
.diagram-card-wide {
  margin-top: 1.6rem;
  padding: 1.35rem;
}
.diagram-card-wide .mermaid {
  min-width: 980px;
}
.mermaid-readable svg {
  min-height: 320px;
}
.mermaid-readable svg text,
.mermaid-readable .messageText,
.mermaid-readable .actor,
.mermaid-readable .labelText {
  font-weight: 700 !important;
}
.diagram-expand {
  align-items: center;
  background: var(--brand-blue);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(25, 53, 78, .18);
  color: #fff7ec;
  cursor: pointer;
  display: inline-flex;
  font-size: 1rem;
  font-weight: 800;
  height: 2.35rem;
  justify-content: center;
  letter-spacing: .02em;
  margin: 0 0 1rem auto;
  padding: 0;
  position: relative;
  width: 2.35rem;
  z-index: 3;
}
.diagram-card.expanded {
  background: #fffdf9;
  bottom: 1.25rem;
  box-shadow: 0 28px 90px rgba(16, 34, 53, .24);
  left: 1.25rem;
  max-width: none;
  overflow: auto;
  padding: 1.5rem;
  position: fixed;
  right: 1.25rem;
  top: 1.25rem;
  z-index: 100;
}
.diagram-card.expanded .diagram-expand {
  margin-bottom: 1.25rem;
}
.diagram-card.expanded .mermaid {
  min-width: 1200px;
}
.diagram-card.expanded .mermaid-readable svg {
  min-height: 560px;
}

.check-list {
  list-style: none;
  margin: 1.3rem 0 0;
  padding: 0;
}
.check-list li {
  border-top: 1px solid var(--line);
  padding: .75rem 0 .75rem 1.75rem;
  position: relative;
}
.check-list li::before {
  color: var(--ok);
  content: "✓";
  font-weight: 800;
  left: 0;
  position: absolute;
}

.cta-panel {
  align-items: center;
  background: linear-gradient(135deg, #fff, #fff4e7);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
  padding: 2rem;
}

.page-header {
  border-bottom: 1px solid var(--line);
  padding: 2.35rem 0 1.7rem;
}
.page-header h1 {
  font-size: clamp(2.15rem, 3.8vw, 3.55rem);
}
.page-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.doc-layout {
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(0, 1fr) 250px;
}
.toc {
  align-self: start;
  background: rgba(255,255,255,.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  position: sticky;
  top: 1rem;
}
.toc strong {
  display: block;
  margin-bottom: .5rem;
}
.toc a {
  color: var(--muted);
  display: block;
  font-size: .86rem;
  padding: .3rem 0;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: .78rem .85rem;
  text-align: left;
  vertical-align: top;
}
th {
  background: #f0ece4;
  color: var(--ink-strong);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.note {
  border-left: 4px solid var(--brand-amber);
  margin: 1rem 0;
}
.note.warning { border-left-color: var(--warn); }
.note.danger { border-left-color: var(--danger); }
.note.success { border-left-color: var(--ok); }
.note strong { display: block; margin-bottom: .35rem; }
details.note {
  padding: 0;
}
details.note > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  list-style: none;
  padding: 1.05rem 1.1rem;
}
details.note > summary::-webkit-details-marker {
  display: none;
}
details.note > summary::after {
  align-items: center;
  background: var(--brand-blue);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(25, 53, 78, .18);
  color: var(--brand-amber);
  content: "+";
  display: inline-flex;
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 800;
  height: 2rem;
  justify-content: center;
  line-height: 1;
  transform: rotate(0deg);
  transition: background .16s ease, color .16s ease, transform .16s ease;
  width: 2rem;
}
details.note[open] > summary::after {
  background: var(--brand-amber);
  color: #fff7ec;
  content: "−";
  transform: rotate(180deg);
}
details.note > summary:hover::after {
  background: var(--brand-amber);
  color: #fff7ec;
}
details.note > p {
  padding: 0 1.1rem 1rem;
}
details.note > .table-wrap {
  border-left: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  border-right: 0;
  border-bottom: 0;
}

.step-list {
  counter-reset: steps;
  display: grid;
  gap: .85rem;
  margin: 1.2rem 0;
  padding: 0;
}
.step-list li {
  background: rgba(255,255,255,.76);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  counter-increment: steps;
  list-style: none;
  padding: 1rem 1rem 1rem 3.2rem;
  position: relative;
}
.step-list li::before {
  align-items: center;
  background: var(--brand-blue);
  border-radius: 999px;
  color: white;
  content: counter(steps);
  display: flex;
  font-weight: 800;
  height: 1.75rem;
  justify-content: center;
  left: .85rem;
  position: absolute;
  top: .9rem;
  width: 1.75rem;
}
.muted { color: var(--muted); }
.kbd-row {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin: .9rem 0 0;
}
.kbd-row span {
  background: #f1ece3;
  border: 1px solid #e4d9ca;
  border-radius: 999px;
  color: #6f3d13;
  font-family: var(--font-mono);
  font-size: .72rem;
  padding: .28rem .52rem;
}
.code-tabs {
  background: rgba(255,255,255,.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 1rem 0 1.45rem;
  overflow: hidden;
}
.code-tab-list {
  align-items: center;
  background: #f3efe7;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: .35rem;
  padding: .55rem .65rem 0;
}
.code-tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px 10px 0 0;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .04em;
  padding: .52rem .85rem;
  text-transform: uppercase;
}
.code-tab.active {
  background: #152331;
  border-color: #152331;
  color: #fff7ec;
}
.code-panel {
  background: #152331;
}
.code-panel pre {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}
.code-panel[hidden] {
  display: none;
}

.copy-btn {
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  color: #e9f2f8;
  cursor: pointer;
  font-size: .72rem;
  font-weight: 700;
  padding: .32rem .5rem;
  position: absolute;
  right: .75rem;
  top: .75rem;
}
.copy-btn.copied { color: #9ee493; }

.nav-toggle {
  background: var(--brand-blue);
  border: 0;
  border-radius: 12px;
  color: white;
  display: none;
  height: 42px;
  left: 1rem;
  position: fixed;
  top: 1rem;
  width: 42px;
  z-index: 40;
}

@media (max-width: 1120px) {
  .feature-grid, .contract-grid, .connector-tiles, .mode-grid, .info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hero, .split, .doc-layout {
    grid-template-columns: 1fr;
  }
  .toc { position: static; }
}

@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .sidebar {
    box-shadow: 20px 0 60px rgba(25,53,78,.18);
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .content {
    margin-left: 0;
    padding-top: 4.8rem;
  }
  .hero { min-height: auto; padding-top: 0; }
  .feature-grid, .contract-grid, .connector-tiles, .mode-grid, .page-grid, .info-grid {
    grid-template-columns: 1fr;
  }
  .cta-panel {
    align-items: flex-start;
    flex-direction: column;
  }
  .button {
    min-width: 0;
    white-space: normal;
  }
}
