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

:root {
  --bg: #141414;
  --surface: #1e1e1e;
  --border: #2e2e2e;
  --text: #d0d0d0;
  --text-dim: #777777;
  --accent: #85ffa4;
  --accent-hover: #85ffa4;
  --code-bg: #1a1a1a;
  --inline-code-bg: #2a2a2a;
  --sidebar-width: 260px;
  --sidebar-width-negative: -260px;
}

html, body { margin: 0; padding: 0; -webkit-text-size-adjust: none; text-size-adjust: none; }

body {
  display: flex;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* --- Sidebar --- */
#sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;  
  z-index: 100;
  font-size: 14px;
  transition: transform 0.2s;
}

#sidebar .back-to-site {
  opacity: 0.5;
  transition: opacity 0.12s;
}

#sidebar .back-to-site:hover {
  color: var(--text);
  background: initial;
  opacity: 1.0;
}


#sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  margin-top: 8px;
}

#sidebar li { margin: 0; }

#sidebar a {
  display: block;
  padding: 0px 8px;
  padding-top: 5px;
  padding-bottom: 6px;
  border-radius: 4px;
  color: var(--text-dim);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebar a:hover {
  background: var(--border);
  color: var(--accent-hover);
}

#sidebar a.active {
  color: var(--accent);
  font-weight: 500;
}

#sidebar details > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0px 8px;
  padding: 0px 8px;
  padding-top: 5px;
  padding-bottom: 6px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
  user-select: none;
  transition: background 0.12s, color 0.12s;
  position: relative;
}

#sidebar details > summary::-webkit-details-marker { display: none; }

#sidebar details > summary::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M3 1l4 4-4 4' stroke='%238888a0' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transition: transform 0.15s;
  transform-origin: center;
  flex-shrink: 0;
}

#sidebar details[open] > summary::before { transform: rotate(90deg); }

#sidebar details > summary:hover {
  background: var(--border);
  color: var(--accent-hover);
}

#sidebar details > ul {
  padding-left: 12px;
  border-left: 1px solid var(--border);
  margin-left: 8px;
  margin-top: 0;
  margin-bottom: 4px;
}

/* --- Main content --- */
#content {
  margin-left: var(--sidebar-width);
  min-width: 0;
  width: calc(100% - var(--sidebar-width));
  padding: 24px 40px 160px;
  padding-right: 0px;
  transition: margin-left 0.2s, width 0.2s;
  overflow-x: clip;
  container-type: inline-size;
}

#content h1, #content h2, #content h3, #content h4,
#content p, #content ul, #content ol,
#content hr, #content img {
  max-width: 780px;
  padding-right: 24px;
  scroll-margin-top: 24px;
}

#content blockquote p {
  max-width: none;
}

#content div.callout-body p {
  max-width: 707px;
}

h1, h2, h3, h4 { margin-top: 32px; color: var(--text); }
h1 { font-size: 29px; }
h2 { font-size: 22px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }

.pre-wrap {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  margin: 0px;
}

pre, pre.hljs {
  background: var(--code-bg);
  padding: 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin: 0;
  white-space: pre;
  width: fit-content;
  min-width: min(780px, 100cqi);
}

@media (max-width: 767px) {
  pre, pre.hljs {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
  }
}

