:root {
  --bg: #fbfaf8;
  --ink: #16150f;
  --ink-soft: #2c2a22;
  --muted: #a49d8e;
  --muted-2: #7b7466;
  --line: #e6e1d6;
  --solid: #16150f;
  --solid-ink: #fbfaf8;
  --fill: #efe9dd;
  --sidebar-w: 232px;
  --content-w: 600px;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  --bg: #121210;
  --ink: #f3f1e9;
  --ink-soft: #dcd9cd;
  --muted: #5a564a;
  --muted-2: #837c6a;
  --line: #262319;
  --solid: #f3f1e9;
  --solid-ink: #121210;
  --fill: #1d1b14;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 64px 22px 22px;
  z-index: 10;
}

.brand {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.3px;
  text-decoration: none;
  color: var(--ink);
}

.nav-toggle {
  display: none;
  width: 40px;
  height: 34px;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.nav-toggle__lines,
.nav-toggle__lines::before,
.nav-toggle__lines::after {
  content: "";
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle__lines { position: relative; }
.nav-toggle__lines::before { position: absolute; top: -7px; left: 0; }
.nav-toggle__lines::after { position: absolute; top: 7px; left: 0; }
.sidebar.is-open .nav-toggle__lines { background: transparent; }
.sidebar.is-open .nav-toggle__lines::before { transform: translateY(7px) rotate(45deg); }
.sidebar.is-open .nav-toggle__lines::after { transform: translateY(-7px) rotate(-45deg); }

.nav {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav__item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 10px;
  border-radius: 7px;
  text-decoration: none;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.1px;
  color: var(--ink);
  transition: background 0.15s ease;
}
.nav__item:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.nav__item.is-active { background: var(--fill); }
.nav__num {
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  min-width: 20px;
}

.sidebar__footer { margin-top: auto; }
.mode {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  border-radius: 999px;
  padding: 6px 12px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 400;
  color: var(--ink);
  transition: background 0.15s ease;
}
.mode:hover { background: var(--fill); }
.mode__icon { font-size: 12px; line-height: 1; }

/* Main */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.rule {
  border: 0;
  border-top: 1px solid var(--line);
  width: var(--content-w);
  max-width: calc(100% - 44px);
  margin: 0 auto;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 68px 24px 36px;
}
.hero__mark {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--ink);
}

html { scroll-behavior: smooth; }
.section { padding: 84px 24px; scroll-margin-top: 24px; }

.section__num {
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 24px;
}
.section__num--center { text-align: center; }

.section__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: 0.1px;
  margin: 0;
  color: var(--ink);
}
.section__title--center { text-align: center; width: var(--content-w); max-width: 100%; margin-left: auto; margin-right: auto; }

.section--intro { padding-top: 20px; padding-bottom: 60px; }
.prose {
  width: var(--content-w);
  max-width: 100%;
  margin: 56px auto 0;
}
.prose p {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 24px;
}
.prose p:last-child { margin-bottom: 0; }
.prose__fade {
  background: linear-gradient(
    to bottom,
    var(--ink-soft) 0%,
    var(--ink-soft) 18%,
    var(--muted) 78%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.section:not(.section--intro) { min-height: 34vh; }
.section:not(.section--intro) .section__num,
.section:not(.section--intro) .section__body {
  width: var(--content-w);
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}
.section:not(.section--intro) .section__num {
  margin-bottom: 22px;
  text-align: center;
}
.section:not(.section--intro) .actions { justify-content: center; }

.section__lead {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 26px;
}
.section__lead a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color 0.15s ease;
}
.section__lead a:hover { color: var(--muted-2); }

.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  border-radius: 7px;
  padding: 10px 18px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.btn__icon { font-size: 13px; line-height: 1; }
.btn--solid { background: var(--solid); color: var(--solid-ink); }
.btn--solid:hover { opacity: 0.86; }

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 28px 32px;
  margin-top: auto;
}
.footer__left, .footer__right {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted-2);
}
.footer a { text-decoration: none; color: var(--muted-2); }
.footer a:hover { color: var(--ink); }
.footer__brand { color: var(--muted-2); }

/* Responsive */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    z-index: 20;
  }
  .brand { order: 1; }
  .nav-toggle { display: inline-flex; order: 2; margin-left: auto; }

  .nav {
    order: 3;
    flex-basis: 100%;
    margin: 4px 0 0;
    padding: 8px 0 2px;
    border-top: 1px solid var(--line);
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    display: none;
  }
  .sidebar.is-open .nav { display: flex; }
  .nav__item { padding: 11px 8px; }

  .sidebar__footer {
    order: 4;
    flex-basis: 100%;
    display: none;
    margin: 0;
    padding-bottom: 6px;
  }
  .sidebar.is-open .sidebar__footer { display: block; }

  .main { margin-left: 0; }

  .hero { padding: 48px 24px 18px; }
  .hero__mark { font-size: 18px; }
  .section { padding: 52px 22px; }
  .section--intro { padding-top: 16px; padding-bottom: 56px; }
  .prose { margin-top: 36px; }
  .section__title { font-size: 25px; }

  .section:not(.section--intro) { min-height: auto; }
  .section:not(.section--intro) .section__num { margin-bottom: 16px; }
}

@media (max-width: 520px) {
  .section__lead br { display: none; }
  .section__title br { display: none; }
}
