.container {
  width: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
}

/* Header */
/* The height of the public header has one place. A stage at the top of a page goes under the header by this height. */
body { --header-h: 104px; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: .875rem;
  text-decoration: none;
  flex: none;
}

.badge {
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: var(--surface);
}

.brand__name {
  font-family: var(--font-display);
  font-weight: var(--fw-title);
  font-size: var(--fs-brand);
  letter-spacing: var(--tracking-title);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* The header on a stage. Each public page opens in black (public_components.css), and the header stands on it. */
/* On black, the focus ring and the lines take the light colors of the panels, and the hard shadow of a button is graphite. */
.site-header--stage { position: relative; z-index: 3; color: var(--terminal-text); --focus: var(--surface); --shadow-button: 6px 6px 0 var(--terminal-rule); --shadow-button-pressed: 3px 3px 0 var(--terminal-rule); }
.site-header--stage .badge { border-color: var(--panel-text); }
.site-header--stage .site-nav__links a:hover { border-bottom-color: var(--terminal-text); }
/* The mark of the current page takes the color of a panel title: the accent of the language has too little contrast on black. */
.site-header--stage .site-nav__links a[aria-current="page"] { border-bottom-color: var(--panel-title); }
.site-header--stage .language-switch { border-color: var(--panel-text); }
.site-header--stage .language-switch__option { background: transparent; }
.site-header--stage .language-switch__option[aria-current="true"] { background: var(--panel-text); color: var(--ink); }
/* The menu of a narrow page keeps its light surface. So its text, its focus ring and the hard shadow of its button keep the colors of a light page. */
.site-header--stage .site-nav__menu > summary { border-color: var(--panel-text); color: var(--ink); }
.site-header--stage .site-nav__menu[open] > summary { color: var(--surface); }
.site-header--stage .site-nav__panel { color: var(--ink); --focus: var(--accent-3); --shadow-button: 6px 6px 0 var(--ink); --shadow-button-pressed: 3px 3px 0 var(--ink); }
/* The black bar behind the header: a stage with the height of the header and with nothing in it. Each page has it, so the header is never on a light surface. */
.site-header--stage + .stage--bar { height: var(--header-h); margin-top: calc(-1 * var(--header-h)); }
/* The opening of a page is a stage with the class stage--top. It goes under the header, over the bar, so the black of the opening starts at the top of the page. */
/* The opening must be the first thing in the flow of main: an ancestor with a top padding or a top margin leaves a light gap below the bar. */
/* The rule sets the top padding. So a stage with a top padding of its own gives it in --stage-pad-top. */
.site-header--stage ~ main .stage--top { margin-top: calc(-1 * var(--header-h)); padding-top: calc(var(--header-h) + var(--stage-pad-top, 0px)); }

.site-nav__account { display: flex; flex: none; align-items: center; gap: 1rem; white-space: nowrap; }
.site-nav__sign-in { display: inline-flex; align-items: center; min-height: 2.75rem; font-weight: var(--fw-ui); font-size: var(--fs-control); text-underline-offset: .25rem; }

.site-nav__links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-weight: var(--fw-ui);
  font-size: var(--fs-control);
  line-height: var(--lh-ui);
}

.site-nav__links a {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  text-decoration: none;
  padding-block: .375rem;
  border-bottom: 3px solid transparent;
}

.site-nav__links a:hover { border-bottom-color: var(--ink); }
.site-nav__links a[aria-current="page"] { border-bottom-color: var(--accent); }

/* The menu of a narrow page: a control with three bars, and a panel with the pages. The open control takes the ink, as the language in use does. */
.site-nav__menu { display: none; position: relative; }
.site-nav__menu > summary {
  position: relative;
  display: flex;
  align-items: center;
  gap: .625rem;
  min-height: 3rem;
  padding: 0 1rem;
  border: var(--border-thin) solid var(--ink);
  border-radius: var(--radius-btn);
  background: var(--surface);
  font-weight: var(--fw-ui);
  font-size: var(--fs-control);
  list-style: none;
  cursor: pointer;
}
.site-nav__menu > summary::-webkit-details-marker { display: none; }
.site-nav__menu > summary:hover { background: var(--surface-muted); }
.site-nav__menu[open] > summary { background: var(--ink); color: var(--surface); }
.site-nav__menu-icon { position: relative; flex: none; width: 1.125rem; height: 2px; background: currentColor; transition: background-color .12s; }
.site-nav__menu-icon::before, .site-nav__menu-icon::after { content: ""; position: absolute; left: 0; width: 100%; height: 2px; background: currentColor; transition: top .12s, transform .12s; }
.site-nav__menu-icon::before { top: -6px; }
.site-nav__menu-icon::after { top: 6px; }
.site-nav__menu[open] .site-nav__menu-icon { background: transparent; }
.site-nav__menu[open] .site-nav__menu-icon::before { top: 0; transform: rotate(45deg); }
.site-nav__menu[open] .site-nav__menu-icon::after { top: 0; transform: rotate(-45deg); }
.site-nav__panel { position: absolute; right: 0; top: calc(100% + .5rem); z-index: 5; min-width: 13rem; overflow: hidden; border: var(--border-thin) solid var(--ink); border-radius: var(--radius-btn); background: var(--surface); box-shadow: var(--shadow-hard); }
.site-nav__menu-links a { display: flex; align-items: center; min-height: 3rem; padding: .75rem 1rem; font-weight: var(--fw-ui); text-decoration: none; outline-offset: -3px; }
.site-nav__menu-links a:hover { background: var(--surface-muted); }
.site-nav__menu-links a[aria-current="page"] { box-shadow: inset 4px 0 0 var(--accent); }
.site-nav__invite { display: none; }
@media (max-width: 1100px) {
  .site-nav__menu { display: block; }
  .site-nav__account { margin-inline-end: .375rem; } /* the room of the hard shadow, before the menu */
}

