:root {
  --ink: #1e2939;
  --muted: #4a5565;
  --faint: #6a7282;
  --paper: #ffffff;
  --paper-soft: #fafafa;
  --line: #e5e7eb;
  --primary: #0f62fe;
  --primary-ink: #002d9c;
  --code: #f6339a;
  --dot: #0f62fe;
  --font-ui: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-body: "PT Serif", Georgia, "Times New Roman", serif;
  --font-display: "Saira Extra Condensed", "Arial Narrow", sans-serif;
  color-scheme: light;
}

html[data-theme="dark"] {
  --ink: #ffffff;
  --muted: #d1d5dc;
  --faint: #99a1af;
  --paper: #0e121a;
  --paper-soft: #101828;
  --line: #1e2939;
  --primary: #78a9ff;
  --primary-ink: #78a9ff;
  --code: #f6339a;
  --dot: #00c758;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

a {
  color: var(--primary);
  text-underline-offset: 0.15em;
}

a:hover,
a:focus-visible {
  opacity: 0.7;
  outline: none;
}

.shell {
  width: min(100% - 2rem, 64rem);
  margin: 0 auto;
  padding:
    clamp(2rem, 8vh, 5rem)
    0
    max(5rem, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 12.5rem minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 4.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.35rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  line-height: 1;
}

html[data-theme="dark"] .mark {
  background: var(--dot);
  color: #0e121a;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0;
  color: var(--faint);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 160ms ease, opacity 160ms ease;
}

.nav a:hover,
.nav a:focus-visible {
  color: var(--ink);
  opacity: 1;
}

.nav a[aria-current="page"] {
  color: var(--primary);
}

.nav-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--dot);
  transform: scale(0);
  transition: transform 160ms ease;
  flex: 0 0 auto;
}

.nav a[aria-current="page"] .nav-dot {
  transform: scale(1.25);
}

.theme-toggle {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  margin-top: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  color: var(--ink);
  border-color: var(--faint);
  outline: none;
}

.theme-icon {
  display: none;
  line-height: 0;
}

html:not([data-theme="dark"]) .theme-icon-moon,
html[data-theme="dark"] .theme-icon-sun {
  display: block;
}

.content {
  min-width: 0;
  max-width: 40rem;
}

.mast {
  margin: 0 0 1.75rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.65rem, 4vw, 2rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--ink);
}

.prose p {
  margin: 0 0 1.2rem;
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--muted);
}

html[data-theme="dark"] .prose p {
  color: #d1d5dc;
}

.prose p strong {
  color: var(--ink);
  font-weight: 600;
}

.prose h2 {
  margin: 2.4rem 0 0.9rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.meta {
  margin: -0.85rem 0 1.6rem;
  font-size: 0.875rem;
  color: var(--faint);
}

.prose .meta-inline {
  margin: -0.45rem 0 0.85rem;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--faint);
}

.foot {
  margin-top: 2.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  font-size: 0.875rem;
  color: var(--faint);
}

.social {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.social a {
  color: var(--faint);
  text-decoration: none;
  display: inline-flex;
}

.social a:hover,
.social a:focus-visible {
  color: var(--ink);
  opacity: 1;
}

.social svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    width: min(100% - 1.75rem, 40rem);
    padding-top: max(1.5rem, env(safe-area-inset-top));
  }

  .sidebar {
    position: static;
    gap: 1rem;
  }

  .nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 1rem;
    padding-bottom: 0.35rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    mask-image: linear-gradient(90deg, #000 88%, transparent);
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav a {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .theme-toggle {
    position: absolute;
    top: max(1.35rem, env(safe-area-inset-top));
    right: max(1rem, env(safe-area-inset-right));
    margin-top: 0;
  }

  .shell {
    position: relative;
  }

  .prose p {
    font-size: 1.05rem;
  }
}
