@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink-900: #08152a;
  --ink-700: #10335f;
  --ink-500: #1f5ea2;
  --ink-300: #4ea3df;
  --signal: #ff8a00;
  --surface: #f4f9ff;
  --panel: #ffffff;
  --text: #10243f;
  --muted: #4d6788;
  --border: rgba(16, 36, 63, 0.16);
  --ring: rgba(31, 94, 162, 0.3);
  --shadow: 0 26px 42px -28px rgba(7, 23, 45, 0.38);
  --grid-line: rgba(78, 163, 223, 0.12);
}

[data-md-color-scheme='slate'] {
  --surface: #081222;
  --panel: #112441;
  --text: #e6efff;
  --muted: #b7c8e7;
  --border: rgba(183, 200, 231, 0.24);
  --ring: rgba(78, 163, 223, 0.4);
  --shadow: 0 30px 54px -30px rgba(0, 0, 0, 0.72);
  --grid-line: rgba(143, 198, 255, 0.17);
}

html,
body {
  font-family: 'IBM Plex Sans', 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    radial-gradient(circle at 12% 0%, rgba(31, 94, 162, 0.14), transparent 30%),
    radial-gradient(circle at 92% 8%, rgba(255, 138, 0, 0.1), transparent 25%),
    var(--surface);
  background-size: 22px 22px, 22px 22px, auto, auto, auto;
}

.md-typeset,
.md-nav {
  font-variant-numeric: lining-nums tabular-nums;
}

.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-header__title,
.md-tabs__link,
.footer-col__title,
.custom-footer__title {
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  letter-spacing: 0.01em;
}

.md-typeset code,
.md-typeset pre > code,
.md-typeset kbd {
  font-family: 'IBM Plex Mono', 'SFMono-Regular', monospace;
}

.md-header,
.md-tabs {
  background:
    linear-gradient(112deg, var(--ink-900) 0%, var(--ink-700) 60%, var(--ink-500) 100%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 2px, transparent 2px 12px) !important;
}

.md-header__title,
.md-tabs__link,
.md-header__button,
.md-search__input,
.md-search__icon,
.md-search__form {
  color: #eef7ff !important;
}

.md-search__input::placeholder {
  color: rgba(238, 247, 255, 0.76) !important;
}

.md-main__inner {
  margin-top: 1rem;
}

.md-content {
  position: relative;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: clamp(1rem, 1.4vw, 1.7rem) clamp(1rem, 2vw, 2rem);
}

.md-content::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% -10%, rgba(78, 163, 223, 0.08), transparent 40%),
    radial-gradient(circle at 80% -30%, rgba(255, 138, 0, 0.08), transparent 38%);
}

.md-typeset h1 {
  font-size: clamp(1.9rem, 2.4vw, 2.8rem);
  line-height: 1.07;
  margin-bottom: 0.9rem;
}

.md-typeset h2 {
  margin-top: 2rem;
  padding-left: 0.74rem;
  border-left: 4px solid var(--ink-300);
}

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

.md-typeset hr {
  border-bottom: 2px solid color-mix(in srgb, var(--ink-300) 44%, transparent);
}