.language-switch {
  display: flex;
  border: var(--border-thin) solid var(--ink);
  border-radius: var(--radius-pill);
  overflow: hidden;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--fs-code);
  flex: none;
}

.language-switch__option {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 2.75rem;
  text-decoration: none;
  background: var(--surface);
}

.language-switch__option[aria-current="true"] {
  background: var(--ink);
  color: var(--surface);
}

/* The switch clips its options to its round shape, and a ring outside an option does not show. So, in the public header, the focus ring stands inside the option, with the round end of the switch. */
/* On the option in use, the ring takes the color of its text. */
.site-header .language-switch__option:focus-visible { outline-offset: -4px; }
.site-header .language-switch__option:first-child { border-radius: var(--radius-pill) 0 0 var(--radius-pill); }
.site-header .language-switch__option:last-child { border-radius: 0 var(--radius-pill) var(--radius-pill) 0; }
.site-header .language-switch__option[aria-current="true"]:focus-visible { outline-color: currentColor; }

/* Trilho de fechamento, antes do rodapé. */
.rail {
  height: 36px;
  background:
    linear-gradient(var(--ink) 0 0) 0 8px / 100% 4px no-repeat,
    linear-gradient(var(--ink) 0 0) 0 24px / 100% 4px no-repeat,
    repeating-linear-gradient(90deg, transparent 0 6px, var(--rail-tie) 6px 18px, transparent 18px 46px);
}

/* Sections */
.section { padding-block: var(--section-pad-y); }

.section--white {
  background: var(--surface);
  border-block: var(--border-thin) solid var(--ink);
}

.section-divider { background: var(--bg); }
.section-divider--white { background: var(--surface); }
.section-divider__line { border-top: var(--border-thin) solid var(--rail-tie); }

.section__title {
  font-size: var(--fs-section);
  line-height: var(--lh-title);
  letter-spacing: var(--tracking-display);
}

.section__title--narrow { max-width: 900px; }
.section__title--medium { font-size: var(--fs-editorial-title); }
.section__title--large { font-size: var(--fs-section); }

.section__lead {
  max-width: var(--reading-measure);
  margin-top: 2.5rem;
  font-size: var(--fs-reading-lead);
  line-height: var(--lh-body);
}

.section__lead--muted { color: var(--ink-muted); font-size: var(--fs-ui-body); }

.section__aside {
  color: var(--ink-muted);
  font-size: var(--fs-reading);
  line-height: var(--lh-body);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3.75rem;
  align-items: start;
}

.judgment .split { grid-template-columns: minmax(0, 1fr) 560px; }
.measure .split { grid-template-columns: minmax(0, 1fr) 500px; gap: 5rem; }

.prose > * + * { margin-top: .875rem; }
.prose p { max-width: var(--reading-measure); line-height: var(--lh-body); }

/* Footer */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding-block: 3.5rem 5.5rem;
}

.site-footer__brand {
  display: flex;
  align-items: center;
  gap: 1.125rem;
}

.site-footer__handle {
  white-space: nowrap;
  font-family: var(--font-display);
  font-weight: var(--fw-title);
  font-size: var(--fs-brand);
  line-height: 1.1;
  letter-spacing: var(--tracking-title);
}

.site-footer__tagline { color: var(--ink-muted); font-size: var(--fs-control); line-height: var(--lh-ui); }

.site-footer__meta { text-align: right; }

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .5rem 1.75rem;
  font-weight: var(--fw-ui);
  font-size: var(--fs-control);
}

