@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Fraunces:opsz,wght@9..144,600;9..144,700&display=swap');

:root {
  --bg: #f4fbf8;
  --bg-soft: #ecf8f3;
  --surface: #ffffff;
  --surface-soft: #f6fcfa;
  --text: #12322a;
  --text-soft: #4c6d64;
  --line: #cce5db;
  --line-strong: #9ccfbc;
  --primary: #0f766e;
  --primary-strong: #0a544f;
  --accent: #1d9b84;
  --danger: #b42318;
  --shadow-sm: 0 6px 18px rgba(13, 62, 51, 0.08);
  --shadow-md: 0 14px 32px rgba(13, 62, 51, 0.12);
}

[data-md-color-scheme='slate'] {
  --bg: #0b1714;
  --bg-soft: #12201c;
  --surface: #102621;
  --surface-soft: #14302a;
  --text: #e8f5f0;
  --text-soft: #a6c5bb;
  --line: #24453c;
  --line-strong: #3d7365;
  --primary: #56ccb2;
  --primary-strong: #85e2ce;
  --accent: #91f5de;
  --shadow-sm: 0 10px 24px rgba(0, 0, 0, 0.36);
  --shadow-md: 0 16px 36px rgba(0, 0, 0, 0.45);
}

html,
body,
.md-typeset {
  font-family: 'Manrope', 'Segoe UI', sans-serif;
}

body {
  background:
    radial-gradient(circle at 12% 8%, rgba(29, 155, 132, 0.1), transparent 26%),
    radial-gradient(circle at 88% 0%, rgba(15, 118, 110, 0.12), transparent 28%),
    linear-gradient(150deg, var(--bg), var(--bg-soft));
  color: var(--text);
}

h1,
h2,
h3,
.md-header__title,
.md-typeset .admonition-title {
  font-family: 'Fraunces', Georgia, serif;
  color: var(--text);
}

.md-header {
  background: linear-gradient(125deg, #e5f7f0 0%, #d8f1ea 55%, #e8f9f6 100%) !important;
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

[data-md-color-scheme='slate'] .md-header {
  background: linear-gradient(125deg, #15332d 0%, #12342d 55%, #133a32 100%) !important;
}

.md-header__title,
.md-header__button,
.md-search__icon,
.md-search__input,
.md-search__input::placeholder {
  color: var(--text) !important;
}

.md-search__form {
  background: rgba(255, 255, 255, 0.58) !important;
  border: 1px solid var(--line);
  border-radius: 999px;
}

[data-md-color-scheme='slate'] .md-search__form {
  background: rgba(17, 35, 30, 0.75) !important;
}

.md-tabs {
  display: block !important;
  background: transparent !important;
  border-top: 1px solid rgba(156, 207, 188, 0.35);
}

.md-tabs__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.65rem 0.3rem 0.9rem;
}

.md-tabs__item {
  margin: 0 !important;
}

.md-tabs__link {
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--text-soft) !important;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.42rem 0.85rem;
  transition: all 0.18s ease;
}

.md-tabs__link:hover {
  transform: translateY(-1px);
  background: rgba(15, 118, 110, 0.16);
  color: var(--text) !important;
}

.md-tabs__link--active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff !important;
  box-shadow: 0 8px 16px rgba(11, 84, 79, 0.28);
}

.md-main {
  background: transparent;
}

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

.md-content,
.md-sidebar__scrollwrap,
.md-nav--secondary {
  background: transparent;
}

.md-content__inner {
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.88), rgba(246, 252, 249, 0.92));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.4rem 1.4rem 1.8rem;
  box-shadow: var(--shadow-sm);
}

[data-md-color-scheme='slate'] .md-content__inner {
  background: linear-gradient(160deg, rgba(16, 38, 33, 0.86), rgba(19, 45, 38, 0.92));
}

.md-nav--primary .md-nav__link,
.md-nav--secondary .md-nav__link {
  border-radius: 12px;
  padding: 0.38rem 0.65rem;
}

.md-nav--primary .md-nav__link:hover,
.md-nav--secondary .md-nav__link:hover {
  background: rgba(15, 118, 110, 0.1);
}

