/* RAIL20 Docs — Base.org design tokens */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --primary: 0 0 255;
  --primary-light: 87 139 250;
  --bg: #ffffff;
  --bg-alt: #f9f9fb;
  --bg-code: #f6f6f7;
  --bg-code-header: #f0f0f2;
  --text: #1a1a2e;
  --text-muted: #6f6f77;
  --text-light: #9e9ea6;
  --border: #e5e5ea;
  --border-subtle: #f0f0f2;
  --link: rgb(var(--primary));
  --link-hover: rgb(var(--primary-light));
  --radius: 16px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --sidebar-w: 260px;
  --navbar-h: 56px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

html.dark {
  --bg: #0b0c10;
  --bg-alt: #111218;
  --bg-code: rgba(255,255,255,0.05);
  --bg-code-header: rgba(255,255,255,0.08);
  --text: #e5e5ea;
  --text-muted: #9e9ea6;
  --text-light: #6f6f77;
  --border: #2a2a32;
  --border-subtle: #1f1f27;
}

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ===================== NAVBAR ===================== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--navbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.navbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
}
.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 18px;
  color: var(--text); text-decoration: none;
  white-space: nowrap;
}
.navbar-brand svg { flex-shrink: 0; }
.navbar-tabs {
  display: flex; gap: 4px; margin-left: 24px;
}
.navbar-tab {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.navbar-tab:hover { background: var(--bg-alt); color: var(--text); }
.navbar-tab.active { background: rgb(var(--primary)); color: #fff; }
.navbar-right {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto;
}
.navbar-search {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s;
}
.navbar-search:hover { border-color: var(--text-light); }
.navbar-search kbd {
  padding: 1px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px; color: var(--text-muted);
}
.hamburger {
  display: none;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px; cursor: pointer;
  color: var(--text);
}
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.theme-toggle:hover { background: var(--bg-alt); color: var(--text); }

/* ===================== SIDEBAR ===================== */
.sidebar {
  position: fixed;
  top: var(--navbar-h); left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--navbar-h));
  overflow-y: auto;
  padding: 24px 16px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  z-index: 50;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 45;
}
.sidebar-section { margin-bottom: 24px; }
.sidebar-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  padding: 0 12px; margin-bottom: 6px;
}
.sidebar-link {
  display: block;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 400;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.sidebar-link:hover { background: var(--bg-alt); color: var(--text); }
.sidebar-link.active {
  background: rgb(var(--primary) / 0.08);
  color: rgb(var(--primary));
  font-weight: 500;
}

/* ===================== LAYOUT ===================== */
.layout {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
  padding-top: var(--navbar-h);
  min-height: 100vh;
}
.content {
  flex: 1; min-width: 0;
  margin-left: var(--sidebar-w);
  margin-right: 240px;
  padding: 40px 48px 80px;
  max-width: 900px;
}

/* ===================== TYPOGRAPHY ===================== */
h1 { font-size: 36px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 12px; line-height: 1.2; }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-light); margin-bottom: 8px; }
.lead { font-size: 18px; color: var(--text-muted); margin-bottom: 32px; line-height: 1.7; }
h2 { font-size: 24px; font-weight: 600; margin: 40px 0 16px; letter-spacing: -0.01em; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
h3 { font-size: 18px; font-weight: 600; margin: 28px 0 12px; }
p { margin-bottom: 16px; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
strong { font-weight: 600; }
code {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 2px 6px;
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  color: var(--text);
}
ol, ul { padding-left: 24px; margin-bottom: 16px; }
li { margin-bottom: 6px; }
li::marker { color: var(--text-light); }

/* ===================== CODE BLOCKS ===================== */
.code-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 20px 0;
  background: var(--bg-code);
}
.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-code-header);
  border-bottom: 1px solid var(--border-subtle);
}
.code-lang {
  font-size: 12px; font-weight: 500;
  color: var(--text-muted);
  text-transform: lowercase;
}
.copy-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none;
  font-size: 12px; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: background 0.12s, color 0.12s;
}
.copy-btn:hover { background: var(--bg); color: var(--text); }
.copy-btn.copied { color: rgb(var(--primary)); }
.code-block pre {
  margin: 0; padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 0;
}
.code-block pre code {
  font-family: inherit; font-size: inherit;
  padding: 0; background: none;
  border: none; border-radius: 0;
}

