:root,
[data-md-color-scheme] {
  --md-primary-fg-color: #0f9cf1;
  --md-primary-fg-color--light: #4bb5f4;
  --md-primary-fg-color--dark: #0d85cd;
  --md-typeset-a-color: #0f9cf1;
  --md-accent-fg-color: #0f9cf1;
}

/* Viewport typography — 125% default, 130% from 100em, 140% from 125em */
html {
  font-size: 125%;
}

@media screen and (min-width: 100em) {
  html {
    font-size: 130%;
  }
}

@media screen and (min-width: 125em) {
  html {
    font-size: 140%;
  }
}

/* Top header bar */
.md-header,
[data-md-color-scheme] .md-header {
  background-color: #060e14 !important;
}

.md-header .md-header__button,
.md-header .md-header__topic,
.md-header .md-header__title,
.md-header .md-logo {
  color: #fff;
}

.md-header .md-tabs {
  background-color: #060e14 !important;
}

.md-header .md-tabs__link {
  color: rgba(255, 255, 255, 0.7);
}

.md-header .md-tabs__link--active,
.md-header .md-tabs__link:hover {
  color: #fff;
}

/* Header Partner link (before Search) */
.qv-docs-partner {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  margin-right: 0.35rem;
}

.qv-docs-partner__link {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.qv-docs-partner__link:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

/* Primary sidebar - brand blue (Wiki.js parity) */
.md-sidebar--primary {
  --md-default-bg-color: #1a76d3;
  --md-default-bg-color--light: #3c8bda;
  --md-default-bg-color--lighter: #3c8bda;
  --md-default-bg-color--lightest: #3c8bda;
  --md-default-fg-color: #fff;
  --md-default-fg-color--light: rgba(255, 255, 255, 0.82);
  --md-default-fg-color--lighter: rgba(255, 255, 255, 0.56);
  --md-default-fg-color--lightest: rgba(255, 255, 255, 0.2);
  --md-typeset-a-color: #fff;
  --md-accent-fg-color: #fff;
  background: #1a76d3 !important;
}

.md-sidebar--primary .md-sidebar__scrollwrap,
.md-sidebar--primary .md-sidebar__inner,
.md-sidebar--primary .md-nav--primary,
.md-sidebar--primary .md-nav--primary .md-nav,
.md-sidebar--primary .md-nav--primary .md-nav__title,
.md-sidebar--primary .md-nav--primary .md-nav__title ~ .md-nav__list,
.md-sidebar--primary .md-nav--primary .md-nav__list {
  background: #1a76d3 !important;
}

/* Site name already shown in header — hide duplicate sticky sidebar title */
.md-sidebar--primary .md-nav--primary > .md-nav__title {
  display: none !important;
}

/* Space between header and first nav item (Home) */
.md-sidebar--primary .md-nav--primary > .md-nav__list {
  padding-top: 1.25rem;
}

.md-sidebar--primary .md-nav--primary .md-nav__title,
.md-sidebar--primary .md-nav--primary label.md-nav__title {
  color: #fff !important;
  font-weight: 700;
  box-shadow: none !important;
}

.md-sidebar--primary .md-nav__item--section > .md-nav__link,
.md-sidebar--primary .md-nav__link {
  color: rgba(255, 255, 255, 0.87);
}

.md-sidebar--primary .md-nav--primary > .md-nav__list > .md-nav__item--section {
  border-top: 1px solid rgba(255, 255, 255, 0.28);
  margin-top: 0.45rem;
  padding-top: 0.45rem;
}

.md-sidebar--primary .md-nav__link--active,
.md-sidebar--primary .md-nav__item--active > .md-nav__link,
.md-sidebar--primary .md-nav__link:hover {
  color: #fff;
  background-color: #3c8bda;
}

.md-sidebar--primary .md-nav__icon {
  color: #fff;
}

/* Primary sidebar - dark mode (shaded brand blue) */
[data-md-color-scheme="slate"] .md-sidebar--primary {
  --md-default-bg-color: #0f4a7a;
  --md-default-bg-color--light: #33658e;
  --md-default-bg-color--lighter: #33658e;
  --md-default-bg-color--lightest: #33658e;
  background: #0f4a7a !important;
}

[data-md-color-scheme="slate"] .md-sidebar--primary .md-sidebar__scrollwrap,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-sidebar__inner,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav--primary,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav--primary .md-nav,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav--primary .md-nav__title,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav--primary .md-nav__title ~ .md-nav__list,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav--primary .md-nav__list {
  background: #0f4a7a !important;
}

[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav__link--active,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav__item--active > .md-nav__link,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav__link:hover {
  background-color: #33658e;
}

[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav--primary > .md-nav__list > .md-nav__item--section {
  border-top-color: rgba(255, 255, 255, 0.18);
}

/* QVOICE content headings - Wiki.js parity (blue H1, black H2/H3, rule below) */
.md-content .md-typeset h1,
.md-content .md-typeset h2,
.md-content .md-typeset h3,
.md-content .md-typeset h4 {
  font-weight: 700;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 0.4rem;
  margin-top: 1.5rem;
  margin-bottom: 0.9rem;
  line-height: 1.3;
}

.md-content .md-typeset h1 {
  color: #0f9cf1;
  font-size: 1.75rem;
  margin-top: 0;
}

.md-content .md-typeset h2 {
  color: #212121;
  font-size: 1.4rem;
}

.md-content .md-typeset h3 {
  color: #212121;
  font-size: 1.15rem;
}

.md-content .md-typeset h4 {
  color: #212121;
  font-size: 1rem;
  font-weight: 600;
}

[data-md-color-scheme="slate"] .md-content .md-typeset h1 {
  color: #4bb5f4;
}

[data-md-color-scheme="slate"] .md-content .md-typeset h2,
[data-md-color-scheme="slate"] .md-content .md-typeset h3,
[data-md-color-scheme="slate"] .md-content .md-typeset h4 {
  color: rgba(255, 255, 255, 0.9);
}

[data-md-color-scheme="slate"] .md-content .md-typeset h1,
[data-md-color-scheme="slate"] .md-content .md-typeset h2,
[data-md-color-scheme="slate"] .md-content .md-typeset h3,
[data-md-color-scheme="slate"] .md-content .md-typeset h4 {
  border-bottom-color: rgba(255, 255, 255, 0.18);
}

/* Layout - fixed sidebar, flexible content, right page TOC */
@media screen and (min-width: 76.25em) {
  .md-main__inner {
    margin-top: 0 !important;
    max-width: 100% !important;
  }

  .md-header__inner.md-grid,
  .md-main__inner.md-grid {
    max-width: none !important;
  }

  .md-content {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: none !important;
    padding-top: 1.5rem;
  }

  .md-sidebar--primary {
    padding: 0 !important;
    margin-left: 0 !important;
    width: 11.5rem !important;
    max-width: 11.5rem !important;
    flex: 0 0 11.5rem !important;
    top: 2.4rem !important;
    align-self: flex-start !important;
    min-height: calc(100vh - 2.4rem) !important;
  }

  .md-sidebar--primary .md-sidebar__scrollwrap {
    margin: 0 !important;
    overflow-anchor: none;
  }

  .md-sidebar--secondary {
    display: block !important;
    height: auto !important;
    width: 12.1rem !important;
    max-width: 12.1rem !important;
    flex: 0 0 12.1rem !important;
    top: 2.4rem !important;
  }
}

/* Nav icons: match link text size — do not increase row height */
.md-sidebar--primary .md-nav__link:has(.qv-nav-icon) {
  display: flex;
  align-items: center;
  gap: 0.35em;
}

.qv-nav-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  margin: 0;
  font-size: 1em;
  line-height: 1;
  vertical-align: unset;
  opacity: 0.95;
}

/* Click-to-zoom hint for Wiki.js / content images (glightbox handles open) */
.md-content .md-typeset img,
.md-content .md-typeset figure.image img {
  cursor: zoom-in;
}

/* Instant navigation — top progress bar (Material) */
:root,
[data-md-color-scheme] {
  --md-progress-delay: 150ms;
}

.md-progress {
  background-color: #0f9cf1 !important;
}

/* Page loading overlay (sidebar / internal nav on large pages) */
#qv-page-loading {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 14, 20, 0.38);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
}

#qv-page-loading.qv-page-loading--visible {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

.qv-page-loading__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.75rem;
  border-radius: 0.5rem;
  background: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
}