.md-nav--primary .md-nav__link--active,
.md-nav--secondary .md-nav__link--active {
  background: rgba(15, 118, 110, 0.16) !important;
  color: var(--primary) !important;
  font-weight: 700;
}

.md-nav--secondary .md-nav__title {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(120deg, rgba(15, 118, 110, 0.14), rgba(29, 155, 132, 0.12));
  color: var(--text);
}

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

.md-typeset a {
  color: var(--primary);
  font-weight: 600;
}

.md-typeset a:hover {
  color: var(--primary-strong);
}

.md-typeset table:not([class]) {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.md-typeset table:not([class]) th {
  background: rgba(15, 118, 110, 0.12);
  color: var(--text);
}

.md-typeset blockquote {
  border-left: 4px solid var(--accent);
  background: rgba(15, 118, 110, 0.07);
  border-radius: 0 12px 12px 0;
  padding: 0.65rem 0.9rem;
}

.header-cta {
  margin-left: auto;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff !important;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.42rem 0.85rem;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.25);
}

.header-cta:hover {
  background: linear-gradient(135deg, var(--primary-strong), var(--primary));
}

.custom-footer {
  margin-top: 2rem;
  background: linear-gradient(120deg, #ddf4ec 0%, #e8f8f3 45%, #dff5ef 100%) !important;
  color: var(--text) !important;
  border-top: 1px solid var(--line) !important;
  padding: 2.8rem 1rem !important;
}

[data-md-color-scheme='slate'] .custom-footer {
  background: linear-gradient(120deg, #14352d 0%, #163c32 45%, #13372f 100%) !important;
}

.custom-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2rem;
}

.custom-footer__title {
  color: var(--text);
}

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

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
}

.footer-col__title {
  color: var(--text);
  font-weight: 800;
  margin-bottom: 0.32rem;
}

.custom-footer__note,
.footer-link {
  color: var(--text-soft) !important;
}

.custom-footer__form {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  padding: 0.5rem;
  max-width: 620px;
}

.custom-footer__input {
  flex: 1;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  padding: 0.45rem 0.85rem !important;
  color: var(--text) !important;
}

.custom-footer__button {
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 700;
  padding: 0.62rem 1.1rem;
}

.custom-footer__button:hover {
  background: linear-gradient(135deg, var(--primary-strong), var(--primary));
}

.md-footer-meta {
  background: transparent !important;
  color: var(--text-soft);
}

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

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

  .md-tabs__list {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
    padding-bottom: 0.7rem;
  }

  .md-tabs__item {
    flex: 0 0 auto;
  }
}

@media (max-width: 700px) {
  .md-content__inner {
    border-radius: 14px;
    padding: 1rem;
  }

  .header-cta {
    display: none;
  }

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

/* ===== UX POLISH: HEADER CLEANUP, FOOTER UNITY, SIDEBAR TOGGLES ===== */
.md-header__inner {
  max-width: 1280px;
  padding: 0.55rem 0.9rem;
  gap: 0.65rem;
}

.md-header__title {
  font-size: 1.05rem;
  font-weight: 700;
}

.md-tabs__list {
  flex-wrap: nowrap;
  overflow-x: auto;
  justify-content: flex-start;
  scrollbar-width: thin;
  padding: 0.55rem 0.4rem 0.75rem;
}

.md-tabs__link {
  white-space: nowrap;
  padding: 0.44rem 0.78rem;
  font-size: 0.8rem;
}

.md-tabs__item {
  flex: 0 0 auto;
}

.header-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.layout-toggle-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}

.layout-toggle-btn:hover {
  background: rgba(15, 118, 110, 0.15);
}

.layout-toggle-btn.active {
  border-color: var(--line-strong);
}

.header-cta {
  margin-left: 0;
  font-size: 0.74rem;
  padding: 0.4rem 0.82rem;
}

.hide-primary-nav .md-sidebar--primary {
  display: none !important;
}

.hide-toc-nav .md-sidebar--secondary {
  display: none !important;
}

