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

.em-skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 500;
  background: #f7f8fa;
  color: #06122a;
  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: #f7f8fa;
  color: #06122a;
  border-bottom: 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
.em-bar::after,
.em-foot::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #f5b000 0 33.33%, #0070e1 33.33% 66.66%, #e21016 66.66% 100%);
  pointer-events: none;
}
.em-bar::after { bottom: 0; }
.em-foot { position: relative; }
.em-foot::before { top: 0; }
body.em-page:not(.em-chart) .em-bar::after { display: none; }

.em-bar .em-brand,
.em-foot .em-brand {
  flex: none;
  display: flex;
  align-items: center;
  text-decoration: none !important;
  line-height: 1 !important;
}
.em-mark {
  display: block !important;
  width: 44px !important;
  height: 44px !important;
  max-width: none !important;
}
.em-foot .em-mark {
  width: 36px !important;
  height: 36px !important;
}
.em-logo {
  display: block !important;
  height: 40px !important;
  width: auto !important;
  max-width: min(240px, 62vw) !important;
}
.em-word {
  display: block;
  margin-left: 10px;
  color: #06122a;
  font-family: Nunito, "Segoe UI", sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  text-transform: none;
}

body.em-home { background: #06122a; }
body.em-home .em-bar {
  background: #f7f8fa;
  color: #06122a;
  border-bottom: 0;
}
body.em-home .em-word { color: #06122a; }
body.em-home .em-bar nav a { color: #06122a !important; }
body.em-home .em-bar nav a.is-on,
body.em-home .em-bar nav a:hover { color: #e21016 !important; }
body.em-home .em-foot {
  background: #050d1c;
  color: #f7f8fa;
  border-top: 0;
}
body.em-home .em-foot .em-mark {
  width: 36px !important;
  height: 36px !important;
}
body.em-home .em-foot nav a { color: #f7f8fa !important; }
body.em-home .em-foot nav a:hover { color: #f5b000 !important; }
body.em-home .em-tag,
body.em-home .em-copy { color: #c5cedd !important; }
body.em-home .em-top {
  background: #f5b000;
  color: #06122a;
  border-color: #f5b000;
}
body.em-home .em-top:hover { background: #e21016; border-color: #e21016; color: #f7f8fa; }

.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: #06122a !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: #0070e1 !important; }

.em-crumb {
  display: none;
}

.em-foot {
  background: #f7f8fa;
  color: #06122a;
  border-top: 0;
  padding: 22px max(20px, calc((100% - 1120px) / 2)) 26px;
  font-family: Nunito, "Segoe UI", sans-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: #516075 !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: #516075 !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: #06122a !important;
  font-family: Nunito, "Segoe UI", sans-serif !important;
  font-size: 1.05rem !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  text-decoration: underline;
  text-decoration-color: #0070e1 !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: #516075 !important;
}

/* Topic 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-mark {
  width: 40px !important;
  height: 40px !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, #f3f6fb) 18%, transparent);
  padding: 16px max(16px, calc((100% - 1200px) / 2)) 20px;
}
body.em-page .em-tag { display: none; }
body.em-page .em-foot .em-mark {
  width: 36px !important;
  height: 36px !important;
}
body.em-page .em-foot nav a,
body.em-page .em-also a {
  color: var(--stage-ink, #f3f6fb) !important;
}
body.em-page .em-foot nav a:hover,
body.em-page .em-also a:hover { color: var(--gold, #f5b000) !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, #f5b000) !important; }

/* Uploaded lessons are white Arial pages with slate rules. The shared chrome follows that, not the homepage stripe. */
body.em-chart {
  --em-bar-h: calc(56px + env(safe-area-inset-top, 0px));
  padding-top: var(--em-bar-h) !important;
  padding-bottom: 0 !important;
  background: #fff;
  color: #26323d;
}
body.em-chart #sources {
  padding-bottom: clamp(56px, 8vw, 96px);
}
body.em-chart .viewer { z-index: 600; }
body.em-chart .em-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 400;
  width: 100%;
  height: var(--em-bar-h);
  margin: 0;
  padding: env(safe-area-inset-top, 0px) max(28px, calc((100% - 1380px) / 2 + 28px)) 0;
  background: #fff;
  color: #26323d;
  border-bottom: 1px solid #d4dee5;
  font-family: Arial, Helvetica, sans-serif;
  pointer-events: auto;
}
body.em-chart .em-bar::after { display: none; }
body.em-chart .em-logo {
  height: 32px !important;
  max-width: min(200px, 58vw) !important;
}
body.em-chart .em-bar nav { display: flex !important; gap: 18px; }
body.em-chart .em-word { display: block; color: #26323d; }
body.em-chart .em-mark {
  width: 32px !important;
  height: 32px !important;
}
body.em-chart .em-foot {
  background: #f4f7f9;
  color: #26323d;
  border-top: 1px solid #d4dee5;
  width: auto;
  margin-inline: 0;
  padding: 22px max(28px, calc((100% - 1380px) / 2 + 28px)) calc(22px + env(safe-area-inset-bottom, 0px));
  font-family: Arial, Helvetica, sans-serif;
}
body.em-chart .em-foot::before { display: none; }
body.em-chart .em-foot-inner { gap: 4px 20px; }
body.em-chart .em-tag {
  display: block;
  color: #596a77 !important;
  font-family: Arial, Helvetica, sans-serif !important;
  font-size: 15px !important;
  font-weight: 400 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
}
body.em-chart .em-foot .em-mark {
  width: 32px !important;
  height: 32px !important;
}
body.em-chart .em-bar nav a,
body.em-chart .em-foot nav a,
body.em-chart .em-also a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: #215f93 !important;
  font: 400 15px/1.3 Arial, Helvetica, sans-serif !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
}
body.em-chart .em-bar nav a:hover,
body.em-chart .em-foot nav a:hover,
body.em-chart .em-also a:hover {
  color: #215f93 !important;
  text-decoration: underline !important;
}
body.em-chart .em-bar a:focus-visible,
body.em-chart .em-foot a:focus-visible {
  outline: 3px solid #2479b6;
  outline-offset: 3px;
}
body.em-chart .em-also span,
body.em-chart .em-copy {
  color: #687c8c !important;
  font: 400 13px/1.4 Arial, Helvetica, sans-serif !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
}
body.em-chart .em-also a { text-decoration-color: #215f93 !important; }
body.em-chart .em-top {
  border-radius: 0;
  background: #315f81;
  border-color: #315f81;
  color: #fff;
  box-shadow: 0 1px 3px #30485d26;
}
body.em-chart .em-top:hover { background: #245779; border-color: #245779; color: #fff; }
body.em-chart .em-top:focus-visible { outline: 3px solid #2479b6; outline-offset: 3px; }

@media (max-width: 760px) {
  body.em-chart input:not([type="range"]):not([type="checkbox"]):not([type="radio"]),
  body.em-chart select {
    min-height: 44px !important;
  }
  body.em-chart .headroom-layout,
  body.em-chart .headroom-layout > *,
  body.em-chart .headroom-results,
  body.em-chart .table-scroll,
  body.em-chart .table-wrap,
  body.em-chart .elevation,
  body.em-chart [data-elevation],
  body.em-chart .depth-section > *,
  body.em-chart .depth-drawing,
  body.em-chart .pitch-drawing,
  body.em-chart .pitch-layout,
  body.em-chart .pitch-layout > *,
  body.em-chart [data-diagram],
  body.em-chart .plane-figure,
  body.em-chart .plane-section,
  body.em-chart .plane-section > * {
    min-width: 0;
    max-width: 100%;
  }
  body.em-chart .table-scroll {
    overflow-x: auto !important;
  }
  body.em-chart figure,
  body.em-chart main img {
    max-width: 100%;
  }
  .em-bar { gap: 12px; padding-inline: 14px; }
  .em-word { font-size: 1.05rem; margin-left: 8px; }
  .em-logo { height: 32px !important; }
  .em-mark { width: 36px !important; height: 36px !important; }
  body.em-home .em-bar nav { flex: 1; min-width: 0; }
  .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; }
  body.em-chart .em-mark { width: 36px !important; height: 36px !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 #06122a;
  border-radius: 50%;
  background: #06122a;
  color: #f7f8fa;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(6, 18, 42, 0.18);
}
.em-top[hidden] { display: none; }
.em-top:hover { background: #e21016; border-color: #e21016; color: #f7f8fa; }
.em-top:focus-visible { outline: 3px solid #0070e1; outline-offset: 3px; }
.em-top svg { display: block; }

.em-film {
  box-sizing: border-box;
  scroll-margin-top: 72px;
  padding: 8px max(16px, calc((100% - 1200px) / 2)) 36px;
  background: var(--ground, #111416);
  color: var(--ink, #06122a);
}
.em-film * { box-sizing: border-box; }
.em-film-kicker {
  margin: 0 0 8px;
  font: 500 0.72rem/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold, #0070e1);
}
.em-film h2 {
  margin: 0 0 16px;
  max-width: none;
  width: 100%;
  font-family: Nunito, "Segoe UI", sans-serif;
  font-weight: 600;
  font-size: clamp(1.55rem, 2.2vw, 2.05rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  text-transform: none;
  text-wrap: wrap;
}
.em-film-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}
.em-film-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.em-film-fallback {
  margin: 10px 0 0;
  font: 500 0.72rem/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.em-film-fallback a { color: inherit; }
