/* Relay documentation wiki stylesheet - engineered obsidian and technical cobalt */
:root {
  --bg: #0d1117;
  --bg-2: #010409;
  --bg-panel: #161b22;
  --bg-raised: #21262d;
  --line: #30363d;
  --line-strong: #484f58;
  --line-focus: #4493f8;
  --ink: #f0f6fc;
  --ink-dim: #8b949e;
  --ink-faint: #8b949e;
  --cobalt: #1f6feb;
  --cobalt-hi: #58a6ff;
  --cobalt-dark: #0969da;
  --emerald: #3fb950;
  --rose: #f85149;
  --amber: #d29922;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--cobalt-hi);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .15s, border-color .15s;
}
a:hover {
  color: #79b8ff;
  border-bottom-color: currentColor;
}
pre, code, kbd { font-family: var(--mono); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* Subtle top background depth */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1000px 450px at 15% -5%, rgba(31, 111, 235, 0.08), transparent 60%),
    radial-gradient(800px 450px at 85% 5%, rgba(31, 111, 235, 0.05), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg) 100%);
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
nav.wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -.01em;
  color: var(--ink);
  white-space: nowrap;
}
.brand a {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  border-bottom: none;
}
.brand svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.brand .badge {
  font-size: .8rem;
  font-family: var(--mono);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(31, 111, 235, 0.15);
  color: var(--cobalt-hi);
  border: 1px solid rgba(88, 166, 255, 0.3);
}
header nav ul {
  display: flex;
  gap: 24px;
  list-style: none;
  align-items: center;
}
header nav a {
  font-size: .9rem;
  color: var(--ink-dim);
  border-bottom: none;
  font-weight: 500;
  transition: color .15s;
}
header nav a:hover,
header nav a.active {
  color: var(--ink);
}
.nav-cta {
  background: var(--cobalt);
  color: #ffffff !important;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 600;
  transition: background .15s;
}
.nav-cta:hover {
  background: #1b5edb;
}

/* Breadcrumb Sub-bar */
.breadcrumb-bar {
  background: rgba(22, 27, 34, 0.75);
  border-bottom: 1px solid var(--line);
  font-size: .82rem;
  color: var(--ink-dim);
}
.breadcrumb-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
}
.menu-btn {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}
.breadcrumb::-webkit-scrollbar {
  display: none;
}
.breadcrumb a {
  color: var(--ink-dim);
  border-bottom: none;
}
.breadcrumb a:hover { color: var(--cobalt-hi); }
.crumb-sep { color: var(--line-strong); }
.crumb-cur { color: var(--ink); font-weight: 500; }

/* Responsive drawer backdrop */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 35;
  backdrop-filter: blur(3px);
}
.drawer-backdrop.open { display: block; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 40px;
  padding-top: 32px;
  padding-bottom: 64px;
}

.content {
  min-width: 0;
  width: 100%;
}

/* Sidebar navigation */
.sidebar {
  position: sticky;
  top: 108px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  padding-right: 12px;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

.side-sec {
  margin-bottom: 4px;
}
details.side-sec[open] {
  margin-bottom: 12px;
}
details.side-sec summary.side-summary,
.side-sec.side-leaf .side-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 4px;
  user-select: none;
  transition: background .12s;
}
details.side-sec summary.side-summary::-webkit-details-marker {
  display: none;
}
details.side-sec summary.side-summary:hover,
.side-sec.side-leaf .side-summary:hover {
  background: rgba(255, 255, 255, 0.04);
}
.side-title-link,
.side-title-text {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-dim);
  border-bottom: none;
  flex: 1;
  transition: color .12s;
}
.side-title-link:hover {
  color: var(--ink);
}
.side-title-link.active {
  color: var(--cobalt-hi);
  font-weight: 800;
}
.side-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-dim);
  padding: 2px;
  transition: color .12s;
}
.side-chevron svg {
  transition: transform .15s ease;
  transform: rotate(0deg);
}
details.side-sec:not([open]) .side-chevron svg {
  transform: rotate(-90deg);
}
details.side-sec summary.side-summary:hover .side-chevron {
  color: var(--ink);
}
.side ul {
  list-style: none;
  padding-left: 6px;
  margin-top: 2px;
}
.side li {
  margin: 2px 0;
}
.side li a {
  display: block;
  font-size: .86rem;
  color: var(--ink-dim);
  padding: 5px 8px;
  border-radius: 4px;
  border-bottom: none;
  line-height: 1.4;
  transition: all .12s;
}
.side li a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
}
.side li.active a {
  color: var(--cobalt-hi);
  background: rgba(31, 111, 235, 0.12);
  font-weight: 600;
}

