:root {
  --brand-color: {{settings.brand_color}};
  --text-color: {{settings.text_color}};
  --background-color: {{settings.background_color}};
  --muted-color: #5b6472;
  --faint-color: #8a93a2;
  --border-color: #e6e8ec;
  --surface-color: #f7f8fa;
  --surface-2: #eef0f4;
  --sidebar-bg: #fbfbfc;
  --code-bg: #f4f5f7;
  --topbar-height: 60px;
  --sidebar-width: 300px;
  --toc-width: 240px;
  --content-max: 760px;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

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

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--brand-color);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  left: 0;
}

/* ---------------------------------------------------------------------------
 * Top bar
 * ------------------------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: 100%;
  padding: 0.5rem;
  box-sizing: border-box;
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--text-color);
  font-weight: 800;
  font-size: 1.02rem;
  white-space: nowrap;
}

.brand-logo {
  display: block;
  max-height: 32px;
}

.brand-mark {
  font-size: 1.02rem;
  font-weight: 500;
  white-space: nowrap;
  margin-left: 1rem;
}

.topbar-search {
  flex: 0 1 auto;
  width: 100%;
  max-width: 400px;
  box-sizing: border-box;
  height: 100%;
}

.topbar-search form,
.topbar-search .search,
.topbar-search input[type="search"] {
  margin: 0;
  box-sizing: border-box;
  height: 100%;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  font-size: 0.92rem;
  white-space: nowrap;
}

.topbar-actions a {
  color: var(--muted-color);
}

.topbar-actions a:hover {
  color: var(--text-color);
}

.topbar-cta {
  padding: 7px 14px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  color: var(--text-color) !important;
}

.topbar-cta:hover {
  border-color: var(--brand-color);
  text-decoration: none;
}

/* Hamburger (mobile only) */
.sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 38px;
  height: 38px;
  padding: 0 9px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
}

.sidebar-toggle-bar {
  display: block;
  height: 2px;
  background: var(--text-color);
  border-radius: 2px;
}

/* ---------------------------------------------------------------------------
 * Search field
 * ------------------------------------------------------------------------ */
input[type="search"],
input[type="text"],
input[type="email"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 9px 13px;
  color: var(--text-color);
  font: inherit;
}

input[type="search"]:focus,
input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-color) 18%, transparent);
}

textarea {
  min-height: 140px;
}

/* ---------------------------------------------------------------------------
 * Layout shell
 * ------------------------------------------------------------------------ */
.docs-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  align-items: start;
}

.docs-sidebar {
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  padding: 22px 14px 48px;
}

.sidebar-head {
  padding: 4px 10px 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-home {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint-color);
}

.sidebar-home:hover {
  color: var(--brand-color);
  text-decoration: none;
}

.docs-content {
  min-width: 0;
  padding: 36px 44px 80px;
}

/* ---------------------------------------------------------------------------
 * Sidebar navigation tree
 * ------------------------------------------------------------------------ */
.kb-nav-status {
  color: var(--faint-color);
  font-size: 0.86rem;
  padding: 8px 10px;
}

.kb-tree,
.kb-branch {
  list-style: none;
  margin: 0;
  padding: 0;
}

.kb-branch {
  display: none;
  margin-left: 12px;
  padding-left: 8px;
  border-left: 1px solid var(--border-color);
}

.kb-cat.is-open > .kb-branch,
.kb-sec.is-open > .kb-branch {
  display: block;
}

.kb-branch-head {
  display: flex;
  align-items: center;
}

.kb-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-color);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.kb-toggle:hover {
  background: var(--surface-2);
}

.kb-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-label-static {
  display: block;
  flex: 1;
  padding: 6px 10px;
  font-size: 0.9rem;
  color: var(--text-color);
}

.kb-cat-toggle .kb-label,
.kb-cat > .kb-branch-head > .kb-label-static {
  font-weight: 700;
}

.kb-sec-toggle .kb-label,
.kb-sec > .kb-branch-head > .kb-label-static {
  color: var(--muted-color);
  font-weight: 600;
}

