:root {
  --lf-paper: #f7f9f6;
  --lf-surface: #ffffff;
  --lf-surface-muted: #edf3ef;
  --lf-ink: #18211f;
  --lf-muted: #59645f;
  --lf-line: #d7ded8;
  --lf-teal: #176d65;
  --lf-rust: #a94732;
  --lf-blue: #355f9a;
  --lf-shadow: 0 18px 48px rgba(24, 33, 31, 0.08);
  --lf-shell: 70rem;
  --lf-gutter: clamp(1.25rem, 3vw, 2.5rem);
  --lf-radius: 8px;
}

body {
  background: var(--lf-paper);
  color: var(--lf-ink);
}

/* Keep the bespoke home page and document routes on one visual token set. */
body:has(.ree-home) {
  --ree-paper: var(--lf-paper);
  --ree-surface: var(--lf-surface);
  --ree-surface-soft: var(--lf-surface-muted);
  --ree-ink: var(--lf-ink);
  --ree-muted: var(--lf-muted);
  --ree-line: var(--lf-line);
  --ree-teal: var(--lf-teal);
  --ree-rust: var(--lf-rust);
  --ree-blue: var(--lf-blue);
  --ree-shadow: var(--lf-shadow);
}

.side-bar {
  background: #fbfcfa;
  border-right: 1px solid var(--lf-line);
}

.site-header {
  background: #fbfcfa;
  border-bottom: 1px solid var(--lf-line);
}

.main {
  background: var(--lf-paper);
}

.main-content-wrap {
  background: var(--lf-surface);
}

/* Canonical public-document grid: one centred shell with fluid gutters. */
.main-content {
  width: min(100%, calc(var(--lf-shell) + (2 * var(--lf-gutter))));
  max-width: none;
  margin-inline: auto;
  padding-inline: var(--lf-gutter);
  color: var(--lf-ink);
}

.main-content h1,
.main-content h2,
.main-content h3 {
  color: var(--lf-ink);
}

.main-content h1 {
  margin-bottom: 1.15rem;
  letter-spacing: 0;
}

.main-content h2 {
  margin-top: 2.6rem;
  border-bottom: 1px solid var(--lf-line);
  padding-bottom: 0.5rem;
}

.main-content a {
  color: var(--lf-teal);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.main-content a:hover {
  color: var(--lf-rust);
}

.main-content blockquote {
  border-left-color: var(--lf-rust);
  background: var(--lf-surface-muted);
  color: var(--lf-ink);
  padding: 1rem 1.25rem;
}

.main-content table,
.main-content th,
.main-content td {
  border-color: var(--lf-line);
}

.main-content th {
  background: var(--lf-surface-muted);
}

.ree-public-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  width: min(100%, calc(var(--lf-shell) + (2 * var(--lf-gutter))));
  margin-inline: auto;
  padding-inline: var(--lf-gutter);
  min-height: 2.75rem;
  color: var(--lf-muted);
  font-size: 0.78rem;
  letter-spacing: 0;
}

.ree-public-header a {
  color: inherit;
  text-decoration: none;
}

.ree-public-header a:hover {
  color: var(--lf-teal);
}

.ree-public-brand {
  color: var(--lf-ink) !important;
  font-weight: 700;
}

.ree-public-section {
  font-weight: 600;
}

.ree-public-status-link {
  margin-left: auto;
  color: var(--lf-teal) !important;
  font-weight: 600;
}

/* Shared top-of-page treatment for curated public routes. */
.ree-doc-intro {
  margin: 0 0 2.4rem;
  padding: 1.5rem 1.7rem;
  border-left: 4px solid var(--lf-teal);
  border-radius: 0 var(--lf-radius) var(--lf-radius) 0;
  background: var(--lf-surface-muted);
}

.ree-eyebrow,
.ree-project-status {
  margin: 0 0 0.55rem;
  color: var(--lf-rust);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ree-doc-lead {
  margin: 0;
  max-width: 52rem;
  color: var(--lf-ink);
  font-size: 1.2rem;
  line-height: 1.65;
}

.ree-doc-meta {
  margin: 0.9rem 0 0;
  color: var(--lf-muted);
  font-size: 0.9rem;
}

.ree-architecture-figure {
  margin: 2rem 0 2.5rem;
  border: 1px solid var(--lf-line);
  border-radius: var(--lf-radius);
  overflow: hidden;
  background: #f3f6f3;
}

.ree-architecture-figure img {
  display: block;
  width: 100%;
  height: auto;
  padding: 1rem;
}

.ree-architecture-figure figcaption {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--lf-line);
  color: var(--lf-muted);
  font-size: 0.86rem;
}

.ree-project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.ree-visual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 2rem 0 2.5rem;
}

.ree-visual-card {
  overflow: hidden;
  border: 1px solid var(--lf-line);
  border-radius: var(--lf-radius);
  background: var(--lf-surface);
  box-shadow: 0 8px 24px rgba(24, 33, 31, 0.05);
}

.ree-visual-image {
  display: block;
  background: #13211f;
}

.ree-visual-image img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.ree-visual-card-body {
  padding: 1.35rem;
}

.ree-visual-card-body h2 {
  margin: 0 0 0.7rem;
  padding: 0;
  border: 0;
  font-size: 1.32rem;
}

.ree-inline-action {
  display: inline-flex;
  margin-top: 0.5rem;
  font-weight: 700;
}

.ree-research-disclosure {
  max-width: 51rem;
  margin: 1.3rem 0 1.7rem;
  padding-left: 0.85rem;
  border-left: 3px solid var(--lf-rust);
  color: var(--lf-ink);
  font-size: 0.95rem;
  line-height: 1.55;
}

