/* Header + tabs */
.md-header,
.md-tabs {
  background: var(--bar-gradient) !important;
  background-size: 180% 180%;
  animation: headerGradient 18s ease infinite;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.24) !important;
}

[data-md-color-scheme="slate"] .md-header,
[data-md-color-scheme="slate"] .md-tabs {
  background: var(--bar-gradient) !important;
  animation: none !important;
  box-shadow: none !important;
}

[data-md-color-scheme="slate"] .md-header {
  border-bottom: 0 !important;
}

[data-md-color-scheme="slate"] .md-tabs {
  border-top: 0 !important;
}

@keyframes headerGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.md-header__inner,
.md-tabs__inner {
  background: transparent !important;
  margin: 0 !important;
  width: 100% !important;
  max-width: none !important;
  padding-left: 0.75rem !important;
  padding-right: 0.75rem !important;
}

.md-header__inner.md-grid,
.md-tabs__inner.md-grid,
.md-header .md-grid,
.md-tabs .md-grid {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
}

.md-header__button.md-logo img,
.md-header__button.md-logo svg {
  height: 2.6rem !important;
  width: auto !important;
  max-width: none !important;
  filter: drop-shadow(0 1px 3px rgba(15, 23, 42, 0.42));
}

.md-header__button.md-logo {
  padding: 0.26rem !important;
  border-radius: 0.58rem;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.24));
  border: 1px solid rgba(255, 255, 255, 0.38);
  box-shadow: 0 8px 16px rgba(2, 6, 23, 0.28);
}

.md-tabs__link {
  border-radius: 999px;
  padding: 0.34rem 0.84rem;
  font-weight: 700;
}

.md-tabs__link:hover,
.md-tabs__link--active {
  background: rgba(255, 255, 255, 0.2);
}

/* Search and top action area */
.md-search__form {
  border-radius: 0.8rem;
  background: rgba(15, 23, 42, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

[data-md-color-scheme="slate"] .md-search__form {
  background: rgba(20, 30, 55, 0.88) !important;
  border-color: rgba(45, 212, 191, 0.28) !important;
  box-shadow: none !important;
}

[data-md-color-scheme="slate"] .md-search__form,
[data-md-color-scheme="slate"] .md-search__input,
[data-md-color-scheme="slate"] .md-search__input::placeholder,
[data-md-color-scheme="slate"] .md-search__icon {
  background: transparent !important;
}

.md-search__input,
.md-search__input::placeholder,
.md-search__icon {
  color: #f8fafc !important;
}

/* Header actions injected by JS */
.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-left: 0.55rem;
}

.header-icon-btn,
.header-cta {
  height: 2.1rem;
  width: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.24);
  transition: transform 160ms ease, background 160ms ease;
}

.header-icon-btn svg {
  width: 1rem;
  height: 1rem;
  fill: #fff;
}

.header-toggle-btn.is-active {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.55);
}

.header-cta {
  width: auto;
  padding: 0 0.88rem;
  color: #fff !important;
  text-decoration: none !important;
  font-weight: 800;
  font-size: 0.78rem;
}

.header-icon-btn:hover,
.header-cta:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.24);
}

[dir="rtl"] .header-actions {
  margin-left: 0;
  margin-right: 0.55rem;
}

