:root {
  --fixed-header-height: 76px;
  --fixed-footer-height: 98px;
  --footer-bg-top: #edf3f9;
  --footer-bg-bottom: #dfe8f1;
  --footer-text: #33485d;
  --footer-link: #164d78;
  --footer-accent: #2b86ba;
}

body {
  padding-top: var(--fixed-header-height);
  padding-bottom: var(--fixed-footer-height);
}

body.settings-open {
  overflow: hidden;
}

main {
  min-height: calc(100vh - var(--fixed-header-height) - var(--fixed-footer-height));
}

.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  height: var(--fixed-header-height);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .18);
  background: linear-gradient(100deg, #12456f 0%, #1d6da7 58%, #2b86ba 100%);
  box-shadow: 0 8px 26px rgba(7, 36, 67, .18);
  backdrop-filter: none;
}

.nav-wrap {
  min-height: var(--fixed-header-height);
}

.brand {
  order: 1;
}

.main-nav {
  order: 2;
  margin-left: auto;
}

.header-controls {
  order: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

.nav-toggle {
  order: 4;
}

.brand,
.brand small,
.main-nav a {
  color: rgba(255, 255, 255, .88);
}

.brand strong {
  color: #fff;
}

.brand-mark {
  color: #14527f;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .14);
}

.main-nav a:hover,
.main-nav a.active {
  color: #fff;
  background: rgba(255, 255, 255, .16);
}

.nav-toggle,
.header-action {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, .08);
  font-weight: 750;
  cursor: pointer;
}

.nav-toggle:hover,
.header-action:hover,
.header-action:focus-visible {
  background: rgba(255, 255, 255, .17);
  outline: none;
}

.header-action {
  padding: .55rem .9rem;
  white-space: nowrap;
}

.language-indicator {
  min-width: 48px;
  letter-spacing: .04em;
  text-align: center;
  cursor: default;
}

.settings-dialog::backdrop {
  background: rgba(9, 24, 42, .64);
  backdrop-filter: blur(8px);
}

.settings-dialog {
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  margin: auto;
  overflow: auto;
  padding: 28px;
  border: 1px solid #cbd8e5;
  border-radius: 22px;
  color: #182b3d;
  background: #f8fbfe;
  box-shadow: 0 28px 80px rgba(3, 18, 35, .32);
}

.settings-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.settings-dialog__header h2 {
  margin: 0 0 6px;
  font-size: 1.75rem;
}

.settings-dialog__header p {
  margin: 0;
  color: #607386;
}

.settings-close {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 1px solid #c6d3df;
  border-radius: 50%;
  color: #29435b;
  background: #fff;
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
}

.settings-fields {
  display: grid;
  gap: 14px;
}

.settings-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  font-weight: 750;
}

.settings-row select {
  width: 100%;
  min-height: 48px;
  padding: .65rem .8rem;
  border: 1px solid #bdccda;
  border-radius: 12px;
  color: #20384d;
  background: #fff;
}

.settings-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #d8e2eb;
}

.settings-save,
.settings-reset {
  min-height: 44px;
  padding: .65rem 1rem;
  border-radius: 11px;
  font-weight: 800;
  cursor: pointer;
}

.settings-save {
  border: 1px solid #0b5fff;
  color: #fff;
  background: #0b5fff;
}

.settings-reset {
  border: 1px solid #bdccda;
  color: #29435b;
  background: #fff;
}

.site-footer {
  position: fixed;
  z-index: 95;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: 100%;
  height: var(--fixed-footer-height);
  margin: 0;
  padding: .48rem max(.75rem, calc((100vw - 96rem) / 2))
    calc(.38rem + env(safe-area-inset-bottom, 0px));
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: .08rem;
  border-top: 1px solid rgba(43, 134, 186, .36);
  color: var(--footer-text);
  background: linear-gradient(180deg, var(--footer-bg-top), var(--footer-bg-bottom));
  box-shadow: 0 -.7rem 1.8rem rgba(24, 55, 84, .08);
  text-align: center;
}

.site-footer::before {
  position: absolute;
  top: 0;
  left: 50%;
  width: min(14rem, 46vw);
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--footer-accent), transparent);
  content: '';
  transform: translateX(-50%);
}

.site-footer .ecosystem-footer__copyright {
  margin: 0;
  color: var(--footer-text);
  font-size: .88rem;
  letter-spacing: .015em;
  line-height: 1.25;
}

.ecosystem-footer__navigation {
  display: flex;
  max-width: calc(100% - 220px);
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 .15rem;
}

.site-footer .ecosystem-footer__link {
  position: relative;
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: .1rem .12rem;
  border-radius: 0;
  color: var(--footer-link);
  background: transparent;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
  font-size: .84rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: none;
}

.site-footer .ecosystem-footer__link + .ecosystem-footer__link {
  margin-left: 1rem;
}

.site-footer .ecosystem-footer__link + .ecosystem-footer__link::before {
  position: absolute;
  left: -.55rem;
  color: rgba(22, 77, 120, .45);
  content: '|';
}

