:root {
  color-scheme: dark;
  --learn-system-font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

body {
  margin: 0;
  padding-top: 3.6rem;
  background: #16143a;
  color: #f7f1e6;
  font-family: var(--learn-system-font);
  font-size: 16px;
  line-height: 1.5;
}

/* Reading size: 18px on mobile, 19px on desktop, line-height 1.7. */
.prose {
  font-size: 18px;
  line-height: 1.7;
}

.prose h1 {
  font-size: 1.75em;
  line-height: 1.2;
  margin: 0.4em 0 0.6em;
}

.prose h2 {
  font-size: 1.35em;
  margin: 1.8em 0 0.6em;
}

.prose h3 {
  font-size: 1.15em;
  margin: 1.5em 0 0.5em;
}

.prose p,
.prose ul {
  margin: 0 0 1em;
}

.prose li {
  margin: 0.35em 0;
}

@media (min-width: 881px) {
  .prose {
    font-size: 19px;
  }

  .prose h1 {
    font-size: 2em;
  }

  .prose h2 {
    font-size: 1.45em;
  }
}

.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: #16143a;
  border-bottom: 1px solid rgba(244, 239, 228, 0.18);
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(14rem, 18rem) minmax(0, 45rem);
  column-gap: 1.5rem;
  justify-content: center;
  align-items: center;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
}

.top-main {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  min-width: 0;
}

.brand {
  color: #f5c542;
  font-family: Fredoka, sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}

.site-nav a,
.nav-pending,
.lang-switch {
  color: #f7f1e6;
  font-family: var(--learn-system-font);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a:focus-visible,
.lang-switch:hover,
.lang-switch:focus-visible {
  color: #f5c542;
}

.nav-sep {
  color: rgba(247, 241, 230, 0.4);
  padding: 0 0.45rem;
}

.nav-pending {
  cursor: default;
}

.drop {
  position: relative;
}

.drop summary {
  color: #f7f1e6;
  font-family: var(--learn-system-font);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  list-style: none;
}

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

.drop summary::after {
  content: " ▾";
  font-size: 0.75em;
}

.drop-panel {
  display: none;
  position: absolute;
  top: calc(100% + 0.55rem);
  left: 0;
  min-width: 14rem;
  max-width: min(18rem, 80vw);
  background: #201c4a;
  border: 1px solid rgba(244, 239, 228, 0.28);
  border-radius: 12px;
  padding: 0.35rem 0;
  z-index: 40;
}

.drop-panel a {
  display: block;
  padding: 0.45rem 0.85rem;
  color: #f7f1e6;
  white-space: normal;
}

.drop[open] > .drop-panel {
  display: block;
}

@media (hover: hover) and (pointer: fine) {
  .site-nav:hover .drop:not(:hover):not(:focus-within) > .drop-panel {
    display: none;
  }

  .drop:hover > .drop-panel,
  .drop:focus-within > .drop-panel {
    display: block;
  }
}

.lang-switch {
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
}

.lang-switch-narrow {
  display: none;
}

main {
  position: relative;
  z-index: 0;
  margin: 0;
  padding: 0;
}

.prose {
  min-width: 0;
  max-width: 68ch;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.content-divider {
  width: 100%;
  margin: 1.75rem 0 0.55rem;
  border: 0;
  border-top: 1px solid rgba(244, 239, 228, 0.28);
}

@media (min-width: 881px) {
  .learn-hub .prose {
    padding-top: 0.4rem;
  }

  .learn-hub .prose > h1:first-child {
    margin-top: 0;
  }
}

.reading-grid {
  display: grid;
  grid-template-columns: minmax(14rem, 18rem) minmax(0, 45rem);
  gap: 1.5rem;
  align-items: start;
  justify-content: center;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 3rem;
}

.reading-grid .prose {
  margin: 0;
  padding: 1rem 0 3rem;
}

.reading-sidebar {
  position: sticky;
  top: 4.25rem;
  max-height: calc(100vh - 5.25rem);
  overflow: auto;
}

.toc {
  color: #f7f1e6;
  font-size: 1rem;
  line-height: 1.5;
}

.toc summary {
  cursor: pointer;
  font-family: var(--learn-system-font);
  font-weight: 700;
}

.toc ol {
  margin: 0.75rem 0 0;
  padding-left: 1.15rem;
}

.toc li {
  margin: 0.35rem 0;
}

.toc a {
  color: #f7f1e6;
  text-decoration: none;
}

.toc a:hover,
.toc a:focus-visible {
  color: #f5c542;
}

h2 {
  scroll-margin-top: 4.5rem;
}

@media (max-width: 880px) {
  :root {
    --learn-mobile-header-height: 3.6rem;
  }

  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .top {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: 0 !important;
    bottom: auto !important;
    width: auto !important;
    z-index: 1000;
    transform: none !important;
    will-change: auto;
    isolation: auto;
  }

  .top-bar {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    box-sizing: border-box;
    padding: 0.6rem 0.5rem;
  }

  body {
    padding-top: 0;
  }

  main {
    position: fixed;
    top: var(--learn-mobile-header-height);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 0;
    overflow-x: hidden;
    overflow-y: auto;
    clip-path: inset(0);
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  .top,
  .top-bar,
  .top-main {
    max-width: 100%;
  }

  .top-main {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr) max-content;
    align-items: center;
    gap: 0.45rem 0.3rem;
    width: 100%;
  }

  .nav-sep {
    display: inline;
    padding: 0 0.18rem;
  }

  .site-nav {
    flex: none;
    flex-wrap: nowrap;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
  }

  .drop-panel {
    position: fixed;
    top: var(--learn-mobile-header-height);
    right: 1rem;
    left: 1rem;
    min-width: 0;
    max-width: none;
  }

  .lang-switch {
    margin-left: 0;
  }

  .lang-switch-wide {
    display: none;
  }

  .lang-switch-narrow {
    display: inline;
  }

  .site-nav,
  .lang-switch,
  .nav-pending,
  .drop summary {
    font-size: 0.78rem;
  }

  .reading-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 0.6rem 1rem 2rem;
  }

  .prose {
    padding: 0.75rem 1rem 3rem;
  }

  .reading-grid .prose {
    padding: 0.5rem 0 3rem;
  }

  .reading-sidebar {
    position: static;
    max-height: none;
  }

  .toc {
    border: 1px solid #f4efe4;
    border-radius: 12px;
    padding: 0.75rem 1rem;
  }
}

h1,
h2,
h3 {
  font-family: var(--learn-system-font);
  line-height: 1.25;
}

a {
  color: #f5c542;
}

pre {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.8em;
  line-height: 1.45;
  white-space: pre;
  overflow-x: auto;
  background: #100e24;
  color: #f7f1e6;
  padding: 1rem;
  border-radius: 12px;
}

blockquote {
  margin-left: 0;
  padding-left: 1rem;
  border-left: 3px solid #f5c542;
}

table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.92em;
  line-height: 1.5;
  margin: 0 0 1.2em;
}

th,
td {
  border: 1px solid #f4efe4;
  padding: 0.55rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

.learn-ad {
  margin-top: 48px;
}

.ad-label {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