.md-footer {
  margin-top: 2rem;
  border-top: 1px solid var(--line);
  background: linear-gradient(118deg, #ddf4ec 0%, #e8f8f3 48%, #e1f6ef 100%) !important;
}

[data-md-color-scheme='slate'] .md-footer {
  background: linear-gradient(118deg, #14372f 0%, #143a31 48%, #163b33 100%) !important;
}

.custom-footer {
  margin-top: 0;
  border-top: none !important;
  border-bottom: 1px solid rgba(156, 207, 188, 0.35);
  background: transparent !important;
}

.md-footer-meta {
  background: transparent !important;
  border-top: none !important;
}

.md-footer-meta__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.95rem 1rem 1.3rem;
}

.md-copyright {
  color: var(--text-soft) !important;
  font-weight: 600;
}

/* Allow custom footer credit link to show */
.md-copyright__credit a {
  display: inline !important;
}

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

@media (max-width: 700px) {
  .header-controls {
    gap: 0.3rem;
  }

  .md-header__title {
    font-size: 0.95rem;
  }
}

/* ===== FINAL LAYOUT + READABILITY FIXES ===== */
@media (min-width: 1220px) {
  .md-main__inner {
    max-width: 1380px;
    display: grid !important;
    grid-template-columns: 280px minmax(0, 1fr) 250px;
    gap: 1.2rem;
    align-items: start;
  }

  .md-sidebar--primary {
    grid-column: 1;
  }

  .md-content {
    grid-column: 2;
    max-width: 100% !important;
  }

  .md-content__inner {
    max-width: 100% !important;
  }

  .md-sidebar--secondary {
    grid-column: 3;
  }

  .hide-primary-nav .md-main__inner {
    grid-template-columns: minmax(0, 1fr) 250px;
  }

  .hide-primary-nav .md-content {
    grid-column: 1;
  }

  .hide-primary-nav .md-sidebar--secondary {
    grid-column: 2;
  }

  .hide-toc-nav .md-main__inner {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .hide-toc-nav .md-content {
    grid-column: 2;
  }

  .hide-toc-nav .md-sidebar--primary {
    grid-column: 1;
  }

  .hide-primary-nav.hide-toc-nav .md-main__inner {
    grid-template-columns: minmax(0, 1fr);
  }

  .hide-primary-nav.hide-toc-nav .md-content {
    grid-column: 1;
  }
}

.md-nav--secondary .md-nav__list {
  border-left: 2px solid rgba(15, 118, 110, 0.2);
  margin-left: 0.35rem;
  padding-left: 0.35rem;
}

.md-nav--secondary .md-nav__link {
  color: var(--text-soft) !important;
  font-weight: 600;
}

.custom-footer {
  border-bottom: none;
  padding: 3.1rem 1rem 2.2rem !important;
}

.custom-footer__inner {
  background: rgba(255, 255, 255, 0.36);
  border: 1px solid rgba(156, 207, 188, 0.5);
  border-radius: 24px;
  box-shadow: var(--shadow-md);
  padding: 2rem;
}

[data-md-color-scheme='slate'] .custom-footer__inner {
  background: rgba(19, 45, 38, 0.58);
  border-color: rgba(61, 115, 101, 0.58);
}

.custom-footer__brand {
  color: var(--text);
  font-weight: 800;
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

.custom-footer__title {
  font-size: 2rem;
  line-height: 1.06;
  margin-bottom: 1rem;
}

.custom-footer__note {
  color: var(--text) !important;
  opacity: 0.86;
  font-size: 0.95rem;
  font-weight: 500;
}

.footer-col__title {
  color: var(--text);
  font-size: 1.02rem;
}

.footer-link {
  color: var(--text) !important;
  opacity: 0.82;
  font-size: 0.96rem;
  font-weight: 600;
}

.footer-link:hover {
  color: var(--primary) !important;
  opacity: 1;
}

.md-footer-meta__inner {
  border-top: 1px solid rgba(156, 207, 188, 0.45);
  padding-top: 1.1rem;
}

.md-copyright,
.md-copyright__highlight {
  color: var(--text) !important;
  opacity: 0.9;
  font-size: 0.95rem;
  font-weight: 600;
}

/* ===== FOOTER SIZE REDUCTION + COLLAPSIBLE MEDIA/CODE ===== */
.custom-footer {
  padding: 1.4rem 0.9rem 0.95rem !important;
}

.custom-footer__inner {
  border-radius: 18px;
  padding: 1.25rem 1.35rem;
  gap: 1.15rem;
}

.custom-footer__brand {
  font-size: 0.98rem;
  margin-bottom: 0.2rem;
}

.custom-footer__title {
  font-size: 1.05rem;
  line-height: 1.2;
  margin-bottom: 0.65rem;
}

.custom-footer__form {
  max-width: 620px;
  padding: 0.38rem;
}

.custom-footer__input {
  font-size: 0.92rem;
}

.custom-footer__button {
  padding: 0.5rem 0.92rem;
  font-size: 0.84rem;
}

.custom-footer__note {
  font-size: 0.88rem;
  margin-top: 0.42rem;
}

.custom-footer__right {
  gap: 0.78rem 1.15rem;
}

.footer-col {
  gap: 0.26rem;
}

.footer-col__title {
  font-size: 0.96rem;
  margin-bottom: 0.16rem;
}

.footer-link {
  font-size: 0.91rem;
  line-height: 1.35;
}

.md-footer-meta__inner {
  padding: 0.72rem 1rem 0.95rem;
}

.md-copyright,
.md-copyright__highlight {
  font-size: 0.88rem;
}

.collapsible-block {
  border: 1px solid rgba(156, 207, 188, 0.62);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.58);
  margin: 0.9rem 0;
  overflow: hidden;
}

[data-md-color-scheme='slate'] .collapsible-block {
  background: rgba(16, 38, 33, 0.62);
  border-color: rgba(61, 115, 101, 0.6);
}

.collapsible-summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid rgba(156, 207, 188, 0.45);
  background: linear-gradient(120deg, rgba(15, 118, 110, 0.09), rgba(29, 155, 132, 0.09));
}

.collapsible-summary::-webkit-details-marker {
  display: none;
}

.collapsible-summary::before {
  content: '+';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  margin-right: 0.35rem;
  font-weight: 800;
}

.collapsible-block[open] .collapsible-summary::before {
  content: '-';
}

.collapsible-body {
  padding: 0.75rem 0.85rem;
}

.collapsible-body pre,
.collapsible-body figure,
.collapsible-body img {
  margin: 0;
}

/* ===== NAV/CONTENT OVERFLOW FIX (DESKTOP) ===== */
@media (min-width: 1220px) {
  .md-main__inner {
    display: grid !important;
    grid-template-columns: 280px minmax(0, 1fr) 250px !important;
    gap: 1.2rem;
    align-items: start;
  }

  .md-sidebar--primary,
  .md-sidebar--secondary {
    display: block;
    max-width: 100%;
  }

  .md-content {
    min-width: 0;
    max-width: 100% !important;
  }

  .md-content__inner {
    width: 100%;
    max-width: 100% !important;
  }

  .hide-primary-nav:not(.hide-toc-nav) .md-main__inner {
    grid-template-columns: minmax(0, 1fr) 250px !important;
  }

  .hide-primary-nav:not(.hide-toc-nav) .md-content {
    grid-column: 1;
  }

  .hide-primary-nav:not(.hide-toc-nav) .md-sidebar--secondary {
    grid-column: 2;
  }

  .hide-toc-nav:not(.hide-primary-nav) .md-main__inner {
    grid-template-columns: 280px minmax(0, 1fr) !important;
  }

  .hide-toc-nav:not(.hide-primary-nav) .md-sidebar--primary {
    grid-column: 1;
  }

  .hide-toc-nav:not(.hide-primary-nav) .md-content {
    grid-column: 2;
  }

  .hide-primary-nav.hide-toc-nav .md-main__inner {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .hide-primary-nav.hide-toc-nav .md-content {
    grid-column: 1;
  }
}

.md-tabs {
  position: relative;
  z-index: 3;
}

.md-content__inner {
  position: relative;
  z-index: 1;
}

/* ===== TABLE RENDERING FIX ===== */
.md-typeset .md-typeset__table {
  display: block;
  width: 100%;
  overflow-x: auto;
  margin: 1rem 0;
}

.md-typeset table:not([class]) {
  width: 100% !important;
  min-width: 680px;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}

.md-typeset table:not([class]) th,
.md-typeset table:not([class]) td {
  vertical-align: top;
  white-space: normal;
  word-break: normal;
}

/* ===== TABLE WIDTH HARD FIX ===== */
.md-typeset .md-typeset__scrollwrap,
.md-typeset .md-typeset__table {
  width: 100% !important;
  max-width: 100% !important;
}

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

/* Exact 2-column sizing */
.md-typeset table:not([class]) tr > th:first-child:nth-last-child(2),
.md-typeset table:not([class]) tr > td:first-child:nth-last-child(2) {
  width: 28%;
}

.md-typeset table:not([class]) tr > th:nth-child(2):last-child,
.md-typeset table:not([class]) tr > td:nth-child(2):last-child {
  width: 72%;
}

/* Exact 4-column sizing (Figure / Description / File Name / Notes style tables) */
.md-typeset table:not([class]) tr > th:first-child:nth-last-child(4),
.md-typeset table:not([class]) tr > td:first-child:nth-last-child(4) {
  width: 16%;
}

.md-typeset table:not([class]) tr > th:nth-child(2):nth-last-child(3),
.md-typeset table:not([class]) tr > td:nth-child(2):nth-last-child(3) {
  width: 27%;
}

.md-typeset table:not([class]) tr > th:nth-child(3):nth-last-child(2),
.md-typeset table:not([class]) tr > td:nth-child(3):nth-last-child(2) {
  width: 17%;
}

.md-typeset table:not([class]) tr > th:nth-child(4):last-child,
.md-typeset table:not([class]) tr > td:nth-child(4):last-child {
  width: 40%;
}

/* ===== FOOTER FULL-WIDTH + SMALLER ===== */
.custom-footer {
  padding: 0.7rem 0.45rem 0.45rem !important;
}

.custom-footer__inner {
  max-width: min(1700px, calc(100vw - 1rem));
  width: 100%;
  border-radius: 14px;
  padding: 0.8rem 0.95rem;
  gap: 0.7rem 1rem;
  grid-template-columns: 1.25fr 1fr;
}

.custom-footer__brand {
  font-size: 0.9rem;
  margin-bottom: 0.08rem;
}

.custom-footer__title {
  font-size: 0.82rem;
  margin-bottom: 0.32rem;
  font-weight: 700;
}

.custom-footer__form {
  max-width: 760px;
  padding: 0.22rem;
}

.custom-footer__input {
  padding: 0.3rem 0.65rem !important;
  font-size: 0.82rem;
}

.custom-footer__button {
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
}

.custom-footer__note {
  margin-top: 0.22rem;
  font-size: 0.76rem;
  line-height: 1.3;
}

.custom-footer__right {
  gap: 0.35rem 0.95rem;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
}

.footer-col {
  gap: 0.1rem;
}

.footer-col__title {
  font-size: 0.78rem;
  margin-bottom: 0.06rem;
}

.footer-link {
  font-size: 0.76rem;
  line-height: 1.2;
}

.md-footer-meta__inner {
  max-width: min(1700px, calc(100vw - 1rem));
  width: 100%;
  padding: 0.4rem 0.95rem 0.55rem;
}

.md-copyright,
.md-copyright__highlight {
  font-size: 0.74rem;
}

.md-copyright__credit a {
  color: var(--primary) !important;
  font-weight: 700;
  text-decoration: none;
}

.md-copyright__credit a:hover {
  color: var(--primary-strong) !important;
  text-decoration: underline;
}

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

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

@media (max-width: 700px) {
  .custom-footer {
    padding: 0.65rem 0.35rem 0.35rem !important;
  }

  .custom-footer__inner {
    max-width: calc(100vw - 0.7rem);
    padding: 0.72rem 0.78rem;
    border-radius: 12px;
  }

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