:root {
  --bg: #ffffff;
  --bg-soft: #f5f6f8;
  --bg-elev: #ffffff;
  --border: #e3e6ea;
  --text: #1c2024;
  --text-soft: #5b636c;
  --accent: #2f6feb;
  --accent-soft: #e7f0ff;
  --model: #2f6feb;
  --source: #16a34a;
  --seed: #b45309;
  --snapshot: #7c3aed;
  --code-bg: #f5f6f8;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --radius: 8px;
}
[data-theme="dark"] {
  --bg: #0e1116;
  --bg-soft: #161b22;
  --bg-elev: #1c2230;
  --border: #2a313c;
  --text: #e6edf3;
  --text-soft: #9aa4b1;
  --accent: #5b8cff;
  --accent-soft: #1b2742;
  --model: #5b8cff;
  --source: #3fb950;
  --seed: #d29922;
  --snapshot: #a371f7;
  --code-bg: #11161d;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: "SF Mono", "Roboto Mono", Menlo, Consolas, monospace; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 16px;
  height: 52px; padding: 0 16px;
  background: var(--bg-elev); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 160px; }
.brand-mark { display: block; width: 24px; height: 24px; border-radius: 6px; }
.search-wrap { position: relative; flex: 1; max-width: 520px; }
#search {
  width: 100%; padding: 7px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
}
#search:focus { outline: none; border-color: var(--accent); }
.search-results {
  position: absolute; top: 110%; left: 0; right: 0; max-height: 60vh; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 40;
}
.search-results a {
  display: block; padding: 8px 12px; color: var(--text); border-bottom: 1px solid var(--border);
}
.search-results a:hover, .search-results a.active { background: var(--accent-soft); text-decoration: none; }
.search-results .sr-meta { color: var(--text-soft); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft);
  color: var(--text); cursor: pointer; font-size: 16px;
}
.icon-btn:hover { border-color: var(--accent); text-decoration: none; }

/* GitHub repo widget (icon + name + stars/forks/version), mkdocs-material-style */
.repo-link {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-soft); color: var(--text); text-decoration: none; max-width: 240px;
}
.repo-link:hover { border-color: var(--accent); text-decoration: none; }
.repo-icon { display: inline-flex; flex-shrink: 0; }
.repo-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) { .repo-name { display: none; } .repo-link { padding: 7px; } }

.version-switcher {
  height: 34px; padding: 0 28px 0 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer;
  /* Custom chevron so the arrow aligns + themes consistently across browsers. */
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%237b8494'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.version-switcher:hover { border-color: var(--accent); }
.version-switcher:focus { outline: none; border-color: var(--accent); }

/* Layout */
.layout { display: flex; height: calc(100vh - 52px); }
.sidebar-col {
  width: 300px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--bg-soft); border-right: 1px solid var(--border);
}
.sidebar { flex: 1; overflow-y: auto; padding: 12px; }
.content { flex: 1; overflow-y: auto; padding: 28px 36px; outline: none; }
.content:focus { outline: none; }

/* Footer pinned to the bottom of the sidebar column */
.site-footer {
  flex-shrink: 0; padding: 10px 14px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.footer-copy { color: var(--text-soft); font-size: 12px; }

/* Build metadata in the header (generated / adapter / edges) */
.topbar-meta {
  color: var(--text-soft); font-size: 11.5px; white-space: nowrap;
  padding-right: 6px; flex-shrink: 0;
}
@media (max-width: 1100px) { .topbar-meta { display: none; } }

/* End-of-page content footer */
.content-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border);
  color: var(--text-soft); font-size: 12px;
}
.content-foot .cf-left { display: inline-flex; align-items: center; gap: 6px; }
.content-foot .cf-left .ic { color: var(--text-soft); }
.content-foot .cf-top { color: var(--text-soft); }
.content-foot .cf-top:hover { color: var(--accent); }
.bmc {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 10px; border-radius: 6px; font-size: 12px; font-weight: 600;
  background: #ffdd00; color: #1a1a1a; text-decoration: none;
}
.bmc:hover { filter: brightness(0.95); text-decoration: none; }

/* Inline icons — uniform 16px, vertically centered with their label. */
.ic { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex-shrink: 0; color: var(--text-soft); }
.ic svg { display: block; }

/* Nav tree */
.nav-section > summary {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 6px 8px; font-weight: 600; border-radius: 6px; list-style: none;
}
.nav-section > summary::-webkit-details-marker { display: none; }
.nav-section > summary:hover { background: var(--bg-elev); }
.nav-db { font-size: 13px; }
.nav-schema > summary { font-weight: 500; color: var(--text-soft); padding-left: 18px; }
.nav-schema > summary .ic { transition: transform 0.15s; }
.nav-schema[open] > summary .ic { transform: rotate(90deg); }
.nav-items { list-style: none; margin: 0; padding: 0 0 4px 0; }
.nav-items li a {
  display: flex; align-items: center; gap: 7px; padding: 4px 8px 4px 30px;
  color: var(--text); border-radius: 6px;
}
.nav-items li a:hover { background: var(--bg-elev); text-decoration: none; }
.nav-items li a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-cta { display: flex; align-items: center; gap: 8px; padding: 8px; margin-bottom: 4px; border-radius: 6px; font-weight: 600; }
.nav-cta:hover { background: var(--bg-elev); text-decoration: none; }
.nav-cta.active { background: var(--accent-soft); color: var(--accent); }
.nav-cta.active .ic { color: var(--accent); }