code {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.875em;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  background: var(--inline-code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre code, pre.hljs code { background: none; padding: 0; font-size: 0.875em; }

/* highlight.js — Visual Studio 2022 dark theme (C#) */
.hljs                          { color: #dcdcdc; }
.hljs-keyword                  { color: #569cd6; }          /* blue — control/type keywords */
.hljs-literal                  { color: #569cd6; }          /* blue — true/false/null */
.hljs-built_in                 { color: #4ec9b0; }          /* teal — built-in types */
.hljs-type                     { color: #4ec9b0; }
.hljs-title.class_             { color: #4ec9b0; }          /* teal — class names */
.hljs-title.class_.inherited__ { color: #4ec9b0; }
.hljs-title.function_          { color: #dcdcaa; }          /* yellow — method names */
.hljs-title                    { color: #4ec9b0; }          /* teal — fallback for class Foo form */
.hljs-number                   { color: #b5cea8; }          /* light green — numeric literals */
.hljs-string                   { color: #ce9178; }          /* orange/rust — string literals */
.hljs-attr                     { color: #ce9178; }
.hljs-comment                  { color: #57a64a; }
.hljs-quote                    { color: #57a64a; }
.hljs-variable                 { color: #9cdcfe; }          /* light blue — locals/fields */
.hljs-template-variable        { color: #9cdcfe; }
.hljs-params                   { color: #9cdcfe; }
.hljs-property                 { color: #9cdcfe; }
.hljs-symbol                   { color: #dcdcdc; }
.hljs-punctuation              { color: #dcdcdc; }
.hljs-operator                 { color: #dcdcdc; }
.hljs-meta                     { color: #9b9b9b; }          /* grey — preprocessor */
.hljs-tag                      { color: #569cd6; }
.hljs-attribute                { color: #9cdcfe; }
.hljs-type-name                { color: #4ec9b0; }          /* teal — PascalCase types */
.hljs-type-name a.type-link,
.hljs-struct a.type-link,
pre a.type-link                         { color: inherit; text-decoration: none; }
.hljs-type-name a.type-link:hover,
.hljs-struct a.type-link:hover,
pre a.type-link:hover                   { text-decoration: underline; }
.hljs-type-name a.type-link-current,
.hljs-struct a.type-link-current,
pre a.type-link-current                 { cursor: default; }
.hljs-type-name a.type-link-current:hover,
.hljs-struct a.type-link-current:hover,
pre a.type-link-current:hover           { text-decoration: none; }
#type-tooltip {
  position: fixed;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 9px;
  font-size: 0.875em;
  white-space: normal;
  word-break: break-word;
  width: max-content;
  max-width: min(1000px, calc(100vw - 16px));
  pointer-events: none;
  z-index: 1000;
  display: none;
}
.hljs-struct                   { color: #86c691; }          /* green — Vector, Matrix, MaterialType */
.hljs-c-function               { color: #dcdcaa; }          /* yellow — C function names */
.hljs-c-type                   { color: #4ec9b0; }          /* teal — C PascalCase type names */
.hljs-c-variable               { color: #9cdcfe; }          /* light blue — C variables/parameters */
.hljs-c-literal                { color: #d8a0df; }          /* pinkish — C true/false/NULL */
.hljs-c-constant               { color: #b8d7a3; }          /* greenish — VAMaterial* constants */
a.c-fn-link,
pre a.c-fn-link                { color: #dcdcaa; text-decoration: none; }
a.c-fn-link:hover,
pre a.c-fn-link:hover          { text-decoration: underline; }
.hljs-c-function a.c-fn-link   { color: inherit; text-decoration: none; }
.hljs-c-function a.c-fn-link:hover { text-decoration: underline; }
.hljs-addition                 { color: #b5cea8; }
.hljs-deletion                 { color: #ce9178; }
.hljs-emphasis                 { font-style: italic; }
.hljs-strong                   { font-weight: bold; }

blockquote {
  border-left: 3px solid var(--accent);
  margin: 16px 0;
  padding: 16px;
  padding-left: 24px;
  padding-bottom: 18px;
  color: var(--text);
  background: var(--code-bg);
  border-radius: 0 4px 4px 0;
  display: table;
  max-width: 100%;
}

blockquote p {
  margin: 0px;
}

blockquote code {
  background: var(--inline-code-bg);
}

.callout-warning {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  padding: 14px 16px;
  padding-right: 24px;
  padding-bottom: 16px;
  background: #3a2e00;
  border: 1px solid #f0c040;
  border-radius: 6px;
  color: var(--text);
  width: fit-content;
}

.callout-icon {
  flex-shrink: 0;
  display: flex;
}

.callout-body {
  flex: 1;
}

.callout-body p {
  margin: 0;
}

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

table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
}

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

th { background: var(--surface); font-weight: 600; }
tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

img { max-width: 100%; height: auto; border-radius: 4px; }

/* --- Sidebar header (title + toggle in a row) --- */
#sidebar-header {
  display: flex;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  gap: 4px;
}

#sidebar-header .site-title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  padding: 0 0 0 8px;
  border: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* --- Sidebar toggle strip --- */
#sidebar-expand {
  -webkit-appearance: none;
  appearance: none;
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  width: 32px;
  height: 100vh;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  transition: transform 0.2s, background 0.12s, color 0.12s;
  padding: 0;
}

@media (hover: hover) {
  #sidebar-expand:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text);
  }
}

/* Collapsed sidebar */
.sidebar-collapsed #sidebar {
  transform: translateX(-100%);
}

.sidebar-collapsed #sidebar-expand {
  transform: translateX(var(--sidebar-width-negative));
}

.sidebar-collapsed #content {
  margin-left: 0;
  width: 100%;
}

@media (hover: hover) {
  .sidebar-collapsed #sidebar-expand:hover {
    background: var(--border);
  }
}

/* Mobile: sidebar overlays content instead of pushing it */
@media (max-width: 767px) {
  #content {
    margin-left: 0 !important;
    width: 100% !important;
  }


}

/* scrollbar */
#sidebar::-webkit-scrollbar { width: 5px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* breadcrumbs */
.breadcrumbs { margin-bottom: 4px; padding: 10px 0; }
.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: var(--text-dim);
  gap: 4px;
}
.bc-item a { color: var(--text-dim); text-decoration: none; }
.bc-item a:hover { color: var(--accent-hover); }
.bc-sep { color: var(--border); padding: 0 2px; user-select: none; }
.bc-current { color: var(--text); }

.page-title { margin-top: 0px; margin-bottom: 24px; }

/* --- Language selector --- */
#lang-selector {
  padding: 10px 8px 10px;
  padding-bottom: 0px;
}

#lang-select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 3.5l3 3 3-3' stroke='%238888a0' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
  padding-right: 26px;
}

#lang-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* data-lang blocks: hidden by default until JS applies selection */
[data-lang] { display: none; }

.td-dim { color: var(--text-dim); float: right; }

/* --- Search --- */
#search-box {
  position: relative;
  padding: 8px 8px 8px;
  border-bottom: 1px solid var(--border);
}

#search-input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

#search-input::-webkit-search-cancel-button { display: none; }

#search-input:focus {
  border-color: var(--accent);
}

#search-input::placeholder {
  color: var(--text-dim);
}

#search-results {
  position: fixed;
  top: auto;
  left: 8px;
  width: min(780px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 200;
  max-height: 60vh;
  overflow-y: auto;
}

.sr-item {
  display: block;
  padding: 8px 10px;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  outline: none;
}

.sr-item:last-child { border-bottom: none; }

.sr-item:hover, .sr-item:focus {
  background: var(--border);
  text-decoration: none;
}

.sr-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sr-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
}

.sr-snippet {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 2px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sr-empty {
  padding: 10px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

#search-results mark {
  background: none;
  color: var(--accent);
  font-weight: 600;
}