/* Article */
article h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -.025em;
  line-height: 1.15;
  margin: 0 0 12px;
}
.page-meta {
  margin-bottom: 24px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: .75rem;
  padding: 2px 10px;
  border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--ink-dim);
}
.chip-type {
  color: var(--cobalt-hi);
  border-color: rgba(88, 166, 255, 0.4);
  background: rgba(31, 111, 235, 0.08);
}
.chip-status {
  color: var(--emerald);
  border-color: rgba(63, 185, 80, 0.4);
  background: rgba(63, 185, 80, 0.08);
}

article h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 1.8em 0 .5em;
  letter-spacing: -.01em;
  border-bottom: 1px solid var(--line);
  padding-bottom: .3em;
}
article h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 1.5em 0 .4em;
}
article p {
  margin: .85em 0;
  color: var(--ink);
  line-height: 1.7;
}
article ul, article ol {
  margin: .85em 0;
  padding-left: 1.5em;
}
article li {
  margin: .35em 0;
  line-height: 1.65;
}
article code {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .15em .4em;
  font-size: .88em;
  color: var(--cobalt-hi);
}
article pre {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
  overflow-x: auto;
  margin: 1.1em 0;
  max-width: 100%;
}
article pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--ink);
  white-space: pre;
}

/* Chroma syntax highlighting (GitHub Dark theme) */
pre.chroma { color: var(--ink); background: var(--bg-2); }
.chroma .err { color: #f85149; }
.chroma .lnlinks { outline: none; text-decoration: none; color: inherit; }
.chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
.chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; }
.chroma .hl { background-color: #6e7681; }
.chroma .lnt { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em; color: #737679; }
.chroma .ln { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em; color: #6e7681; }
.chroma .k { color: #ff7b72; }
.chroma .kc { color: #79c0ff; }
.chroma .kd { color: #ff7b72; }
.chroma .kn { color: #ff7b72; }
.chroma .kp { color: #79c0ff; }
.chroma .kr { color: #ff7b72; }
.chroma .kt { color: #ff7b72; }
.chroma .nc { color: #f0883e; font-weight: bold; }
.chroma .no { color: #79c0ff; font-weight: bold; }
.chroma .nd { color: #d2a8ff; font-weight: bold; }
.chroma .ni { color: #ffa657; }
.chroma .ne { color: #f0883e; font-weight: bold; }
.chroma .nl { color: #79c0ff; font-weight: bold; }
.chroma .nn { color: #ff7b72; }
.chroma .py { color: #79c0ff; }
.chroma .nt { color: #7ee787; }
.chroma .nv { color: #79c0ff; }
.chroma .vc { color: #79c0ff; }
.chroma .vg { color: #79c0ff; }
.chroma .vi { color: #79c0ff; }
.chroma .vm { color: #79c0ff; }
.chroma .nf { color: #d2a8ff; font-weight: bold; }
.chroma .fm { color: #d2a8ff; font-weight: bold; }
.chroma .l { color: #a5d6ff; }
.chroma .ld { color: #79c0ff; }
.chroma .s { color: #a5d6ff; }
.chroma .sa { color: #79c0ff; }
.chroma .sb { color: #a5d6ff; }
.chroma .sc { color: #a5d6ff; }
.chroma .dl { color: #79c0ff; }
.chroma .sd { color: #a5d6ff; }
.chroma .s2 { color: #a5d6ff; }
.chroma .se { color: #79c0ff; }
.chroma .sh { color: #79c0ff; }
.chroma .si { color: #a5d6ff; }
.chroma .sx { color: #a5d6ff; }
.chroma .sr { color: #79c0ff; }
.chroma .s1 { color: #a5d6ff; }
.chroma .ss { color: #a5d6ff; }
.chroma .m { color: #a5d6ff; }
.chroma .mb { color: #a5d6ff; }
.chroma .mf { color: #a5d6ff; }
.chroma .mh { color: #a5d6ff; }
.chroma .mi { color: #a5d6ff; }
.chroma .il { color: #a5d6ff; }
.chroma .mo { color: #a5d6ff; }
.chroma .o { color: #ff7b72; font-weight: bold; }
.chroma .ow { color: #ff7b72; font-weight: bold; }
.chroma .or { color: #ff7b72; font-weight: bold; }
.chroma .c { color: #8b949e; font-style: italic; }
.chroma .ch { color: #8b949e; font-style: italic; }
.chroma .cm { color: #8b949e; font-style: italic; }
.chroma .c1 { color: #8b949e; font-style: italic; }
.chroma .cs { color: #8b949e; font-weight: bold; font-style: italic; }
.chroma .cp { color: #8b949e; font-weight: bold; font-style: italic; }
.chroma .cpf { color: #8b949e; font-weight: bold; font-style: italic; }
.chroma .gd { color: #ffa198; background-color: #490202; }
.chroma .ge { font-style: italic; }
.chroma .gr { color: #ffa198; }
.chroma .gh { color: #79c0ff; font-weight: bold; }
.chroma .gi { color: #56d364; background-color: #0f5323; }
.chroma .go { color: #8b949e; }
.chroma .gp { color: #8b949e; }
.chroma .gs { font-weight: bold; }
.chroma .gu { color: #79c0ff; }
.chroma .gt { color: #ff7b72; }
.chroma .gl { text-decoration: underline; }
.chroma .w { color: #6e7681; }
article blockquote {
  border: 1px solid var(--line);
  border-left: 3px solid var(--cobalt);
  background: rgba(31, 111, 235, 0.04);
  padding: .6em 1.2em;
  margin: 1.1em 0;
  border-radius: 0 6px 6px 0;
  color: var(--ink-dim);
}
article table {
  border-collapse: collapse;
  margin: 1.2em 0;
  width: 100%;
  font-size: .92rem;
}
article th, article td {
  border: 1px solid var(--line);
  padding: 8px 14px;
  text-align: left;
}
article th {
  background: var(--bg-panel);
  color: var(--ink);
  font-weight: 600;
}
article tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.015);
}
article hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2em 0;
}

/* GitHub-style callouts */
.callout {
  padding: 14px 18px;
  margin: 1.4em 0;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  font-size: .92rem;
}
.callout-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: .88rem;
  margin-bottom: 8px;
}
.callout-title svg {
  flex-shrink: 0;
}
.callout-body > *:first-child {
  margin-top: 0;
}
.callout-body > *:last-child {
  margin-bottom: 0;
}
.callout-body p {
  margin: .4em 0;
  line-height: 1.6;
}

.callout-note {
  border-color: rgba(88, 166, 255, 0.35);
  background: rgba(31, 111, 235, 0.08);
}
.callout-note .callout-title { color: #58a6ff; }

.callout-tip {
  border-color: rgba(63, 185, 80, 0.35);
  background: rgba(63, 185, 80, 0.08);
}
.callout-tip .callout-title { color: #3fb950; }

.callout-important {
  border-color: rgba(163, 113, 247, 0.35);
  background: rgba(163, 113, 247, 0.08);
}
.callout-important .callout-title { color: #a371f7; }

.callout-warning {
  border-color: rgba(210, 153, 34, 0.35);
  background: rgba(210, 153, 34, 0.08);
}
.callout-warning .callout-title { color: #d29922; }

.callout-caution {
  border-color: rgba(248, 81, 73, 0.35);
  background: rgba(248, 81, 73, 0.08);
}
.callout-caution .callout-title { color: #f85149; }

/* Mermaid diagram container */
pre.mermaid {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: .88rem;
  line-height: 1.5;
}
pre.mermaid.mermaid-fallback {
  text-align: left;
  border-color: rgba(210, 153, 34, 0.4);
  color: var(--ink-dim);
  white-space: pre;
}

/* TOC dropdown/inline */
.toc {
  border: 1px solid var(--line);
  background: var(--bg-panel);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 1.5em 0;
}
.toc summary {
  font-size: .82rem;
  letter-spacing: .05em;
  color: var(--ink-dim);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after {
  content: "▾";
  color: var(--ink-dim);
  font-size: .85em;
  transition: transform .15s;
}
.toc[open] summary::after { transform: rotate(180deg); }
.toc ul {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}
.toc li {
  margin: 4px 0;
}
.toc li.l3 {
  padding-left: 14px;
  font-size: .86rem;
}
.toc a {
  font-size: .88rem;
  color: var(--ink-dim);
  border-bottom: none;
}
.toc a:hover {
  color: var(--cobalt-hi);
}

@media (max-width: 900px) {
  header nav ul { display: none; }
  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding-top: 20px;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 290px;
    max-width: 85vw;
    height: 100vh;
    max-height: 100vh;
    background: var(--bg-panel);
    border-right: 1px solid var(--line);
    z-index: 40;
    padding: 24px 16px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 24px rgba(1, 4, 9, 0.7);
    overflow-y: auto;
  }
  .sidebar.open {
    transform: translateX(0);
  }
}

@media(max-width: 680px) {
  .wrap { padding: 0 16px; }
  article h1 { font-size: 2.0rem; }
  article pre { padding: 12px 14px; }
  article table { display: block; overflow-x: auto; }
}