[data-md-color-scheme="slate"] .qv-page-loading__panel {
  background: #2e3039;
  color: rgba(255, 255, 255, 0.87);
}

.qv-page-loading__spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid rgba(15, 156, 241, 0.22);
  border-top-color: #0f9cf1;
  border-radius: 50%;
  animation: qv-page-loading-spin 0.8s linear infinite;
}

@keyframes qv-page-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.qv-page-loading__label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #616161;
}

[data-md-color-scheme="slate"] .qv-page-loading__label {
  color: rgba(255, 255, 255, 0.72);
}

/* Full-width 3-column screenshot grids (callback gallery, config walkthrough) */
.md-typeset .md-typeset__table:has(table.qv-screenshot-grid),
.md-typeset .md-typeset__scrollwrap:has(table.qv-screenshot-grid),
.md-typeset .md-typeset__table:has(table:has(thead th:nth-child(3):last-child):has(td img):not(:has(thead th:nth-child(4)))),
.md-typeset .md-typeset__scrollwrap:has(table:has(thead th:nth-child(3):last-child):has(td img):not(:has(thead th:nth-child(4)))) {
  width: 100%;
  max-width: 100%;
  display: block;
  overflow-x: visible;
}

.md-typeset table.qv-screenshot-grid,
.md-typeset table:has(thead th:nth-child(3):last-child):has(td img):not(:has(thead th:nth-child(4))) {
  width: 100%;
  table-layout: fixed;
  margin: 1rem 0 1.5rem;
}