.kb-art a {
  display: block;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--muted-color);
  font-weight: 500;
}

.kb-art a:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.kb-toggle.is-active,
.kb-art a.is-active {
  background: color-mix(in srgb, var(--brand-color) 12%, transparent);
  color: var(--brand-color);
  font-weight: 700;
  box-shadow: inset 2px 0 0 var(--brand-color);
}

.kb-toggle.is-active .kb-label {
  color: var(--brand-color);
}

.kb-caret {
  flex: none;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--faint-color);
  border-bottom: 2px solid var(--faint-color);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.kb-cat.is-open > .kb-branch-head .kb-caret,
.kb-sec.is-open > .kb-branch-head .kb-caret {
  transform: rotate(45deg);
}

/* ---------------------------------------------------------------------------
 * Content primitives
 * ------------------------------------------------------------------------ */
.container,
.page,
.narrow-page {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.narrow-page {
  max-width: 760px;
}

.breadcrumbs {
  margin-bottom: 20px;
  color: var(--faint-color);
  font-size: 0.86rem;
}

.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 0;
}

.breadcrumbs li {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.breadcrumbs li + li::before {
  content: "\203A";
  margin: 0 8px;
  color: var(--faint-color);
}

.breadcrumbs a {
  color: var(--muted-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumbs a:hover {
  color: var(--brand-color);
}

.page-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 2rem;
  line-height: 1.2;
}

.page-header p {
  margin: 0;
  color: var(--muted-color);
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0 0 4px;
}

.section-heading p {
  margin: 0;
  color: var(--muted-color);
}

.section-block {
  padding: 0 0 40px;
}

/* Hero (home) — compact for a manual */
.hero {
  padding: 28px 0 36px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  line-height: 1.1;
}

.hero p {
  margin: 0 0 18px;
  max-width: 620px;
  color: var(--muted-color);
}

.search-full {
  max-width: 560px;
}

/* Cards */
.card-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 18px 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text-color);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.card h2,
.card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

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

.card .article-list {
  margin-top: 12px;
}

/* Lists of links */
.article-list,
.search-results {
  margin: 0;
  padding: 0;
  list-style: none;
}

.article-list li {
  padding: 9px 0;
  border-bottom: 1px solid var(--border-color);
}

.article-list.compact li {
  padding: 5px 0;
  border-bottom: 0;
  font-size: 0.9rem;
}

.search-result {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
}

.search-result a {
  font-weight: 600;
}

.search-result p {
  margin: 4px 0 0;
  color: var(--muted-color);
  font-size: 0.92rem;
}

/* ---------------------------------------------------------------------------
 * Documentation index (category / section landing) + home landing
 * ------------------------------------------------------------------------ */
.doc-index-group {
  margin-bottom: 28px;
}

.doc-index-group > h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.doc-index-group > h2 a {
  color: var(--text-color);
}

.doc-index-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-index-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-color);
}

.doc-index-list li:last-child {
  border-bottom: 0;
}

.doc-index-list a {
  font-weight: 500;
}

.home-hero {
  max-width: var(--content-max);
  margin: 0 0 12px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.home-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 3.5vw, 2.5rem);
  line-height: 1.15;
}

.home-hero p {
  margin: 0 0 18px;
  color: var(--muted-color);
}

.home-section {
  max-width: var(--content-max);
  margin-top: 28px;
}

.home-section h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

/* ---------------------------------------------------------------------------
 * Article + table of contents
 * ------------------------------------------------------------------------ */
.doc-article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--toc-width);
  gap: 48px;
  align-items: start;
}

.doc-article {
  min-width: 0;
  max-width: var(--content-max);
}

.article-header {
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-color);
}

.article-header h1 {
  margin: 0 0 10px;
  font-size: 2.1rem;
  line-height: 1.15;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--faint-color);
  font-size: 0.88rem;
}

.article-body {
  font-size: 1rem;
}

.article-body h2,
.article-body h3,
.article-body h4 {
  scroll-margin-top: calc(var(--topbar-height) + 16px);
  line-height: 1.3;
}