.site-footer__links a { display: inline-flex; align-items: center; justify-content: center; min-width: var(--target-size); min-height: var(--target-size); text-underline-offset: 3px; text-decoration-thickness: 2px; }

.site-footer__copyright {
  margin-top: .75rem;
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  color: var(--ink-muted);
}

/* O rodapé ocupa a base da janela ou segue o conteúdo, conforme a altura da página. */
.member-layout:has(> .site-footer--member) {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.member-layout > #main { flex: 1 0 auto; min-width: 0; }
.member-layout > .member-header, .member-layout > .rail, .member-layout > .site-footer--member { flex-shrink: 0; }

.site-footer--member {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-xs) var(--space-l);
  padding-block: var(--space-m);
}

.site-footer--member .site-footer__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0 var(--space-m);
}

.site-footer--member .site-footer__handle {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-size);
  font-size: var(--fs-caption);
  font-weight: var(--fw-body);
  line-height: var(--lh-ui);
  color: var(--ink-muted);
}

.site-footer--member .site-footer__links { justify-content: flex-start; column-gap: var(--space-l); }
.site-footer--member .site-footer__copyright { margin-top: 0; white-space: nowrap; }

@media (max-width: 1100px) {
  .site-nav__links { display: none; }
  .split, .judgment .split, .measure .split { grid-template-columns: 1fr; gap: 2rem; }
}

/* The name of the control needs the width of a wide tablet. Below that, the three bars stand alone, and the aria-label of the summary gives the name. */
@media (max-width: 860px) {
  .site-nav__menu > summary { justify-content: center; width: 3rem; padding: 0; }
  .site-nav__menu-label { display: none; }
}

@media (max-width: 720px) {
  body { --header-h: 84px; }
  .site-nav { gap: .75rem; }
  .brand__name { display: none; }
  .brand .badge { width: 52px; height: 52px; }
  .site-footer { flex-direction: column; align-items: flex-start; }
  .site-footer__meta { text-align: left; }
  .site-footer__links { justify-content: flex-start; }
  .site-footer--member { grid-template-columns: minmax(0, 1fr); }
  .site-footer--member .site-footer__meta { justify-content: space-between; }
}

@media (max-width: 560px) {
  .site-header { gap: .75rem; }
  .site-nav { min-width: 0; flex-wrap: wrap; justify-content: flex-end; padding-block: .75rem; }

  /* The public header on a phone: one row. The link to sign in is the one account action, with the look of the small accent button.
     The invitation to create an account opens with the menu, in a panel as wide as the page. */
  .site-header--public { position: relative; }
  .site-header--public .site-nav { flex-wrap: nowrap; gap: .625rem; padding-block: 0; }
  .site-header--public .site-nav .language-switch__option { width: 2.5rem; }
  .site-nav__account .site-nav__create { display: none; }
  .site-nav__account .button { padding-inline: 1rem; }
  .site-nav__sign-in {
    justify-content: center;
    min-height: 3rem;
    padding: .5rem 1rem;
    border: var(--border-thin) solid var(--ink);
    border-radius: var(--radius-btn);
    background: var(--accent-fill);
    box-shadow: var(--shadow-button);
    color: var(--on-accent);
    font-family: var(--font-display);
    line-height: var(--lh-ui);
    text-decoration: none;
  }
  .site-nav__sign-in:hover { background: var(--accent-hover); }
  .site-nav__sign-in:active { transform: translate(3px, 3px); box-shadow: var(--shadow-button-pressed, 3px 3px 0 var(--ink)); }
  .site-nav__menu { position: static; }
  .site-nav__panel { left: 0; right: 0; top: 100%; }
  .site-nav__menu-links a { min-height: 3.5rem; padding-inline: 1.25rem; font-size: var(--fs-control-large); }
  .site-nav__invite { display: grid; gap: .75rem; padding: 1.25rem 1.25rem 1.5rem; border-top: var(--border-thin) solid var(--ink); background: var(--surface-muted); }
  .site-nav__invite .button { width: 100%; }
  .site-footer__brand { gap: .75rem; }
  .site-footer__brand .badge { width: 64px; height: 64px; }
  .site-footer__brand > div { min-width: 0; }
}

/* A narrow phone has no room for the two languages beside the account action. The switch then shows only the other language. */
@media (max-width: 379px) {
  .site-header--public, .site-header--public .site-nav { gap: .5rem; }
  .site-header--public .site-nav:has(.site-nav__member) .language-switch__option[aria-current="true"] { display: none; }
}

@media (max-width: 339px) {
  .site-header--public .site-nav .language-switch__option[aria-current="true"] { display: none; }
  .site-header--public .brand .badge { width: 44px; height: 44px; }
  .site-header--public .site-nav { gap: .375rem; }
  .site-nav__account .button, .site-nav__sign-in { padding-inline: .75rem; }
}