.ree-research-disclosure a {
  color: inherit;
  font-weight: 700;
}

.ree-project-card {
  display: flex;
  flex-direction: column;
  min-height: 17rem;
  padding: 1.35rem;
  border: 1px solid var(--lf-line);
  border-radius: var(--lf-radius);
  background: var(--lf-surface);
  box-shadow: 0 8px 24px rgba(24, 33, 31, 0.05);
}

.ree-project-card h2 {
  margin: 0 0 0.7rem;
  padding: 0;
  border: 0;
  font-size: 1.2rem;
}

.ree-project-card p {
  margin: 0 0 0.8rem;
}

.ree-project-card-topline,
.ree-project-links {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.ree-project-repo {
  font-size: 0.82rem;
}

.ree-project-note {
  margin-top: auto !important;
  color: var(--lf-muted);
  font-size: 0.88rem;
}

.ree-project-links {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 0.55rem;
  font-size: 0.9rem;
}

.ree-nav-footer {
  display: grid;
  gap: 0.45rem;
  padding: 1.25rem 0 0;
  border-top: 1px solid var(--lf-line);
  font-size: 0.84rem;
}

.ree-public-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--lf-line);
  color: var(--lf-muted);
  font-size: 0.84rem;
}

.ree-public-footer p {
  margin: 0 0 0.5rem;
}

body:has(.ree-home) .ree-public-header {
  display: none;
}

@media (min-width: 66.5rem) {
  /* Keep the content edge stable as the Just-the-Docs viewport widens. */
  .main-content {
    padding-left: var(--lf-gutter);
    padding-right: var(--lf-gutter);
  }
}

@media (max-width: 700px) {
  :root {
    --lf-gutter: 1.25rem;
  }

  .ree-public-header {
    align-items: flex-start;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
  }

  .ree-public-status-link {
    width: 100%;
    margin-left: 0;
  }

  .ree-project-grid {
    grid-template-columns: 1fr;
  }

  .ree-visual-grid {
    grid-template-columns: 1fr;
  }

  .ree-doc-intro {
    padding: 1.15rem;
  }

  .ree-doc-lead {
    font-size: 1.05rem;
  }
}

@media (max-width: 640px) {
  :root {
    /* Match the home page's 14px mobile shell inset exactly. */
    --lf-gutter: 0.875rem;
  }
}

/* ------------------------------------------------------------------
   Full-bleed, centred layout (2026-10-01, site-redesign-20261001).
   Just-the-Docs caps .main at 50rem and, on wide screens, grows the
   sidebar to fill the left gutter, leaving the page background to stop
   short on the right. Instead: the page background runs edge to edge,
   the sidebar keeps its natural width, and the content column is centred
   in the remaining space at a reading width.
   ------------------------------------------------------------------ */
html,
body {
  background: var(--lf-paper);
}

.main,
.main-content-wrap,
.main-header {
  background: var(--lf-paper);
}

.main-header {
  border-bottom: 1px solid var(--lf-line);
}

.main-content {
  width: min(100%, calc(48rem + (2 * var(--lf-gutter))));
}

@media (min-width: 50rem) {
  .main {
    max-width: none;
  }
}

@media (min-width: 66.5rem) {
  .side-bar {
    width: 16.5rem;
    min-width: 16.5rem;
  }

  .side-bar + .main {
    margin-left: 16.5rem;
    max-width: none;
  }
}

/* Bespoke home page: full width, its own centred shell, no sidebar. */
body:has(.ree-home) .main,
body:has(.ree-home) .side-bar + .main {
  margin-left: 0;
  max-width: none;
}

body:has(.ree-home) .main-content {
  width: auto;
}

/* Story and document figures: one consistent, centred treatment. */
.main-content figure {
  margin-inline: auto;
}

.main-content figure img {
  display: block;
  margin-inline: auto;
}

/* Home header: full-width bar, contents aligned with the home shell. */
body:has(.ree-home) .main-header {
  max-width: none;
  background: var(--lf-paper);
  padding-inline: max(1.25rem, calc((100% - 1120px) / 2));
}

/* Sidebar footer links: aligned with the nav, not pushed to the right edge. */
.side-bar .ree-nav-footer {
  align-self: stretch;
  margin: 0 1rem 1.25rem 2rem;
}

/* One link colour across nav, top links and content (theme default is purple). */
.site-nav a,
.nav-list .nav-list-item .nav-list-link,
.aux-nav .aux-nav-list-link {
  color: var(--lf-teal);
}

.nav-list .nav-list-item .nav-list-link.active {
  color: var(--lf-ink);
  font-weight: 600;
}

.aux-nav .aux-nav-list-link {
  white-space: nowrap;
}

/* Phone readability: the theme drops the root size to 14px below 50rem; keep body text at 16px. */
/* The theme sets html to 0.875rem !important below 31.25rem; html:root + !important outranks it. */
html:root {
  font-size: 16px !important;
}

.ree-public-footer {
  font-size: 0.9rem;
}

/* Shared hero motif (same file, opacity and fade on the REE home and the Latent Fields front page). */
.ree-hero-image {
  opacity: 0.9;
}

/* Long words and URLs wrap instead of widening the page. */
.main-content p,
.main-content li,
.main-content figcaption {
  overflow-wrap: anywhere;
}

.main-content img {
  max-width: 100%;
  height: auto;
}

/* On phones the sidebar is a top bar; its footer links repeat the page footer, so hide them there. */
@media (max-width: 49.99rem) {
  .side-bar .ree-nav-footer {
    display: none;
  }
}

/* Theme link colour is applied with high specificity in the header; match the site teal. */
.aux-nav a,
.aux-nav .aux-nav-list-link {
  color: var(--lf-teal) !important;
}