/* Resource-type dot */
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot.model { background: var(--model); }
.dot.source { background: var(--source); }
.dot.seed { background: var(--seed); }
.dot.snapshot { background: var(--snapshot); }

/* Content blocks */
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 28px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.page-id { color: var(--text-soft); font-size: 13px; font-family: monospace; }
.badges { margin: 10px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--border); font-size: 12px; color: var(--text-soft);
}
.badge.rtype { color: #fff; border: none; }
.badge.rtype.model { background: var(--model); }
.badge.rtype.source { background: var(--source); }
.badge.rtype.seed { background: var(--seed); }
.badge.rtype.snapshot { background: var(--snapshot); }
.tag { background: var(--accent-soft); color: var(--accent); border: none; }
.description { color: var(--text); margin: 8px 0 0; }
.muted { color: var(--text-soft); }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.card { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; align-items: center; gap: 9px; }
.card .num { font-size: 28px; font-weight: 700; }
.card .lbl { color: var(--text-soft); margin-top: 2px; }
.card-ic { width: 18px; height: 18px; }
.card-ic.model { color: var(--model); }
.card-ic.source { color: var(--source); }
.card-ic.seed { color: var(--seed); }
.card-ic.snapshot { color: var(--snapshot); }

/* Tables */
table { border-collapse: collapse; width: 100%; margin: 6px 0; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-soft); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-top: 8px; }
.tab { padding: 6px 14px; cursor: pointer; border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; color: var(--text-soft); }
.tab.active { background: var(--bg-soft); color: var(--text); border-color: var(--border); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
pre.code { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; overflow-x: auto; font-size: 12.5px; }

/* Details / macros */
details.macro { border: 1px solid var(--border); border-radius: var(--radius); margin: 8px 0; }
details.macro > summary { cursor: pointer; padding: 8px 12px; font-weight: 600; }
details.macro pre.code { margin: 0; border: none; border-top: 1px solid var(--border); border-radius: 0; }

/* Inline column-lineage chips (in the Columns table) */
.up-chip { display: inline-block; font-size: 12px; padding: 1px 7px; margin: 1px 3px 1px 0; border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--border); }
.up-chip .up-model { color: var(--text-soft); font-family: monospace; }
.up-chip a { font-family: monospace; font-weight: 600; }

/* Graph host (React Flow bundle mounts here) */
.graph-host { width: 100%; }
/* Fullscreen: the host fills the screen; its inner .dbd-graph grows to match. */
.graph-host:fullscreen { background: var(--bg); padding: 0; }
.graph-host:fullscreen .dbd-graph { height: 100vh; border: none; border-radius: 0; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fs-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-soft); color: var(--text-soft); font-size: 13px; cursor: pointer;
}
.fs-btn:hover { border-color: var(--accent); color: var(--accent); }
.fs-btn .ic { color: inherit; }

/* Version not-latest warning banner */
.version-warning {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 16px; background: #fde68a; color: #663c00;
  border-bottom: 1px solid #f59e0b; font-size: 13px;
}
.version-warning a { color: #663c00; font-weight: 700; text-decoration: underline; }
[data-theme="dark"] .version-warning { background: #3a2f12; color: #f3d27a; border-color: #6b5212; }
[data-theme="dark"] .version-warning a { color: #f3d27a; }

.empty { color: var(--text-soft); font-style: italic; padding: 8px 0; }

/* ---------- README / rendered markdown ---------- */
.readme { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.markdown-body { line-height: 1.6; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4 { margin: 22px 0 10px; line-height: 1.3; }
.markdown-body h1 { font-size: 22px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.markdown-body h2 { font-size: 18px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.markdown-body h3 { font-size: 16px; }
.markdown-body p { margin: 10px 0; }
.markdown-body a { color: var(--accent); }
.markdown-body ul, .markdown-body ol { padding-left: 24px; margin: 10px 0; }
.markdown-body li { margin: 4px 0; }
.markdown-body code {
  font-family: "SF Mono", "Roboto Mono", Menlo, Consolas, monospace; font-size: 0.9em;
  background: var(--code-bg); padding: 1px 5px; border-radius: 4px;
}
.markdown-body pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; overflow-x: auto;
}
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote {
  margin: 12px 0; padding: 4px 14px; color: var(--text-soft);
  border-left: 3px solid var(--border); background: var(--bg-soft); border-radius: 0 6px 6px 0;
}
.markdown-body table { border-collapse: collapse; margin: 12px 0; display: block; overflow-x: auto; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 6px 10px; }
.markdown-body th { background: var(--bg-soft); }
.markdown-body img { max-width: 100%; height: auto; border-radius: 6px; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
