*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--sloth-bg-0);
  color: var(--sloth-fg-1);
  font: 16px/1.6 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, video, svg { display: block; max-width: 100%; }
a { color: var(--sloth-accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--sloth-accent); outline-offset: 2px; }
::selection { background: var(--sloth-accent-soft); }
button { font: inherit; color: inherit; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 32px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }

/* Navigation */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--sloth-bg-0) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-base) var(--ease);
}
.nav.is-stuck { border-bottom-color: var(--sloth-line); }
.nav-in { display: flex; align-items: center; gap: 32px; height: 72px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--sloth-fg-0); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.nav-links { display: flex; align-items: center; gap: 28px; margin-right: auto; }
.nav-links a { color: var(--sloth-fg-2); font-size: 15px; font-weight: 500; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--sloth-fg-0); text-decoration: none; }
.nav-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#authNav { display: flex; align-items: center; gap: 8px; min-height: 40px; }
@media (max-width: 860px) {
  .nav-in { flex-wrap: wrap; height: auto; gap: 0 16px; padding-top: 22px; }
  .nav-links { order: 3; flex: 1 0 100%; gap: 22px; margin: 0 -20px; padding: 8px 20px 10px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .nav-links::-webkit-scrollbar { display: none; }
  html { scroll-padding-top: 120px; }
}
@media (max-width: 480px) {
  .wrap { padding: 0 20px; }
  #authNav [data-auth="signin"] { display: none; }
}

.theme-toggle {
  width: 40px; height: 40px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--sloth-fg-2); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.theme-toggle:hover { background: var(--sloth-bg-1); color: var(--sloth-fg-0); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border: 0; border-radius: var(--radius-md);
  font: 600 15px/1 var(--font-ui); white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: default; transform: none; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--sloth-accent); color: var(--sloth-on-accent); }
.btn-primary:hover { background: var(--sloth-accent-hover); color: var(--sloth-on-accent); }
.btn-quiet { background: transparent; color: var(--sloth-fg-1); box-shadow: inset 0 0 0 1px var(--sloth-line-strong); }
.btn-quiet:hover { background: var(--sloth-bg-1); color: var(--sloth-fg-0); }
.btn-text { height: auto; padding: 0; background: none; color: var(--sloth-accent-text); }
.btn-text:hover { text-decoration: underline; text-underline-offset: 3px; }
.btn svg { width: 16px; height: 16px; }

/* Segmented control, as in the panel */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-md); background: var(--sloth-bg-1); }
.seg button { height: 36px; padding: 0 16px; border: 0; border-radius: 8px; background: none; cursor: pointer; color: var(--sloth-fg-2); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--sloth-bg-0); color: var(--sloth-fg-0); font-weight: 600; box-shadow: 0 0 0 1px var(--sloth-line); }

/* Type */
.display, h1, h2 { font-family: var(--font-read); font-weight: 500; color: var(--sloth-fg-0); letter-spacing: -0.015em; text-wrap: balance; }
h1 { margin: 0; font-size: clamp(44px, 6.6vw, 88px); line-height: 1.02; }
h2 { margin: 0; font-size: clamp(34px, 4.2vw, 54px); line-height: 1.06; }
h3 { margin: 0; font-size: 17px; line-height: 1.3; font-weight: 600; color: var(--sloth-fg-0); }
.lead { margin: 0; font-size: 19px; line-height: 1.55; color: var(--sloth-fg-2); max-width: 36em; text-wrap: pretty; }
.meta { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--sloth-fg-3); }

/* Time rail: the page is read like a summary, one timestamp per chapter */
.chapters { position: relative; }
.chapters::before {
  content: ''; position: absolute; top: 0; bottom: 0;
  left: calc(max(32px, 50% - var(--wrap) / 2 + 32px) + var(--gutter) - 20px);
  width: 1px; background: var(--sloth-line);
}
.rail-track {
  position: absolute; top: 0; bottom: 0; width: 9px;
  left: calc(max(32px, 50% - var(--wrap) / 2 + 32px) + var(--gutter) - 24px);
  pointer-events: none;
}
.rail-now {
  position: sticky; top: 50vh; width: 9px; height: 9px; border-radius: 50%;
  background: var(--sloth-accent); box-shadow: 0 0 0 4px var(--sloth-bg-0);
}
.chapter { display: grid; grid-template-columns: var(--gutter) minmax(0, 1fr); padding-top: 128px; }
.chapter-ts {
  position: relative; align-self: start; padding-right: 32px; text-align: right;
  font: 500 13px/24px var(--font-ui); font-variant-numeric: tabular-nums; color: var(--sloth-fg-3);
}
.chapter-ts:hover { color: var(--sloth-accent-text); }
.chapter-ts::after {
  content: ''; position: absolute; top: 12px; right: 16px; width: 9px; height: 1px; background: var(--sloth-line-strong);
}
.chapter.is-now .chapter-ts { color: var(--sloth-accent-text); font-weight: 600; }
/* A small leaf grows from the rail at each chapter mark */
.chapter-ts::before {
  content: ''; position: absolute; top: 0; right: 7px; width: 12px; height: 16px;
  background: var(--sloth-line-strong); opacity: 0.55;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 16'%3E%3Cpath d='M1 15C1 7 5 2 11 1c0 7-4 13-10 14z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 16'%3E%3Cpath d='M1 15C1 7 5 2 11 1c0 7-4 13-10 14z'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: background-color var(--dur-base) var(--ease), opacity var(--dur-base) var(--ease);
}
.chapter.is-now .chapter-ts::before { background: var(--sloth-accent); opacity: 1; }
.chapter-ts .ts-name { display: none; }
@media (max-width: 900px) {
  .chapters::before, .rail-track { display: none; }
  .chapter { grid-template-columns: minmax(0, 1fr); padding-top: 96px; }
  .chapter-ts { text-align: left; padding: 0 0 12px; }
  .chapter-ts::after, .chapter-ts::before { display: none; }
  .chapter-ts .ts-name { display: inline; }
  .chapter-ts .ts-name::before { content: ' · '; }
}

/* Footer */
.footer { margin-top: 0; border-top: 1px solid var(--sloth-line); }
.footer-in { display: grid; grid-template-columns: var(--gutter) 1fr auto; gap: 32px 0; padding-block: 48px 40px; }
.footer-end { font: 500 13px/24px var(--font-ui); font-variant-numeric: tabular-nums; color: var(--sloth-fg-3); text-align: right; padding-right: 32px; }
.footer-brand { display: flex; flex-direction: column; gap: 10px; max-width: 320px; }
.footer-brand p { margin: 0; color: var(--sloth-fg-3); font-size: 14px; }
.footer-cols { display: flex; gap: 64px; flex-wrap: wrap; margin-left: 32px; }
.footer-col { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.footer-col b { font-weight: 600; color: var(--sloth-fg-0); font-size: 13px; margin-bottom: 4px; }
.footer-col a { color: var(--sloth-fg-2); }
.footer-col a:hover { color: var(--sloth-fg-0); }
.footer-legal { border-top: 1px solid var(--sloth-line); padding: 20px 0 28px; font-size: 13px; color: var(--sloth-fg-3); }
@media (max-width: 900px) {
  .footer-in { grid-template-columns: 1fr; }
  .footer-end { display: none; }
  .footer-cols { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
