:root {
  --bg: #090b10;
  --surface: #11151e;
  --surface-2: #161c28;
  --border: #232b3a;
  --border-strong: #323e54;
  --text: #e6ebf5;
  --muted: #94a3b8;
  --accent: #6ee7b7;
  --accent-dim: rgba(110, 231, 183, 0.12);
  --accent-border: rgba(110, 231, 183, 0.35);
  --code-bg: #0d1118;
  --radius: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 24px;
}

header.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(9, 11, 16, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.brand:hover {
  text-decoration: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 0.9rem;
}

.nav-links a {
  color: var(--muted);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  text-decoration: none;
}

.hero {
  padding: 72px 0 48px;
}

.hero h1 {
  margin: 16px 0 14px;
  font-size: clamp(2.1rem, 4.5vw, 3.2rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.hero p.lead {
  max-width: 680px;
  margin: 0 0 28px;
  font-size: 1.12rem;
  color: var(--muted);
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn:hover {
  text-decoration: none;
  border-color: var(--accent-border);
  background: var(--surface-2);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06130e;
}

.btn-primary:hover {
  background: #86efac;
  border-color: #86efac;
  color: #06130e;
}

section {
  padding: 40px 0;
  border-top: 1px solid var(--border);
}

section h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

section p.section-sub {
  margin: 0 0 24px;
  color: var(--muted);
}

.diagram-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
}

.diagram-card svg {
  width: 100%;
  height: auto;
  display: block;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card .num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: 6px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
}

.tab-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--accent-border);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.code-wrap {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.copy-btn {
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.copy-btn:hover {
  border-color: var(--accent-border);
  color: var(--accent);
}

pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.55;
  color: #dbe6f5;
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.security-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

footer {
  padding: 36px 0 48px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

/* Spec page layout */
.spec-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 40px;
  padding: 40px 0 64px;
}

.spec-toc {
  position: sticky;
  top: 80px;
  align-self: start;
  font-size: 0.86rem;
}

.spec-toc h4 {
  margin: 0 0 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.spec-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spec-toc a {
  color: var(--muted);
}

.spec-toc a:hover {
  color: var(--accent);
}

.spec-body h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.spec-body h2 {
  margin: 36px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 1.35rem;
}

.spec-body h3 {
  margin: 24px 0 8px;
  font-size: 1.05rem;
}

.spec-body p,
.spec-body li {
  color: #cbd5e1;
}

.spec-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.9rem;
}

.spec-body th,
.spec-body td {
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
}

.spec-body th {
  background: var(--surface);
  color: var(--text);
}

@media (max-width: 780px) {
  .spec-layout {
    grid-template-columns: 1fr;
  }
  .spec-toc {
    position: static;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
  }
  .nav-links {
    gap: 12px;
    font-size: 0.84rem;
  }
}