/* Sidebar collapse toggles (desktop) */
@media (min-width: 1220px) {
  body.sg-hide-left-sidebar .md-sidebar--primary {
    display: none !important;
  }

  body.sg-hide-right-sidebar .md-sidebar--secondary {
    display: none !important;
  }

  body.sg-hide-left-sidebar .md-main__inner {
    grid-template-columns: minmax(0, 1fr) minmax(13rem, 16rem) !important;
  }

  body.sg-hide-right-sidebar .md-main__inner {
    grid-template-columns: minmax(13rem, 16rem) minmax(0, 1fr) !important;
  }

  body.sg-hide-left-sidebar.sg-hide-right-sidebar .md-main__inner {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.sg-hide-left-sidebar .md-content,
  body.sg-hide-right-sidebar .md-content,
  body.sg-hide-left-sidebar.sg-hide-right-sidebar .md-content,
  body.sg-hide-left-sidebar .md-main .md-grid,
  body.sg-hide-right-sidebar .md-main .md-grid,
  body.sg-hide-left-sidebar.sg-hide-right-sidebar .md-main .md-grid,
  body.sg-hide-left-sidebar .md-content__inner,
  body.sg-hide-right-sidebar .md-content__inner,
  body.sg-hide-left-sidebar.sg-hide-right-sidebar .md-content__inner {
    max-width: min(100%, 1360px) !important;
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  body.sg-hide-left-sidebar.sg-hide-right-sidebar .md-content,
  body.sg-hide-left-sidebar.sg-hide-right-sidebar .md-main .md-grid,
  body.sg-hide-left-sidebar.sg-hide-right-sidebar .md-content__inner {
    max-width: min(100%, 1480px) !important;
  }

  body.sg-hide-left-sidebar .md-typeset__table,
  body.sg-hide-right-sidebar .md-typeset__table,
  body.sg-hide-left-sidebar.sg-hide-right-sidebar .md-typeset__table {
    width: 100% !important;
    max-width: min(100%, 1360px) !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  body.sg-hide-left-sidebar .md-typeset__table table,
  body.sg-hide-right-sidebar .md-typeset__table table,
  body.sg-hide-left-sidebar.sg-hide-right-sidebar .md-typeset__table table {
    width: 100% !important;
    min-width: 100% !important;
  }

  body.sg-hide-left-sidebar .md-typeset__scrollwrap,
  body.sg-hide-right-sidebar .md-typeset__scrollwrap,
  body.sg-hide-left-sidebar.sg-hide-right-sidebar .md-typeset__scrollwrap {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto;
  }

  body.sg-hide-left-sidebar .md-typeset table:not([class]),
  body.sg-hide-right-sidebar .md-typeset table:not([class]),
  body.sg-hide-left-sidebar.sg-hide-right-sidebar .md-typeset table:not([class]) {
    width: 100% !important;
    min-width: 100% !important;
  }
}

/* Typography */
.md-typeset h1 {
  font-weight: 900 !important;
  letter-spacing: -0.02em;
}

.md-typeset h2 {
  margin-top: 2.2rem !important;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line-soft);
}

.md-typeset h3 {
  font-weight: 800 !important;
  color: #0f766e;
}

[data-md-color-scheme="slate"] .md-typeset h3 {
  color: #5eead4;
}

.md-typeset .headerlink {
  display: none !important;
}

.md-typeset p,
.md-typeset li,
.md-typeset td {
  color: var(--text-main);
}

/* Tables: fill content width with balanced columns */
.md-typeset__table {
  width: 100% !important;
  max-width: 100% !important;
}

.md-typeset__table table,
.md-typeset table:not([class]) {
  display: table !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 100% !important;
  table-layout: auto !important;
  box-sizing: border-box;
}

.md-typeset__table th,
.md-typeset__table td,
.md-typeset table:not([class]) th,
.md-typeset table:not([class]) td {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Cleaner primary nav: remove status badges only */
.md-status {
  display: none !important;
}

/* Primary sidebar (native MkDocs structure) */
.md-sidebar--primary .md-sidebar__scrollwrap {
  padding-top: 0.9rem;
}

/* Show the left sidebar title (match TOC title card) */
.md-sidebar--primary .md-nav--primary > .md-nav__title,
.md-sidebar--primary .md-nav--primary > label.md-nav__title{
  display: block !important;
  margin: 0.2rem 0.55rem 0.55rem;
  padding: 0.55rem 0.72rem;
  border-radius: 0.72rem;
  color: #e9fcfa !important;
  background: var(--bar-gradient) !important;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(15, 60, 66, 0.2);
}

/* Dark mode: keep same card */
[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 > label.md-nav__title{
  color: #e8fffb !important;
  background: var(--bar-gradient) !important;
}

/* Left sidebar heading card: match right TOC title graphics */
.md-sidebar--primary .md-nav--primary .md-nav__item--active > .md-nav > .md-nav__title,
.md-sidebar--primary .md-nav--primary .md-nav__item--active > .md-nav > label.md-nav__title {
  margin: 0.2rem 0.55rem 0.55rem;
  padding: 0.55rem 0.72rem;
  border-radius: 0.72rem;
  color: #e9fcfa !important;
  background: var(--bar-gradient) !important;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(15, 60, 66, 0.2);
}

.md-nav--primary .md-nav__item > .md-nav__link {
  border-radius: 0.62rem;
  margin: 0.08rem 0.46rem;
  padding: 0.32rem 0.56rem;
}

.md-nav--primary .md-nav__item > .md-nav__link:hover {
  background: rgba(17, 94, 89, 0.14);
}

.md-nav--primary .md-nav__link--active {
  background: rgba(17, 94, 89, 0.2);
  color: #0f4b52 !important;
  font-weight: 800;
}

[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav--primary .md-nav__item--active > .md-nav > .md-nav__title,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav--primary .md-nav__item--active > .md-nav > label.md-nav__title {
  color: #e8fffb !important;
  background: var(--bar-gradient) !important;
}

[data-md-color-scheme="slate"] .md-nav--primary .md-nav__item > .md-nav__link {
  color: #8ef1e4;
}

[data-md-color-scheme="slate"] .md-nav--primary .md-nav__item > .md-nav__link:hover {
  background: rgba(45, 212, 191, 0.16);
}

[data-md-color-scheme="slate"] .md-nav--primary .md-nav__link--active {
  background: rgba(45, 212, 191, 0.24);
  color: #dcfffb !important;
}

/* TOC title card style */
.md-nav--secondary .md-nav__title {
  border-radius: 0.72rem;
  padding: 0.55rem 0.72rem;
  color: #e9fcfa !important;
  background: var(--bar-gradient) !important;
  box-shadow: 0 8px 18px rgba(15, 60, 66, 0.2);
}

[data-md-color-scheme="slate"] .md-nav--secondary .md-nav__title {
  color: #e8fffb !important;
  background: var(--bar-gradient) !important;
}

.md-nav--secondary .md-nav__link {
  color: #115a61 !important;
  border-radius: 0.6rem;
  padding: 0.32rem 0.42rem;
}

.md-nav--secondary .md-nav__link:hover,
.md-nav--secondary .md-nav__link--active {
  color: #0d4f55 !important;
  background: rgba(17, 94, 89, 0.14);
}

[data-md-color-scheme="slate"] .md-nav--secondary .md-nav__link {
  color: #8ef1e4 !important;
}

[data-md-color-scheme="slate"] .md-nav--secondary .md-nav__link:hover,
[data-md-color-scheme="slate"] .md-nav--secondary .md-nav__link--active {
  color: #d8fffa !important;
  background: rgba(45, 212, 191, 0.16);
}

/* Footer */
.md-footer {
  background: transparent !important;
}

.custom-footer,
.md-footer-meta {
  color: #fff !important;
  background: var(--bar-gradient) !important;
}

.custom-footer {
  padding: 1.8rem 1rem 1.2rem !important;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.custom-footer__inner {
  width: min(97vw, 1680px);
  max-width: 1680px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(22rem, 1fr) minmax(36rem, 1.45fr);
  gap: 1.3rem 2rem;
  padding: 1.2rem 1.4rem;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.13);
  box-shadow: 0 16px 36px rgba(2, 6, 23, 0.3);
  backdrop-filter: blur(8px);
}

.custom-footer__right {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.15fr;
  gap: 0.8rem 1rem;
}

.custom-footer__brand {
  display: inline-flex;
  align-items: center;
  margin: 0 0 0.75rem;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e9fffc;
  background: rgba(15, 23, 42, 0.28);
  border: 1px solid rgba(45, 212, 191, 0.42);
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.25);
}

.custom-footer__title {
  font-size: clamp(2rem, 2.1vw, 2.6rem);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.custom-footer__subtitle,
.custom-footer__note,
.footer-link {
  font-size: 0.82rem;
}

.custom-footer__form {
  display: flex;
  gap: 0.5rem;
  max-width: 560px;
  margin-top: 0.7rem;
  padding: 0.45rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.14);
}

.custom-footer__input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: #fff;
}

.custom-footer__button {
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 800;
  color: #0f172a;
}

.footer-col__title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 800;
}

.footer-col--support {
  min-width: 0;
}

.footer-col {
  min-width: 0;
}

.footer-link {
  color: rgba(255, 255, 255, 0.93);
  text-decoration: none;
  line-height: 1.5;
  display: block;
  padding: 0.15rem 0;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

.footer-link:hover {
  color: #fff;
  text-decoration: underline;
}

@media (max-width: 900px) {
  .custom-footer__inner {
    grid-template-columns: 1fr;
  }

  .custom-footer__right {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .custom-footer__right {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .header-toggle-btn,
  .header-github {
    display: none;
  }

  .header-actions {
    gap: 0.38rem;
    margin-left: 0.35rem;
  }

  .header-cta {
    padding: 0 0.72rem;
    font-size: 0.74rem;
  }
}

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 520ms ease, transform 520ms ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
