:root { --em-bar-h: calc(64px + env(safe-area-inset-top, 0px)); }

.em-skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 500;
  background: #efeae1;
  color: #1c1915;
  padding: 8px 12px;
  font: 500 14px/1 "IBM Plex Mono", ui-monospace, monospace;
}
.em-skip:focus { top: 8px; }

.em-bar,
.em-foot,
.em-bar *,
.em-foot * { box-sizing: border-box; }

.em-bar {
  position: sticky;
  top: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 22px;
  height: var(--em-bar-h);
  padding: env(safe-area-inset-top, 0px) max(20px, calc((100% - 1120px) / 2)) 0;
  background: #efeae1;
  color: #1c1915;
  border-bottom: 1px solid #1c1915;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.em-bar .em-brand,
.em-foot .em-brand {
  flex: none;
  display: flex;
  align-items: center;
  text-decoration: none !important;
  line-height: 1 !important;
}
.em-logo,
.em-mark {
  display: block !important;
  width: auto !important;
  max-width: none !important;
  height: 40px !important;
}
.em-mark { display: none !important; }

.em-bar nav {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.em-bar nav::-webkit-scrollbar { display: none; }

.em-bar nav a,
.em-foot nav a {
  color: #1c1915 !important;
  text-decoration: none !important;
  font: 500 11px/1 "IBM Plex Mono", ui-monospace, monospace !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  white-space: nowrap;
}
.em-bar nav a[aria-current="page"],
.em-bar nav a:hover,
.em-foot nav a:hover { color: #9a3e22 !important; }

.em-crumb {
  display: none;
}

.em-foot {
  background: #efeae1;
  color: #1c1915;
  border-top: 1px solid #1c1915;
  padding: 22px max(20px, calc((100% - 1120px) / 2)) 26px;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1rem;
  line-height: 1.5;
}
.em-foot-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
}
.em-tag {
  flex: 1 1 16rem;
  margin: 0 !important;
  color: #5e584f !important;
  font-size: 1rem !important;
}
.em-foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-left: auto;
}
.em-also {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 4px 0 0 !important;
  color: #5e584f !important;
}
.em-also span {
  font: 500 11px/1.4 "IBM Plex Mono", ui-monospace, monospace !important;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.em-also a {
  color: #1c1915 !important;
  font-family: Fraunces, Georgia, serif !important;
  font-size: 1.05rem !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  text-decoration: underline;
  text-decoration-color: #9a3e22 !important;
  text-underline-offset: 0.18em;
}
.em-copy {
  flex: 1 1 100%;
  margin: 2px 0 0 !important;
  font: 400 11px/1 "IBM Plex Mono", ui-monospace, monospace !important;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5e584f !important;
}

/* Mechanism pages already have a chapter bar. Keep that as the only header. */
body.em-page { --em-bar-h: 0px; }
body.em-page > nav.nav { top: env(safe-area-inset-top, 0px) !important; }
body.em-page .em-bar {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: max(14px, calc((100% - 1200px) / 2));
  z-index: 80;
  width: auto;
  height: 56px;
  padding: 0;
  background: transparent;
  border: 0;
  pointer-events: none;
}
body.em-page .em-bar .em-brand { pointer-events: auto; }
body.em-page .em-bar nav { display: none !important; }
body.em-page .em-logo { display: none !important; }
body.em-page .em-mark {
  display: block !important;
  width: 34px !important;
  height: 34px !important;
}
body.em-page > nav.nav {
  padding-left: calc(max(16px, (100% - 1200px) / 2) + 44px) !important;
}

body.em-page .em-foot {
  background: var(--velvet-3, #111416);
  color: var(--stage-2, #d9d0c4);
  border-top: 1px solid color-mix(in srgb, var(--stage-ink, #f4efe6) 18%, transparent);
  padding: 16px max(16px, calc((100% - 1200px) / 2)) 20px;
}
body.em-page .em-tag { display: none; }
body.em-page .em-foot .em-logo { display: none !important; }
body.em-page .em-foot .em-mark {
  display: block !important;
  width: 28px !important;
  height: 28px !important;
}
body.em-page .em-foot nav a,
body.em-page .em-also a {
  color: var(--stage-ink, #f4efe6) !important;
}
body.em-page .em-foot nav a:hover,
body.em-page .em-also a:hover { color: var(--gold, #e6b85a) !important; }
body.em-page .em-also span,
body.em-page .em-copy { color: var(--stage-2, #d9d0c4) !important; }
body.em-page .em-also a { text-decoration-color: var(--gold, #e6b85a) !important; }

@media (max-width: 760px) {
  .em-bar { gap: 12px; padding-inline: 14px; }
  .em-logo { height: 28px !important; }
  .em-bar nav { gap: 12px; }
  .em-bar nav a,
  .em-foot nav a { letter-spacing: 0.08em !important; }
  .em-foot nav { margin-left: 0; }
  body.em-page .em-mark { width: 30px !important; height: 30px !important; }
  .em-top { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}

.em-top {
  position: fixed;
  z-index: 450;
  right: 22px;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #1c1915;
  border-radius: 50%;
  background: #1c1915;
  color: #efeae1;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(28, 25, 21, 0.18);
}
.em-top[hidden] { display: none; }
.em-top:hover { background: #9a3e22; border-color: #9a3e22; color: #efeae1; }
.em-top:focus-visible { outline: 3px solid #9a3e22; outline-offset: 3px; }
.em-top svg { display: block; }