/* Syntax highlighting */
.hl-keyword { color: rgb(var(--primary)); font-weight: 500; }
.hl-comment { color: #6a9955; font-style: italic; }
.hl-string { color: #ce9178; }
.hl-number { color: #b5cea8; }
.hl-function { color: #dcdcaa; }
.hl-operator { color: var(--text-muted); }

/* ===================== CARDS ===================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin: 16px 0 32px;
}
.doc-card {
  display: block;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.doc-card:hover {
  border-color: rgb(var(--primary) / 0.3);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  text-decoration: none;
}
.doc-card-title {
  font-size: 15px; font-weight: 600; margin-bottom: 6px;
  color: var(--text);
}
.doc-card-desc {
  font-size: 13px; line-height: 1.5;
  color: var(--text-muted);
}

/* ===================== CALLOUT ===================== */
.callout {
  display: flex; gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 16px 0;
  font-size: 14px; line-height: 1.6;
}
.callout-icon {
  flex-shrink: 0;
  margin-top: 2px;
  width: 20px;
  height: 20px;
}
.callout-icon svg,
.callout svg {
  width: 20px;
  height: 20px;
}
.callout > img,
.callout > svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.callout-info { background: rgb(var(--primary) / 0.04); border-color: rgb(var(--primary) / 0.15); }
.callout-warn { background: rgba(251,191,36,0.06); border-color: rgba(251,191,36,0.25); }

/* ===================== TABLE ===================== */
.table-wrap {
  margin: 16px 0;
  padding: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  background: var(--bg);
}
.content th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-code-header);
  font-size: 12px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}
.content td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.content tr:last-child td { border-bottom: none; }
.content th:first-child { border-top-left-radius: calc(var(--radius) - 1px); }
.content th:last-child { border-top-right-radius: calc(var(--radius) - 1px); }
.content tr:last-child td:first-child { border-bottom-left-radius: calc(var(--radius) - 1px); }
.content tr:last-child td:last-child { border-bottom-right-radius: calc(var(--radius) - 1px); }

/* ===================== DOC NAV (prev/next) ===================== */
.doc-nav {
  display: flex; gap: 16px;
  margin-top: 48px; padding-top: 24px;
  border-top: 1px solid var(--border);
}
.doc-nav a {
  flex: 1; display: block;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.doc-nav a:hover {
  border-color: rgb(var(--primary) / 0.3);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  text-decoration: none;
}
.doc-nav .label {
  font-size: 13px; font-weight: 500;
  color: var(--text-light); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.doc-nav .title {
  font-size: 17px; font-weight: 600; color: var(--text);
}
.doc-nav .next { margin-left: auto; text-align: right; }

/* ===================== FEEDBACK ===================== */
.feedback {
  display: flex; align-items: center; gap: 14px;
  margin-top: 32px; padding-top: 24px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.feedback-label { font-size: 15px; font-weight: 500; color: var(--text-muted); }
.feedback-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 14px; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.feedback-btn:hover {
  background: var(--bg-alt);
  color: var(--text);
  border-color: var(--text-light);
}
.feedback-btn.selected {
  background: rgb(var(--primary) / 0.08);
  color: rgb(var(--primary));
  border-color: rgb(var(--primary) / 0.25);
}
.suggest-links {
  display: flex; gap: 16px; margin-left: auto;
}
.suggest-link {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--text-light);
  text-decoration: none;
}
.suggest-link:hover { color: var(--link); text-decoration: underline; }

/* ===================== TOC (right sidebar) ===================== */
.toc {
  position: fixed;
  top: calc(var(--navbar-h) + 40px);
  right: 32px;
  width: 200px;
  font-size: 13px;
  z-index: 10;
  overflow-y: auto;
  max-height: calc(100vh - var(--navbar-h) - 80px);
}
.toc-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-light);
  margin-bottom: 10px;
}
.toc-link {
  display: block;
  padding: 4px 0 4px 12px;
  border-left: 2px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.12s, border-color 0.12s;
}
.toc-link:hover { color: var(--text); text-decoration: none; }
.toc-link.active {
  color: rgb(var(--primary));
  border-left-color: rgb(var(--primary));
  font-weight: 500;
}

/* ===================== FOOTER ===================== */
.doc-footer {
  margin-top: 48px; padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--text-light);
}
.doc-footer a { color: var(--text-muted); }
.doc-footer a:hover { color: var(--text); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1200px) {
  .toc { display: none; }
  .content { margin-right: 0; }
}
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .navbar-tabs { display: none; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 60;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; z-index: 55; }
  .content {
    margin-left: 0;
    margin-right: 0;
    padding: 24px 20px 60px;
  }
  .layout { flex-direction: column; }
  .navbar-search { display: none; }
  .doc-nav { flex-direction: column; }
  .card-grid { grid-template-columns: 1fr; }
  .feedback { flex-direction: column; align-items: flex-start; }
  .suggest-links { margin-left: 0; }
}
