.masthead {
  position: relative;
  z-index: 10;
  top: 0;
  left: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  width: 100%;
  min-height: 83px;
  padding: 18px 3.4vw;
  color: var(--paper);
  font-size: var(--text-label);
  font-weight: 600;
  background: var(--ink);
}

.masthead--overlay {
  position: fixed;
  background: transparent;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .65);
  transition: background-color .2s ease;
}

.masthead--overlay.masthead--scrolled {
  background: #000;
  text-shadow: none;
}

html:has(.masthead--overlay) {
  scroll-padding-top: var(--navbar-height, 112px);
}

.masthead__nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  white-space: nowrap;
}

.masthead__nav a:hover,
.masthead__nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 6px;
}

.masthead a:focus-visible {
  outline-color: var(--paper);
}

.masthead a {
  transition: color .2s ease;
}

.masthead a:hover {
  color: var(--paper);
}

.masthead__nav {
  display: flex;
  grid-column: 1;
  grid-row: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px clamp(12px, 1.4vw, 24px);
  justify-self: start;
  min-width: 0;
}

.masthead__brand {
  display: inline-flex;
  grid-column: 2;
  grid-row: 1;
  align-items: center;
  justify-self: center;
}

.masthead__actions,
.masthead__account {
  display: flex;
  align-items: center;
  gap: 16px;
  white-space: nowrap;
}

.masthead__actions {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

.masthead__account form {
  margin: 0;
}

.masthead__signup {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--text-secondary);
  border-radius: 4px;
  color: var(--ink);
  background: var(--paper);
  font: inherit;
  text-shadow: none;
  cursor: pointer;
}

.masthead .masthead__signup:hover {
  color: var(--ink);
}

.masthead__account button:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
}

.account-menu {
  position: relative;
  text-shadow: none;
}

.account-menu__toggle {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 10px;
  place-items: center;
  border: 1px solid var(--line-light);
  border-radius: 6px;
  color: var(--paper);
  background: rgba(17, 18, 20, .4);
  list-style: none;
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}

.account-menu__toggle::-webkit-details-marker {
  display: none;
}

.account-menu__toggle svg {
  display: block;
  width: 24px;
  height: 24px;
}

.account-menu[open] .account-menu__toggle,
.account-menu__toggle:hover {
  color: var(--ink);
  background: var(--paper);
}

.account-menu__toggle:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
}

.account-menu__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 228px;
  max-width: calc(100vw - 40px);
  max-height: calc(100svh - 140px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .25);
  font-size: var(--text-caption);
  font-weight: 500;
  line-height: 1.45;
}

.account-menu__members-title {
  margin: 4px 10px;
  color: var(--text-secondary);
  font-size: var(--text-caption);
  font-weight: 600;
}

.account-menu__members-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.account-menu__member,
.account-menu__empty {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.account-menu__empty {
  padding: 6px 10px;
  color: var(--text-secondary);
  font-size: var(--text-caption);
}

.account-menu__member-profile {
  min-width: 0;
}

.account-menu__panel a,
.account-menu__panel button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 0;
  border-radius: 4px;
  color: inherit;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.masthead .account-menu__panel a:hover,
.account-menu__panel button:hover {
  color: var(--ink);
  background: rgba(17, 18, 20, .07);
}

.account-menu__panel a:focus-visible,
.account-menu__panel button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.account-menu__panel hr {
  margin: 4px 2px;
  border: 0;
  border-top: 1px solid var(--line-dark);
}

@media (pointer: coarse) {
  .account-menu__panel a,
  .account-menu__panel button {
    min-height: 44px;
  }
}

@media (max-width: 900px) {
  .masthead {
    padding-right: 25px;
    padding-left: 25px;
  }

  .masthead__nav {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-wrap: nowrap;
    width: 100%;
    overflow-x: auto;
    padding: 4px 0 8px;
  }

  .masthead__nav a {
    flex: none;
  }

  .masthead__nav a:focus-visible {
    outline-offset: -2px;
  }
}

@media (max-width: 760px) {
  .masthead {
    min-height: 74px;
    gap: 12px;
    padding: 16px 20px;
  }

  .masthead__nav {
    gap: 20px;
    font-size: var(--text-caption);
  }

  .masthead__brand img {
    width: 48px;
  }

  .masthead__account {
    gap: 12px;
    font-size: var(--text-caption);
  }
}

@media (max-width: 600px) {
  .masthead__account {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }

  .masthead__signup {
    padding: 6px 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .masthead--overlay {
    transition: none;
  }
}