.md-typeset table.qv-screenshot-grid td,
.md-typeset table:has(thead th:nth-child(3):last-child):has(td img):not(:has(thead th:nth-child(4))) td {
  vertical-align: top;
  text-align: center;
  padding: 0.35rem;
  width: 33.333%;
}

.md-typeset table.qv-screenshot-grid td a.glightbox,
.md-typeset table:has(thead th:nth-child(3):last-child):has(td img):not(:has(thead th:nth-child(4))) td a.glightbox {
  display: block;
  width: 100%;
}

.md-typeset table.qv-screenshot-grid img,
.md-typeset table:has(thead th:nth-child(3):last-child):has(td img):not(:has(thead th:nth-child(4))) img {
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  display: block;
  cursor: zoom-in;
  border-radius: 0.25rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.15s ease;
}

.md-typeset table.qv-screenshot-grid img:hover,
.md-typeset table:has(thead th:nth-child(3):last-child):has(td img):not(:has(thead th:nth-child(4))) img:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

[data-md-color-scheme="slate"] .md-typeset table.qv-screenshot-grid img,
[data-md-color-scheme="slate"] .md-typeset table:has(thead th:nth-child(3):last-child):has(td img):not(:has(thead th:nth-child(4))) img {
  border-color: rgba(255, 255, 255, 0.12);
}

@media screen and (max-width: 59.984em) {
  .md-typeset table.qv-screenshot-grid,
  .md-typeset table.qv-screenshot-grid tbody,
  .md-typeset table.qv-screenshot-grid tr,
  .md-typeset table.qv-screenshot-grid td,
  .md-typeset table:has(thead th:nth-child(3):last-child):has(td img):not(:has(thead th:nth-child(4))),
  .md-typeset table:has(thead th:nth-child(3):last-child):has(td img):not(:has(thead th:nth-child(4))) tbody,
  .md-typeset table:has(thead th:nth-child(3):last-child):has(td img):not(:has(thead th:nth-child(4))) tr,
  .md-typeset table:has(thead th:nth-child(3):last-child):has(td img):not(:has(thead th:nth-child(4))) td {
    display: block;
    width: 100%;
  }

  .md-typeset table.qv-screenshot-grid tr,
  .md-typeset table:has(thead th:nth-child(3):last-child):has(td img):not(:has(thead th:nth-child(4))) tr {
    margin-bottom: 0.75rem;
  }
}