.md-typeset table:not([class]) {
  width: 100%;
  table-layout: auto;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.md-typeset__scrollwrap,
.md-typeset__table {
  width: 100%;
}

.md-typeset__table {
  display: block;
}

.md-typeset table:not([class]) th,
.md-typeset table:not([class]) td {
  width: 1%;
  word-break: break-word;
}

.md-typeset table:not([class]) th {
  background: linear-gradient(116deg, var(--ink-700), var(--ink-300));
  color: #fff;
}

.md-typeset table:not([class]) tr:nth-child(even) {
  background: color-mix(in srgb, var(--ink-300) 9%, transparent);
}

.md-typeset .admonition,
.md-typeset details {
  border-radius: 14px;
  border-color: color-mix(in srgb, var(--ink-300) 48%, transparent);
}

.md-typeset .admonition-title,
.md-typeset summary {
  font-weight: 700;
}

.md-nav--primary,
.md-nav--secondary {
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 0.5rem;
}

.md-nav--primary .md-nav__link,
.md-nav--secondary .md-nav__link {
  border-radius: 10px;
}

.md-nav--primary .md-nav__link:hover,
.md-nav--secondary .md-nav__link:hover {
  background: color-mix(in srgb, var(--ink-300) 14%, transparent);
}

.md-nav--primary .md-nav__link--active,
.md-nav--secondary .md-nav__link--active {
  background: color-mix(in srgb, var(--ink-300) 20%, transparent);
  font-weight: 700;
}

/* Sidebar toggle controls */
.layout-toggle {
  border: 1px solid rgba(238, 247, 255, 0.5);
  color: #eef7ff;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.38rem 0.64rem;
  margin-left: 0.5rem;
  cursor: pointer;
}

.layout-toggle:hover {
  background: rgba(255, 255, 255, 0.18);
}

.layout-toggle.is-active {
  background: rgba(255, 255, 255, 0.25);
}

.header-cta {
  margin-left: 0.5rem;
  border: 1px solid rgba(238, 247, 255, 0.55);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  color: #eef7ff;
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
}

.header-cta:hover {
  background: rgba(255, 255, 255, 0.18);
}

body.nav-collapsed .md-sidebar--primary {
  display: none;
}

body.toc-collapsed .md-sidebar--secondary {
  display: none;
}

body.nav-collapsed .md-content,
body.toc-collapsed .md-content {
  margin-inline: 0;
}

/* Footer redesign */
.md-footer {
  margin-top: 0 !important;
  background: transparent !important;
}

.custom-footer {
  margin-top: 0;
  border-top: none;
  position: relative;
  overflow: hidden;
  padding: clamp(2rem, 3vw, 3.2rem) 1rem;
  background:
    linear-gradient(130deg, var(--ink-900) 0%, var(--ink-700) 56%, var(--ink-500) 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 22px);
  color: #e8f3ff;
}

.custom-footer::before {
  content: '';
  position: absolute;
  inset: -30% 58% auto -12%;
  height: 320px;
  background: radial-gradient(circle, rgba(255, 138, 0, 0.2), transparent 62%);
}

.custom-footer__inner {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 1.8rem;
  grid-template-columns: minmax(280px, 1.2fr) minmax(280px, 1fr);
}

.custom-footer__brand {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  font-size: 0.8rem;
  opacity: 0.9;
}

.custom-footer__title {
  margin: 0.35rem 0 0.6rem;
  font-size: clamp(1.3rem, 1.95vw, 2rem);
  line-height: 1.08;
}

.custom-footer__subtitle {
  max-width: 48ch;
  color: rgba(232, 243, 255, 0.92);
}

.custom-footer__equations {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.eq-chip {
  border: 1px solid rgba(232, 243, 255, 0.28);
  border-radius: 999px;
  padding: 0.26rem 0.64rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: rgba(232, 243, 255, 0.95);
  background: rgba(255, 255, 255, 0.08);
}

.custom-footer__label {
  display: block;
  margin-top: 1.1rem;
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.custom-footer__form {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  max-width: 480px;
  border-radius: 999px;
  padding: 0.35rem;
  border: 1px solid rgba(232, 243, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
}

.custom-footer__input {
  flex: 1;
  border: none;
  background: transparent;
  color: #fff;
  outline: none;
  padding: 0.5rem 0.75rem;
}

.custom-footer__input::placeholder {
  color: rgba(232, 243, 255, 0.78);
}

.custom-footer__button {
  border: none;
  border-radius: 999px;
  padding: 0.52rem 0.9rem;
  font-weight: 800;
  cursor: pointer;
  color: #0a2040;
  background: linear-gradient(120deg, #fdfefe, #e8f3ff);
}

.custom-footer__button:hover {
  filter: brightness(0.96);
}

.custom-footer__note {
  margin-top: 0.45rem;
  color: rgba(232, 243, 255, 0.86);
}

.custom-footer__right {
  display: grid;
  gap: 1rem 1.4rem;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
}

.footer-col__title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.45rem;
  color: #eff7ff;
}

.footer-link {
  display: block;
  text-decoration: none;
  color: rgba(232, 243, 255, 0.9);
  padding: 0.2rem 0;
}

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

/* Replace and restyle bottom meta without black bar */
.md-footer-meta {
  background: linear-gradient(105deg, #0d2a4f, #1f5ea2) !important;
  border-top: 0 !important;
}

.md-footer-meta__inner {
  background: transparent !important;
}

.md-footer-meta,
.md-footer-meta * {
  color: rgba(232, 243, 255, 0.9) !important;
}

.md-footer-meta .md-copyright {
  font-family: 'IBM Plex Sans', sans-serif;
}

.md-footer-meta .md-copyright a {
  text-decoration: none;
}

@media (max-width: 1220px) {
  .layout-toggle {
    display: none;
  }
}

@media (max-width: 1040px) {
  .md-main__inner {
    margin-top: 0.65rem;
  }

  .md-content {
    border-radius: 16px;
  }
}

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

  .custom-footer__right {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 640px) {
  .md-content {
    border-radius: 14px;
    padding: 0.9rem;
  }

  .md-typeset h1 {
    font-size: 1.56rem;
  }

  .custom-footer {
    padding: 1.7rem 0.85rem;
  }

  .custom-footer__form {
    flex-direction: column;
    border-radius: 14px;
    align-items: stretch;
  }

  .custom-footer__button {
    width: 100%;
  }

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

}
