:root {
  --bg: #0b0d10;
  --panel: #11151b;
  --panel2: #0f1318;
  --text: #e8eef6;
  --muted: #9aa7b6;
  --border: rgba(255,255,255,0.10);
  --link: #7db7ff;
  --code-bg: #0f141b;
  --shadow: 0 8px 20px rgba(0,0,0,0.35);
  --radius: 12px;
  --sidebar: 320px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fa;
    --panel: #ffffff;
    --panel2: #f3f5f7;
    --text: #1a222c;
    --muted: #5a6b7d;
    --border: rgba(0,0,0,0.10);
    --link: #0b63ce;
    --code-bg: #f3f5f7;
    --shadow: 0 8px 20px rgba(0,0,0,0.10);
  }
}

html, body { height: 100%; }

/* Page layout: site header (injected) + viewer */
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header-slot {
  flex: 0 0 auto;

  /*
    Contrast fix for the injected https://bimwerxfea.com header.
    The main site header is designed to sit over its own hero/background,
    but here it sits over the documentation viewer.
    Force a darker bar so the sticky menu remains readable.
  */
  position: relative;
  z-index: 1000;
}

/* Darken the injected header/menu area and force readable foreground colours */
.site-header-slot > * {
  background-color: #0b0d10 !important;
}

.site-header-slot header,
.site-header-slot nav,
.site-header-slot .navbar,
.site-header-slot .topbar {
  background-color: #0b0d10 !important;
  color: #e8eef6 !important;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 4px 18px rgba(0,0,0,0.35);
}

.site-header-slot a,
.site-header-slot a:visited,
.site-header-slot button,
.site-header-slot [role="button"],
.site-header-slot .menu,
.site-header-slot .nav-link {
  color: #e8eef6 !important;
}

.site-header-slot a:hover {
  opacity: 0.90;
}

/* SVG icons/logos often rely on currentColor */
.site-header-slot svg {
  color: #e8eef6 !important;
}

.site-header-slot svg * {
  fill: currentColor;
  stroke: currentColor;
}

/* Scope all viewer styling so the site header keeps its own look */
.mdv-root {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

.mdv-root *,
.mdv-root *::before,
.mdv-root *::after {
  box-sizing: border-box;
}

.mdv-root a { color: var(--link); }
.mdv-root a:hover { text-decoration: underline; }

/* Viewer grid */
.mdv-root .app {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.mdv-root .sidebar {
  width: var(--sidebar);
  flex: 0 0 auto;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  display: flex;
  flex-direction: column;
  min-width: 220px;
  max-width: 760px;
}

.mdv-root .resizer {
  flex: 0 0 auto;
  width: 10px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  user-select: none;
  touch-action: none;
}

.mdv-root .resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 2px;
  background: var(--border);
  opacity: 0.65;
}

.mdv-root .resizer:hover::before {
  opacity: 1;
}

body.mdv-resizing {
  cursor: col-resize;
  user-select: none;
}

.mdv-root .main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

/* Sidebar */
.mdv-root .sidebar__header {
  padding: 16px 14px 10px;
}

.mdv-root .brand {
  font-weight: 700;
  letter-spacing: 0.3px;
  font-size: 14px;
  line-height: 1.2;
}

.mdv-root .small { font-size: 12px; }
.mdv-root .muted { color: var(--muted); }

.mdv-root .sidebar__search {
  padding: 0 14px 10px;
}

.mdv-root #search {
  width: 100%;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  outline: none;
}

.mdv-root #search:focus {
  border-color: rgba(125,183,255,0.6);
  box-shadow: 0 0 0 3px rgba(125,183,255,0.15);
}

.mdv-root .sidebar__tree {
  padding: 6px 10px 14px;
  overflow: auto;
  flex: 1;
}

.mdv-root .sidebar__footer {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
}

/* Tree */
.mdv-root .tree-node {
  margin: 2px 0;
}

.mdv-root .tree-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 10px;
}

.mdv-root .tree-row:hover {
  background: rgba(255,255,255,0.06);
}

.mdv-root .tree-toggle {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
}

.mdv-root .tree-toggle:hover {
  border-color: var(--border);
}

.mdv-root .tree-name {
  min-width: 0;
}

.mdv-root .tree-name a {
  text-decoration: none;
  color: var(--text);
}

.mdv-root .tree-name a.active {
  color: var(--link);
  font-weight: 600;
}

.mdv-root .tree-children {
  margin-left: 18px;
  padding-left: 10px;
  border-left: 1px dashed var(--border);
}

/* Main */
.mdv-root .toolbar {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel);
}

.mdv-root .current-file {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.mdv-root .btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
}

.mdv-root .btn:hover {
  background: rgba(255,255,255,0.06);
}

.mdv-root .content {
  padding: 22px 22px 50px;
  overflow: auto;
}

.mdv-root .empty {
  max-width: 760px;
  margin: 40px auto;
  padding: 18px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

/* Markdown */
.mdv-root .content h1,
.mdv-root .content h2,
.mdv-root .content h3,
.mdv-root .content h4,
.mdv-root .content h5,
.mdv-root .content h6 {
  line-height: 1.2;
  margin-top: 1.2em;
}

.mdv-root .content p,
.mdv-root .content li {
  line-height: 1.55;
}

.mdv-root .content pre {
  background: var(--code-bg);
  padding: 12px 12px;
  border-radius: 12px;
  overflow: auto;
  border: 1px solid var(--border);
}

.mdv-root .content code {
  font-family: var(--mono);
  font-size: 0.95em;
}

.mdv-root .content :not(pre) > code {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 8px;
}

.mdv-root .content blockquote {
  border-left: 4px solid rgba(125,183,255,0.7);
  margin: 1em 0;
  padding: 0.2em 0.9em;
  color: var(--muted);
  background: rgba(125,183,255,0.07);
  border-radius: 10px;
}

.mdv-root .content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

.mdv-root .content th,
.mdv-root .content td {
  border: 1px solid var(--border);
  padding: 8px 10px;
}

.mdv-root .content img {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
}

@media (max-width: 900px) {
  .mdv-root .app {
    flex-direction: column;
  }

  .mdv-root .resizer {
    display: none;
  }

  .mdv-root .sidebar {
    width: 100%;
    max-width: none;
    height: 42vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .mdv-root .main {
    height: 58vh;
  }
}


/* Mermaid diagrams */
.mermaid {
  overflow-x: auto;
}

.mermaid svg {
  max-width: 100%;
  height: auto;
}
