@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&family=Source+Serif+4:opsz,wght@8..60,500;8..60,600;8..60,700&display=swap");

:root {
  --ink: #17211c;
  --ink-soft: #45534b;
  --muted: #6d7a73;
  --paper: #fbfcf8;
  --surface: #ffffff;
  --line: #d9ddd4;
  --nav: #111b16;
  --nav-soft: #1a2921;
  --nav-text: #e8eee9;
  --nav-muted: #9caaa1;
  --accent: #9bd315;
  --accent-strong: #6f9f00;
  --link: #176b54;
  --sidebar-width: 318px;
  --shadow: 0 18px 50px rgba(24, 35, 29, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(90deg, rgba(23, 33, 28, 0.025) 1px, transparent 1px), var(--paper);
  background-size: 72px 72px;
  font-family: "Manrope", sans-serif;
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

.mobile-header,
.nav-backdrop {
  display: none;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  color: var(--nav-text);
  background: linear-gradient(145deg, rgba(155, 211, 21, 0.08), transparent 34%), var(--nav);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 26px 20px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
  padding: 0 8px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand img {
  width: 34px;
  height: 48px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand div {
  min-width: 0;
}

.kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 0;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: var(--nav-muted);
  font-size: 11px;
}

.controls {
  padding: 22px 8px 14px;
}

.controls label,
#topic-list li.section-label {
  color: var(--nav-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.controls label {
  display: block;
  margin-bottom: 7px;
}

.controls select {
  width: 100%;
  min-height: 40px;
  color: var(--nav-text);
  background: var(--nav-soft);
  border: 1px solid #35463c;
  border-radius: 4px;
  padding: 8px 11px;
  cursor: pointer;
}

.controls select:focus-visible,
#topic-list button:focus-visible,
.nav-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sidebar nav {
  flex: 1;
}

#topic-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#topic-list li {
  margin: 2px 0;
}

#topic-list li.section-label {
  margin: 20px 0 7px;
  padding: 0 9px;
}

#topic-list button {
  position: relative;
  width: 100%;
  min-height: 38px;
  color: #cad4ce;
  background: transparent;
  border: 0;
  border-radius: 4px;
  padding: 9px 12px 9px 22px;
  text-align: left;
  font-size: 13px;
  line-height: 1.45;
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease;
}

#topic-list button::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #52625a;
  transform: translateY(-50%);
  transition: background-color 150ms ease, transform 150ms ease;
}

#topic-list button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.055);
}

#topic-list button.active {
  color: #fff;
  background: var(--nav-soft);
  font-weight: 600;
}

#topic-list button.active::before {
  background: var(--accent);
  transform: translateY(-50%) scale(1.5);
}

.sidebar-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 24px;
  padding: 16px 8px 2px;
  color: #708078;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.content {
  min-width: 0;
  padding: clamp(42px, 6vw, 86px) clamp(30px, 8vw, 128px) 100px;
}

.content-header,
#topic-content {
  width: min(100%, 960px);
  margin-inline: auto;
}

.content-header {
  margin-bottom: 40px;
}

.section-context {
  margin: 0 0 12px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.content-header h2 {
  max-width: 850px;
  margin: 0;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: clamp(34px, 5vw, 58px);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: 0;
}

.header-rule {
  width: 72px;
  height: 4px;
  margin-top: 26px;
  background: var(--accent);
}

#topic-content {
  color: var(--ink-soft);
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 18px;
  line-height: 1.72;
}

#topic-content > * {
  max-width: 760px;
}

#topic-content h1,
#topic-content h2,
#topic-content h3 {
  color: var(--ink);
  font-family: "Manrope", sans-serif;
  letter-spacing: 0;
}

#topic-content h1 {
  margin: 70px 0 20px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
  font-size: 29px;
  font-weight: 700;
  line-height: 1.22;
}

#topic-content h1:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

#topic-content h2 {
  margin: 44px 0 14px;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.3;
}

#topic-content h3 {
  margin: 30px 0 10px;
  color: #2e4237;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

#topic-content p {
  margin: 0 0 18px;
  white-space: pre-line;
}

#topic-content ul {
  margin: 18px 0 28px;
  padding: 0;
  list-style: none;
}

#topic-content li {
  position: relative;
  margin: 10px 0;
  padding-left: 24px;
}

#topic-content li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.72em;
  width: 8px;
  height: 2px;
  background: var(--accent-strong);
}

#topic-content pre {
  max-width: 900px;
  margin: 28px 0;
  overflow-x: auto;
  color: #e1ece5;
  background: var(--nav);
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  padding: 20px 22px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}

#topic-content img {
  display: block;
  width: min(100%, 920px);
  max-height: 680px;
  object-fit: contain;
  object-position: left center;
  margin: 30px 0 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

#topic-content a {
  color: var(--link);
  font-family: "Manrope", sans-serif;
  font-size: 15px;
  font-weight: 700;
  text-decoration-color: rgba(23, 107, 84, 0.35);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

#topic-content a:hover {
  color: #0d4939;
  text-decoration-color: currentColor;
}

@media (max-width: 900px) {
  body.nav-open {
    overflow: hidden;
  }

  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    color: var(--nav-text);
    background: var(--nav);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 18px;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 18px;
    font-weight: 600;
  }

  .mobile-brand img {
    width: 20px;
    height: 32px;
    object-fit: contain;
  }

  .nav-toggle {
    display: grid;
    width: 42px;
    height: 42px;
    place-content: center;
    gap: 5px;
    color: inherit;
    background: transparent;
    border: 1px solid #405047;
    border-radius: 4px;
    cursor: pointer;
  }

  .nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    transition: transform 150ms ease, opacity 150ms ease;
  }

  .nav-open .nav-toggle span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .nav-open .nav-toggle span:nth-child(2) {
    opacity: 0;
  }

  .nav-open .nav-toggle span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  .nav-backdrop {
    position: fixed;
    inset: 64px 0 0;
    z-index: 20;
    width: 100%;
    height: calc(100vh - 64px);
    background: rgba(7, 13, 10, 0.58);
    border: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .nav-open .nav-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 64px;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(88vw, var(--sidebar-width));
    height: calc(100vh - 64px);
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

  .nav-open .sidebar {
    transform: translateX(0);
  }

  .sidebar .brand {
    display: none;
  }

  .controls {
    padding-top: 4px;
  }

  .content {
    padding: 42px 22px 72px;
  }

  .content-header {
    margin-bottom: 34px;
  }

  .content-header h2 {
    font-size: clamp(32px, 9vw, 46px);
  }

  #topic-content {
    font-size: 17px;
    line-height: 1.68;
  }

  #topic-content h1 {
    margin-top: 54px;
    font-size: 25px;
  }
}

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