.site-footer .ecosystem-footer__link:hover,
.site-footer .ecosystem-footer__link:focus-visible,
.site-footer .footer-pdf-button:hover,
.site-footer .footer-pdf-button:focus-visible {
  color: #0b5fff;
  background: transparent;
}

.site-footer .footer-pdf-button {
  color: #0b5fff;
  background: transparent;
  box-shadow: none;
}

.ecosystem-footer__version {
  position: absolute;
  right: max(.8rem, 2vw);
  bottom: .35rem;
  margin: 0;
  color: rgba(45, 67, 87, .68);
  font-family: 'Courier New', Courier, monospace;
  font-size: .64rem;
  letter-spacing: .025em;
  line-height: 1;
  white-space: nowrap;
}

.sidebar {
  top: calc(var(--fixed-header-height) + 24px);
}

.lesson section {
  scroll-margin-top: calc(var(--fixed-header-height) + 24px);
}

.lesson [id] {
  scroll-margin-top: calc(var(--fixed-header-height) + 24px);
}

html[data-ntt-text='large'] {
  font-size: 112.5%;
}

html[data-ntt-spacing='compact'] .section {
  padding-block: 58px;
}

html[data-ntt-spacing='compact'] .content-layout {
  padding-block: 38px 68px;
}

html[data-ntt-motion='reduced'] {
  scroll-behavior: auto;
}

html[data-ntt-motion='reduced'] *,
html[data-ntt-motion='reduced'] *::before,
html[data-ntt-motion='reduced'] *::after {
  scroll-behavior: auto !important;
  animation-duration: .01ms !important;
  transition-duration: .01ms !important;
}

html[data-ntt-theme='dark'] body {
  color: #e5edf5;
  background: #0d1825;
}

html[data-ntt-theme='dark'] .hero,
html[data-ntt-theme='dark'] .page-hero {
  background: linear-gradient(180deg, #142235, #0d1825);
}

html[data-ntt-theme='dark'] .section-muted,
html[data-ntt-theme='dark'] .feature-card,
html[data-ntt-theme='dark'] .module-card,
html[data-ntt-theme='dark'] .question-card,
html[data-ntt-theme='dark'] .sidebar,
html[data-ntt-theme='dark'] .table-wrap {
  color: #e5edf5;
  border-color: #31445a;
  background: #162437;
}

html[data-ntt-theme='dark'] .settings-dialog {
  color: #e5edf5;
  border-color: #40546a;
  background: #152438;
}

html[data-ntt-theme='dark'] .settings-dialog__header p {
  color: #aab9c7;
}

html[data-ntt-theme='dark'] .settings-row select,
html[data-ntt-theme='dark'] .settings-close,
html[data-ntt-theme='dark'] .settings-reset {
  color: #e5edf5;
  border-color: #52677c;
  background: #22354a;
}

@media (prefers-color-scheme: dark) {
  html[data-ntt-theme='system'] body {
    color: #e5edf5;
    background: #0d1825;
  }

  html[data-ntt-theme='system'] .hero,
  html[data-ntt-theme='system'] .page-hero {
    background: linear-gradient(180deg, #142235, #0d1825);
  }
}

@media (max-width: 1060px) {
  .main-nav a {
    padding-inline: .62rem;
  }

  .header-action {
    padding-inline: .7rem;
  }
}

@media (max-width: 840px) {
  :root {
    --fixed-header-height: 68px;
    --fixed-footer-height: 126px;
  }

  .brand > span:last-child {
    display: none;
  }

  .main-nav {
    position: absolute;
    top: calc(var(--fixed-header-height) - 2px);
    left: 16px;
    right: 16px;
    order: 5;
    margin-left: 0;
    color: #152033;
    background: #fff;
  }

  .main-nav a {
    color: #5d6a7e;
  }

  .main-nav a:hover,
  .main-nav a.active {
    color: #0b5fff;
    background: #eef3ff;
  }

  .header-controls {
    margin-left: auto;
  }

  .settings-button {
    padding-inline: .72rem;
  }

  .site-footer {
    padding: .4rem .625rem calc(.35rem + env(safe-area-inset-bottom, 0px));
  }

  .ecosystem-footer__navigation {
    max-width: 100%;
    column-gap: .4rem;
  }

  .site-footer .ecosystem-footer__link + .ecosystem-footer__link {
    margin-left: 0;
  }

  .site-footer .ecosystem-footer__link + .ecosystem-footer__link::before {
    display: none;
  }

  .ecosystem-footer__version {
    position: static;
    margin-top: .1rem;
  }
}

@media (max-width: 560px) {
  :root {
    --fixed-footer-height: 146px;
  }

  .header-controls {
    gap: 5px;
  }

  .header-action {
    min-height: 38px;
    padding: .45rem .58rem;
    font-size: .76rem;
  }

  .language-indicator {
    min-width: 44px;
  }

  .settings-dialog {
    padding: 20px;
  }

  .settings-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .settings-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .settings-save,
  .settings-reset {
    width: 100%;
  }

  .ecosystem-footer__navigation {
    max-width: 360px;
  }

  .site-footer .ecosystem-footer__link {
    min-height: 26px;
    padding: .04rem .1rem;
    font-size: .75rem;
  }
}