.article-body h2 {
  margin: 2.4rem 0 0.8rem;
  padding-top: 0.4rem;
  font-size: 1.5rem;
}

.article-body h3 {
  margin: 1.8rem 0 0.6rem;
  font-size: 1.2rem;
}

.article-body p,
.article-body ul,
.article-body ol {
  margin: 0 0 1rem;
}

.article-body img {
  border-radius: var(--radius-sm);
}

.article-body figure {
  margin: 1.4rem 0;
}

.article-body figure img {
  display: block;
}

.article-body figcaption {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 3px solid var(--border-color);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--faint-color);
  text-align: left;
}

.article-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 5px;
}

.article-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
}

.article-body pre code {
  background: none;
  padding: 0;
}

.article-body blockquote {
  margin: 1.4rem 0;
  padding: 14px 18px;
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--brand-color);
  border-radius: var(--radius);
  background: var(--surface-color);
  color: var(--text-color);
}

.article-body blockquote > :first-child {
  margin-top: 0;
}

.article-body blockquote > :last-child {
  margin-bottom: 0;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

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

.article-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.vote-label {
  font-weight: 600;
  margin-right: 4px;
}

/* TOC */
.doc-toc {
  position: sticky;
  top: calc(var(--topbar-height) + 28px);
  align-self: start;
  max-height: calc(100vh - var(--topbar-height) - 56px);
  overflow-y: auto;
  font-size: 0.86rem;
}

.doc-toc-title {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint-color);
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border-color);
}

.toc-item a {
  display: block;
  padding: 4px 12px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--muted-color);
  line-height: 1.4;
}

.toc-item a:hover {
  color: var(--text-color);
  text-decoration: none;
}

.toc-h3 a {
  padding-left: 24px;
  font-size: 0.82rem;
}

.toc-item a.is-active {
  color: var(--brand-color);
  border-left-color: var(--brand-color);
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
 * Buttons, pills, tables, forms
 * ------------------------------------------------------------------------ */
.button,
button.button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--brand-color);
  color: #fff;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button:hover,
input[type="submit"]:hover {
  text-decoration: none;
  filter: brightness(0.95);
}

.button-secondary {
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-color);
}

.button-large {
  padding: 11px 20px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted-color);
  padding: 2px 10px;
  font-size: 0.76rem;
  font-weight: 600;
}

.form-card,
.empty-state {
  padding: 24px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: #fff;
}

.empty-state {
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

.request-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.request-table th,
.request-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.request-table th {
  background: var(--surface-color);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-color);
}

/* Comments */
.comments {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.comment {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
}

.comment-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--faint-color);
}

.request-meta {
  margin-top: 32px;
  padding: 18px 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface-color);
}

.request-meta dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 18px;
  margin: 0;
}

.request-meta dt {
  color: var(--faint-color);
  font-size: 0.85rem;
}

.request-meta dd {
  margin: 0;
}

/* ---------------------------------------------------------------------------
 * Footer
 * ------------------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--border-color);
  background: var(--surface-color);
  color: var(--muted-color);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  font-size: 0.88rem;
}

.footer-inner p {
  margin: 0;
}

/* ---------------------------------------------------------------------------
 * Backdrop (mobile)
 * ------------------------------------------------------------------------ */
.sidebar-backdrop {
  display: none;
}

/* ---------------------------------------------------------------------------
 * Responsive
 * ------------------------------------------------------------------------ */
@media (max-width: 1080px) {
  .doc-article-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .doc-toc {
    display: none;
  }
}

@media (max-width: 860px) {
  .sidebar-toggle {
    display: flex;
  }

  .docs-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .docs-sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: min(86vw, var(--sidebar-width));
    height: auto;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 45;
    box-shadow: var(--shadow);
  }

  .docs-sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: var(--topbar-height) 0 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 44;
  }

  .docs-content {
    padding: 24px 18px 64px;
  }

  .topbar-cta,
  .topbar-actions a {
    display: none;
  }

  body.sidebar-open {
    overflow: hidden;
  }
}

@media (max-width: 560px) {
  .topbar-search {
    display: none;
  }
}
